28 #ifndef _LPROWSETBASE_H_ 29 #define _LPROWSETBASE_H_ 278 SPX_MSG_ERROR(std::cerr <<
"EROWST01 RANGE not supported in LPRowSet::setType()" << std::endl);
351 const int& pscaleExp = 0)
354 add(k, plhs, prowVector, prhs, pobj, pscaleExp);
359 void add(
const S* lhsValue,
const S* rowValues,
const int* rowIndices,
int rowSize,
360 const S* rhsValue,
const S* objValue = 0)
362 assert(lhsValue != 0);
363 assert(rowSize <= 0 || rowValues != 0);
364 assert(rowSize <= 0 || rowIndices != 0);
365 assert(rhsValue != 0);
368 add(k, lhsValue, rowValues, rowIndices, rowSize, rhsValue, objValue);
374 void add(
DataKey& newkey,
const S* lhsValue,
const S* rowValues,
const int* rowIndices,
int rowSize,
375 const S* rhsValue,
const S* objValue = 0)
377 assert(lhsValue != 0);
378 assert(rowSize <= 0 || rowValues != 0);
379 assert(rowSize <= 0 || rowIndices != 0);
380 assert(rhsValue != 0);
391 left[
num() - 1] = *lhsValue;
392 right[
num() - 1] = *rhsValue;
395 object[
num() - 1] = *objValue;
397 object[
num() - 1] = 0;
403 const R& newobj = 0,
const int& newscaleExp = 0)
415 left[
num() - 1] = newlhs;
416 right[
num() - 1] = newrhs;
417 object[
num() - 1] = newobj;
418 scaleExp[
num() - 1] = newscaleExp;
436 for(
int j = 0; i <
num(); ++i, ++j)
438 left[i] = newset.
lhs(j);
439 right[i] = newset.
rhs(j);
440 object[i] = newset.
obj(j);
452 for(
int j = 0; i <
num(); ++i, ++j)
469 void add2(
const DataKey& k,
int n,
const int idx[],
const R val[])
475 void add2(
int i,
int n,
const int idx[],
const R val[])
482 void add2(
int i,
int n,
const int idx[],
const S val[])
489 const int& pscaleExp = 0)
492 return create(k, pnonzeros, plhs, prhs, pobj, pscaleExp);
497 const R& newobj = 0,
const int& newscaleExp = 0)
499 if(
num() + 1 > left.
dim())
503 object.reDim(
num() + 1);
507 left[
num()] = newlhs;
508 right[
num()] = newrhs;
509 object[
num()] = newobj;
510 scaleExp[
num()] = newscaleExp;
529 left[i] = left[
num()];
530 right[i] = right[
num()];
531 object[i] =
object[
num()];
532 scaleExp[i] = scaleExp[
num()];
546 void remove(
int perm[])
552 for(
int i = 0; i < j; ++i)
554 if(perm[i] >= 0 && perm[i] != i)
556 left[perm[i]] = left[i];
557 right[perm[i]] = right[i];
558 object[perm[i]] =
object[i];
559 scaleExp[perm[i]] = scaleExp[i];
570 void remove(
const int nums[],
int n)
573 remove(nums, n, perm.
get_ptr());
578 void remove(
const int nums[],
int n,
int* perm)
584 for(
int i = 0; i < j; ++i)
586 if(perm[i] >= 0 && perm[i] != i)
588 left[perm[i]] = left[i];
589 right[perm[i]] = right[i];
590 object[perm[i]] =
object[i];
591 scaleExp[perm[i]] = scaleExp[i];
627 object.reSize(
max());
663 #ifdef ENABLE_CONSISTENCY_CHECKS 664 const int ldim = left.
dim();
666 if(ldim != right.
dim())
669 if(ldim !=
object.dim())
694 :
SVSetBase<R>(pmax, pmemmax), left(0), right(0), object(0), scaleExp(0)
740 , scaleExp(rs.scaleExp)
752 , scaleExp(rs.scaleExp)
764 #endif // _LPROWSETBASE_H_ DataKey key(int i) const
Returns the DataKey of the i 'th LPRowBase in LPRowSetBase.
SVectorBase< R > & rowVector_w(const DataKey &k)
Returns a writable rowVector of the LPRowBase with DataKey k.
VectorBase< R > & obj_w()
Returns the vector of objective coefficients (writeable).
int max() const
Returns the maximum number of LPRowBases that fit.
int memMax() const
Returns length of nonzero memory.
int memSize() const
Returns number of used nonzero entries.
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
const R & value(const DataKey &k) const
Returns the value of the LPRowBase with DataKey k.
void add(const S *lhsValue, const S *rowValues, const int *rowIndices, int rowSize, const S *rhsValue, const S *objValue=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
VectorBase< R > left
vector of left hand sides (lower bounds) of LPRowBases.
const SVectorBase< R > & rowVector(const DataKey &k) const
Returns the rowVector of the LPRowBase with DataKey k.
void add2(int i, int n, const int idx[], const R val[])
Adds n nonzero (idx, val)-pairs to i 'th rowVector.
LPRowBase< R >::Type type(int i) const
Returns the inequalitiy type of the i 'th LPRowBase.
SVSetBase< R > & operator=(const SVSetBase< R > &rhs)
Assignment operator.
void add(DataKey keys[], const LPRowSetBase< R > &set)
Adds all LPRowBases of set to LPRowSetBase.
Entry identifier class for items of a DataSet.
R & rhs_w(int i)
Returns the rhs of the i 'th LPRowBase (writeable).
void reMax(int newmax=0)
Resets maximum number of SVectorBases.
Dense vector.Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std...
T * get_ptr()
get a C pointer to the data.
const VectorBase< R > & lhs() const
Returns the vector of lhs values.
void xtend(int n, int newmax)
Extends row n to fit newmax nonzeros.
void clear()
Removes all LPRowBases.
const R & rhs(const DataKey &k) const
Returns the rhs of the LPRowBase with DataKey k in LPRowSetBase.
const SVectorBase< R > & rowVector() const
Constraint row vector.
#define SPX_MSG_INCONSISTENT(name)
R & lhs_w(const DataKey &k)
Returns the lhs of the LPRowBase with DataKey k in LPRowSetBase.
const R & lhs(const DataKey &k) const
Returns the lhs of the LPRowBase with DataKey k in LPRowSetBase.
R rhs() const
Right-hand side value.
const R & value(int i) const
Returns the value of the i'th LPRowBase.
int number(const DataKey &k) const
Gets vector number of DataKey.
void setType(int i, typename LPRowBase< R >::Type t)
Changes the inequality type of row i to type.
virtual ~LPRowSetBase()
Destructor.
#define SPX_MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
void clear()
remove all elements.
int memSize() const
Used nonzero memory.
SVectorBase< R > * create(int idxmax=0)
Creates new SVectorBase in set.
VectorBase< R > & lhs_w()
Returns the vector of lhs values.
void xtend(const DataKey &pkey, int pnewmax)
Extends row with DataKey key to fit newmax nonzeros.
void add(const LPRowBase< R > &row)
R & lhs_w(int i)
Returns the lhs of the i 'th LPRowBase.
LPRowSetBase(const LPRowSetBase< S > &rs)
Copy constructor.
Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ...
DataKey key(int n) const
Gets DataKey of vector number.
void memRemax(int newmax)
Reallocates memory to be able to store newmax nonzeros.
void memPack()
Garbage collection in nonzero memory.
void add(DataKey &pkey, const LPRowBase< R > &prow)
Adds row to LPRowSetBase.
const R & obj(const DataKey &k) const
Returns the objective coefficient of the LPRowBase with DataKey k in LPRowSetBase.
VectorBase< R > right
vector of right hand sides (upper bounds) of LPRowBases.
const R & lhs(int i) const
Returns the lhs of the i 'th LPRowBase.
void add(const SVectorBase< R > &svec)
Adds svec to the set.
const VectorBase< R > & rhs() const
Returns the vector of rhs values.
R lhs() const
Left-hand side value.
void add2(int i, int n, const int idx[], const S val[])
Adds n nonzero (idx, val)-pairs to i 'th rowVector.
LPRowSetBase< R > & operator=(const LPRowSetBase< R > &rs)
Assignment operator.
SVectorBase< R > & rowVector_w(int i)
Returns a writable rowVector of the i 'th LPRowBase.
int memMax() const
Length of nonzero memory.
SVectorBase< R > & operator[](int n)
Gets SVectorBase by number, writeable.
bool has(const DataKey &k) const
True iff SVSetBase contains a SVectorBase for DataKey k.
const R & obj(int i) const
Returns the objective coefficient of the i 'th LPRowBase.
bool isConsistent() const
Consistency check.
void add2(const DataKey &k, int n, const int idx[], const R val[])
Adds n nonzero (idx, val)-pairs to rowVector with DataKey k.
void reSize(int newsize)
Resets VectorBase's memory size to newsize.
void add(DataKey &newkey, const R &newlhs, const SVectorBase< R > &newrowVector, const R &newrhs, const R &newobj=0, const int &newscaleExp=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
SVectorBase< R > & create(DataKey &newkey, int nonzeros=0, const R &newlhs=0, const R &newrhs=1, const R &newobj=0, const int &newscaleExp=0)
Creates new LPRowBase with specified parameters and returns a reference to its row vector...
DataArray< int > scaleExp
row scaling factors (stored as bitshift)
SOPLEX_THREADLOCAL const Real infinity
LPRowSetBase< R > & operator=(const LPRowSetBase< S > &rs)
Assignment operator.
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
void memRemax(int newmax)
Reset length of nonzero memory.
void memPack()
Garbage collection in nonzero memory.
Debugging, floating point type and parameter definitions.
R & obj_w(int i)
Returns the objective coefficient of the i 'th LPRowBase (writeable).
Collection of dense, sparse, and semi-sparse vectors.
int dim() const
Dimension of vector.
LPRowBase< R >::Type type(const DataKey &k) const
Returns the inequality type of the LPRowBase with DataKey k.
Everything should be within this namespace.
LPRowSetBase(const LPRowSetBase< R > &rs)
Copy constructor.
void reMax(int newmax=0)
Reallocates memory to be able to store newmax LPRowBases.
void add(const LPRowSetBase< R > &newset)
R & obj_w(const DataKey &k)
Returns the objective coefficient of the LPRowBase with DataKey k in LPRowSetBase (writeable)...
const SVectorBase< R > & rowVector(int i) const
Returns the rowVector of the i 'th LPRowBase.
Type
(In)Equality type of an LP row.
void add(DataKey &newkey, const S *lhsValue, const S *rowValues, const int *rowIndices, int rowSize, const S *rhsValue, const S *objValue=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
R obj() const
Objective coefficient value.
void reDim(int newdim, const bool setZero=true)
Resets VectorBase's dimension to newdim.
bool has(const DataKey &k) const
does DataKey k belong to LPRowSetBase ?
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
LPRowSetBase(int pmax=-1, int pmemmax=-1)
Default constructor.
void add2(SVectorBase< R > &svec, int idx, R val)
Adds nonzero (idx, val) to svec of this SVSetBase.
VectorBase< R > object
vector of objective coefficients.
bool isConsistent() const
Checks consistency.
void add(const R &plhs, const SVectorBase< R > &prowVector, const R &prhs, const R &pobj=0, const int &pscaleExp=0)
Adds LPRowBase consisting of left hand side lhs, row vector rowVector, and right hand side rhs to LPR...
void xtend(SVectorBase< R > &svec, int newmax)
Extends svec to fit newmax nonzeros.
void remove(const DataKey &removekey)
Removes the vector with key removekey from the set.
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
const R & rhs(int i) const
Returns the rhs of the i 'th LPRowBase.
int number(const DataKey &k) const
Returns the number of the LPRowBase with DataKey k in LPRowSetBase.
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
const SVSetBase< R > * rowSet() const
Returns the complete SVSet.
R & rhs_w(const DataKey &k)
Returns the rhs of the LPRowBase with DataKey k in LPRowSetBase (writeable).
int max() const
Current maximum number of SVectorBases.
const VectorBase< R > & obj() const
Returns the vector of objective coefficients.
void reSize(int newsize)
reset size to newsize.
SVectorBase< R > & create(int pnonzeros=0, const R &plhs=0, const R &prhs=1, const R &pobj=0, const int &pscaleExp=0)
Creates new LPRowBase with specified parameters and returns a reference to its row vector...
int num() const
Current number of SVectorBases.
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
void clear()
Removes all elements.
int num() const
Returns the number of LPRowBases in LPRowSetBase.