24 #define SOPLEX_DEBUG_SPXLPBASE 128 spxout = &newOutstream;
169 for(
int i = 0; i <
nCols(); ++i)
176 virtual R
minAbsNzo(
bool unscaled =
true)
const;
179 virtual R
maxAbsNzo(
bool unscaled =
true)
const;
201 for(
int i = start; i <= end; i++)
360 for(
int i = start; i <= end; i++)
371 for(
int i = start; i <= end; i++)
594 doAddRow(lhsValue, rowVec, rhsValue, scale);
599 void addRow(
const S* lhsValue,
const S* rowValues,
const int* rowIndices,
int rowSize,
602 assert(lhsValue != 0);
603 assert(rowSize <= 0 || rowValues != 0);
604 assert(rowSize <= 0 || rowIndices != 0);
605 assert(rhsValue != 0);
608 int oldColNumber =
nCols();
613 for(
int j = rowSize - 1; j >= 0; --j)
615 const S& val = rowValues[j];
616 int i = rowIndices[j];
623 for(
int k =
nCols(); k <= i; ++k)
650 void addRows(
const S* lhsValues,
const S* rowValues,
const int* rowIndices,
const int* rowStarts,
651 const int* rowLengths,
const int numRows,
const int numValues,
const S* rhsValues)
653 assert(lhsValues != 0);
654 assert(numValues <= 0 || rowValues != 0);
655 assert(numValues <= 0 || rowIndices != 0);
656 assert(numValues <= 0 || rowStarts != 0);
657 assert(numValues <= 0 || rowLengths != 0);
658 assert(rhsValues != 0);
663 int oldRowNumber =
nRows();
664 int oldColNumber =
nCols();
668 for(i = 0; i < numRows; i++)
670 assert(numValues <= 0 || rowStarts[i] + rowLengths[i] <= numValues);
676 rowLengths[i], &(rhsValues[i]));
683 for(i =
nCols() - 1; i >= 0; --i)
688 for(i = 0; i < numRows; i++)
690 for(j = rowStarts[i]; j < rowStarts[i] + rowLengths[i]; j++)
693 assert(rowIndices[j] >= 0);
694 assert(rowIndices[j] < oldColNumber);
695 newCols[rowIndices[j]]++;
701 for(i =
nCols() - 1; i >= 0; --i)
705 int len = newCols[i] +
colVector(i).size();
715 for(i =
nRows() - 1; i >= oldRowNumber; --i)
719 for(j = vec.
size() - 1; j >= 0; --j)
723 idx = col->
size() - newCols[k];
724 assert(newCols[k] > 0);
734 for(i = 0; i <
nCols(); ++i)
735 assert(newCols[i] == 0);
741 assert(numRows ==
nRows() - oldRowNumber);
752 for(
int j = 0; i <
nRows(); ++i, ++j)
764 const R& upperValue,
bool scale =
false)
766 doAddCol(objValue, lowerValue, colVec, upperValue, scale);
771 void addCol(
const S* objValue,
const S* lowerValue,
const S* colValues,
const int* colIndices,
772 int colSize,
const S* upperValue)
775 int oldRowNumber =
nRows();
783 for(
int j = colSize - 1; j >= 0; --j)
785 const S& val = colValues[j];
786 int i = colIndices[j];
793 for(
int k =
nRows(); k <= i; ++k)
820 void addCols(
const S* objValue,
const S* lowerValues,
const S* colValues,
const int* colIndices,
821 const int* colStarts,
const int* colLengths,
const int numCols,
const int numValues,
822 const S* upperValues)
824 assert(lowerValues != 0);
825 assert(numValues <= 0 || colValues != 0);
826 assert(numValues <= 0 || colIndices != 0);
827 assert(numValues <= 0 || colStarts != 0);
828 assert(numValues <= 0 || colLengths != 0);
829 assert(upperValues != 0);
834 int oldColNumber =
nCols();
835 int oldRowNumber =
nRows();
840 for(i = 0; i < numCols; i++)
842 assert(numValues <= 0 || colStarts[i] + colLengths[i] <= numValues);
848 &(colIndices[colStarts[i]]), colLengths[i], &(upperValues[i]));
858 for(i =
nRows() - 1; i >= 0; --i)
861 for(i = numValues - 1; i >= 0; --i)
864 assert(colIndices[i] >= 0);
865 assert(colIndices[i] < oldRowNumber);
866 newRows[colIndices[i]]++;
870 for(i =
nRows() - 1; i >= 0; --i)
874 int len = newRows[i] +
rowVector(i).size();
884 for(i =
nCols() - 1; i >= oldColNumber; --i)
888 for(j = vec.
size() - 1; j >= 0; --j)
892 idx = row->
size() - newRows[k];
893 assert(newRows[k] > 0);
903 for(i = 0; i <
nRows(); ++i)
904 assert(newRows[i] == 0);
910 assert(numCols ==
nCols() - oldColNumber);
922 for(
int j = 0; i <
nCols(); ++i, ++j)
968 for(
int i =
nRows() - 1; i >= 0; --i)
993 for(
int i =
nRows() - 1; i >= 0; --i)
1008 int i = end - start + 1;
1020 for(i = 0; i < start; ++i)
1023 for(; i <= end; ++i)
1026 for(; i <
nRows(); ++i)
1068 for(
int i =
nCols() - 1; i >= 0; --i)
1072 perm[
number(
id[n])] = -1;
1093 for(
int i =
nCols() - 1; i >= 0; --i)
1108 int i = end - start + 1;
1120 for(i = 0; i < start; ++i)
1123 for(; i <= end; ++i)
1126 for(; i <
nCols(); ++i)
1184 ok = ((c ==
'*') || (c ==
'N'))
1185 ?
readMPS(in, rowNames, colNames, intVars)
1186 :
readLPF(in, rowNames, colNames, intVars);
1201 return read(file, rowNames, colNames, intVars);
1209 const DIdxSet* p_intvars = 0)
const;
1213 const DIdxSet* p_intvars = 0)
const;
1220 std::ofstream tmp(filename);
1221 size_t len_f = strlen(filename);
1223 if(len_f > 4 && filename[len_f - 1] ==
's' && filename[len_f - 2] ==
'p' 1224 && filename[len_f - 3] ==
'm' && filename[len_f - 4] ==
'.')
1226 writeMPS(tmp, rowNames, colNames, p_intvars);
1230 writeLPF(tmp, rowNames, colNames, p_intvars);
1240 int countFreeCol = 0;
1245 int countRanged = 0;
1246 int countFreeRow = 0;
1248 for(
int i = 0; i <
nCols(); i++)
1250 bool hasLower =
false;
1251 bool hasUpper =
false;
1265 if(hasUpper && hasLower)
1272 if(!hasUpper && !hasLower)
1276 for(
int i = 0; i <
nRows(); i++)
1278 bool hasRhs =
false;
1279 bool hasLhs =
false;
1293 if(hasRhs && hasLhs)
1304 if(!hasRhs && !hasLhs)
1309 os <<
" Columns : " <<
nCols() <<
"\n" 1310 <<
" boxed : " << countBoxed <<
"\n" 1311 <<
" lower bound : " << countLower <<
"\n" 1312 <<
" upper bound : " << countUpper <<
"\n" 1313 <<
" free : " << countFreeCol <<
"\n" 1314 <<
" Rows : " <<
nRows() <<
"\n" 1315 <<
" equal : " << countEqual <<
"\n" 1316 <<
" ranged : " << countRanged <<
"\n" 1317 <<
" lhs : " << countLhs <<
"\n" 1318 <<
" rhs : " << countRhs <<
"\n" 1319 <<
" free : " << countFreeRow <<
"\n" 1320 <<
" Nonzeros : " <<
nNzos() <<
"\n" 1344 virtual void changeObj(
int i,
const R& newVal,
bool scale =
false)
1353 template <
class S >
1373 assert(scale ==
false);
1395 template <
class S >
1411 assert(scale ==
false);
1412 assert(
lower().dim() == newLower.
dim());
1418 virtual void changeLower(
int i,
const R& newLower,
bool scale =
false)
1433 template <
class S >
1449 assert(scale ==
false);
1450 assert(
upper().dim() == newUpper.
dim());
1456 virtual void changeUpper(
int i,
const R& newUpper,
bool scale =
false)
1471 template <
class S >
1494 virtual void changeBounds(
int i,
const R& newLower,
const R& newUpper,
bool scale =
false)
1502 template <
class S >
1519 assert(scale ==
false);
1520 assert(
lhs().dim() == newLhs.
dim());
1526 virtual void changeLhs(
int i,
const R& newLhs,
bool scale =
false)
1541 template <
class S >
1557 assert(scale ==
false);
1558 assert(
rhs().dim() == newRhs.
dim());
1564 virtual void changeRhs(
int i,
const R& newRhs,
bool scale =
false)
1594 virtual void changeRange(
int i,
const R& newLhs,
const R& newRhs,
bool scale =
false)
1602 template <
class S >
1660 for(j = row.
size() - 1; j >= 0; --j)
1663 int position = col.
pos(n);
1665 assert(position != -1);
1679 for(j = newrow.size() - 1; j >= 0; --j)
1681 int idx = newrow.index(j);
1682 R val = newrow.value(j);
1709 for(j = col.
size() - 1; j >= 0; --j)
1712 int position = row.
pos(n);
1714 assert(position != -1);
1728 for(j = newcol.size() - 1; j >= 0; --j)
1730 int idx = newcol.index(j);
1731 R val = newcol.value(j);
1771 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1782 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1792 template <
class S >
1801 if(mpq_get_d(*val) != R(0))
1803 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1814 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1851 const bool unscaled =
true)
const;
1863 for(
int i = primal.
size() - 1; i >= 0; i--)
1865 assert(primal.
index(i) >= 0);
1875 const bool unscaled =
true)
const;
1887 for(
int i = dual.
size() - 1; i >= 0; i--)
1889 assert(dual.
index(i) >= 0);
1910 for(
int r = 0; r <
nRows(); r++)
1928 SPxRowId dualRowIds[] = 0,
SPxColId dualColIds[] = 0,
int* nprimalrows = 0,
int* nprimalcols = 0,
1929 int* ndualrows = 0,
int* ndualcols = 0);
1940 #ifdef ENABLE_CONSISTENCY_CHECKS 1942 for(
int i =
nCols() - 1; i >= 0; --i)
1946 for(
int j = v.
size() - 1; j >= 0; --j)
1959 for(
int i =
nRows() - 1; i >= 0; --i)
1963 for(
int j = v.
size() - 1; j >= 0; --j)
2051 for(
int i = vec.
size() - 1; i >= 0; --i)
2054 int position = remvec.
pos(j);
2061 int idx =
nRows() - 1;
2067 for(
int i = l_vec.
size() - 1; i >= 0; --i)
2070 int position = movevec.
pos(idx);
2072 assert(position != -1);
2075 movevec.
index(position) = j;
2089 for(
int i = 0; i < j; ++i)
2093 for(
int k = vec.
size() - 1; k >= 0; --k)
2095 int idx = vec.
index(k);
2100 vec.
index(k) = perm[idx];
2113 for(i = vec.
size() - 1; i >= 0; --i)
2116 int position = remvec.
pos(j);
2118 assert(position != -1);
2125 int idx =
nCols() - 1;
2131 for(i = l_vec.
size() - 1; i >= 0; --i)
2134 int position = movevec.
pos(idx);
2136 assert(position != -1);
2139 movevec.
index(position) = j;
2149 int nrows =
nRows();
2153 for(
int i = 0; i < nrows; ++i)
2157 for(
int k = vec.
size() - 1; k >= 0; --k)
2159 int idx = vec.
index(k);
2164 vec.
index(k) = perm[idx];
2185 int* more = moreArray.
get_ptr();
2187 for(
int i =
set.
num() - 1; i >= 0; --i)
2191 int end = addset.
num();
2193 for(
int i = addset.
num() - n; i < end; ++i)
2199 for(
int j = vec.
size() - 1; j >= 0; --j)
2200 more[vec.
index(j)]++;
2206 for(
int i =
set.
num() - 1; i >= 0; --i)
2208 int j =
set[i].size();
2209 set.xtend(
set[i], j + more[i]);
2210 set[i].set_size(j + more[i]);
2214 for(
int i = addset.
num() - n; i < addset.
num(); ++i)
2218 for(
int j = vec.
size() - 1; j >= 0; --j)
2220 int k = vec.
index(j);
2223 l_xtend.
index(m) = i;
2254 int oldColNumber =
nCols();
2255 int newRowScaleExp = 0;
2280 for(
int j = vec.
size() - 1; j >= 0; --j)
2282 int i = vec.
index(j);
2288 R val = vec.
value(j);
2295 for(
int k =
nCols(); k <= i; ++k)
2299 assert(i <
nCols());
2312 int oldColNumber =
nCols();
2313 int newRowScaleExp = 0;
2338 for(
int j = vec.
size() - 1; j >= 0; --j)
2340 int i = vec.
index(j);
2346 R val = vec.
value(j);
2353 for(
int k =
nCols(); k <= i; ++k)
2357 assert(i <
nCols());
2368 int i, j, k, ii, idx;
2371 int oldRowNumber =
nRows();
2372 int oldColNumber =
nCols();
2381 for(i =
nCols() - 1; i >= 0; --i)
2384 for(i =
set.
num() - 1; i >= 0; --i)
2388 for(j = vec.
size() - 1; j >= 0; --j)
2398 for(k =
nCols(); k <= ii; ++k)
2405 assert(ii <
nCols());
2411 for(i =
nCols() - 1; i >= 0; --i)
2415 int len = newCols[i] +
colVector(i).size();
2425 for(i =
nRows() - 1; i >= oldRowNumber; --i)
2428 int newRowScaleExp = 0;
2448 for(j = vec.
size() - 1; j >= 0; --j)
2452 idx = col->
size() - newCols[k];
2453 assert(newCols[k] > 0);
2456 col->
index(idx) = i;
2468 for(i = 0; i <
nCols(); ++i)
2469 assert(newCols[i] == 0);
2475 assert(
set.
num() ==
nRows() - oldRowNumber);
2484 int oldRowNumber =
nRows();
2485 int newColScaleExp = 0;
2513 for(
int j = vec.
size() - 1; j >= 0; --j)
2515 int i = vec.
index(j);
2521 R val = vec.
value(j);
2528 for(
int k =
nRows(); k <= i; ++k)
2532 assert(i <
nRows());
2542 const R& upperValue,
bool scale =
false)
2545 int oldRowNumber =
nRows();
2546 int newColScaleExp = 0;
2574 for(
int j = vec.
size() - 1; j >= 0; --j)
2576 int i = vec.
index(j);
2581 R val = vec.
value(j);
2588 for(
int k =
nRows(); k <= i; ++k)
2592 assert(i <
nRows());
2604 int oldColNumber =
nCols();
2605 int oldRowNumber =
nRows();
2615 for(i =
nRows() - 1; i >= 0; --i)
2618 for(i =
set.
num() - 1; i >= 0; --i)
2622 for(j = vec.
size() - 1; j >= 0; --j)
2625 int l = vec.
index(j);
2632 for(
int k =
nRows(); k <= l; ++k)
2640 assert(l <
nRows());
2646 for(i = 0; i <
nRows(); ++i)
2650 int len = newRows[i] +
rowVector(i).size();
2657 for(i = oldColNumber; i <
nCols(); ++i)
2661 int newColScaleExp = 0;
2681 for(j = vec.
size() - 1; j >= 0; --j)
2683 int k = vec.
index(j);
2685 int idx = row.
size() - newRows[k];
2686 assert(newRows[k] > 0);
2700 for(i = 0; i <
nRows(); ++i)
2701 assert(newRows[i] == 0);
2707 assert(
set.
num() ==
nCols() - oldColNumber);
2746 template <
class S >
2779 template <
class S >
2814 const bool unscaled)
const;
2922 int* nprimalcols,
int* ndualrows,
int* ndualcols);
2928 #ifdef SOPLEX_DEBUG_SPXLPBASE 2929 #define SOPLEX_DEBUG 2930 #undef SOPLEX_DEBUG_SPXLPBASE 2933 #endif // _SPXLPBASE_H_ const VectorBase< R > & rhs() const
Returns right hand side vector.
virtual void buildDualProblem(SPxLPBase< R > &dualLP, SPxRowId primalRowIds[]=0, SPxColId primalColIds[]=0, SPxRowId dualRowIds[]=0, SPxColId dualColIds[]=0, int *nprimalrows=0, int *nprimalcols=0, int *ndualrows=0, int *ndualcols=0)
Building the dual problem from a given LP.
VectorBase< R > & obj_w()
Returns the vector of objective coefficients (writeable).
bool has(const SPxId &id) const
Returns the row or column number for identifier id.
LPRowBase< R >::Type rowType(const SPxRowId &id) const
Returns the inequality type of the row with identifier key.
void getRhsUnscaled(VectorBase< Real > &vec) const
Gets unscaled right hand side vector.
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
int number(const SPxId &id) const
Returns the row or column number for identifier id.
virtual void removeRow(int i)
Removes i 'th row.
void getRow(int i, LPRowBase< R > &row) const
Gets i 'th row.
virtual void changeObj(SPxColId id, const R &newVal, bool scale=false)
Changes objective value of column with identifier id to newVal. scale determines whether the new data...
void memRemax(int newmax)
Resets length of nonzero memory.
const SVectorBase< R > & colVector(const SPxColId &id) const
Returns column vector of column with identifier id.
void addRows(const S *lhsValues, const S *rowValues, const int *rowIndices, const int *rowStarts, const int *rowLengths, const int numRows, const int numValues, const S *rhsValues)
SPxRowId rId(int n) const
Returns the row identifier for row n.
void doAddCol(const LPColBase< R > &col, bool scale=false)
const VectorBase< R > & lower() const
const R & objOffset() const
Returns the objective function value offset.
LPRowBase< R >::Type type(int i) const
Returns the inequalitiy type of the i 'th LPRowBase.
const VectorBase< R > & upper() const
Returns upper bound vector.
virtual R minAbsNzo(bool unscaled=true) const
Absolute smallest non-zero element in (possibly scaled) LP.
THREADLOCAL const Real infinity
void getRows(int start, int end, LPRowSetBase< R > &set) const
Gets rows start, ... end.
Entry identifier class for items of a DataSet.
void setOutstream(SPxOut &newOutstream)
const R & upper(int i) const
Returns upper bound of column i.
bool _isScaled
true, if scaling has been performed
Dense vector.Class VectorBase provides dense linear algebra vectors. It does not provide memory manag...
bool has(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Geometric mean row/column scaling.This SPxScaler implementation performs geometric mean scaling of th...
void changeObj(int i, const S *newVal)
changes i 'th objective vector element to newVal.
virtual void changeRange(SPxRowId id, const R &newLhs, const R &newRhs, bool scale=false)
Changes left and right hand side of row with identifier id. scale determines whether the new data sho...
virtual Real scaleElement(const SPxLPBase< Real > &lp, int row, int col, Real val) const
returns scaled LP element in row and col.
const R & maxObj(int i) const
Returns objective value of column i for maximization problem.
virtual void addRows(SPxRowId id[], const LPRowSetBase< R > &set, bool scale=false)
adds all LPRowBases of pset to LPRowSetBase.
T * get_ptr()
get a C pointer to the data.
R & maxObj_w(int i)
Returns objective value of column i for maximization problem.
const VectorBase< R > & lhs() const
Returns the vector of lhs values.
virtual void removeRowRange(int start, int end, int perm[]=0)
Removes rows from start to end (including both).
int size() const
Number of used indices.
void doAddCols(const LPColSetBase< R > &set, bool scale=false)
void xtend(int n, int newmax)
Extends row n to fit newmax nonzeros.
virtual void changeLower(int i, const R &newLower, bool scale=false)
changes i 'th lower bound to newLower. scale determines whether the new data should be scaled ...
void changeRange(int i, const S *newLhs, const S *newRhs)
Changes left and right hand side of row i.
virtual bool readFile(const char *filename, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP from a file.
virtual void changeMaxObj(int i, const R &newVal, bool scale=false)
changes i 'th objective vector element to newVal. scale determines whether the new data should be sca...
bool isScaled() const
Returns true if and only if the LP is scaled.
R rhsUnscaled(int i) const
Returns unscaled right hand side of row number i.
void clear()
Removes all LPRowBases.
virtual void changeCol(int n, const LPColBase< R > &newCol, bool scale=false)
Replaces i 'th column of LP with newCol. scale determines whether the new data should be scaled...
virtual void changeRowObj(int i, const R &newRowObj, bool scale=false)
Changes i 'th row objective function value to newRowObj. scale determines whether the new data should...
virtual void removeCols(int perm[])
Removes multiple columns.
void getObj(VectorBase< R > &pobj) const
Gets objective vector.
void doAddRow(const R &lhsValue, const SVectorBase< R > &rowVec, const R &rhsValue, bool scale=false)
const SVectorBase< R > & rowVector() const
Constraint row vector.
virtual void addedCols(int newcols)
Called after the last n columns have just been added.
R rhs() const
Right-hand side value.
Dynamic sparse vectors.Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with a...
void remove(int i)
Removes i 'th LPColBase.
Least squares scaling.This SPxScaler implementation performs least squares scaling as suggested by Cu...
virtual void changeElement(SPxRowId rid, SPxColId cid, const R &val, bool scale=false)
Changes LP element identified by (rid, cid) to val. scale determines whether the new data should be s...
virtual void changeBounds(int i, const R &newLower, const R &newUpper, bool scale=false)
Changes bounds of column i to newLower and newUpper. scale determines whether the new data should be ...
const R & lhs(int i) const
Returns left hand side of row number i.
R obj(const SPxColId &id) const
Returns objective value of column with identifier id.
void addRow(const S *lhsValue, const S *rowValues, const int *rowIndices, int rowSize, const S *rhsValue)
virtual void removeRows(int nums[], int n, int perm[]=0)
Removes n LPRowBases.
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
void setLower(const R &p_low)
Sets lower bound.
const LPRowSetBase< R > * lprowset() const
Returns the LP as an LPRowSetBase.
void add(const LPColBase< R > &pcol)
SPxLPBase< R > & operator=(const SPxLPBase< R > &old)
Assignment operator.
virtual Real scaleUpper(const SPxLPBase< Real > &lp, int col, Real upper) const
returns scaled upper bound of column col.
R obj() const
Gets objective value.
virtual void changeRange(int i, const R &newLhs, const R &newRhs, bool scale=false)
Changes left and right hand side of row i. scale determines whether the new data should be scaled...
virtual bool read(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP in LP or MPS format from input stream in.
virtual void removeCol(int i)
Removes i 'th column.
void getRowObj(VectorBase< R > &prowobj) const
Gets row objective function vector.
R & value(int n)
Reference to value of n 'th nonzero.
virtual void changeRow(SPxRowId id, const LPRowBase< R > &newRow, bool scale=false)
Replaces row with identifier id with newRow. scale determines whether the new data should be scaled...
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
VectorBase< R > & lhs_w()
Returns the vector of lhs values.
R & rhs_w(int i)
Returns right hand side of row i.
void setUpper(const R &p_up)
Sets upper bound.
virtual bool readMPS(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads an LP in MPS format from input stream in.
VectorBase< R > & maxObj_w()
Returns vector of objective values w.r.t. maximization.
void remove(int n, int m)
Remove nonzeros n thru m.
VectorBase< R > & lower_w()
Returns vector of lower bound values.
const SVectorBase< R > & rowVector(const SPxRowId &id) const
Gets row vector of row with identifier id.
virtual Real scaleLhs(const SPxLPBase< Real > &lp, int row, Real lhs) const
returns scaled left hand side of row row.
void add(const LPRowBase< R > &row)
const VectorBase< R > & maxObj() const
VectorBase< R > & upper_w()
Returns vector of upper bound values.
virtual void changeObjOffset(const R &o)
SPxColId cId(int n) const
Returns the column identifier for column n.
SVectorBase< R > & rowVector_w(int i)
int number(const SPxColId &id) const
Returns the column number of the column with identifier id.
virtual void removeRows(int perm[])
Removes multiple rows.
void changeLower(int i, const S *newLower)
changes i 'th lower bound to newLower.
void getObjUnscaled(VectorBase< Real > &pobj) const
Gets unscaled objective vector.
void memRemax(int newmax)
Reallocates memory to be able to store newmax nonzeros.
int nRows() const
Returns number of rows in LP.
bool isConsistent() const
Checks consistency.
R lower() const
Gets lower bound.
int number(const DataKey &k) const
Returns number of LPColBase with DataKey k in LPColSetBase.
const SVectorBase< R > & colVector() const
Gets constraint column vector.
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
R objUnscaled(int i) const
Returns unscaled objective value of column i.
int nNzos() const
Returns number of nonzeros in LP.
virtual void changeLhs(SPxRowId id, const R &newLhs, bool scale=false)
Changes left hand side value for row with identifier id. scale determines whether the new data should...
virtual void addCol(const R &objValue, const R &lowerValue, const SVectorBase< R > &colVec, const R &upperValue, bool scale=false)
virtual void changeObj(int i, const R &newVal, bool scale=false)
changes i 'th objective vector element to newVal. scale determines whether the new data should be sca...
void getLowerUnscaled(DVector &vec) const
Gets unscaled lower bound vector.
Real spxLdexp(Real x, int exp)
returns x * 2^exp
virtual int computeScaleExp(const SVector &vec, const DataArray< int > &oldScaleExp) const
compute a single scaling vector , e.g. of a newly added row
SPxSense
Optimization sense.
virtual void writeFile(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *p_intvars=0) const
Write loaded LP to filename.
declaration of types for file output
void maxObjUnscaled(VectorBase< Real > &vec) const
Returns unscaled objective vector for maximization problem.
virtual void changeUpper(SPxColId id, const R &newUpper, bool scale=false)
Changes upper bound of column with identifier id to newLower. scale determines whether the new data s...
virtual void changeMaxObj(SPxColId id, const R &newVal, bool scale=false)
Changes objective value of column with identifier id to newVal. scale determines whether the new data...
virtual void computeDualActivity(const VectorBase< R > &dual, VectorBase< R > &activity, const bool unscaled=true) const
Computes "dual" activity of the columns for a given dual vector, i.e., y^T A; activity does not need ...
virtual void doRemoveRows(int perm[])
Internal helper method.
void getColVectorUnscaled(int i, DSVectorBase< Real > &vec) const
Gets column vector of column i.
Row and columns Id's SPxLP.
static void setFixed(std::ostream &stream, int precision=8)
Sets the precision of the stream to 8 and the floatfield to fixed.
SPxSense spxSense() const
Returns the optimization sense.
int & index(int n)
Reference to index of n 'th nonzero.
virtual void changeMaxObj(const VectorBase< R > &newObj, bool scale=false)
Changes objective vector to newObj. scale determines whether the new data should be scaled...
bool has(const DataKey &k) const
Does DataKey k belong to LPColSetBase ?
SVectorBase< R > & colVector_w(int i)
const VectorBase< R > & rhs() const
Returns the vector of rhs values.
R upperUnscaled(int i) const
Returns unscaled upper bound of column i.
R lhs() const
Left-hand side value.
virtual void addCol(SPxColId &id, const LPColBase< R > &col, bool scale=false)
Adds col to LPColSetVBase.
LPRowSetBase< R > & operator=(const LPRowSetBase< R > &rs)
Assignment operator.
SVectorBase< R > & rowVector_w(int i)
Returns a writable rowVector of the i 'th LPRowBase.
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
virtual void addRows(const LPRowSetBase< R > &pset, bool scale=false)
virtual void changeBounds(SPxColId id, const R &newLower, const R &newUpper, bool scale=false)
Changes bounds of column with identifier id. scale determines whether the new data should be scaled...
virtual void changeRowObj(SPxRowId id, const R &newRowObj, bool scale=false)
Changes row objective function value for row with identifier id. scale determines whether the new dat...
void doAddRows(const LPRowSetBase< R > &set, bool scale=false)
void changeBounds(int i, const S *newLower, const S *newUpper)
Changes bounds of column i to newLower and newUpper.
virtual void changeLower(const VectorBase< R > &newLower, bool scale=false)
Changes vector of lower bounds to newLower. scale determines whether the new data should be scaled...
LPRowBase< R >::Type rowType(int i) const
Returns the inequality type of the i'th LPRow.
virtual bool readLPF(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP in LP format from input stream in.
virtual void removeRow(SPxRowId id)
Removes row with identifier id.
virtual void changeRhs(const VectorBase< R > &newRhs, bool scale=false)
Changes right hand side vector for constraints to newRhs. scale determines whether the new data shoul...
R obj(int i) const
Returns objective value of column i.
virtual void changeCol(SPxColId id, const LPColBase< R > &newCol, bool scale=false)
Replaces column with identifier id with newCol. scale determines whether the new data should be scale...
const VectorBase< R > & lhs() const
Returns left hand side vector.
R & lower_w(int i)
Returns lower bound of column i.
virtual void changeRhs(SPxRowId id, const R &newRhs, bool scale=false)
Changes right hand side value for row with identifier id. scale determines whether the new data shoul...
virtual void removeCols(int nums[], int n, int perm[]=0)
Removes n LPCols.
void add2(const DataKey &k, int n, const int idx[], const R val[])
Adds n nonzero (idx, val)-pairs to rowVector with DataKey k.
virtual void addPrimalActivity(const SVectorBase< R > &primal, VectorBase< R > &activity) const
Updates activity of the rows for a given primal vector; activity does not need to be zero...
void addCols(const S *objValue, const S *lowerValues, const S *colValues, const int *colIndices, const int *colStarts, const int *colLengths, const int numCols, const int numValues, const S *upperValues)
R rowObj(const SPxRowId &id) const
Returns row objective function value of row with identifier id.
const R & lhs(const SPxRowId &id) const
Returns left hand side of row with identifier id.
virtual void scaleObj(const SPxLPBase< Real > &lp, VectorReal &origObj) const
apply scaling to objective function vector origObj.
void getRhs(VectorBase< R > &vec) const
Gets (internal and possibly scaled) right hand side vector.
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
virtual void changeBounds(const VectorBase< R > &newLower, const VectorBase< R > &newUpper, bool scale=false)
Changes variable bounds to newLower and newUpper. scale determines whether the new data should be sca...
void getCol(int i, LPColBase< R > &col) const
Gets i 'th column.
LPColSetBase< R > & operator=(const LPColSetBase< R > &rs)
Assignment operator.
virtual void addCols(SPxColId id[], const LPColSetBase< R > &set, bool scale=false)
Adds all LPColBases of set to LPColSetBase.
void setObj(const R &p_obj)
Sets objective coefficient value.
const VectorBase< R > & maxRowObj() const
R lhsUnscaled(int i) const
Returns unscaled left hand side of row number i.
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
void setScalingInfo(bool scaled)
set whether the LP is scaled or not
virtual void changeRow(int n, const LPRowBase< R > &newRow, bool scale=false)
Replaces i 'th row of LP with newRow. scale determines whether the new data should be scaled...
void added2Set(SVSetBase< R > &set, const SVSetBase< R > &addset, int n)
virtual void changeUpper(const VectorBase< R > &newUpper, bool scale=false)
Changes vector of upper bounds to newUpper. scale determines whether the new data should be scaled...
R & maxRowObj_w(int i)
Returns objective function value of row i.
Debugging, floating point type and parameter definitions.
Simplex basis.Consider the linear program as provided from class SPxLP: where , and ...
virtual void removeRows(SPxRowId id[], int n, int perm[]=0)
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
virtual void addRow(const R &lhsValue, const SVectorBase< R > &rowVec, const R &rhsValue, bool scale=false)
void setLhs(const R &p_left)
Sets left-hand side value.
bool EQ(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| <= eps
virtual void changeObj(const VectorBase< R > &newObj, bool scale=false)
Changes objective vector to newObj. scale determines whether the new data should be scaled...
virtual Real scaleLower(const SPxLPBase< Real > &lp, int col, Real lower) const
returns scaled lower bound of column col.
void getCol(const SPxColId &id, LPColBase< R > &col) const
Gets column with identifier id.
R offset
offset computed, e.g., in simplification step
virtual void addDualActivity(const SVectorBase< R > &dual, VectorBase< R > &activity) const
Updates "dual" activity of the columns for a given dual vector, i.e., y^T A; activity does not need t...
void changeLhs(int i, const S *newLhs)
Changes i 'th left hand side value to newLhs.
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
Collection of dense, sparse, and semi-sparse vectors.
virtual void addCol(const LPColBase< R > &col, bool scale=false)
SPxLPBase< R > & operator=(const SPxLPBase< S > &old)
Assignment operator.
int dim() const
Dimension of vector.
virtual void doRemoveCols(int perm[])
Internal helper method.
bool has(const SPxColId &id) const
Returns the column number of the column with identifier id.
Everything should be within this namespace.
const R & maxRowObj(int i) const
void getCols(int start, int end, LPColSetBase< R > &set) const
Gets columns start, ..., end.
virtual void changeLower(SPxColId id, const R &newLower, bool scale=false)
changes lower bound of column with identifier id to newLower. scale determines whether the new data s...
virtual void changeRange(const VectorBase< R > &newLhs, const VectorBase< R > &newRhs, bool scale=false)
Changes left and right hand side vectors. scale determines whether the new data should be scaled...
void changeElement(int i, int j, const S *val)
Changes LP element (i, j) to val.
void clear()
Remove all indices.
virtual void writeLPF(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const
R & upper_w(int i)
Returns upper bound of column i.
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
Set of LP columns.Class LPColSetBase implements a set of LPColBase%s. Unless for memory limitations...
const SVectorBase< R > & rowVector(int i) const
Returns the rowVector of the i 'th LPRowBase.
void setObj(const R &p_object)
Sets objective value.
R lowerUnscaled(int i) const
Returns unscaled lower bound of column i.
virtual void clearRowObjs()
Clears row objective function values for all rows.
Type
(In)Equality type of an LP row.
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
SPxScaler * lp_scaler
points to the scaler if the lp has been scaled, to 0 otherwise
R upper() const
Gets upper bound.
R obj() const
Objective coefficient value.
const R & upper(const SPxColId &id) const
Returns upper bound of column with identifier id.
void setRowVector(const DSVectorBase< R > &p_vec)
access constraint row vector.
void doAddCol(const R &objValue, const R &lowerValue, const SVectorBase< R > &colVec, const R &upperValue, bool scale=false)
const LPColSetBase< R > * lpcolset() const
Returns the LP as an LPColSetBase.
bool has(const DataKey &k) const
does DataKey k belong to LPRowSetBase ?
int memMax() const
Returns length of nonzero memory.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
virtual void writeMPS(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const
Writes a file in MPS format to out.
virtual void addRow(const LPRowBase< R > &row, bool scale=false)
virtual void changeRowObj(const VectorBase< R > &newRowObj, bool scale=false)
Changes row objective function vector to newRowObj. scale determines whether the new data should be s...
LP scaler abstract base class.Instances of classes derived from SPxScaler may be loaded to SoPlex in ...
std::ifstream spxifstream
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
virtual void changeSense(SPxSense sns)
Changes optimization sense to sns.
void getUpperUnscaled(DVector &vec) const
Gets unscaled upper bound vector.
void xtend(int n, int newmax)
Extends column n to fit newmax nonzeros.
void unscaleLP()
unscales the lp and clears basis
bool isConsistent() const
Checks consistency.
const VectorBase< R > & upper() const
void printProblemStatistics(std::ostream &os)
virtual void changeLhs(int i, const R &newLhs, bool scale=false)
Changes i 'th left hand side value to newLhs. scale determines whether the new data should be scaled...
int pos(int i) const
Position of index i.
bool isConsistent() const
Consistency check.
virtual void removeColRange(int start, int end, int perm[]=0)
Removes columns from start to end (including both).
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
int nCols() const
Returns number of columns in LP.
virtual void removeCols(SPxColId id[], int n, int perm[]=0)
void changeUpper(int i, const S *newUpper)
Changes i 'th upper bound to newUpper.
virtual void changeElement(int i, int j, const R &val, bool scale=false)
Changes LP element (i, j) to val. scale determines whether the new data should be scaled...
virtual void removeCol(SPxColId id)
Removes column with identifier id.
virtual void changeLhs(const VectorBase< R > &newLhs, bool scale=false)
Changes left hand side vector for constraints to newLhs. scale determines whether the new data should...
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
const R & rhs(int i) const
Returns right hand side of row number i.
virtual void changeRhs(int i, const R &newRhs, bool scale=false)
Changes i 'th right hand side value to newRhs. scale determines whether the new data should be scaled...
virtual void doRemoveRow(int j)
Internal helper method.
SPxSense thesense
optimization sense.
void add2(const DataKey &k, int n, const int idx[], const R val[])
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
virtual void addedRows(int newrows)
Called after the last n rows have just been added.
const R & lower(int i) const
Returns (internal and possibly scaled) lower bound of column i.
void addCol(const S *objValue, const S *lowerValue, const S *colValues, const int *colIndices, int colSize, const S *upperValue)
#define MSGinconsistent(name)
int number(const DataKey &k) const
Returns the number of the LPRowBase with DataKey k in LPRowSetBase.
void setColVector(const SVectorBase< R > &p_vec)
Sets constraint column vector.
void getLhsUnscaled(VectorBase< Real > &vec) const
Returns unscaled left hand side vector.
void doAddRow(const LPRowBase< R > &row, bool scale=false)
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
virtual Real scaleRhs(const SPxLPBase< Real > &lp, int row, Real rhs) const
returns scaled right hand side of row row.
Save arrays of data objects.
const R & maxObj(const SPxColId &id) const
Returns objective value of column with identifier id for maximization problem.
SVectorBase< R > & colVector_w(int i)
Returns the LP as an LPRowSet.
const SVectorBase< R > & colVector(int i) const
Returns colVector of i 'th LPColBase in LPColSetBase.
virtual void clear()
clears the LP.
virtual void doRemoveCol(int j)
Internal helper method.
const R & lower(const SPxColId &id) const
Returns (internal and possibly scaled) lower bound of column with identifier id.
void clear()
Removes all LPColBases from the set.
Equilibrium row/column scaling.This SPxScaler implementation performs equilibrium scaling of the LPs ...
const VectorBase< R > & obj() const
Returns the vector of objective coefficients.
void setRhs(const R &p_right)
Sets right-hand side value.
virtual void addRow(SPxRowId &id, const LPRowBase< R > &row, bool scale=false)
Adds row to LPRowSetBase.
void reSize(int newsize)
reset size to newsize.
void changeMaxObj(int i, const S *newVal)
changes i 'th objective vector element to newVal.
virtual void changeUpper(int i, const R &newUpper, bool scale=false)
Changes i 'th upper bound to newUpper. scale determines whether the new data should be scaled...
int num() const
Current number of SVectorBases.
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
virtual R maxAbsNzo(bool unscaled=true) const
Absolute biggest non-zero element in (in rational case possibly scaled) LP.
int num() const
Returns the number of LPColBases currently in LPColSetBase.
virtual void computePrimalActivity(const VectorBase< R > &primal, VectorBase< R > &activity, const bool unscaled=true) const
Computes activity of the rows for a given primal vector; activity does not need to be zero...
void getRow(const SPxRowId &id, LPRowBase< R > &row) const
Gets row with identifier id.
LP column.Class LPColBase provides a datatype for storing the column of an LP a the form similar to ...
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
void getRowVectorUnscaled(int i, DSVectorBase< Real > &vec) const
Gets unscaled row vector of row i.
VectorBase< R > & multSub(const S &x, const SVectorBase< T > &vec)
Subtraction of scaled vector.
virtual void addCols(const LPColSetBase< R > &pset, bool scale=false)
const R & maxRowObj(const SPxRowId &id) const
Returns row objective function value of row with identifier id.
int num() const
Returns the number of LPRowBases in LPRowSetBase.
LP simplifier for removing uneccessary row/columns.This SPxSimplifier is mainly based on the paper "P...
R & lhs_w(int i)
Returns left hand side of row i.
virtual void subDualActivity(const VectorBase< R > &dual, VectorBase< R > &activity) const
Updates "dual" activity of the columns for a given dual vector, i.e., y^T A; activity does not need t...
void remove(int i)
Removes i 'th LPRowBase.
const R & rhs(const SPxRowId &id) const
Returns right hand side of row with identifier id.