33 #define SOPLEX_DEBUG_SPXLPBASE 155 spxout = &newOutstream;
208 for(
int i = 0; i <
nCols(); ++i)
215 virtual R
minAbsNzo(
bool unscaled =
true)
const;
218 virtual R
maxAbsNzo(
bool unscaled =
true)
const;
240 for(
int i = start; i <= end; i++)
399 for(
int i = start; i <= end; i++)
410 for(
int i = start; i <= end; i++)
633 doAddRow(lhsValue, rowVec, rhsValue, scale);
638 void addRow(
const S* lhsValue,
const S* rowValues,
const int* rowIndices,
int rowSize,
641 assert(lhsValue != 0);
642 assert(rowSize <= 0 || rowValues != 0);
643 assert(rowSize <= 0 || rowIndices != 0);
644 assert(rhsValue != 0);
647 int oldColNumber =
nCols();
652 for(
int j = rowSize - 1; j >= 0; --j)
654 const S& val = rowValues[j];
655 int i = rowIndices[j];
662 for(
int k =
nCols(); k <= i; ++k)
689 void addRows(
const S* lhsValues,
const S* rowValues,
const int* rowIndices,
const int* rowStarts,
690 const int* rowLengths,
const int numRows,
const int numValues,
const S* rhsValues)
692 assert(lhsValues != 0);
693 assert(numValues <= 0 || rowValues != 0);
694 assert(numValues <= 0 || rowIndices != 0);
695 assert(numValues <= 0 || rowStarts != 0);
696 assert(numValues <= 0 || rowLengths != 0);
697 assert(rhsValues != 0);
702 int oldRowNumber =
nRows();
703 int oldColNumber =
nCols();
707 for(i = 0; i < numRows; i++)
709 assert(numValues <= 0 || rowStarts[i] + rowLengths[i] <= numValues);
715 rowLengths[i], &(rhsValues[i]));
722 for(i =
nCols() - 1; i >= 0; --i)
727 for(i = 0; i < numRows; i++)
729 for(j = rowStarts[i]; j < rowStarts[i] + rowLengths[i]; j++)
732 assert(rowIndices[j] >= 0);
733 assert(rowIndices[j] < oldColNumber);
734 newCols[rowIndices[j]]++;
740 for(i =
nCols() - 1; i >= 0; --i)
744 int len = newCols[i] +
colVector(i).size();
754 for(i =
nRows() - 1; i >= oldRowNumber; --i)
758 for(j = vec.
size() - 1; j >= 0; --j)
762 idx = col->
size() - newCols[k];
763 assert(newCols[k] > 0);
773 for(i = 0; i <
nCols(); ++i)
774 assert(newCols[i] == 0);
780 assert(numRows ==
nRows() - oldRowNumber);
791 for(
int j = 0; i <
nRows(); ++i, ++j)
803 const R& upperValue,
bool scale =
false)
805 doAddCol(objValue, lowerValue, colVec, upperValue, scale);
810 void addCol(
const S* objValue,
const S* lowerValue,
const S* colValues,
const int* colIndices,
811 int colSize,
const S* upperValue)
814 int oldRowNumber =
nRows();
822 for(
int j = colSize - 1; j >= 0; --j)
824 const S& val = colValues[j];
825 int i = colIndices[j];
832 for(
int k =
nRows(); k <= i; ++k)
859 void addCols(
const S* objValue,
const S* lowerValues,
const S* colValues,
const int* colIndices,
860 const int* colStarts,
const int* colLengths,
const int numCols,
const int numValues,
861 const S* upperValues)
863 assert(lowerValues != 0);
864 assert(numValues <= 0 || colValues != 0);
865 assert(numValues <= 0 || colIndices != 0);
866 assert(numValues <= 0 || colStarts != 0);
867 assert(numValues <= 0 || colLengths != 0);
868 assert(upperValues != 0);
873 int oldColNumber =
nCols();
874 int oldRowNumber =
nRows();
879 for(i = 0; i < numCols; i++)
881 assert(numValues <= 0 || colStarts[i] + colLengths[i] <= numValues);
887 &(colIndices[colStarts[i]]), colLengths[i], &(upperValues[i]));
897 for(i =
nRows() - 1; i >= 0; --i)
900 for(i = numValues - 1; i >= 0; --i)
903 assert(colIndices[i] >= 0);
904 assert(colIndices[i] < oldRowNumber);
905 newRows[colIndices[i]]++;
909 for(i =
nRows() - 1; i >= 0; --i)
913 int len = newRows[i] +
rowVector(i).size();
923 for(i =
nCols() - 1; i >= oldColNumber; --i)
927 for(j = vec.
size() - 1; j >= 0; --j)
931 idx = row->
size() - newRows[k];
932 assert(newRows[k] > 0);
942 for(i = 0; i <
nRows(); ++i)
943 assert(newRows[i] == 0);
949 assert(numCols ==
nCols() - oldColNumber);
961 for(
int j = 0; i <
nCols(); ++i, ++j)
1007 for(
int i =
nRows() - 1; i >= 0; --i)
1011 perm[
number(
id[n])] = -1;
1032 for(
int i =
nRows() - 1; i >= 0; --i)
1047 int i = end - start + 1;
1059 for(i = 0; i < start; ++i)
1062 for(; i <= end; ++i)
1065 for(; i <
nRows(); ++i)
1107 for(
int i =
nCols() - 1; i >= 0; --i)
1111 perm[
number(
id[n])] = -1;
1132 for(
int i =
nCols() - 1; i >= 0; --i)
1147 int i = end - start + 1;
1159 for(i = 0; i < start; ++i)
1162 for(; i <= end; ++i)
1165 for(; i <
nCols(); ++i)
1223 ok = ((c ==
'*') || (c ==
'N'))
1224 ?
readMPS(in, rowNames, colNames, intVars)
1225 :
readLPF(in, rowNames, colNames, intVars);
1240 return read(file, rowNames, colNames, intVars);
1248 const DIdxSet* p_intvars = 0)
const;
1252 const DIdxSet* p_intvars = 0)
const;
1259 std::ofstream tmp(filename);
1260 size_t len_f = strlen(filename);
1262 if(len_f > 4 && filename[len_f - 1] ==
's' && filename[len_f - 2] ==
'p' 1263 && filename[len_f - 3] ==
'm' && filename[len_f - 4] ==
'.')
1265 writeMPS(tmp, rowNames, colNames, p_intvars);
1269 writeLPF(tmp, rowNames, colNames, p_intvars);
1279 int countFreeCol = 0;
1284 int countRanged = 0;
1285 int countFreeRow = 0;
1287 for(
int i = 0; i <
nCols(); i++)
1289 bool hasLower =
false;
1290 bool hasUpper =
false;
1304 if(hasUpper && hasLower)
1311 if(!hasUpper && !hasLower)
1315 for(
int i = 0; i <
nRows(); i++)
1317 bool hasRhs =
false;
1318 bool hasLhs =
false;
1332 if(hasRhs && hasLhs)
1343 if(!hasRhs && !hasLhs)
1348 os <<
" Columns : " <<
nCols() <<
"\n" 1349 <<
" boxed : " << countBoxed <<
"\n" 1350 <<
" lower bound : " << countLower <<
"\n" 1351 <<
" upper bound : " << countUpper <<
"\n" 1352 <<
" free : " << countFreeCol <<
"\n" 1353 <<
" Rows : " <<
nRows() <<
"\n" 1354 <<
" equal : " << countEqual <<
"\n" 1355 <<
" ranged : " << countRanged <<
"\n" 1356 <<
" lhs : " << countLhs <<
"\n" 1357 <<
" rhs : " << countRhs <<
"\n" 1358 <<
" free : " << countFreeRow <<
"\n" 1359 <<
" Nonzeros : " <<
nNzos() <<
"\n" 1360 <<
" per column : " << R(
nNzos()) / R(
nCols()) <<
"\n" 1361 <<
" per row : " << R(
nNzos()) / R(
nRows()) <<
"\n" 1363 <<
" min. abs. value : " << R(
minAbsNzo()) <<
"\n" 1364 <<
" max. abs. value : " << R(
maxAbsNzo()) <<
"\n";
1383 virtual void changeObj(
int i,
const R& newVal,
bool scale =
false)
1392 template <
class S >
1419 for(
int i = 0; i <
maxObj().dim(); i++)
1444 template <
class S >
1460 assert(
lower().dim() == newLower.
dim());
1467 for(
int i = 0; i <
lower().dim(); i++)
1477 virtual void changeLower(
int i,
const R& newLower,
bool scale =
false)
1479 if(scale && newLower > R(-
infinity))
1492 template <
class S >
1508 assert(
upper().dim() == newUpper.
dim());
1515 for(
int i = 0; i <
upper().dim(); i++)
1525 virtual void changeUpper(
int i,
const R& newUpper,
bool scale =
false)
1527 if(scale && newUpper < R(
infinity))
1540 template <
class S >
1563 virtual void changeBounds(
int i,
const R& newLower,
const R& newUpper,
bool scale =
false)
1571 template <
class S >
1588 assert(
lhs().dim() == newLhs.
dim());
1595 for(
int i = 0; i <
lhs().dim(); i++)
1605 virtual void changeLhs(
int i,
const R& newLhs,
bool scale =
false)
1620 template <
class S >
1636 assert(
rhs().dim() == newRhs.
dim());
1643 for(
int i = 0; i <
rhs().dim(); i++)
1653 virtual void changeRhs(
int i,
const R& newRhs,
bool scale =
false)
1683 virtual void changeRange(
int i,
const R& newLhs,
const R& newRhs,
bool scale =
false)
1691 template <
class S >
1749 for(j = row.
size() - 1; j >= 0; --j)
1752 int position = col.
pos(n);
1754 assert(position != -1);
1768 for(j = newrow.size() - 1; j >= 0; --j)
1770 int idx = newrow.index(j);
1771 R val = newrow.value(j);
1798 for(j = col.
size() - 1; j >= 0; --j)
1801 int position = row.
pos(n);
1803 assert(position != -1);
1817 for(j = newcol.size() - 1; j >= 0; --j)
1819 int idx = newcol.index(j);
1820 R val = newcol.value(j);
1847 if(isNotZero(val, this->
tolerances()->epsilon()))
1855 newVal =
lp_scaler->scaleElement(*
this, i, j, val);
1860 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1871 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1881 template <
class S >
1890 if(mpq_get_d(*val) != R(0))
1892 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1903 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1930 template <
typename T>
1942 const bool unscaled =
true)
const;
1954 for(
int i = primal.
size() - 1; i >= 0; i--)
1956 assert(primal.
index(i) >= 0);
1966 const bool unscaled =
true)
const;
1978 for(
int i = dual.
size() - 1; i >= 0; i--)
1980 assert(dual.
index(i) >= 0);
2001 for(
int r = 0; r <
nRows(); r++)
2019 SPxRowId dualRowIds[] = 0,
SPxColId dualColIds[] = 0,
int* nprimalrows = 0,
int* nprimalcols = 0,
2020 int* ndualrows = 0,
int* ndualcols = 0);
2034 #ifdef ENABLE_CONSISTENCY_CHECKS 2036 for(
int i =
nCols() - 1; i >= 0; --i)
2040 for(
int j = v.
size() - 1; j >= 0; --j)
2053 for(
int i =
nRows() - 1; i >= 0; --i)
2057 for(
int j = v.
size() - 1; j >= 0; --j)
2147 for(
int i = vec.
size() - 1; i >= 0; --i)
2150 int position = remvec.
pos(j);
2157 int idx =
nRows() - 1;
2163 for(
int i = l_vec.
size() - 1; i >= 0; --i)
2166 int position = movevec.
pos(idx);
2168 assert(position != -1);
2171 movevec.
index(position) = j;
2185 for(
int i = 0; i < j; ++i)
2189 for(
int k = vec.
size() - 1; k >= 0; --k)
2191 int idx = vec.
index(k);
2196 vec.
index(k) = perm[idx];
2209 for(i = vec.
size() - 1; i >= 0; --i)
2212 int position = remvec.
pos(j);
2214 assert(position != -1);
2221 int idx =
nCols() - 1;
2227 for(i = l_vec.
size() - 1; i >= 0; --i)
2230 int position = movevec.
pos(idx);
2232 assert(position != -1);
2235 movevec.
index(position) = j;
2245 int nrows =
nRows();
2249 for(
int i = 0; i < nrows; ++i)
2253 for(
int k = vec.
size() - 1; k >= 0; --k)
2255 int idx = vec.
index(k);
2260 vec.
index(k) = perm[idx];
2283 for(
int i =
set.
num() - 1; i >= 0; --i)
2287 int end = addset.
num();
2289 for(
int i = addset.
num() - n; i < end; ++i)
2295 for(
int j = vec.
size() - 1; j >= 0; --j)
2296 more[vec.
index(j)]++;
2302 for(
int i =
set.
num() - 1; i >= 0; --i)
2304 int j =
set[i].size();
2305 set.xtend(
set[i], j + more[i]);
2306 set[i].set_size(j + more[i]);
2310 for(
int i = addset.
num() - n; i < addset.
num(); ++i)
2314 for(
int j = vec.
size() - 1; j >= 0; --j)
2316 int k = vec.
index(j);
2319 l_xtend.
index(m) = i;
2350 int oldColNumber =
nCols();
2351 int newRowScaleExp = 0;
2362 newRowScaleExp =
lp_scaler->computeScaleExp(vec, colscaleExp);
2376 for(
int j = vec.
size() - 1; j >= 0; --j)
2378 int i = vec.
index(j);
2384 R val = vec.
value(j);
2391 for(
int k =
nCols(); k <= i; ++k)
2395 assert(i <
nCols());
2408 int oldColNumber =
nCols();
2409 int newRowScaleExp = 0;
2418 newRowScaleExp =
lp_scaler->computeScaleExp(rowVec, colscaleExp);
2434 for(
int j = vec.
size() - 1; j >= 0; --j)
2436 int i = vec.
index(j);
2442 R val = vec.
value(j);
2449 for(
int k =
nCols(); k <= i; ++k)
2453 assert(i <
nCols());
2464 int i, j, k, ii, idx;
2467 int oldRowNumber =
nRows();
2468 int oldColNumber =
nCols();
2477 for(i =
nCols() - 1; i >= 0; --i)
2480 for(i =
set.
num() - 1; i >= 0; --i)
2484 for(j = vec.
size() - 1; j >= 0; --j)
2494 for(k =
nCols(); k <= ii; ++k)
2501 assert(ii <
nCols());
2507 for(i =
nCols() - 1; i >= 0; --i)
2511 int len = newCols[i] +
colVector(i).size();
2521 for(i =
nRows() - 1; i >= oldRowNumber; --i)
2524 int newRowScaleExp = 0;
2531 newRowScaleExp =
lp_scaler->computeScaleExp(vec, colscaleExp);
2544 for(j = vec.
size() - 1; j >= 0; --j)
2548 idx = col->
size() - newCols[k];
2549 assert(newCols[k] > 0);
2552 col->
index(idx) = i;
2564 for(i = 0; i <
nCols(); ++i)
2565 assert(newCols[i] == 0);
2571 assert(
set.
num() ==
nRows() - oldRowNumber);
2580 int oldRowNumber =
nRows();
2581 int newColScaleExp = 0;
2595 newColScaleExp =
lp_scaler->computeScaleExp(vec, rowscaleExp);
2609 for(
int j = vec.
size() - 1; j >= 0; --j)
2611 int i = vec.
index(j);
2617 R val = vec.
value(j);
2624 for(
int k =
nRows(); k <= i; ++k)
2628 assert(i <
nRows());
2638 const R& upperValue,
bool scale =
false)
2641 int oldRowNumber =
nRows();
2642 int newColScaleExp = 0;
2654 newColScaleExp =
lp_scaler->computeScaleExp(colVec, rowscaleExp);
2670 for(
int j = vec.
size() - 1; j >= 0; --j)
2672 int i = vec.
index(j);
2677 R val = vec.
value(j);
2684 for(
int k =
nRows(); k <= i; ++k)
2688 assert(i <
nRows());
2700 int oldColNumber =
nCols();
2701 int oldRowNumber =
nRows();
2711 for(i =
nRows() - 1; i >= 0; --i)
2714 for(i =
set.
num() - 1; i >= 0; --i)
2718 for(j = vec.
size() - 1; j >= 0; --j)
2721 int l = vec.
index(j);
2728 for(
int k =
nRows(); k <= l; ++k)
2736 assert(l <
nRows());
2742 for(i = 0; i <
nRows(); ++i)
2746 int len = newRows[i] +
rowVector(i).size();
2753 for(i = oldColNumber; i <
nCols(); ++i)
2766 int newColScaleExp = 0;
2773 newColScaleExp =
lp_scaler->computeScaleExp(vec, rowscaleExp);
2786 for(j = vec.
size() - 1; j >= 0; --j)
2788 int k = vec.
index(j);
2790 int idx = row.
size() - newRows[k];
2791 assert(newRows[k] > 0);
2805 for(i = 0; i <
nRows(); ++i)
2806 assert(newRows[i] == 0);
2812 assert(
set.
num() ==
nCols() - oldColNumber);
2841 , thesense(old.thesense)
2842 , offset(old.offset)
2843 , _isScaled(old._isScaled)
2845 , spxout(old.spxout)
2852 template <
class S >
2857 , offset(old.offset)
2858 , _isScaled(old._isScaled)
2859 , spxout(old.spxout)
2887 template <
class S >
2920 #include "spxlpbase_real.hpp" 2921 #include "spxlpbase_rational.hpp" 2925 #ifdef SOPLEX_DEBUG_SPXLPBASE 2926 #define SOPLEX_DEBUG 2927 #undef SOPLEX_DEBUG_SPXLPBASE 2930 #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.
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.
virtual void writeFileLPBase(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *p_intvars=0) const
Write loaded LP to filename.
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.
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. Internally, VectorBase wraps std...
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...
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.
Simplex basis.Consider the linear program as provided from class SPxLP: where , and ...
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.
#define SPX_MSG_INCONSISTENT(name)
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.
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.
std::shared_ptr< Tolerances > _tolerances
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.
SPxLPBase()
Default constructor.
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 getColVectorUnscaled(int i, DSVectorBase< R > &vec) const
Gets column vector of column i.
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.
void add(const LPRowBase< R > &row)
void getLowerUnscaled(VectorBase< R > &vec) const
Gets unscaled lower bound vector.
const VectorBase< R > & maxObj() const
SPxLPBase(const SPxLPBase< S > &old)
Copy constructor.
VectorBase< R > & upper_w()
Returns vector of upper bound values.
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 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 std::shared_ptr< Tolerances > tolerances() const
returns current tolerances
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...
SPxSense
Optimization sense.
declaration of types for file output
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.
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 setTolerances(std::shared_ptr< Tolerances > tolerances)
set tolerances
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.
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.
SOPLEX_THREADLOCAL const Real infinity
boost::multiprecision::number< T > spxLdexp(boost::multiprecision::number< T, eto > x, int exp)
(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
void getLhsUnscaled(VectorBase< R > &vec) const
Returns unscaled left hand side vector.
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.
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...
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
void getUpperUnscaled(VectorBase< R > &vec) const
Gets unscaled upper bound vector.
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.
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 changeObjOffset(const T &o)
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.
void maxObjUnscaled(VectorBase< R > &vec) const
Returns unscaled objective vector for maximization problem.
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...
SPxLPBase(const SPxLPBase< R > &old)
Copy constructor.
virtual void changeSense(SPxSense sns)
Changes optimization sense to sns.
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.
void getRhsUnscaled(VectorBase< R > &vec) const
Gets unscaled right hand side vector.
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...
virtual ~SPxLPBase()
Destructor.
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)
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 doAddRow(const LPRowBase< R > &row, bool scale=false)
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
void getObjUnscaled(VectorBase< R > &pobj) const
Gets unscaled objective vector.
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 LPRowBase<R>Set.
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...
SPxScaler< R > * lp_scaler
points to the scaler if the lp has been scaled, to nullptr otherwise
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...
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.
void getRowVectorUnscaled(int i, DSVectorBase< R > &vec) const
Gets unscaled row vector of row i.
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.