24 #define SOPLEX_DEBUG_SPXLPBASE 127 spxout = &newOutstream;
167 for(
int i = 0; i <
nCols(); ++i )
174 virtual R
minAbsNzo(
bool unscaled =
true)
const;
177 virtual R
maxAbsNzo(
bool unscaled =
true)
const;
199 for(
int i = start; i <= end; i++ )
357 for(
int i = start; i <= end; i++ )
367 for(
int i = start; i <= end; i++ )
588 doAddRow(lhsValue, rowVec, rhsValue, scale);
593 void addRow(
const S* lhsValue,
const S* rowValues,
const int* rowIndices,
int rowSize,
const S* rhsValue)
595 assert(lhsValue != 0);
596 assert(rowSize <= 0 || rowValues != 0);
597 assert(rowSize <= 0 || rowIndices != 0);
598 assert(rhsValue != 0);
601 int oldColNumber =
nCols();
606 for(
int j = rowSize - 1; j >= 0; --j )
608 const S& val = rowValues[j];
609 int i = rowIndices[j];
615 for(
int k =
nCols(); k <= i; ++k )
642 void addRows(
const S* lhsValues,
const S* rowValues,
const int* rowIndices,
const int* rowStarts,
const int* rowLengths,
const int numRows,
const int numValues,
const S* rhsValues)
644 assert(lhsValues != 0);
645 assert(numValues <= 0 || rowValues != 0);
646 assert(numValues <= 0 || rowIndices != 0);
647 assert(numValues <= 0 || rowStarts != 0);
648 assert(numValues <= 0 || rowLengths != 0);
649 assert(rhsValues != 0);
654 int oldRowNumber =
nRows();
655 int oldColNumber =
nCols();
658 for( i = 0; i < numRows; i++ )
660 assert(numValues <= 0 || rowStarts[i] + rowLengths[i] <= numValues);
664 LPRowSetBase<R>::add(&(lhsValues[i]), &(rowValues[rowStarts[i]]), &(rowIndices[rowStarts[i]]), rowLengths[i], &(rhsValues[i]));
671 for( i =
nCols() - 1; i >= 0; --i )
675 for( i = 0; i < numRows; i++ )
677 for( j = rowStarts[i]; j < rowStarts[i] + rowLengths[i]; j++ )
680 assert(rowIndices[j] >= 0);
681 assert(rowIndices[j] < oldColNumber);
682 newCols[rowIndices[j]]++;
688 for( i =
nCols() - 1; i >= 0; --i )
692 int len = newCols[i] +
colVector(i).size();
702 for( i =
nRows() - 1; i >= oldRowNumber; --i )
706 for( j = vec.
size() - 1; j >= 0; --j )
710 idx = col->
size() - newCols[k];
711 assert(newCols[k] > 0);
720 for( i = 0; i <
nCols(); ++i )
721 assert( newCols[i] == 0 );
726 assert( numRows ==
nRows() - oldRowNumber );
736 for(
int j = 0; i <
nRows(); ++i, ++j )
747 virtual void addCol(
const R& objValue,
const R& lowerValue,
const SVectorBase<R>& colVec,
const R& upperValue,
bool scale =
false)
749 doAddCol(objValue, lowerValue, colVec, upperValue, scale);
754 void addCol(
const S* objValue,
const S* lowerValue,
const S* colValues,
const int* colIndices,
int colSize,
const S* upperValue)
757 int oldRowNumber =
nRows();
764 for(
int j = colSize - 1; j >= 0; --j )
766 const S& val = colValues[j];
767 int i = colIndices[j];
773 for(
int k =
nRows(); k <= i; ++k )
800 void addCols(
const S* objValue,
const S* lowerValues,
const S* colValues,
const int* colIndices,
const int* colStarts,
const int* colLengths,
const int numCols,
const int numValues,
const S* upperValues)
802 assert(lowerValues != 0);
803 assert(numValues <= 0 || colValues != 0);
804 assert(numValues <= 0 || colIndices != 0);
805 assert(numValues <= 0 || colStarts != 0);
806 assert(numValues <= 0 || colLengths != 0);
807 assert(upperValues != 0);
812 int oldColNumber =
nCols();
813 int oldRowNumber =
nRows();
817 for( i = 0; i < numCols; i++ )
819 assert(numValues <= 0 || colStarts[i] + colLengths[i] <= numValues);
823 LPColSetBase<R>::add(&(objValue[i]), &(lowerValues[i]), &(colValues[colStarts[i]]), &(colIndices[colStarts[i]]), colLengths[i], &(upperValues[i]));
833 for( i =
nRows() - 1; i >= 0; --i )
835 for( i = numValues - 1; i >= 0; --i )
838 assert(colIndices[i] >= 0);
839 assert(colIndices[i] < oldRowNumber);
840 newRows[colIndices[i]]++;
844 for( i =
nRows() - 1; i >= 0; --i )
848 int len = newRows[i] +
rowVector(i).size();
858 for( i =
nCols() - 1; i >= oldColNumber; --i )
862 for( j = vec.
size() - 1; j >= 0; --j )
866 idx = row->
size() - newRows[k];
867 assert(newRows[k] > 0);
876 for( i = 0; i <
nRows(); ++i )
877 assert( newRows[i] == 0 );
882 assert( numCols ==
nCols() - oldColNumber );
893 for(
int j = 0; i <
nCols(); ++i, ++j )
939 for(
int i =
nRows() - 1; i >= 0; --i )
964 for(
int i =
nRows() - 1; i >= 0; --i )
979 int i = end - start + 1;
990 for( i = 0; i < start; ++i )
992 for( ; i <= end; ++i )
994 for( ; i <
nRows(); ++i )
1036 for(
int i =
nCols() - 1; i >= 0; --i )
1040 perm[
number(
id[n])] = -1;
1061 for(
int i =
nCols() - 1; i >= 0; --i )
1076 int i = end - start + 1;
1087 for( i = 0; i < start; ++i )
1089 for( ; i <= end; ++i )
1091 for( ; i <
nCols(); ++i )
1146 ok = ((c ==
'*') || (c ==
'N'))
1147 ?
readMPS(in, rowNames, colNames, intVars)
1148 :
readLPF(in, rowNames, colNames, intVars);
1162 return read(file, rowNames, colNames, intVars);
1178 std::ofstream tmp(filename);
1179 size_t len_f = strlen(filename);
1181 if( len_f > 4 && filename[len_f-1] ==
's' && filename[len_f-2] ==
'p' && filename[len_f-3] ==
'm' && filename[len_f-4] ==
'.' )
1183 writeMPS(tmp, rowNames, colNames, p_intvars);
1187 writeLPF(tmp, rowNames, colNames, p_intvars);
1197 int countFreeCol = 0;
1201 int countRanged = 0;
1202 int countFreeRow = 0;
1204 for(
int i = 0; i <
nCols(); i++ )
1206 bool hasLower =
false;
1207 bool hasUpper =
false;
1221 if( hasUpper && hasLower )
1224 if( !hasUpper && !hasLower )
1228 for(
int i = 0; i <
nRows(); i++)
1230 bool hasRhs =
false;
1231 bool hasLhs =
false;
1245 if( hasRhs && hasLhs )
1248 if( !hasRhs && !hasLhs )
1253 os <<
" Columns : " <<
nCols() <<
"\n" 1254 <<
" boxed : " << countBoxed <<
"\n" 1255 <<
" lower bound : " << countLower <<
"\n" 1256 <<
" upper bound : " << countUpper <<
"\n" 1257 <<
" free : " << countFreeCol <<
"\n" 1258 <<
" Rows : " <<
nRows() <<
"\n" 1259 <<
" ranged : " << countRanged <<
"\n" 1260 <<
" lhs : " << countLhs <<
"\n" 1261 <<
" rhs : " << countRhs <<
"\n" 1262 <<
" free : " << countFreeRow <<
"\n" 1263 <<
" Nonzeros : " <<
nNzos() <<
"\n" 1286 virtual void changeObj(
int i,
const R& newVal,
bool scale =
false)
1294 template <
class S >
1332 template <
class S >
1348 assert(
lower().dim() == newLower.
dim());
1354 virtual void changeLower(
int i,
const R& newLower,
bool scale =
false)
1368 template <
class S >
1384 assert(
upper().dim() == newUpper.
dim());
1390 virtual void changeUpper(
int i,
const R& newUpper,
bool scale =
false)
1404 template <
class S >
1426 virtual void changeBounds(
int i,
const R& newLower,
const R& newUpper,
bool scale =
false)
1434 template <
class S >
1451 assert(
lhs().dim() == newLhs.
dim());
1457 virtual void changeLhs(
int i,
const R& newLhs,
bool scale =
false)
1467 template <
class S >
1483 assert(
rhs().dim() == newRhs.
dim());
1489 virtual void changeRhs(
int i,
const R& newRhs,
bool scale =
false)
1513 virtual void changeRange(
int i,
const R& newLhs,
const R& newRhs,
bool scale =
false)
1521 template <
class S >
1574 for( j = row.
size() - 1; j >= 0; --j )
1577 int position = col.
pos(n);
1579 assert(position != -1);
1592 for( j = newrow.size() - 1; j >= 0; --j )
1594 int idx = newrow.index(j);
1595 R val = newrow.value(j);
1619 for( j = col.
size() - 1; j >= 0; --j )
1622 int position = row.
pos(n);
1624 assert(position != -1);
1637 for( j = newcol.size() - 1; j >= 0; --j )
1639 int idx = newcol.index(j);
1640 R val = newcol.value(j);
1659 if( i < 0 || j < 0 )
1678 if( row.
pos(j) >= 0 && col.
pos(i) >= 0 )
1689 else if( row.
pos(j) >= 0 && col.
pos(i) >= 0 )
1699 template <
class S >
1708 if( mpq_get_d(*val) != R(0) )
1710 if( row.
pos(j) >= 0 && col.
pos(i) >= 0 )
1721 else if( row.
pos(j) >= 0 && col.
pos(i) >= 0 )
1739 if( sns != thesense )
1768 for(
int i = primal.
size() - 1; i >= 0; i-- )
1770 assert(primal.
index(i) >= 0);
1791 for(
int i = dual.
size() - 1; i >= 0; i-- )
1793 assert(dual.
index(i) >= 0);
1814 for(
int r = 0; r <
nRows(); r++ )
1831 SPxRowId dualRowIds[] = 0,
SPxColId dualColIds[] = 0,
int* nprimalrows = 0,
int* nprimalcols = 0,
1832 int* ndualrows = 0,
int* ndualcols = 0);
1843 #ifdef ENABLE_CONSISTENCY_CHECKS 1845 for(
int i =
nCols() - 1; i >= 0; --i )
1849 for(
int j = v.
size() - 1; j >= 0; --j )
1862 for(
int i =
nRows() - 1; i >= 0; --i )
1866 for(
int j = v.
size() - 1; j >= 0; --j )
1954 for(
int i = vec.
size() - 1; i >= 0; --i )
1957 int position = remvec.
pos(j);
1963 int idx =
nRows() - 1;
1967 for(
int i = l_vec.
size() - 1; i >= 0; --i )
1970 int position = movevec.
pos(idx);
1972 assert(position != -1);
1975 movevec.
index(position) = j;
1989 for(
int i = 0; i < j; ++i )
1992 for(
int k = vec.
size() - 1; k >= 0; --k )
1994 int idx = vec.
index(k);
1998 vec.
index(k) = perm[idx];
2011 for( i = vec.
size() - 1; i >= 0; --i )
2014 int position = remvec.
pos(j);
2016 assert(position != -1);
2023 int idx =
nCols() - 1;
2027 for( i = l_vec.
size() - 1; i >= 0; --i )
2030 int position = movevec.
pos(idx);
2032 assert(position != -1);
2035 movevec.
index(position) = j;
2045 int nrows =
nRows();
2049 for(
int i = 0; i < nrows; ++i )
2053 for(
int k = vec.
size() - 1; k >= 0; --k )
2055 int idx = vec.
index(k);
2059 vec.
index(k) = perm[idx];
2080 int* more = moreArray.
get_ptr();
2082 for(
int i =
set.
num() - 1; i >= 0; --i )
2086 int end = addset.
num();
2088 for(
int i = addset.
num() - n; i < end; ++i )
2093 for(
int j = vec.
size() - 1; j >= 0; --j )
2094 more[vec.
index(j)]++;
2100 for(
int i =
set.
num() - 1; i >= 0; --i )
2102 int j =
set[i].size();
2103 set.xtend(
set[i], j + more[i]);
2104 set[i].set_size( j + more[i] );
2108 for(
int i = addset.
num() - n; i < addset.
num(); ++i)
2112 for(
int j = vec.
size() - 1; j >= 0; --j )
2114 int k = vec.
index(j);
2117 l_xtend.
index(m) = i;
2148 int oldColNumber =
nCols();
2149 int newRowScaleExp = 0;
2173 for(
int j = vec.
size() - 1; j >= 0; --j )
2175 int i = vec.
index(j);
2181 R val = vec.
value(j);
2187 for(
int k =
nCols(); k <= i; ++k )
2191 assert(i <
nCols());
2203 int oldColNumber =
nCols();
2204 int newRowScaleExp = 0;
2228 for(
int j = vec.
size() - 1; j >= 0; --j )
2230 int i = vec.
index(j);
2236 R val = vec.
value(j);
2242 for(
int k =
nCols(); k <= i; ++k )
2246 assert(i <
nCols());
2257 int i, j, k, ii, idx;
2260 int oldRowNumber =
nRows();
2261 int oldColNumber =
nCols();
2270 for( i =
nCols() - 1; i >= 0; --i )
2272 for( i =
set.
num() - 1; i >= 0; --i )
2276 for( j = vec.
size() - 1; j >= 0; --j )
2284 for( k =
nCols(); k <= ii; ++k )
2291 assert(ii <
nCols());
2297 for( i =
nCols() - 1; i >= 0; --i )
2299 if( newCols[i] > 0 )
2301 int len = newCols[i] +
colVector(i).size();
2311 for( i =
nRows() - 1; i >= oldRowNumber; --i )
2314 int newRowScaleExp = 0;
2333 for( j = vec.
size() - 1; j >= 0; --j )
2337 idx = col->
size() - newCols[k];
2338 assert(newCols[k] > 0);
2341 col->
index(idx) = i;
2351 for( i = 0; i <
nCols(); ++i )
2352 assert( newCols[i] == 0 );
2357 assert(
set.
num() ==
nRows() - oldRowNumber);
2366 int oldRowNumber =
nRows();
2367 int newColScaleExp = 0;
2393 for(
int j = vec.
size() - 1; j >= 0; --j )
2395 int i = vec.
index(j);
2401 R val = vec.
value(j);
2407 for(
int k =
nRows(); k <= i; ++k )
2411 assert(i <
nRows());
2420 void doAddCol (
const R& objValue,
const R& lowerValue,
const SVectorBase<R>& colVec,
const R& upperValue,
bool scale =
false)
2423 int oldRowNumber =
nRows();
2424 int newColScaleExp = 0;
2450 for(
int j = vec.
size() - 1; j >= 0; --j )
2452 int i = vec.
index(j);
2457 R val = vec.
value(j);
2463 for(
int k =
nRows(); k <= i; ++k )
2467 assert(i <
nRows());
2479 int oldColNumber =
nCols();
2480 int oldRowNumber =
nRows();
2490 for( i =
nRows() - 1; i >= 0; --i )
2493 for( i =
set.
num() - 1; i >= 0; --i )
2497 for( j = vec.
size() - 1; j >= 0; --j )
2500 int l = vec.
index(j);
2505 for(
int k =
nRows(); k <= l; ++k )
2513 assert(l <
nRows());
2519 for( i = 0; i <
nRows(); ++i )
2521 if( newRows[i] > 0 )
2523 int len = newRows[i] +
rowVector(i).size();
2530 for( i = oldColNumber; i <
nCols(); ++i )
2534 int newColScaleExp = 0;
2553 for( j = vec.
size() - 1; j >= 0; --j )
2555 int k = vec.
index(j);
2557 int idx = row.
size() - newRows[k];
2558 assert(newRows[k] > 0);
2570 for( i = 0; i <
nRows(); ++i )
2571 assert( newRows[i] == 0 );
2576 assert(
set.
num() ==
nCols() - oldColNumber);
2615 template <
class S >
2648 template <
class S >
2674 #ifdef SOPLEX_DEBUG_SPXLPBASE 2675 #define SOPLEX_DEBUG 2676 #undef SOPLEX_DEBUG_SPXLPBASE 2679 #endif // _SPXLPBASE_H_ const VectorBase< R > & rhs() const
Returns right hand side vector.
virtual void buildDualProblem(SPxLPBase< R > &dualLP, SPxRowId primalRowIds[]=0, SPxColId primalColIds[]=0, SPxRowId dualRowIds[]=0, SPxColId dualColIds[]=0, int *nprimalrows=0, int *nprimalcols=0, int *ndualrows=0, int *ndualcols=0)
Building the dual problem from a given LP.
VectorBase< R > & obj_w()
Returns the vector of objective coefficients (writeable).
bool has(const SPxId &id) const
Returns the row or column number for identifier id.
LPRowBase< R >::Type rowType(const SPxRowId &id) const
Returns the inequality type of the row with identifier key.
void getRhsUnscaled(VectorBase< Real > &vec) const
Gets unscaled right hand side vector.
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
int number(const SPxId &id) const
Returns the row or column number for identifier id.
virtual void removeRow(int i)
Removes i 'th row.
void getRow(int i, LPRowBase< R > &row) const
Gets i 'th row.
virtual void changeObj(SPxColId id, const R &newVal, bool scale=false)
Changes objective value of column with identifier id to newVal. scale determines whether the new data...
void memRemax(int newmax)
Resets length of nonzero memory.
const SVectorBase< R > & colVector(const SPxColId &id) const
Returns column vector of column with identifier id.
void addRows(const S *lhsValues, const S *rowValues, const int *rowIndices, const int *rowStarts, const int *rowLengths, const int numRows, const int numValues, const S *rhsValues)
SPxRowId rId(int n) const
Returns the row identifier for row n.
void doAddCol(const LPColBase< R > &col, bool scale=false)
const VectorBase< R > & lower() const
const R & objOffset() const
Returns the objective function value offset.
LPRowBase< R >::Type type(int i) const
Returns the inequalitiy type of the i 'th LPRowBase.
const VectorBase< R > & upper() const
Returns upper bound vector.
virtual R minAbsNzo(bool unscaled=true) const
Absolute smallest non-zero element in (possibly scaled) LP.
THREADLOCAL const Real infinity
void getRows(int start, int end, LPRowSetBase< R > &set) const
Gets rows start, ... end.
Entry identifier class for items of a DataSet.
void setOutstream(SPxOut &newOutstream)
const R & upper(int i) const
Returns upper bound of column i.
bool _isScaled
true, if scaling has been performed
Dense vector.Class VectorBase provides dense linear algebra vectors. It does not provide memory manag...
bool has(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Geometric mean row/column scaling.This SPxScaler implementation performs geometric mean scaling of th...
void changeObj(int i, const S *newVal)
changes i 'th objective vector element to newVal.
virtual void changeRange(SPxRowId id, const R &newLhs, const R &newRhs, bool scale=false)
Changes left and right hand side of row with identifier id. scale determines whether the new data sho...
virtual Real scaleElement(const SPxLPBase< Real > &lp, int row, int col, Real val) const
returns scaled LP element in row and col.
const R & maxObj(int i) const
Returns objective value of column i for maximization problem.
virtual void addRows(SPxRowId id[], const LPRowSetBase< R > &set, bool scale=false)
adds all LPRowBases of pset to LPRowSetBase.
T * get_ptr()
get a C pointer to the data.
R & maxObj_w(int i)
Returns objective value of column i for maximization problem.
const VectorBase< R > & lhs() const
Returns the vector of lhs values.
virtual void removeRowRange(int start, int end, int perm[]=0)
Removes rows from start to end (including both).
int size() const
Number of used indices.
void doAddCols(const LPColSetBase< R > &set, bool scale=false)
void xtend(int n, int newmax)
Extends row n to fit newmax nonzeros.
virtual void changeLower(int i, const R &newLower, bool scale=false)
changes i 'th lower bound to newLower. scale determines whether the new data should be scaled ...
void changeRange(int i, const S *newLhs, const S *newRhs)
Changes left and right hand side of row i.
virtual bool readFile(const char *filename, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP from a file.
virtual void changeMaxObj(int i, const R &newVal, bool scale=false)
changes i 'th objective vector element to newVal. scale determines whether the new data should be sca...
bool isScaled() const
Returns true if and only if the LP is scaled.
R rhsUnscaled(int i) const
Returns unscaled right hand side of row number i.
void clear()
Removes all LPRowBases.
virtual void changeCol(int n, const LPColBase< R > &newCol, bool scale=false)
Replaces i 'th column of LP with newCol. scale determines whether the new data should be scaled...
virtual void changeRowObj(int i, const R &newRowObj, bool scale=false)
Changes i 'th row objective function value to newRowObj. scale determines whether the new data should...
virtual void removeCols(int perm[])
Removes multiple columns.
void getObj(VectorBase< R > &pobj) const
Gets objective vector.
void doAddRow(const R &lhsValue, const SVectorBase< R > &rowVec, const R &rhsValue, bool scale=false)
const SVectorBase< R > & rowVector() const
Constraint row vector.
virtual void addedCols(int newcols)
Called after the last n columns have just been added.
R rhs() const
Right-hand side value.
Dynamic sparse vectors.Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with a...
void remove(int i)
Removes i 'th LPColBase.
Least squares scaling.This SPxScaler implementation performs least squares scaling as suggested by Cu...
virtual void changeElement(SPxRowId rid, SPxColId cid, const R &val, bool scale=false)
Changes LP element identified by (rid, cid) to val. scale determines whether the new data should be s...
virtual void changeBounds(int i, const R &newLower, const R &newUpper, bool scale=false)
Changes bounds of column i to newLower and newUpper. scale determines whether the new data should be ...
const R & lhs(int i) const
Returns left hand side of row number i.
R obj(const SPxColId &id) const
Returns objective value of column with identifier id.
void addRow(const S *lhsValue, const S *rowValues, const int *rowIndices, int rowSize, const S *rhsValue)
virtual void removeRows(int nums[], int n, int perm[]=0)
Removes n LPRowBases.
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
void setLower(const R &p_low)
Sets lower bound.
const LPRowSetBase< R > * lprowset() const
Returns the LP as an LPRowSetBase.
void add(const LPColBase< R > &pcol)
SPxLPBase< R > & operator=(const SPxLPBase< R > &old)
Assignment operator.
virtual Real scaleUpper(const SPxLPBase< Real > &lp, int col, Real upper) const
returns scaled upper bound of column col.
R obj() const
Gets objective value.
virtual void changeRange(int i, const R &newLhs, const R &newRhs, bool scale=false)
Changes left and right hand side of row i. scale determines whether the new data should be scaled...
virtual bool read(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP in LP or MPS format from input stream in.
virtual void removeCol(int i)
Removes i 'th column.
void getRowObj(VectorBase< R > &prowobj) const
Gets row objective function vector.
R & value(int n)
Reference to value of n 'th nonzero.
virtual void changeRow(SPxRowId id, const LPRowBase< R > &newRow, bool scale=false)
Replaces row with identifier id with newRow. scale determines whether the new data should be scaled...
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
VectorBase< R > & lhs_w()
Returns the vector of lhs values.
R & rhs_w(int i)
Returns right hand side of row i.
void setUpper(const R &p_up)
Sets upper bound.
virtual bool readMPS(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads an LP in MPS format from input stream in.
VectorBase< R > & maxObj_w()
Returns vector of objective values w.r.t. maximization.
void remove(int n, int m)
Remove nonzeros n thru m.
VectorBase< R > & lower_w()
Returns vector of lower bound values.
const SVectorBase< R > & rowVector(const SPxRowId &id) const
Gets row vector of row with identifier id.
virtual Real scaleLhs(const SPxLPBase< Real > &lp, int row, Real lhs) const
returns scaled left hand side of row row.
void add(const LPRowBase< R > &row)
const VectorBase< R > & maxObj() const
VectorBase< R > & upper_w()
Returns vector of upper bound values.
virtual void changeObjOffset(const R &o)
SPxColId cId(int n) const
Returns the column identifier for column n.
SVectorBase< R > & rowVector_w(int i)
int number(const SPxColId &id) const
Returns the column number of the column with identifier id.
virtual void removeRows(int perm[])
Removes multiple rows.
void changeLower(int i, const S *newLower)
changes i 'th lower bound to newLower.
void getObjUnscaled(VectorBase< Real > &pobj) const
Gets unscaled objective vector.
void memRemax(int newmax)
Reallocates memory to be able to store newmax nonzeros.
int nRows() const
Returns number of rows in LP.
bool isConsistent() const
Checks consistency.
R lower() const
Gets lower bound.
int number(const DataKey &k) const
Returns number of LPColBase with DataKey k in LPColSetBase.
const SVectorBase< R > & colVector() const
Gets constraint column vector.
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
R objUnscaled(int i) const
Returns unscaled objective value of column i.
int nNzos() const
Returns number of nonzeros in LP.
virtual void changeLhs(SPxRowId id, const R &newLhs, bool scale=false)
Changes left hand side value for row with identifier id. scale determines whether the new data should...
virtual void addCol(const R &objValue, const R &lowerValue, const SVectorBase< R > &colVec, const R &upperValue, bool scale=false)
virtual void changeObj(int i, const R &newVal, bool scale=false)
changes i 'th objective vector element to newVal. scale determines whether the new data should be sca...
void getLowerUnscaled(DVector &vec) const
Gets unscaled lower bound vector.
Real spxLdexp(Real x, int exp)
returns x * 2^exp
virtual int computeScaleExp(const SVector &vec, const DataArray< int > &oldScaleExp) const
compute a single scaling vector , e.g. of a newly added row
SPxSense
Optimization sense.
virtual void writeFile(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *p_intvars=0) const
Write loaded LP to filename.
declaration of types for file output
void maxObjUnscaled(VectorBase< Real > &vec) const
Returns unscaled objective vector for maximization problem.
virtual void changeUpper(SPxColId id, const R &newUpper, bool scale=false)
Changes upper bound of column with identifier id to newLower. scale determines whether the new data s...
virtual void changeMaxObj(SPxColId id, const R &newVal, bool scale=false)
Changes objective value of column with identifier id to newVal. scale determines whether the new data...
virtual void computeDualActivity(const VectorBase< R > &dual, VectorBase< R > &activity, const bool unscaled=true) const
Computes "dual" activity of the columns for a given dual vector, i.e., y^T A; activity does not need ...
virtual void doRemoveRows(int perm[])
Internal helper method.
void getColVectorUnscaled(int i, DSVectorBase< Real > &vec) const
Gets column vector of column i.
Row and columns Id's SPxLP.
static void setFixed(std::ostream &stream, int precision=8)
Sets the precision of the stream to 8 and the floatfield to fixed.
SPxSense spxSense() const
Returns the optimization sense.
int & index(int n)
Reference to index of n 'th nonzero.
virtual void changeMaxObj(const VectorBase< R > &newObj, bool scale=false)
Changes objective vector to newObj. scale determines whether the new data should be scaled...
bool has(const DataKey &k) const
Does DataKey k belong to LPColSetBase ?
SVectorBase< R > & colVector_w(int i)
const VectorBase< R > & rhs() const
Returns the vector of rhs values.
R upperUnscaled(int i) const
Returns unscaled upper bound of column i.
R lhs() const
Left-hand side value.
virtual void addCol(SPxColId &id, const LPColBase< R > &col, bool scale=false)
Adds col to LPColSetVBase.
LPRowSetBase< R > & operator=(const LPRowSetBase< R > &rs)
Assignment operator.
SVectorBase< R > & rowVector_w(int i)
Returns a writable rowVector of the i 'th LPRowBase.
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
virtual void addRows(const LPRowSetBase< R > &pset, bool scale=false)
virtual void changeBounds(SPxColId id, const R &newLower, const R &newUpper, bool scale=false)
Changes bounds of column with identifier id. scale determines whether the new data should be scaled...
virtual void changeRowObj(SPxRowId id, const R &newRowObj, bool scale=false)
Changes row objective function value for row with identifier id. scale determines whether the new dat...
void doAddRows(const LPRowSetBase< R > &set, bool scale=false)
void changeBounds(int i, const S *newLower, const S *newUpper)
Changes bounds of column i to newLower and newUpper.
virtual void changeLower(const VectorBase< R > &newLower, bool scale=false)
Changes vector of lower bounds to newLower. scale determines whether the new data should be scaled...
LPRowBase< R >::Type rowType(int i) const
Returns the inequality type of the i'th LPRow.
virtual bool readLPF(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP in LP format from input stream in.
virtual void removeRow(SPxRowId id)
Removes row with identifier id.
virtual void changeRhs(const VectorBase< R > &newRhs, bool scale=false)
Changes right hand side vector for constraints to newRhs. scale determines whether the new data shoul...
R obj(int i) const
Returns objective value of column i.
virtual void changeCol(SPxColId id, const LPColBase< R > &newCol, bool scale=false)
Replaces column with identifier id with newCol. scale determines whether the new data should be scale...
const VectorBase< R > & lhs() const
Returns left hand side vector.
R & lower_w(int i)
Returns lower bound of column i.
virtual void changeRhs(SPxRowId id, const R &newRhs, bool scale=false)
Changes right hand side value for row with identifier id. scale determines whether the new data shoul...
virtual void removeCols(int nums[], int n, int perm[]=0)
Removes n LPCols.
void add2(const DataKey &k, int n, const int idx[], const R val[])
Adds n nonzero (idx, val)-pairs to rowVector with DataKey k.
virtual void addPrimalActivity(const SVectorBase< R > &primal, VectorBase< R > &activity) const
Updates activity of the rows for a given primal vector; activity does not need to be zero...
void addCols(const S *objValue, const S *lowerValues, const S *colValues, const int *colIndices, const int *colStarts, const int *colLengths, const int numCols, const int numValues, const S *upperValues)
R rowObj(const SPxRowId &id) const
Returns row objective function value of row with identifier id.
const R & lhs(const SPxRowId &id) const
Returns left hand side of row with identifier id.
virtual void scaleObj(const SPxLPBase< Real > &lp, VectorReal &origObj) const
apply scaling to objective function vector origObj.
void getRhs(VectorBase< R > &vec) const
Gets (internal and possibly scaled) right hand side vector.
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
virtual void changeBounds(const VectorBase< R > &newLower, const VectorBase< R > &newUpper, bool scale=false)
Changes variable bounds to newLower and newUpper. scale determines whether the new data should be sca...
void getCol(int i, LPColBase< R > &col) const
Gets i 'th column.
LPColSetBase< R > & operator=(const LPColSetBase< R > &rs)
Assignment operator.
virtual void addCols(SPxColId id[], const LPColSetBase< R > &set, bool scale=false)
Adds all LPColBases of set to LPColSetBase.
void setObj(const R &p_obj)
Sets objective coefficient value.
const VectorBase< R > & maxRowObj() const
R lhsUnscaled(int i) const
Returns unscaled left hand side of row number i.
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
void setScalingInfo(bool scaled)
set whether the LP is scaled or not
virtual void changeRow(int n, const LPRowBase< R > &newRow, bool scale=false)
Replaces i 'th row of LP with newRow. scale determines whether the new data should be scaled...
void added2Set(SVSetBase< R > &set, const SVSetBase< R > &addset, int n)
virtual void changeUpper(const VectorBase< R > &newUpper, bool scale=false)
Changes vector of upper bounds to newUpper. scale determines whether the new data should be scaled...
R & maxRowObj_w(int i)
Returns objective function value of row i.
Debugging, floating point type and parameter definitions.
Simplex basis.Consider the linear program as provided from class SPxLP: where , and ...
virtual void removeRows(SPxRowId id[], int n, int perm[]=0)
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
virtual void addRow(const R &lhsValue, const SVectorBase< R > &rowVec, const R &rhsValue, bool scale=false)
void setLhs(const R &p_left)
Sets left-hand side value.
virtual void changeObj(const VectorBase< R > &newObj, bool scale=false)
Changes objective vector to newObj. scale determines whether the new data should be scaled...
virtual Real scaleLower(const SPxLPBase< Real > &lp, int col, Real lower) const
returns scaled lower bound of column col.
void getCol(const SPxColId &id, LPColBase< R > &col) const
Gets column with identifier id.
R offset
offset computed, e.g., in simplification step
virtual void addDualActivity(const SVectorBase< R > &dual, VectorBase< R > &activity) const
Updates "dual" activity of the columns for a given dual vector, i.e., y^T A; activity does not need t...
void changeLhs(int i, const S *newLhs)
Changes i 'th left hand side value to newLhs.
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
Collection of dense, sparse, and semi-sparse vectors.
virtual void addCol(const LPColBase< R > &col, bool scale=false)
SPxLPBase< R > & operator=(const SPxLPBase< S > &old)
Assignment operator.
int dim() const
Dimension of vector.
virtual void doRemoveCols(int perm[])
Internal helper method.
bool has(const SPxColId &id) const
Returns the column number of the column with identifier id.
Everything should be within this namespace.
const R & maxRowObj(int i) const
void getCols(int start, int end, LPColSetBase< R > &set) const
Gets columns start, ..., end.
virtual void changeLower(SPxColId id, const R &newLower, bool scale=false)
changes lower bound of column with identifier id to newLower. scale determines whether the new data s...
virtual void changeRange(const VectorBase< R > &newLhs, const VectorBase< R > &newRhs, bool scale=false)
Changes left and right hand side vectors. scale determines whether the new data should be scaled...
void changeElement(int i, int j, const S *val)
Changes LP element (i, j) to val.
void clear()
Remove all indices.
virtual void writeLPF(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const
R & upper_w(int i)
Returns upper bound of column i.
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
Set of LP columns.Class LPColSetBase implements a set of LPColBase%s. Unless for memory limitations...
const SVectorBase< R > & rowVector(int i) const
Returns the rowVector of the i 'th LPRowBase.
void setObj(const R &p_object)
Sets objective value.
R lowerUnscaled(int i) const
Returns unscaled lower bound of column i.
virtual void clearRowObjs()
Clears row objective function values for all rows.
Type
(In)Equality type of an LP row.
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
SPxScaler * lp_scaler
points to the scaler if the lp has been scaled, to 0 otherwise
R upper() const
Gets upper bound.
R obj() const
Objective coefficient value.
const R & upper(const SPxColId &id) const
Returns upper bound of column with identifier id.
void setRowVector(const DSVectorBase< R > &p_vec)
access constraint row vector.
void doAddCol(const R &objValue, const R &lowerValue, const SVectorBase< R > &colVec, const R &upperValue, bool scale=false)
const LPColSetBase< R > * lpcolset() const
Returns the LP as an LPColSetBase.
bool has(const DataKey &k) const
does DataKey k belong to LPRowSetBase ?
int memMax() const
Returns length of nonzero memory.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
virtual void writeMPS(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const
Writes a file in MPS format to out.
virtual void addRow(const LPRowBase< R > &row, bool scale=false)
virtual void changeRowObj(const VectorBase< R > &newRowObj, bool scale=false)
Changes row objective function vector to newRowObj. scale determines whether the new data should be s...
LP scaler abstract base class.Instances of classes derived from SPxScaler may be loaded to SoPlex in ...
std::ifstream spxifstream
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
virtual void changeSense(SPxSense sns)
Changes optimization sense to sns.
void getUpperUnscaled(DVector &vec) const
Gets unscaled upper bound vector.
void xtend(int n, int newmax)
Extends column n to fit newmax nonzeros.
void unscaleLP()
unscales the lp and clears basis
bool isConsistent() const
Checks consistency.
const VectorBase< R > & upper() const
void printProblemStatistics(std::ostream &os)
virtual void changeLhs(int i, const R &newLhs, bool scale=false)
Changes i 'th left hand side value to newLhs. scale determines whether the new data should be scaled...
int pos(int i) const
Position of index i.
bool isConsistent() const
Consistency check.
virtual void removeColRange(int start, int end, int perm[]=0)
Removes columns from start to end (including both).
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
int nCols() const
Returns number of columns in LP.
virtual void removeCols(SPxColId id[], int n, int perm[]=0)
void changeUpper(int i, const S *newUpper)
Changes i 'th upper bound to newUpper.
virtual void changeElement(int i, int j, const R &val, bool scale=false)
Changes LP element (i, j) to val. scale determines whether the new data should be scaled...
virtual void removeCol(SPxColId id)
Removes column with identifier id.
virtual void changeLhs(const VectorBase< R > &newLhs, bool scale=false)
Changes left hand side vector for constraints to newLhs. scale determines whether the new data should...
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
const R & rhs(int i) const
Returns right hand side of row number i.
virtual void changeRhs(int i, const R &newRhs, bool scale=false)
Changes i 'th right hand side value to newRhs. scale determines whether the new data should be scaled...
virtual void doRemoveRow(int j)
Internal helper method.
SPxSense thesense
optimization sense.
void add2(const DataKey &k, int n, const int idx[], const R val[])
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
virtual void addedRows(int newrows)
Called after the last n rows have just been added.
const R & lower(int i) const
Returns (internal and possibly scaled) lower bound of column i.
void addCol(const S *objValue, const S *lowerValue, const S *colValues, const int *colIndices, int colSize, const S *upperValue)
#define MSGinconsistent(name)
int number(const DataKey &k) const
Returns the number of the LPRowBase with DataKey k in LPRowSetBase.
void setColVector(const SVectorBase< R > &p_vec)
Sets constraint column vector.
void getLhsUnscaled(VectorBase< Real > &vec) const
Returns unscaled left hand side vector.
void doAddRow(const LPRowBase< R > &row, bool scale=false)
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
virtual Real scaleRhs(const SPxLPBase< Real > &lp, int row, Real rhs) const
returns scaled right hand side of row row.
Save arrays of data objects.
const R & maxObj(const SPxColId &id) const
Returns objective value of column with identifier id for maximization problem.
SVectorBase< R > & colVector_w(int i)
Returns the LP as an LPRowSet.
const SVectorBase< R > & colVector(int i) const
Returns colVector of i 'th LPColBase in LPColSetBase.
virtual void clear()
clears the LP.
virtual void doRemoveCol(int j)
Internal helper method.
const R & lower(const SPxColId &id) const
Returns (internal and possibly scaled) lower bound of column with identifier id.
void clear()
Removes all LPColBases from the set.
Equilibrium row/column scaling.This SPxScaler implementation performs equilibrium scaling of the LPs ...
const VectorBase< R > & obj() const
Returns the vector of objective coefficients.
void setRhs(const R &p_right)
Sets right-hand side value.
virtual void addRow(SPxRowId &id, const LPRowBase< R > &row, bool scale=false)
Adds row to LPRowSetBase.
void reSize(int newsize)
reset size to newsize.
void changeMaxObj(int i, const S *newVal)
changes i 'th objective vector element to newVal.
virtual void changeUpper(int i, const R &newUpper, bool scale=false)
Changes i 'th upper bound to newUpper. scale determines whether the new data should be scaled...
int num() const
Current number of SVectorBases.
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
virtual R maxAbsNzo(bool unscaled=true) const
Absolute biggest non-zero element in (in rational case possibly scaled) LP.
int num() const
Returns the number of LPColBases currently in LPColSetBase.
virtual void computePrimalActivity(const VectorBase< R > &primal, VectorBase< R > &activity, const bool unscaled=true) const
Computes activity of the rows for a given primal vector; activity does not need to be zero...
void getRow(const SPxRowId &id, LPRowBase< R > &row) const
Gets row with identifier id.
LP column.Class LPColBase provides a datatype for storing the column of an LP a the form similar to ...
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
void getRowVectorUnscaled(int i, DSVectorBase< Real > &vec) const
Gets unscaled row vector of row i.
VectorBase< R > & multSub(const S &x, const SVectorBase< T > &vec)
Subtraction of scaled vector.
virtual void addCols(const LPColSetBase< R > &pset, bool scale=false)
const R & maxRowObj(const SPxRowId &id) const
Returns row objective function value of row with identifier id.
int num() const
Returns the number of LPRowBases in LPRowSetBase.
LP simplifier for removing uneccessary row/columns.This SPxSimplifier is mainly based on the paper "P...
R & lhs_w(int i)
Returns left hand side of row i.
virtual void subDualActivity(const VectorBase< R > &dual, VectorBase< R > &activity) const
Updates "dual" activity of the columns for a given dual vector, i.e., y^T A; activity does not need t...
void remove(int i)
Removes i 'th LPRowBase.
const R & rhs(const SPxRowId &id) const
Returns right hand side of row with identifier id.