24 #define SOPLEX_DEBUG_SPXLPBASE 146 spxout = &newOutstream;
187 for(
int i = 0; i <
nCols(); ++i)
194 virtual R
minAbsNzo(
bool unscaled =
true)
const;
197 virtual R
maxAbsNzo(
bool unscaled =
true)
const;
219 for(
int i = start; i <= end; i++)
378 for(
int i = start; i <= end; i++)
389 for(
int i = start; i <= end; i++)
612 doAddRow(lhsValue, rowVec, rhsValue, scale);
617 void addRow(
const S* lhsValue,
const S* rowValues,
const int* rowIndices,
int rowSize,
620 assert(lhsValue != 0);
621 assert(rowSize <= 0 || rowValues != 0);
622 assert(rowSize <= 0 || rowIndices != 0);
623 assert(rhsValue != 0);
626 int oldColNumber =
nCols();
631 for(
int j = rowSize - 1; j >= 0; --j)
633 const S& val = rowValues[j];
634 int i = rowIndices[j];
641 for(
int k =
nCols(); k <= i; ++k)
668 void addRows(
const S* lhsValues,
const S* rowValues,
const int* rowIndices,
const int* rowStarts,
669 const int* rowLengths,
const int numRows,
const int numValues,
const S* rhsValues)
671 assert(lhsValues != 0);
672 assert(numValues <= 0 || rowValues != 0);
673 assert(numValues <= 0 || rowIndices != 0);
674 assert(numValues <= 0 || rowStarts != 0);
675 assert(numValues <= 0 || rowLengths != 0);
676 assert(rhsValues != 0);
681 int oldRowNumber =
nRows();
682 int oldColNumber =
nCols();
686 for(i = 0; i < numRows; i++)
688 assert(numValues <= 0 || rowStarts[i] + rowLengths[i] <= numValues);
694 rowLengths[i], &(rhsValues[i]));
701 for(i =
nCols() - 1; i >= 0; --i)
706 for(i = 0; i < numRows; i++)
708 for(j = rowStarts[i]; j < rowStarts[i] + rowLengths[i]; j++)
711 assert(rowIndices[j] >= 0);
712 assert(rowIndices[j] < oldColNumber);
713 newCols[rowIndices[j]]++;
719 for(i =
nCols() - 1; i >= 0; --i)
723 int len = newCols[i] +
colVector(i).size();
733 for(i =
nRows() - 1; i >= oldRowNumber; --i)
737 for(j = vec.
size() - 1; j >= 0; --j)
741 idx = col->
size() - newCols[k];
742 assert(newCols[k] > 0);
752 for(i = 0; i <
nCols(); ++i)
753 assert(newCols[i] == 0);
759 assert(numRows ==
nRows() - oldRowNumber);
770 for(
int j = 0; i <
nRows(); ++i, ++j)
782 const R& upperValue,
bool scale =
false)
784 doAddCol(objValue, lowerValue, colVec, upperValue, scale);
789 void addCol(
const S* objValue,
const S* lowerValue,
const S* colValues,
const int* colIndices,
790 int colSize,
const S* upperValue)
793 int oldRowNumber =
nRows();
801 for(
int j = colSize - 1; j >= 0; --j)
803 const S& val = colValues[j];
804 int i = colIndices[j];
811 for(
int k =
nRows(); k <= i; ++k)
838 void addCols(
const S* objValue,
const S* lowerValues,
const S* colValues,
const int* colIndices,
839 const int* colStarts,
const int* colLengths,
const int numCols,
const int numValues,
840 const S* upperValues)
842 assert(lowerValues != 0);
843 assert(numValues <= 0 || colValues != 0);
844 assert(numValues <= 0 || colIndices != 0);
845 assert(numValues <= 0 || colStarts != 0);
846 assert(numValues <= 0 || colLengths != 0);
847 assert(upperValues != 0);
852 int oldColNumber =
nCols();
853 int oldRowNumber =
nRows();
858 for(i = 0; i < numCols; i++)
860 assert(numValues <= 0 || colStarts[i] + colLengths[i] <= numValues);
866 &(colIndices[colStarts[i]]), colLengths[i], &(upperValues[i]));
876 for(i =
nRows() - 1; i >= 0; --i)
879 for(i = numValues - 1; i >= 0; --i)
882 assert(colIndices[i] >= 0);
883 assert(colIndices[i] < oldRowNumber);
884 newRows[colIndices[i]]++;
888 for(i =
nRows() - 1; i >= 0; --i)
892 int len = newRows[i] +
rowVector(i).size();
902 for(i =
nCols() - 1; i >= oldColNumber; --i)
906 for(j = vec.
size() - 1; j >= 0; --j)
910 idx = row->
size() - newRows[k];
911 assert(newRows[k] > 0);
921 for(i = 0; i <
nRows(); ++i)
922 assert(newRows[i] == 0);
928 assert(numCols ==
nCols() - oldColNumber);
940 for(
int j = 0; i <
nCols(); ++i, ++j)
986 for(
int i =
nRows() - 1; i >= 0; --i)
1011 for(
int i =
nRows() - 1; i >= 0; --i)
1026 int i = end - start + 1;
1038 for(i = 0; i < start; ++i)
1041 for(; i <= end; ++i)
1044 for(; i <
nRows(); ++i)
1086 for(
int i =
nCols() - 1; i >= 0; --i)
1090 perm[
number(
id[n])] = -1;
1111 for(
int i =
nCols() - 1; i >= 0; --i)
1126 int i = end - start + 1;
1138 for(i = 0; i < start; ++i)
1141 for(; i <= end; ++i)
1144 for(; i <
nCols(); ++i)
1202 ok = ((c ==
'*') || (c ==
'N'))
1203 ?
readMPS(in, rowNames, colNames, intVars)
1204 :
readLPF(in, rowNames, colNames, intVars);
1219 return read(file, rowNames, colNames, intVars);
1227 const DIdxSet* p_intvars = 0)
const;
1231 const DIdxSet* p_intvars = 0)
const;
1238 std::ofstream tmp(filename);
1239 size_t len_f = strlen(filename);
1241 if(len_f > 4 && filename[len_f - 1] ==
's' && filename[len_f - 2] ==
'p' 1242 && filename[len_f - 3] ==
'm' && filename[len_f - 4] ==
'.')
1244 writeMPS(tmp, rowNames, colNames, p_intvars);
1248 writeLPF(tmp, rowNames, colNames, p_intvars);
1258 int countFreeCol = 0;
1263 int countRanged = 0;
1264 int countFreeRow = 0;
1266 for(
int i = 0; i <
nCols(); i++)
1268 bool hasLower =
false;
1269 bool hasUpper =
false;
1283 if(hasUpper && hasLower)
1290 if(!hasUpper && !hasLower)
1294 for(
int i = 0; i <
nRows(); i++)
1296 bool hasRhs =
false;
1297 bool hasLhs =
false;
1311 if(hasRhs && hasLhs)
1322 if(!hasRhs && !hasLhs)
1327 os <<
" Columns : " <<
nCols() <<
"\n" 1328 <<
" boxed : " << countBoxed <<
"\n" 1329 <<
" lower bound : " << countLower <<
"\n" 1330 <<
" upper bound : " << countUpper <<
"\n" 1331 <<
" free : " << countFreeCol <<
"\n" 1332 <<
" Rows : " <<
nRows() <<
"\n" 1333 <<
" equal : " << countEqual <<
"\n" 1334 <<
" ranged : " << countRanged <<
"\n" 1335 <<
" lhs : " << countLhs <<
"\n" 1336 <<
" rhs : " << countRhs <<
"\n" 1337 <<
" free : " << countFreeRow <<
"\n" 1338 <<
" Nonzeros : " <<
nNzos() <<
"\n" 1339 <<
" per column : " << R(
nNzos()) / R(
nCols()) <<
"\n" 1340 <<
" per row : " << R(
nNzos()) / R(
nRows()) <<
"\n" 1342 <<
" min. abs. value : " << R(
minAbsNzo()) <<
"\n" 1343 <<
" max. abs. value : " << R(
maxAbsNzo()) <<
"\n";
1362 virtual void changeObj(
int i,
const R& newVal,
bool scale =
false)
1371 template <
class S >
1391 assert(scale ==
false);
1413 template <
class S >
1429 assert(scale ==
false);
1430 assert(
lower().dim() == newLower.
dim());
1436 virtual void changeLower(
int i,
const R& newLower,
bool scale =
false)
1438 if(scale && newLower > R(-
infinity))
1451 template <
class S >
1467 assert(scale ==
false);
1468 assert(
upper().dim() == newUpper.
dim());
1474 virtual void changeUpper(
int i,
const R& newUpper,
bool scale =
false)
1476 if(scale && newUpper < R(
infinity))
1489 template <
class S >
1512 virtual void changeBounds(
int i,
const R& newLower,
const R& newUpper,
bool scale =
false)
1520 template <
class S >
1537 assert(scale ==
false);
1538 assert(
lhs().dim() == newLhs.
dim());
1544 virtual void changeLhs(
int i,
const R& newLhs,
bool scale =
false)
1559 template <
class S >
1575 assert(scale ==
false);
1576 assert(
rhs().dim() == newRhs.
dim());
1582 virtual void changeRhs(
int i,
const R& newRhs,
bool scale =
false)
1612 virtual void changeRange(
int i,
const R& newLhs,
const R& newRhs,
bool scale =
false)
1620 template <
class S >
1678 for(j = row.
size() - 1; j >= 0; --j)
1681 int position = col.
pos(n);
1683 assert(position != -1);
1697 for(j = newrow.size() - 1; j >= 0; --j)
1699 int idx = newrow.index(j);
1700 R val = newrow.value(j);
1727 for(j = col.
size() - 1; j >= 0; --j)
1730 int position = row.
pos(n);
1732 assert(position != -1);
1746 for(j = newcol.size() - 1; j >= 0; --j)
1748 int idx = newcol.index(j);
1749 R val = newcol.value(j);
1784 newVal =
lp_scaler->scaleElement(*
this, i, j, val);
1789 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1800 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1810 template <
class S >
1819 if(mpq_get_d(*val) != R(0))
1821 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1832 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1859 template <
typename T>
1871 const bool unscaled =
true)
const;
1883 for(
int i = primal.
size() - 1; i >= 0; i--)
1885 assert(primal.
index(i) >= 0);
1895 const bool unscaled =
true)
const;
1907 for(
int i = dual.
size() - 1; i >= 0; i--)
1909 assert(dual.
index(i) >= 0);
1930 for(
int r = 0; r <
nRows(); r++)
1948 SPxRowId dualRowIds[] = 0,
SPxColId dualColIds[] = 0,
int* nprimalrows = 0,
int* nprimalcols = 0,
1949 int* ndualrows = 0,
int* ndualcols = 0);
1960 #ifdef ENABLE_CONSISTENCY_CHECKS 1962 for(
int i =
nCols() - 1; i >= 0; --i)
1966 for(
int j = v.
size() - 1; j >= 0; --j)
1979 for(
int i =
nRows() - 1; i >= 0; --i)
1983 for(
int j = v.
size() - 1; j >= 0; --j)
2071 for(
int i = vec.
size() - 1; i >= 0; --i)
2074 int position = remvec.
pos(j);
2081 int idx =
nRows() - 1;
2087 for(
int i = l_vec.
size() - 1; i >= 0; --i)
2090 int position = movevec.
pos(idx);
2092 assert(position != -1);
2095 movevec.
index(position) = j;
2109 for(
int i = 0; i < j; ++i)
2113 for(
int k = vec.
size() - 1; k >= 0; --k)
2115 int idx = vec.
index(k);
2120 vec.
index(k) = perm[idx];
2133 for(i = vec.
size() - 1; i >= 0; --i)
2136 int position = remvec.
pos(j);
2138 assert(position != -1);
2145 int idx =
nCols() - 1;
2151 for(i = l_vec.
size() - 1; i >= 0; --i)
2154 int position = movevec.
pos(idx);
2156 assert(position != -1);
2159 movevec.
index(position) = j;
2169 int nrows =
nRows();
2173 for(
int i = 0; i < nrows; ++i)
2177 for(
int k = vec.
size() - 1; k >= 0; --k)
2179 int idx = vec.
index(k);
2184 vec.
index(k) = perm[idx];
2205 int* more = moreArray.
get_ptr();
2207 for(
int i =
set.
num() - 1; i >= 0; --i)
2211 int end = addset.
num();
2213 for(
int i = addset.
num() - n; i < end; ++i)
2219 for(
int j = vec.
size() - 1; j >= 0; --j)
2220 more[vec.
index(j)]++;
2226 for(
int i =
set.
num() - 1; i >= 0; --i)
2228 int j =
set[i].size();
2229 set.xtend(
set[i], j + more[i]);
2230 set[i].set_size(j + more[i]);
2234 for(
int i = addset.
num() - n; i < addset.
num(); ++i)
2238 for(
int j = vec.
size() - 1; j >= 0; --j)
2240 int k = vec.
index(j);
2243 l_xtend.
index(m) = i;
2274 int oldColNumber =
nCols();
2275 int newRowScaleExp = 0;
2286 newRowScaleExp =
lp_scaler->computeScaleExp(vec, colscaleExp);
2300 for(
int j = vec.
size() - 1; j >= 0; --j)
2302 int i = vec.
index(j);
2308 R val = vec.
value(j);
2315 for(
int k =
nCols(); k <= i; ++k)
2319 assert(i <
nCols());
2332 int oldColNumber =
nCols();
2333 int newRowScaleExp = 0;
2342 newRowScaleExp =
lp_scaler->computeScaleExp(rowVec, colscaleExp);
2358 for(
int j = vec.
size() - 1; j >= 0; --j)
2360 int i = vec.
index(j);
2366 R val = vec.
value(j);
2373 for(
int k =
nCols(); k <= i; ++k)
2377 assert(i <
nCols());
2388 int i, j, k, ii, idx;
2391 int oldRowNumber =
nRows();
2392 int oldColNumber =
nCols();
2401 for(i =
nCols() - 1; i >= 0; --i)
2404 for(i =
set.
num() - 1; i >= 0; --i)
2408 for(j = vec.
size() - 1; j >= 0; --j)
2418 for(k =
nCols(); k <= ii; ++k)
2425 assert(ii <
nCols());
2431 for(i =
nCols() - 1; i >= 0; --i)
2435 int len = newCols[i] +
colVector(i).size();
2445 for(i =
nRows() - 1; i >= oldRowNumber; --i)
2448 int newRowScaleExp = 0;
2455 newRowScaleExp =
lp_scaler->computeScaleExp(vec, colscaleExp);
2468 for(j = vec.
size() - 1; j >= 0; --j)
2472 idx = col->
size() - newCols[k];
2473 assert(newCols[k] > 0);
2476 col->
index(idx) = i;
2488 for(i = 0; i <
nCols(); ++i)
2489 assert(newCols[i] == 0);
2495 assert(
set.
num() ==
nRows() - oldRowNumber);
2504 int oldRowNumber =
nRows();
2505 int newColScaleExp = 0;
2519 newColScaleExp =
lp_scaler->computeScaleExp(vec, rowscaleExp);
2533 for(
int j = vec.
size() - 1; j >= 0; --j)
2535 int i = vec.
index(j);
2541 R val = vec.
value(j);
2548 for(
int k =
nRows(); k <= i; ++k)
2552 assert(i <
nRows());
2562 const R& upperValue,
bool scale =
false)
2565 int oldRowNumber =
nRows();
2566 int newColScaleExp = 0;
2578 newColScaleExp =
lp_scaler->computeScaleExp(colVec, rowscaleExp);
2594 for(
int j = vec.
size() - 1; j >= 0; --j)
2596 int i = vec.
index(j);
2601 R val = vec.
value(j);
2608 for(
int k =
nRows(); k <= i; ++k)
2612 assert(i <
nRows());
2624 int oldColNumber =
nCols();
2625 int oldRowNumber =
nRows();
2635 for(i =
nRows() - 1; i >= 0; --i)
2638 for(i =
set.
num() - 1; i >= 0; --i)
2642 for(j = vec.
size() - 1; j >= 0; --j)
2645 int l = vec.
index(j);
2652 for(
int k =
nRows(); k <= l; ++k)
2660 assert(l <
nRows());
2666 for(i = 0; i <
nRows(); ++i)
2670 int len = newRows[i] +
rowVector(i).size();
2677 for(i = oldColNumber; i <
nCols(); ++i)
2690 int newColScaleExp = 0;
2697 newColScaleExp =
lp_scaler->computeScaleExp(vec, rowscaleExp);
2710 for(j = vec.
size() - 1; j >= 0; --j)
2712 int k = vec.
index(j);
2714 int idx = row.
size() - newRows[k];
2715 assert(newRows[k] > 0);
2729 for(i = 0; i <
nRows(); ++i)
2730 assert(newRows[i] == 0);
2736 assert(
set.
num() ==
nCols() - oldColNumber);
2775 template <
class S >
2808 template <
class S >
2840 #include "spxlpbase_real.hpp" 2844 #ifdef SOPLEX_DEBUG_SPXLPBASE 2845 #define SOPLEX_DEBUG 2846 #undef SOPLEX_DEBUG_SPXLPBASE 2849 #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.
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. 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.
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.
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 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
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.
Rational spxLdexp(Rational x, int exp)
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...
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 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.
(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...
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...
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 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.