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" ); 534 MSG_DEBUG( std::cout << "xtend (2), this = " << (void*)this << ": updateUnusedMemEstimation += " << ps->size() << "\n" ); 548 /** Adds one nonzero (\p idx, \p val) to SVectorBase \p svec in the SVSetBase. If \p svec is not large enough to 560 /** Adds \p n nonzeros to SVectorBase \p svec in the SVSetBase. If \p svec is not large enough to hold the additional 572 /** Adds \p n nonzeros to SVectorBase \p svec in the SVSetBase. If \p svec is not large enough to hold the additional 586 // ------------------------------------------------------------------------------------------------------------------ 616 /** Removes all SVectorBase%s for the SVSetBase with an index \c i such that \p perm[i] < 0. Upon completion, \p 617 * perm[i] >= 0 indicates the new index where the \c i 'th SVectorBase has been moved to due to this removal. 625 /* due to performance reasons we use a backwards loop to delete entries, because it could result instead of only 711 // ------------------------------------------------------------------------------------------------------------------ 741 // ------------------------------------------------------------------------------------------------------------------ 801 // ------------------------------------------------------------------------------------------------------------------ 825 MSG_DEBUG( std::cout << "counting unused memory (unusedMem = " << unusedMem << ", numUnusedMemUpdates = " << numUnusedMemUpdates << ", this = " << (void*)this << ")\n" ); 852 MSG_DEBUG( std::cout << " --> NEW: unusedMem = " << unusedMem << " after memRemax(" << newmax << ")\n" ); 858 /** Pack the svectors together as tightly as possible. This removes all additional unused memory, i.e., size = max 861 * Note: do *not* call isConsistent() here, because the following might happen: In SPxLP::doAddRows(const LPRowSet& 862 * p_set), when adding rows, the sizes of the vectors for the columns of the LP are increased (without yet filling 863 * in the data) to recieve the additional entries. This is done by calling xtend() above. xtend() in turn might call 864 * this method, which checks the yet unfilled positions, i.e., isConsistent() is likely to fail. In general, 865 * isConsistent() should not be called within this class, but in classes further up in the hierarchy. 893 MSG_DEBUG( std::cout << "counting unused memory (unusedMem = " << unusedMem << ", numUnusedMemUpdates = " << numUnusedMemUpdates << ", this = " << (void*)this << ")\n" ); 894 MSG_DEBUG( std::cout << " --> NEW: unusedMem = " << memSize() - used << ", zero after memPack() at memMax() = "<< memMax() << "\n" ); 910 // ------------------------------------------------------------------------------------------------------------------ 949 // ------------------------------------------------------------------------------------------------------------------
void clear(bool pDestroyElements=false) removes all elements from an IsList. Definition: islist.h:283 SVSetBase< R > & operator=(const SVSetBase< R > &rhs) Assignment operator. Definition: svsetbase.h:970 int unusedMem an estimate of the unused memory (the difference of max() and size() summed up over all vectors) due ... Definition: svsetbase.h:149 Generic Real linked list. Entry identifier class for items of a DataSet. int number(const SVectorBase< R > *svec) const Gets vector number of SVectorBase. Definition: svsetbase.h:776 SVectorBase< R > & operator[](const DataKey &k) Gets SVectorBase by DataKey, writeable. Definition: svsetbase.h:728 void ensurePSVec(int n) Provides enough vector memory for n more SVectorBases. Definition: svsetbase.h:195 void setMem(int n, Nonzero< R > *elmem) Set the memory area where the nonzeros will be stored. Definition: svectorbase.h:674 void deleteVec(DLPSV *ps) Deleting a vector from the data array and the list. Definition: svsetbase.h:248 Generic Real linked list.Class IdList implements an intrusive Real linked list as a template class... Definition: idlist.h:123 bool has(const DataKey &k) const True iff SVSetBase contains a SVectorBase for DataKey k. Definition: svsetbase.h:782 void add(DataKey &nkey, const S *rowValues, const int *rowIndices, int rowSize) Adds svec to SVSetBase. Definition: svsetbase.h:338 void add(DataKey nkey[], const SVSetBase< S > &pset) Adds all SVectorBases of pset to SVSetBase. Definition: svsetbase.h:414 DataKey key(const SVectorBase< R > *svec) const Gets DataKey of SVectorBase. Definition: svsetbase.h:764 T * next(const T *elem) const returns successor of elem or 0, if elem is the last element. Definition: idlist.h:143 Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ... Definition: datakey.h:46 Save arrays of data objects. Set of data objects.Class DataSet manages of sets of data objects of a template type DATA... Definition: dataset.h:86 Set of data objects. void add(DataKey nkey[], const SVectorBase< R > svec[], int n) Adds n SVectorBases to SVSetBase. Definition: svsetbase.h:379 int numUnusedMemUpdates counter for how often unusedMem has been updated since last exact value Definition: svsetbase.h:150 const SVectorBase< R > & operator[](int n) const Gets SVectorBase by number. Definition: svsetbase.h:722 SVectorBase< R > * create(DataKey &nkey, int idxmax=-1) Creates new SVectorBase in set. Definition: svsetbase.h:463 ClassArray< Nonzero< R > > SVSetBaseArray Definition: svsetbase.h:68 void updateUnusedMemEstimation(int change) update estimation of unused memory Definition: svsetbase.h:185 bool has(const SVectorBase< R > *svec) const Is an SVectorBase in the set? Definition: svsetbase.h:794 SVectorBase< R > & operator[](int n) Gets SVectorBase by number, writeable. Definition: svsetbase.h:716 void add(const SVectorBase< R > svec[], int n) Adds all n SVectorBases in the array svec to the set. Definition: svsetbase.h:355 Safe arrays of class objects.Class ClassArray provides safe arrays of general C++ objects (in contras... Definition: classarray.h:55 void add(DataKey &nkey, const SVectorBase< R > &svec) Adds svec to SVSetBase. Definition: svsetbase.h:321 Debugging, floating point type and parameter definitions. SVSetBase< R > & operator=(const SVSetBase< S > &rhs) Assignment operator. Definition: svsetbase.h:1006 Everything should be within this namespace. void add2(SVectorBase< R > &svec, int n, const int idx[], const S val[]) Adds n nonzeros to svec of this SVSetBase. Definition: svsetbase.h:578 Sparse vectors. ptrdiff_t reMax(int newMax=1, int newSize=-1) Resets maximum number of elements. Definition: classarray.h:248 SVectorBase< R > & assignArray(const S *rowValues, const int *rowIndices, int rowSize) Assignment operator. Definition: svectorbase.h:627 void ensureMem(int n, bool shortenLast=true) Provides enough nonzero memory for n more Nonzeros. Definition: svsetbase.h:206 void insert(int i, int n) Inserts n uninitialized elements before i 'th element. Definition: classarray.h:132 void add2(SVectorBase< R > &svec, int idx, R val) Adds nonzero (idx, val) to svec of this SVSetBase. Definition: svsetbase.h:553 void add2(SVectorBase< R > &svec, int n, const int idx[], const R val[]) Adds n nonzeros to svec of this SVSetBase. Definition: svsetbase.h:565 void xtend(SVectorBase< R > &svec, int newmax) Extends svec to fit newmax nonzeros. Definition: svsetbase.h:475 void add(const SVSetBase< S > &pset) Adds all SVectorBases in pset to SVSetBase. Definition: svsetbase.h:389 Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors... Definition: dvectorbase.h:31 const SVectorBase< R > & operator[](const DataKey &k) const Gets SVectorBase by DataKey. Definition: svsetbase.h:734 Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a... Definition: ssvectorbase.h:33 bool has(int n) const True iff SVSetBase contains a SVectorBase for vector number n. Definition: svsetbase.h:788 |