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++ )
568 doAddRow(lhsValue, rowVec, rhsValue, scale);
573 void addRow(
const S* lhsValue,
const S* rowValues,
const int* rowIndices,
int rowSize,
const S* rhsValue)
575 assert(lhsValue != 0);
576 assert(rowSize <= 0 || rowValues != 0);
577 assert(rowSize <= 0 || rowIndices != 0);
578 assert(rhsValue != 0);
581 int oldColNumber =
nCols();
586 for(
int j = rowSize - 1; j >= 0; --j )
588 const S& val = rowValues[j];
589 int i = rowIndices[j];
595 for(
int k =
nCols(); k <= i; ++k )
622 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)
624 assert(lhsValues != 0);
625 assert(numValues <= 0 || rowValues != 0);
626 assert(numValues <= 0 || rowIndices != 0);
627 assert(numValues <= 0 || rowStarts != 0);
628 assert(numValues <= 0 || rowLengths != 0);
629 assert(rhsValues != 0);
634 int oldRowNumber =
nRows();
635 int oldColNumber =
nCols();
638 for( i = 0; i < numRows; i++ )
640 assert(numValues <= 0 || rowStarts[i] + rowLengths[i] <= numValues);
644 LPRowSetBase<R>::add(&(lhsValues[i]), &(rowValues[rowStarts[i]]), &(rowIndices[rowStarts[i]]), rowLengths[i], &(rhsValues[i]));
651 for( i =
nCols() - 1; i >= 0; --i )
655 for( i = 0; i < numRows; i++ )
657 for( j = rowStarts[i]; j < rowStarts[i] + rowLengths[i]; j++ )
660 assert(rowIndices[j] >= 0);
661 assert(rowIndices[j] < oldColNumber);
662 newCols[rowIndices[j]]++;
668 for( i =
nCols() - 1; i >= 0; --i )
672 int len = newCols[i] +
colVector(i).size();
682 for( i =
nRows() - 1; i >= oldRowNumber; --i )
686 for( j = vec.
size() - 1; j >= 0; --j )
690 idx = col->
size() - newCols[k];
691 assert(newCols[k] > 0);
700 for( i = 0; i <
nCols(); ++i )
701 assert( newCols[i] == 0 );
706 assert( numRows ==
nRows() - oldRowNumber );
716 for(
int j = 0; i <
nRows(); ++i, ++j )
727 virtual void addCol(
const R& objValue,
const R& lowerValue,
const SVectorBase<R>& colVec,
const R& upperValue,
bool scale =
false)
729 doAddCol(objValue, lowerValue, colVec, upperValue, scale);
734 void addCol(
const S* objValue,
const S* lowerValue,
const S* colValues,
const int* colIndices,
int colSize,
const S* upperValue)
737 int oldRowNumber =
nRows();
744 for(
int j = colSize - 1; j >= 0; --j )
746 const S& val = colValues[j];
747 int i = colIndices[j];
753 for(
int k =
nRows(); k <= i; ++k )
780 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)
782 assert(lowerValues != 0);
783 assert(numValues <= 0 || colValues != 0);
784 assert(numValues <= 0 || colIndices != 0);
785 assert(numValues <= 0 || colStarts != 0);
786 assert(numValues <= 0 || colLengths != 0);
787 assert(upperValues != 0);
792 int oldColNumber =
nCols();
793 int oldRowNumber =
nRows();
797 for( i = 0; i < numCols; i++ )
799 assert(numValues <= 0 || colStarts[i] + colLengths[i] <= numValues);
803 LPColSetBase<R>::add(&(objValue[i]), &(lowerValues[i]), &(colValues[colStarts[i]]), &(colIndices[colStarts[i]]), colLengths[i], &(upperValues[i]));
813 for( i =
nRows() - 1; i >= 0; --i )
815 for( i = numValues - 1; i >= 0; --i )
818 assert(colIndices[i] >= 0);
819 assert(colIndices[i] < oldRowNumber);
820 newRows[colIndices[i]]++;
824 for( i =
nRows() - 1; i >= 0; --i )
828 int len = newRows[i] +
rowVector(i).size();
838 for( i =
nCols() - 1; i >= oldColNumber; --i )
842 for( j = vec.
size() - 1; j >= 0; --j )
846 idx = row->
size() - newRows[k];
847 assert(newRows[k] > 0);
856 for( i = 0; i <
nRows(); ++i )
857 assert( newRows[i] == 0 );
862 assert( numCols ==
nCols() - oldColNumber );
873 for(
int j = 0; i <
nCols(); ++i, ++j )
919 for(
int i =
nRows() - 1; i >= 0; --i )
944 for(
int i =
nRows() - 1; i >= 0; --i )
959 int i = end - start + 1;
970 for( i = 0; i < start; ++i )
972 for( ; i <= end; ++i )
974 for( ; i <
nRows(); ++i )
1016 for(
int i =
nCols() - 1; i >= 0; --i )
1020 perm[
number(
id[n])] = -1;
1041 for(
int i =
nCols() - 1; i >= 0; --i )
1056 int i = end - start + 1;
1067 for( i = 0; i < start; ++i )
1069 for( ; i <= end; ++i )
1071 for( ; i <
nCols(); ++i )
1126 ok = ((c ==
'*') || (c ==
'N'))
1127 ?
readMPS(in, rowNames, colNames, intVars)
1128 :
readLPF(in, rowNames, colNames, intVars);
1142 return read(file, rowNames, colNames, intVars);
1158 std::ofstream tmp(filename);
1159 size_t len_f = strlen(filename);
1161 if( len_f > 4 && filename[len_f-1] ==
's' && filename[len_f-2] ==
'p' && filename[len_f-3] ==
'm' && filename[len_f-4] ==
'.' )
1163 writeMPS(tmp, rowNames, colNames, p_intvars);
1167 writeLPF(tmp, rowNames, colNames, p_intvars);
1177 int countFreeCol = 0;
1181 int countRanged = 0;
1182 int countFreeRow = 0;
1184 for(
int i = 0; i <
nCols(); i++ )
1186 bool hasLower =
false;
1187 bool hasUpper =
false;
1201 if( hasUpper && hasLower )
1204 if( !hasUpper && !hasLower )
1208 for(
int i = 0; i <
nRows(); i++)
1210 bool hasRhs =
false;
1211 bool hasLhs =
false;
1225 if( hasRhs && hasLhs )
1228 if( !hasRhs && !hasLhs )
1232 os <<
" Columns : " <<
nCols() <<
"\n" 1233 <<
" boxed : " << countBoxed <<
"\n" 1234 <<
" lower bound : " << countLower <<
"\n" 1235 <<
" upper bound : " << countUpper <<
"\n" 1236 <<
" free : " << countFreeCol <<
"\n" 1237 <<
" Rows : " <<
nRows() <<
"\n" 1238 <<
" ranged : " << countRanged <<
"\n" 1239 <<
" lhs : " << countLhs <<
"\n" 1240 <<
" rhs : " << countRhs <<
"\n" 1241 <<
" free : " << countFreeRow <<
"\n" 1242 <<
" Nonzeros : " <<
nNzos() <<
"\n" 1265 virtual void changeObj(
int i,
const R& newVal,
bool scale =
false)
1273 template <
class S >
1311 template <
class S >
1327 assert(
lower().dim() == newLower.
dim());
1333 virtual void changeLower(
int i,
const R& newLower,
bool scale =
false)
1347 template <
class S >
1363 assert(
upper().dim() == newUpper.
dim());
1369 virtual void changeUpper(
int i,
const R& newUpper,
bool scale =
false)
1383 template <
class S >
1405 virtual void changeBounds(
int i,
const R& newLower,
const R& newUpper,
bool scale =
false)
1413 template <
class S >
1430 assert(
lhs().dim() == newLhs.
dim());
1436 virtual void changeLhs(
int i,
const R& newLhs,
bool scale =
false)
1446 template <
class S >
1462 assert(
rhs().dim() == newRhs.
dim());
1468 virtual void changeRhs(
int i,
const R& newRhs,
bool scale =
false)
1492 virtual void changeRange(
int i,
const R& newLhs,
const R& newRhs,
bool scale =
false)
1500 template <
class S >
1553 for( j = row.
size() - 1; j >= 0; --j )
1566 for( j = newrow.size() - 1; j >= 0; --j )
1568 int idx = newrow.index(j);
1569 R val = newrow.value(j);
1593 for( j = col.
size() - 1; j >= 0; --j )
1606 for( j = newcol.size() - 1; j >= 0; --j )
1608 int idx = newcol.index(j);
1609 R val = newcol.value(j);
1628 if( i < 0 || j < 0 )
1647 if( row.
pos(j) >= 0 )
1658 else if( row.
pos(j) >= 0 )
1668 template <
class S >
1677 if( mpq_get_d(*val) != R(0) )
1679 if( row.
pos(j) >= 0 )
1690 else if( row.
pos(j) >= 0 )
1708 if( sns != thesense )
1737 for(
int i = primal.
size() - 1; i >= 0; i-- )
1739 assert(primal.
index(i) >= 0);
1760 for(
int i = dual.
size() - 1; i >= 0; i-- )
1762 assert(dual.
index(i) >= 0);
1783 for(
int r = 0; r <
nRows(); r++ )
1800 SPxRowId dualRowIds[] = 0,
SPxColId dualColIds[] = 0,
int* nprimalrows = 0,
int* nprimalcols = 0,
1801 int* ndualrows = 0,
int* ndualcols = 0);
1812 #ifdef ENABLE_CONSISTENCY_CHECKS 1814 for(
int i =
nCols() - 1; i >= 0; --i )
1818 for(
int j = v.
size() - 1; j >= 0; --j )
1831 for(
int i =
nRows() - 1; i >= 0; --i )
1835 for(
int j = v.
size() - 1; j >= 0; --j )
1923 for(
int i = vec.
size() - 1; i >= 0; --i )
1930 int idx =
nRows() - 1;
1934 for(
int i = l_vec.
size() - 1; i >= 0; --i )
1937 movevec.
index(movevec.
pos(idx)) = j;
1951 for(
int i = 0; i < j; ++i )
1954 for(
int k = vec.
size() - 1; k >= 0; --k )
1956 int idx = vec.
index(k);
1960 vec.
index(k) = perm[idx];
1973 for( i = vec.
size() - 1; i >= 0; --i )
1980 int idx =
nCols() - 1;
1984 for( i = l_vec.
size() - 1; i >= 0; --i )
1987 movevec.
index(movevec.
pos(idx)) = j;
1997 int nrows =
nRows();
2001 for(
int i = 0; i < nrows; ++i )
2005 for(
int k = vec.
size() - 1; k >= 0; --k )
2007 int idx = vec.
index(k);
2011 vec.
index(k) = perm[idx];
2032 int* more = moreArray.
get_ptr();
2034 for(
int i =
set.
num() - 1; i >= 0; --i )
2038 int end = addset.
num();
2040 for(
int i = addset.
num() - n; i < end; ++i )
2045 for(
int j = vec.
size() - 1; j >= 0; --j )
2046 more[vec.
index(j)]++;
2052 for(
int i =
set.
num() - 1; i >= 0; --i )
2054 int j =
set[i].size();
2055 set.xtend(
set[i], j + more[i]);
2056 set[i].set_size( j + more[i] );
2060 for(
int i = addset.
num() - n; i < addset.
num(); ++i)
2064 for(
int j = vec.
size() - 1; j >= 0; --j )
2066 int k = vec.
index(j);
2069 l_xtend.
index(m) = i;
2100 int oldColNumber =
nCols();
2101 int newRowScaleExp = 0;
2125 for(
int j = vec.
size() - 1; j >= 0; --j )
2127 int i = vec.
index(j);
2133 R val = vec.
value(j);
2139 for(
int k =
nCols(); k <= i; ++k )
2143 assert(i <
nCols());
2155 int oldColNumber =
nCols();
2156 int newRowScaleExp = 0;
2180 for(
int j = vec.
size() - 1; j >= 0; --j )
2182 int i = vec.
index(j);
2188 R val = vec.
value(j);
2194 for(
int k =
nCols(); k <= i; ++k )
2198 assert(i <
nCols());
2209 int i, j, k, ii, idx;
2212 int oldRowNumber =
nRows();
2213 int oldColNumber =
nCols();
2222 for( i =
nCols() - 1; i >= 0; --i )
2224 for( i =
set.
num() - 1; i >= 0; --i )
2228 for( j = vec.
size() - 1; j >= 0; --j )
2236 for( k =
nCols(); k <= ii; ++k )
2243 assert(ii <
nCols());
2249 for( i =
nCols() - 1; i >= 0; --i )
2251 if( newCols[i] > 0 )
2253 int len = newCols[i] +
colVector(i).size();
2263 for( i =
nRows() - 1; i >= oldRowNumber; --i )
2266 int newRowScaleExp = 0;
2285 for( j = vec.
size() - 1; j >= 0; --j )
2289 idx = col->
size() - newCols[k];
2290 assert(newCols[k] > 0);
2293 col->
index(idx) = i;
2303 for( i = 0; i <
nCols(); ++i )
2304 assert( newCols[i] == 0 );
2309 assert(
set.
num() ==
nRows() - oldRowNumber);
2318 int oldRowNumber =
nRows();
2319 int newColScaleExp = 0;
2345 for(
int j = vec.
size() - 1; j >= 0; --j )
2347 int i = vec.
index(j);
2353 R val = vec.
value(j);
2359 for(
int k =
nRows(); k <= i; ++k )
2363 assert(i <
nRows());
2372 void doAddCol (
const R& objValue,
const R& lowerValue,
const SVectorBase<R>& colVec,
const R& upperValue,
bool scale =
false)
2375 int oldRowNumber =
nRows();
2376 int newColScaleExp = 0;
2402 for(
int j = vec.
size() - 1; j >= 0; --j )
2404 int i = vec.
index(j);
2409 R val = vec.
value(j);
2415 for(
int k =
nRows(); k <= i; ++k )
2419 assert(i <
nRows());
2431 int oldColNumber =
nCols();
2432 int oldRowNumber =
nRows();
2442 for( i =
nRows() - 1; i >= 0; --i )
2445 for( i =
set.
num() - 1; i >= 0; --i )
2449 for( j = vec.
size() - 1; j >= 0; --j )
2452 int l = vec.
index(j);
2457 for(
int k =
nRows(); k <= l; ++k )
2465 assert(l <
nRows());
2471 for( i = 0; i <
nRows(); ++i )
2473 if( newRows[i] > 0 )
2475 int len = newRows[i] +
rowVector(i).size();
2482 for( i = oldColNumber; i <
nCols(); ++i )
2486 int newColScaleExp = 0;
2505 for( j = vec.
size() - 1; j >= 0; --j )
2507 int k = vec.
index(j);
2509 int idx = row.
size() - newRows[k];
2510 assert(newRows[k] > 0);
2522 for( i = 0; i <
nRows(); ++i )
2523 assert( newRows[i] == 0 );
2528 assert(
set.
num() ==
nCols() - oldColNumber);
2567 template <
class S >
2600 template <
class S >
2626 #ifdef SOPLEX_DEBUG_SPXLPBASE 2627 #define SOPLEX_DEBUG 2628 #undef SOPLEX_DEBUG_SPXLPBASE 2631 #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).
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...
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.
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...
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.
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.
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.