All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svsetbase.h
Go to the documentation of this file.
23 /* undefine SOPLEX_DEBUG flag from including files; if SOPLEX_DEBUG should be defined in this file, do so below */
43 * Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBase%s in an SVSetBase share one big
44 * memory block for their nonzeros. This memory is reffered to as the \em nonzero \em memory. The SVectorBase%s
45 * themselves are saved in another memory block refered to as the \em vector \em memory. Both memory blocks will grow
46 * automatically if required, when adding more SVectorBase%s to the set or enlarging SVectorBase%s within the set. For
47 * controlling memory consumption, methods are provided to inquire and reset the size of the memory blocks used for
50 * SVectorBase%s in an SVSetBase are numbered from 0 thru num()-1. They can be accessed using the index
51 * operator[](). When removing SVectorBase%s of a SVSetBase the remaining ones will be renumbered. However, all
52 * SVectorBase with a smaller number than the lowest number of the removed SVectorBase%s will remain unchanged.
54 * For providing a uniform access to SVectorBase%s in a %set even if others are removed or added, SVSetBase assigns a
55 * DataKey to each SVectorBase in the %set. Such a DataKey remains unchanged as long as the corresponding SVectorBase
56 * is in the SVSetBase, no matter what other SVectorBase%s are added to or removed from the SVSetBase. Methods are
57 * provided for getting the DataKey to a SVectorBase or its number and vice versa. Further, each add() method for
58 * enlarging an SVSetBase is provided with two signatures. One of them returns the DataKey%s assigned to the
74 * The management of the SVectorBase%s is implemented by a DataSet<DLPSV>, the keys used externally are DataKey%s.
76 * The management of nonzeros is done by a Real linked list IdList<DLPSV>, where the SVectorBase%s are kept in the
77 * order in which their indices occurr in the Array. The SVectorBase%s are kept without holes: If one is removed or
78 * moved to the end, the SVectorBase preceeding it obtains the space for all the nonzeros that previously belonged
85 // ---------------------------------------------------------------------------------------------------------------
96 // ---------------------------------------------------------------------------------------------------------------
112 // ---------------------------------------------------------------------------------------------------------------
143 // ------------------------------------------------------------------------------------------------------------------
149 int unusedMem; ///< an estimate of the unused memory (the difference of max() and size() summed up over all vectors) due to deleteVec() and xtend()
150 int numUnusedMemUpdates; ///< counter for how often unusedMem has been updated since last exact value
154 // ------------------------------------------------------------------------------------------------------------------
162 // ------------------------------------------------------------------------------------------------------------------
170 MSG_DEBUG( std::cout << "counting unused memory (unusedMem = " << unusedMem << ", numUnusedMemUpdates = " << numUnusedMemUpdates << ", this = " << (void*)this << ")\n" );
224 MSG_DEBUG( std::cout << "ensureMem, this = " << (void*)this << ": updateUnusedMemEstimation -= " << unusedPsMem << "\n" );
229 // if the missing memory can be acquired by packing the memory, we prefer this to allocating new memory
232 if( missingMem > 0 && missingMem <= unusedMem && unusedMem > (SVSetBaseArray::memFactor - 1.0) * memMax() )
257 MSG_DEBUG( std::cout << "deleteVec (1), this = " << (void*)this << ": updateUnusedMemEstimation -= " << ps->max() - ps->size() << "\n" );
261 /* merge space of predecessor with position which will be deleted, therefore we do not need to delete any memory
274 MSG_DEBUG( std::cout << "deleteVec (2), this = " << (void*)this << ": updateUnusedMemEstimation += " << ps->size() << "\n" );
278 /* simply remove the front entries; we do not shift the second vector to the front, because we count the unused
285 MSG_DEBUG( std::cout << "deleteVec (3), this = " << (void*)this << ": updateUnusedMemEstimation += " << ps->size() << "\n" );
297 // ------------------------------------------------------------------------------------------------------------------
302 /** This includes copying its nonzeros to the sets nonzero memory and creating an additional SVectorBase entry in
316 /** Adds SVectorBase \p svec to the %set. This includes copying its nonzeros to the sets nonzero memory and creating
317 * an additional SVectorBase entry in vector memory. If neccessary, the memory blocks are enlarged appropriately.
319 * @return \p nkey contains the DataKey, that the SVSetBase has assosicated to the new SVectorBase.
332 /** Adds SVectorBase \p svec to the %set. This includes copying its nonzeros to the sets nonzero memory and creating
333 * an additional SVectorBase entry in vector memory. If neccessary, the memory blocks are enlarged appropriately.
335 * @return \p nkey contains the DataKey, that the SVSetBase has assosicated to the new SVectorBase.
375 * @return \p nkey contains the DataKey%s, that the SVSetBase has assosicated to the new SVectorBase%s.
409 * @return \p nkey contains the DataKey%s, that the SVSetBase has assosicated to the new SVectorBase%s.
499 MSG_DEBUG( std::cout << "xtend (1), this = " << (void*)this << ": updateUnusedMemEstimation -= " << ps->max() - sz << "\n" );
530 MSG_DEBUG( std::cout << "xtend (2), this = " << (void*)this << ": updateUnusedMemEstimation += " << ps->size() << "\n" );
544 /** Adds one nonzero (\p idx, \p val) to SVectorBase \p svec in the SVSetBase. If \p svec is not large enough to
556 /** Adds \p n nonzeros to SVectorBase \p svec in the SVSetBase. If \p svec is not large enough to hold the additional
568 /** Adds \p n nonzeros to SVectorBase \p svec in the SVSetBase. If \p svec is not large enough to hold the additional
582 // ------------------------------------------------------------------------------------------------------------------
612 /** Removes all SVectorBase%s for the SVSetBase with an index \c i such that \p perm[i] < 0. Upon completion, \p
613 * perm[i] >= 0 indicates the new index where the \c i 'th SVectorBase has been moved to due to this removal.
621 /* due to performance reasons we use a backwards loop to delete entries, because it could result instead of only
707 // ------------------------------------------------------------------------------------------------------------------
737 // ------------------------------------------------------------------------------------------------------------------
797 // ------------------------------------------------------------------------------------------------------------------
821 MSG_DEBUG( std::cout << "counting unused memory (unusedMem = " << unusedMem << ", numUnusedMemUpdates = " << numUnusedMemUpdates << ", this = " << (void*)this << ")\n" );
848 MSG_DEBUG( std::cout << " --> NEW: unusedMem = " << unusedMem << " after memRemax(" << newmax << ")\n" );
854 /** Pack the svectors together as tightly as possible. This removes all additional unused memory, i.e., size = max
857 * Note: do *not* call isConsistent() here, because the following might happen: In SPxLP::doAddRows(const LPRowSet&
858 * p_set), when adding rows, the sizes of the vectors for the columns of the LP are increased (without yet filling
859 * in the data) to recieve the additional entries. This is done by calling xtend() above. xtend() in turn might call
860 * this method, which checks the yet unfilled positions, i.e., isConsistent() is likely to fail. In general,
861 * isConsistent() should not be called within this class, but in classes further up in the hierarchy.
889 MSG_DEBUG( std::cout << "counting unused memory (unusedMem = " << unusedMem << ", numUnusedMemUpdates = " << numUnusedMemUpdates << ", this = " << (void*)this << ")\n" );
890 MSG_DEBUG( std::cout << " --> NEW: unusedMem = " << memSize() - used << ", zero after memPack() at memMax() = "<< memMax() << "\n" );
906 // ------------------------------------------------------------------------------------------------------------------
|