34#define SOPLEX_DEBUG_SVSETBASE
209 "counting unused memory (unusedMem = {}, numUnusedMemUpdates = {}, this = {})\n",
252 if(
list.last() && shortenLast)
256 int unusedPsMem = ps->
max() - ps->
size();
257 assert(unusedPsMem >= 0);
265 SPxOut::debug(
this,
"ensureMem, this = {} : updateUnusedMemEstimation -= {}\n", (
void*)
this,
275 if(missingMem > 0 && missingMem <=
unusedMem
295 if(ps ==
list.last())
301 SPxOut::debug(
this,
"deleteVec (1), this = {} : updateUnusedMemEstimation -= {}\n", (
void*)
this,
309 else if(ps !=
list.first())
312 int sz = prev->
size();
319 SPxOut::debug(
this,
"deleteVec (2), this = {} : updateUnusedMemEstimation += {}\n", (
void*)
this,
331 SPxOut::debug(
this,
"deleteVec (3), this = {} : updateUnusedMemEstimation += {}\n", (
void*)
this,
385 void add(
DataKey& nkey,
const S* rowValues,
const int* rowIndices,
int rowSize)
387 assert(rowSize <= 0 || rowIndices !=
nullptr);
388 assert(rowSize <= 0 || rowValues !=
nullptr);
396 new_svec->
assignArray(rowValues, rowIndices, rowSize);
409 for(i = len = 0; i < n; ++i)
410 len += svec[i].
size();
415 for(i = 0; i < n; ++i)
430 for(
int i =
num() - 1; --n; --i)
444 for(i = len = 0; i < n; ++i)
445 len += pset[i].
size();
450 for(i = 0; i < n; ++i)
470 nkey[--n] =
key(--i);
483 if(
memSize() == 0 && idxmax <= 0)
525 if(svec.
max() < newmax)
532 if(ps ==
list.last())
547 SPxOut::debug(
this,
"xtend (1), this = {} : updateUnusedMemEstimation -= {}\n", (
void*)
this,
575 if(ps !=
list.first())
578 int prevsz = prev->
size();
585 SPxOut::debug(
this,
"xtend (2), this = {} : updateUnusedMemEstimation += {}\n", (
void*)
this,
620 svec.
add(n, idx, val);
633 svec.
add(n, idx, val);
648 set.remove(removekey);
680 for(
int i = j - 1; i >= 0; --i)
712 for(
int i =
num() - 1; i >= 0; --i)
716 perm[
number(*keys++)] = -1;
728 void remove(
const int nums[],
int n,
int* perm)
730 for(
int i =
num() - 1; i >= 0; --i)
818 return set.key(
static_cast<const DLPSV*
>(svec));
824 return set.number(k);
830 return set.number(
static_cast<const DLPSV*
>(svec));
848 return set.has(
static_cast<const DLPSV*
>(svec));
878 "counting unused memory (unusedMem = {}, numUnusedMemUpdates = {}, this = {})\n",
891 int l_max = ps->max();
895 ps->setMem(l_max, newmem);
929 for(used = 0, ps =
list.first(); ps; ps =
list.next(ps))
931 const int sz = ps->
size();
933 if(ps->
mem() != &this->SVSetBaseArray::operator[](used))
936 for(j = 0; j < sz; ++j)
937 this->SVSetBaseArray::operator[](used + j) = ps->
mem()[j];
939 ps->
setMem(sz, &this->SVSetBaseArray::operator[](used));
950 "counting unused memory (unusedMem = {}, numUnusedMemUpdates = {}, this = {})\n",
unusedMem,
953 " --> NEW: unusedMem = {}, zero after memPack() at memMax() = {}\n",
983#ifdef ENABLE_CONSISTENCY_CHECKS
987 for(ps =
list.first(); ps; ps = next)
995 next =
list.next(ps);
997 if(next && ps->
mem() + ps->
max() != next->
mem())
1015 SVSetBase(
int pmax = -1,
int pmemmax = -1,
double pfac = 1.1,
double pmemFac = 1.2)
1016 :
SVSetBaseArray(0, (pmemmax > 0) ? pmemmax : 8 * ((pmax > 0) ? pmax : 8), pmemFac)
1017 ,
set((pmax > 0) ? pmax : 8)
1046 ptrdiff_t delta =
reinterpret_cast<char*
>(delta0) -
reinterpret_cast<char*
>(delta1);
1048 for(ps = rhs.
list.first(); ps; ps = rhs.
list.next(ps))
1053 reinterpret_cast<Nonzero<R>*
>(
reinterpret_cast<char*
>(ps->
mem()) + delta));
1065 template <
class S >
1094 template <
class S >
1113#ifdef SOPLEX_DEBUG_SVSETBASE
1115#undef SOPLEX_DEBUG_SVSETBASE
Save arrays of data objects.
Safe arrays of class objects.
bool isConsistent() const
Consistency check.
ClassArray & operator=(const ClassArray &rhs)
Assignment operator.
Nonzero< R > * get_ptr()
Gets a C pointer to the data.
int max() const
Returns maximum number of elements.
void insert(int i, int n)
Inserts n uninitialized elements before i 'th element.
ptrdiff_t reMax(int newMax=1, int newSize=-1)
Resets maximum number of elements.
void reSize(int newsize)
Resets size to newsize.
void removeLast(int m=1)
Removes m last elements.
Nonzero< R > * data
the array of elements
void clear()
Removes all elements.
double memFactor
memory extension factor.
Nonzero< R > & last()
Reference to last element.
int size() const
Returns number of elements.
T * get_ptr()
get a C pointer to the data.
Entry identifier class for items of a DataSet.
Generic Real linked list.
Sparse vector nonzero element.
static void debug(const T *, Args &&... args)
SVectorBase with prev/next pointers.
DLPSV()
Default constructor.
DLPSV * thenext
next SVectorBase
DLPSV(DLPSV &©)
move constructor.
DLPSV *const & prev() const
Previous SVectorBase.
DLPSV *& prev()
Previous SVectorBase.
DLPSV *const & next() const
Next SVectorBase.
DLPSV * theprev
previous SVectorBase
DLPSV *& next()
Next SVectorBase.
DLPSV & operator=(DLPSV &&rhs)
move assignment operator.
DLPSV & operator=(const DLPSV &rhs)
Assignment operator.
DLPSV(const DLPSV ©)
Copy constructor.
void add2(SVectorBase< R > &svec, int n, const int idx[], const S val[])
Adds n nonzeros to svec of this SVSetBase.
void countUnusedMem()
count size of unused memory exactly
void remove(int removenum)
Removes the vector with number removenum from the set.
bool has(int n) const
True iff SVSetBase contains a SVectorBase for vector number n.
void updateUnusedMemEstimation(int change)
update estimation of unused memory
void remove(const DataKey keys[], int n, int *perm)
void add(const SVectorBase< R > svec[], int n)
Adds all n SVectorBases in the array svec to the set.
void add(const SVSetBase< S > &pset)
Adds all SVectorBases in pset to SVSetBase.
int numUnusedMemUpdates
counter for how often unusedMem has been updated since last exact value
SVectorBase< R > * create(DataKey &nkey, int idxmax=-1)
Creates new SVectorBase in set.
void remove(const DataKey &removekey)
Removes the vector with key removekey from the set.
double factor
sparse vector memory enlargment factor
void xtend(SVectorBase< R > &svec, int newmax)
Extends svec to fit newmax nonzeros.
IdList< DLPSV > list
doubly linked list for non-zero management
void remove(const DataKey keys[], int n)
Removes n SVectorBases from set.
bool isConsistent() const
Consistency check.
void ensureMem(int n, bool shortenLast=true)
Provides enough nonzero memory for n more Nonzeros.
void add2(SVectorBase< R > &svec, int idx, R val)
Adds nonzero (idx, val) to svec of this SVSetBase.
void ensurePSVec(int n)
Provides enough vector memory for n more SVectorBases.
const SVectorBase< R > & operator[](int n) const
Gets SVectorBase by number.
int memSize() const
Used nonzero memory.
void remove(int perm[])
Removes multiple elements.
SVectorBase< R > & operator[](int n)
Gets SVectorBase by number, writeable.
int number(const DataKey &k) const
Gets vector number of DataKey.
int max() const
Current maximum number of SVectorBases.
ClassSet< DLPSV > set
set of SVectorBases
void remove(const int nums[], int n, int *perm)
int unusedMem
an estimate of the unused memory (the difference of max() and size() summed up over all vectors) due ...
void deleteVec(DLPSV *ps)
Deleting a vector from the data array and the list.
SVectorBase< R > & operator[](const DataKey &k)
Gets SVectorBase by DataKey, writeable.
int number(const SVectorBase< R > *svec) const
Gets vector number of SVectorBase.
int memMax() const
Length of nonzero memory.
void memRemax(int newmax)
Reset length of nonzero memory.
int num() const
Current number of SVectorBases.
void add(DataKey &nkey, const S *rowValues, const int *rowIndices, int rowSize)
Adds svec to SVSetBase.
void add2(SVectorBase< R > &svec, int n, const int idx[], const R val[])
Adds n nonzeros to svec of this SVSetBase.
SVSetBase< R > & operator=(const SVSetBase< R > &rhs)
Assignment operator.
SVSetBase(int pmax=-1, int pmemmax=-1, double pfac=1.1, double pmemFac=1.2)
Default constructor.
bool has(const SVectorBase< R > *svec) const
Is an SVectorBase in the set?
SVSetBase< R > & operator=(const SVSetBase< S > &rhs)
Assignment operator.
bool has(const DataKey &k) const
True iff SVSetBase contains a SVectorBase for DataKey k.
void add(DataKey nkey[], const SVectorBase< R > svec[], int n)
Adds n SVectorBases to SVSetBase.
void clear(int minNewSize=-1)
Removes all SVectorBases from set.
DataKey key(const SVectorBase< R > *svec) const
Gets DataKey of SVectorBase.
void reMax(int newmax=0)
Resets maximum number of SVectorBases.
SVSetBase(const SVSetBase< R > &old)
Copy constructor.
void remove(const int nums[], int n)
Removes n SVectorBases from set.
void add(DataKey nkey[], const SVSetBase< S > &pset)
Adds all SVectorBases of pset to SVSetBase.
void memPack()
Garbage collection in nonzero memory.
DataKey key(int n) const
Gets DataKey of vector number.
SVSetBase(const SVSetBase< S > &old)
Copy constructor.
virtual ~SVSetBase()
Destructor.
SVectorBase< R > * create(int idxmax=0)
Creates new SVectorBase in set.
void remove(const SVectorBase< R > *svec)
Removes one SVectorBase from set.
ClassArray< Nonzero< R > > SVSetBaseArray
void add(const SVectorBase< R > &svec)
Adds svec to the set.
void add(DataKey &nkey, const SVectorBase< R > &svec)
Adds svec to SVSetBase.
const SVectorBase< R > & operator[](const DataKey &k) const
Gets SVectorBase by DataKey.
bool isConsistent() const
Consistency check.
void setMem(int n, Nonzero< R > *elmem)
Set the memory area where the nonzeros will be stored.
void add(int i, const R &v)
Append one nonzero (i,v).
int max() const
Maximal number of indices.
void set_size(int s)
Set size of the vector.
SVectorBase< R > & assignArray(const S *rowValues, const int *rowIndices, int rowSize)
Assignment operator.
Nonzero< R > * mem() const
get pointer to internal memory.
SVectorBase< R > & operator=(const VectorBase< S > &vec)
Assignment operator.
void set_max(int m)
Set the maximum number of nonzeros in the vector.
int size() const
Number of used indices.
Entry identifier class for items of a DataSet.
Generic Real linked list.
Everything should be within this namespace.
Debugging, floating point type and parameter definitions.
#define SPX_MSG_INCONSISTENT(name)