33#define SOPLEX_DEBUG_SPXLPBASE
208 for(
int i = 0; i <
nCols(); ++i)
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 !=
nullptr);
642 assert(rowSize <= 0 || rowValues !=
nullptr);
643 assert(rowSize <= 0 || rowIndices !=
nullptr);
644 assert(rhsValue !=
nullptr);
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 !=
nullptr);
693 assert(numValues <= 0 || rowValues !=
nullptr);
694 assert(numValues <= 0 || rowIndices !=
nullptr);
695 assert(numValues <= 0 || rowStarts !=
nullptr);
696 assert(numValues <= 0 || rowLengths !=
nullptr);
697 assert(rhsValues !=
nullptr);
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 !=
nullptr);
864 assert(numValues <= 0 || colValues !=
nullptr);
865 assert(numValues <= 0 || colIndices !=
nullptr);
866 assert(numValues <= 0 || colStarts !=
nullptr);
867 assert(numValues <= 0 || colLengths !=
nullptr);
868 assert(upperValues !=
nullptr);
873 int oldColNumber =
nCols();
874 int oldRowNumber =
nRows();
879 for(i = 0; i < numCols; i++)
881 assert(numValues <= 0 || colStarts[i] + colLengths[i] <= numValues);
884 LPColSetBase<R>::add(&(objValue[i]), &(lowerValues[i]), (S*)0, (
int*)
nullptr, 0, &(upperValues[i]));
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);
1241 return read(file, rowNames, colNames, intVars);
1249 const DIdxSet* p_intvars =
nullptr,
1250 const bool writeZeroObjective =
false)
const;
1254 const DIdxSet* p_intvars =
nullptr,
1255 const bool writeZeroObjective =
false)
const;
1259 const NameSet* colNames =
nullptr,
const DIdxSet* p_intvars =
nullptr,
1260 const bool writeZeroObjective =
false)
const
1263 std::ofstream tmp(filename);
1264 size_t len_f = strlen(filename);
1266 if(len_f > 4 && filename[len_f - 1] ==
's' && filename[len_f - 2] ==
'p'
1267 && filename[len_f - 3] ==
'm' && filename[len_f - 4] ==
'.')
1269 writeMPS(tmp, rowNames, colNames, p_intvars, writeZeroObjective);
1273 writeLPF(tmp, rowNames, colNames, p_intvars, writeZeroObjective);
1283 int countFreeCol = 0;
1288 int countRanged = 0;
1289 int countFreeRow = 0;
1291 for(
int i = 0; i <
nCols(); i++)
1293 bool hasLower =
false;
1294 bool hasUpper =
false;
1308 if(hasUpper && hasLower)
1315 if(!hasUpper && !hasLower)
1319 for(
int i = 0; i <
nRows(); i++)
1321 bool hasRhs =
false;
1322 bool hasLhs =
false;
1336 if(hasRhs && hasLhs)
1347 if(!hasRhs && !hasLhs)
1352 os <<
" Columns : " <<
nCols() <<
"\n"
1353 <<
" boxed : " << countBoxed <<
"\n"
1354 <<
" lower bound : " << countLower <<
"\n"
1355 <<
" upper bound : " << countUpper <<
"\n"
1356 <<
" free : " << countFreeCol <<
"\n"
1357 <<
" Rows : " <<
nRows() <<
"\n"
1358 <<
" equal : " << countEqual <<
"\n"
1359 <<
" ranged : " << countRanged <<
"\n"
1360 <<
" lhs : " << countLhs <<
"\n"
1361 <<
" rhs : " << countRhs <<
"\n"
1362 <<
" free : " << countFreeRow <<
"\n"
1363 <<
" Nonzeros : " <<
nNzos() <<
"\n"
1364 <<
" per column : " << R(
nNzos()) / R(
nCols()) <<
"\n"
1365 <<
" per row : " << R(
nNzos()) / R(
nRows()) <<
"\n"
1367 <<
" min. abs. value : " << R(
minAbsNzo()) <<
"\n"
1368 <<
" max. abs. value : " << R(
maxAbsNzo()) <<
"\n";
1387 virtual void changeObj(
int i,
const R& newVal,
bool scale =
false)
1396 template <
class S >
1423 for(
int i = 0; i <
maxObj().dim(); i++)
1448 template <
class S >
1464 assert(
lower().dim() == newLower.
dim());
1471 for(
int i = 0; i <
lower().dim(); i++)
1481 virtual void changeLower(
int i,
const R& newLower,
bool scale =
false)
1483 if(scale && newLower > R(-
infinity))
1496 template <
class S >
1512 assert(
upper().dim() == newUpper.
dim());
1519 for(
int i = 0; i <
upper().dim(); i++)
1529 virtual void changeUpper(
int i,
const R& newUpper,
bool scale =
false)
1531 if(scale && newUpper < R(
infinity))
1544 template <
class S >
1567 virtual void changeBounds(
int i,
const R& newLower,
const R& newUpper,
bool scale =
false)
1575 template <
class S >
1592 assert(
lhs().dim() == newLhs.
dim());
1599 for(
int i = 0; i <
lhs().dim(); i++)
1609 virtual void changeLhs(
int i,
const R& newLhs,
bool scale =
false)
1624 template <
class S >
1640 assert(
rhs().dim() == newRhs.
dim());
1647 for(
int i = 0; i <
rhs().dim(); i++)
1657 virtual void changeRhs(
int i,
const R& newRhs,
bool scale =
false)
1687 virtual void changeRange(
int i,
const R& newLhs,
const R& newRhs,
bool scale =
false)
1695 template <
class S >
1753 for(j = row.
size() - 1; j >= 0; --j)
1756 int position = col.
pos(n);
1758 assert(position != -1);
1772 for(j = newrow.
size() - 1; j >= 0; --j)
1774 int idx = newrow.
index(j);
1775 R val = newrow.
value(j);
1802 for(j = col.
size() - 1; j >= 0; --j)
1805 int position = row.
pos(n);
1807 assert(position != -1);
1821 for(j = newcol.
size() - 1; j >= 0; --j)
1823 int idx = newcol.
index(j);
1824 R val = newcol.
value(j);
1851 if(isNotZero(val, this->
tolerances()->epsilon()))
1859 newVal =
lp_scaler->scaleElement(*
this, i, j, val);
1864 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1875 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1885 template <
class S >
1894 if(mpq_get_d(*val) != R(0))
1896 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1907 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
1934 template <
typename T>
1946 const bool unscaled =
true)
const;
1958 for(
int i = primal.
size() - 1; i >= 0; i--)
1960 assert(primal.
index(i) >= 0);
1970 const bool unscaled =
true)
const;
1982 for(
int i = dual.
size() - 1; i >= 0; i--)
1984 assert(dual.
index(i) >= 0);
2005 for(
int r = 0; r <
nRows(); r++)
2023 SPxRowId dualRowIds[] =
nullptr,
SPxColId dualColIds[] =
nullptr,
int* nprimalrows =
nullptr,
2024 int* nprimalcols =
nullptr,
2025 int* ndualrows =
nullptr,
int* ndualcols =
nullptr);
2039#ifdef ENABLE_CONSISTENCY_CHECKS
2041 for(
int i =
nCols() - 1; i >= 0; --i)
2045 for(
int j = v.
size() - 1; j >= 0; --j)
2058 for(
int i =
nRows() - 1; i >= 0; --i)
2062 for(
int j = v.
size() - 1; j >= 0; --j)
2152 for(
int i = vec.
size() - 1; i >= 0; --i)
2155 int position = remvec.
pos(j);
2162 int idx =
nRows() - 1;
2168 for(
int i = l_vec.
size() - 1; i >= 0; --i)
2171 int position = movevec.
pos(idx);
2173 assert(position != -1);
2176 movevec.
index(position) = j;
2190 for(
int i = 0; i < j; ++i)
2194 for(
int k = vec.
size() - 1; k >= 0; --k)
2196 int idx = vec.
index(k);
2201 vec.
index(k) = perm[idx];
2214 for(i = vec.
size() - 1; i >= 0; --i)
2217 int position = remvec.
pos(j);
2219 assert(position != -1);
2226 int idx =
nCols() - 1;
2232 for(i = l_vec.
size() - 1; i >= 0; --i)
2235 int position = movevec.
pos(idx);
2237 assert(position != -1);
2240 movevec.
index(position) = j;
2250 int nrows =
nRows();
2254 for(
int i = 0; i < nrows; ++i)
2258 for(
int k = vec.
size() - 1; k >= 0; --k)
2260 int idx = vec.
index(k);
2265 vec.
index(k) = perm[idx];
2286 int* more = moreArray.
get_ptr();
2288 for(
int i =
set.num() - 1; i >= 0; --i)
2292 int end = addset.
num();
2294 for(
int i = addset.
num() - n; i < end; ++i)
2300 for(
int j = vec.
size() - 1; j >= 0; --j)
2301 more[vec.
index(j)]++;
2304 if(
set.memMax() < tot)
2307 for(
int i =
set.num() - 1; i >= 0; --i)
2309 int j =
set[i].size();
2310 set.xtend(
set[i], j + more[i]);
2311 set[i].set_size(j + more[i]);
2315 for(
int i = addset.
num() - n; i < addset.
num(); ++i)
2319 for(
int j = vec.
size() - 1; j >= 0; --j)
2321 int k = vec.
index(j);
2324 l_xtend.
index(m) = i;
2355 int oldColNumber =
nCols();
2356 int newRowScaleExp = 0;
2367 newRowScaleExp =
lp_scaler->computeScaleExp(vec, colscaleExp);
2381 for(
int j = vec.
size() - 1; j >= 0; --j)
2383 int i = vec.
index(j);
2389 R val = vec.
value(j);
2396 for(
int k =
nCols(); k <= i; ++k)
2400 assert(i <
nCols());
2413 int oldColNumber =
nCols();
2414 int newRowScaleExp = 0;
2423 newRowScaleExp =
lp_scaler->computeScaleExp(rowVec, colscaleExp);
2439 for(
int j = vec.
size() - 1; j >= 0; --j)
2441 int i = vec.
index(j);
2447 R val = vec.
value(j);
2454 for(
int k =
nCols(); k <= i; ++k)
2458 assert(i <
nCols());
2469 int i, j, k, ii, idx;
2472 int oldRowNumber =
nRows();
2473 int oldColNumber =
nCols();
2482 for(i =
nCols() - 1; i >= 0; --i)
2485 for(i =
set.num() - 1; i >= 0; --i)
2489 for(j = vec.
size() - 1; j >= 0; --j)
2499 for(k =
nCols(); k <= ii; ++k)
2506 assert(ii <
nCols());
2512 for(i =
nCols() - 1; i >= 0; --i)
2516 int len = newCols[i] +
colVector(i).size();
2526 for(i =
nRows() - 1; i >= oldRowNumber; --i)
2529 int newRowScaleExp = 0;
2536 newRowScaleExp =
lp_scaler->computeScaleExp(vec, colscaleExp);
2549 for(j = vec.
size() - 1; j >= 0; --j)
2553 idx = col->
size() - newCols[k];
2554 assert(newCols[k] > 0);
2557 col->
index(idx) = i;
2569 for(i = 0; i <
nCols(); ++i)
2570 assert(newCols[i] == 0);
2576 assert(
set.num() ==
nRows() - oldRowNumber);
2585 int oldRowNumber =
nRows();
2586 int newColScaleExp = 0;
2600 newColScaleExp =
lp_scaler->computeScaleExp(vec, rowscaleExp);
2614 for(
int j = vec.
size() - 1; j >= 0; --j)
2616 int i = vec.
index(j);
2622 R val = vec.
value(j);
2629 for(
int k =
nRows(); k <= i; ++k)
2633 assert(i <
nRows());
2643 const R& upperValue,
bool scale =
false)
2646 int oldRowNumber =
nRows();
2647 int newColScaleExp = 0;
2659 newColScaleExp =
lp_scaler->computeScaleExp(colVec, rowscaleExp);
2675 for(
int j = vec.
size() - 1; j >= 0; --j)
2677 int i = vec.
index(j);
2682 R val = vec.
value(j);
2689 for(
int k =
nRows(); k <= i; ++k)
2693 assert(i <
nRows());
2705 int oldColNumber =
nCols();
2706 int oldRowNumber =
nRows();
2716 for(i =
nRows() - 1; i >= 0; --i)
2719 for(i =
set.num() - 1; i >= 0; --i)
2723 for(j = vec.
size() - 1; j >= 0; --j)
2726 int l = vec.
index(j);
2733 for(
int k =
nRows(); k <= l; ++k)
2741 assert(l <
nRows());
2747 for(i = 0; i <
nRows(); ++i)
2751 int len = newRows[i] +
rowVector(i).size();
2758 for(i = oldColNumber; i <
nCols(); ++i)
2771 int newColScaleExp = 0;
2778 newColScaleExp =
lp_scaler->computeScaleExp(vec, rowscaleExp);
2791 for(j = vec.
size() - 1; j >= 0; --j)
2793 int k = vec.
index(j);
2795 int idx = row.
size() - newRows[k];
2796 assert(newRows[k] > 0);
2810 for(i = 0; i <
nRows(); ++i)
2811 assert(newRows[i] == 0);
2817 assert(
set.num() ==
nCols() - oldColNumber);
2857 template <
class S >
2892 template <
class S >
2925#include "spxlpbase_real.hpp"
2926#include "spxlpbase_rational.hpp"
2930#ifdef SOPLEX_DEBUG_SPXLPBASE
2932#undef SOPLEX_DEBUG_SPXLPBASE
Collection of dense, sparse, and semi-sparse vectors.
T * get_ptr()
get a C pointer to the data.
void reSize(int newsize)
reset size to newsize.
R upper() const
Gets upper bound.
void setLower(const R &p_low)
Sets lower bound.
const SVectorBase< R > & colVector() const
Gets constraint column vector.
void setUpper(const R &p_up)
Sets upper bound.
void setColVector(const SVectorBase< R > &p_vec)
Sets constraint column vector.
R lower() const
Gets lower bound.
R obj() const
Gets objective value.
void setObj(const R &p_object)
Sets objective value.
void remove(int i)
Removes i 'th LPColBase.
VectorBase< R > & lower_w()
Returns vector of lower bound values.
LPColSetBase< R > & operator=(const LPColSetBase< R > &rs)
Assignment operator.
VectorBase< R > & maxObj_w()
Returns vector of objective values w.r.t. maximization.
const VectorBase< R > & maxObj() const
const VectorBase< R > & lower() const
bool isConsistent() const
Checks consistency.
void add2(const DataKey &k, int n, const int idx[], const R val[])
int number(const DataKey &k) const
Returns number of LPColBase with DataKey k in LPColSetBase.
SVectorBase< R > & colVector_w(int i)
void memRemax(int newmax)
Resets length of nonzero memory.
int num() const
Returns the number of LPColBases currently in LPColSetBase.
void xtend(int n, int newmax)
Extends column n to fit newmax nonzeros.
bool has(const DataKey &k) const
Does DataKey k belong to LPColSetBase ?
VectorBase< R > & upper_w()
Returns vector of upper bound values.
void add(const LPColBase< R > &pcol)
void clear()
Removes all LPColBases from the set.
const VectorBase< R > & upper() const
const SVectorBase< R > & colVector(int i) const
Returns colVector of i 'th LPColBase in LPColSetBase.
const SVectorBase< R > & rowVector() const
Constraint row vector.
Type
(In)Equality type of an LP row.
void setLhs(const R &p_left)
Sets left-hand side value.
void setRhs(const R &p_right)
Sets right-hand side value.
R rhs() const
Right-hand side value.
void setObj(const R &p_obj)
Sets objective coefficient value.
R lhs() const
Left-hand side value.
R obj() const
Objective coefficient value.
void setRowVector(const DSVectorBase< R > &p_vec)
access constraint row vector.
const VectorBase< R > & rhs() const
Returns the vector of rhs values.
const VectorBase< R > & lhs() const
Returns the vector of lhs values.
void remove(int i)
Removes i 'th LPRowBase.
bool isConsistent() const
Checks consistency.
void add2(const DataKey &k, int n, const int idx[], const R val[])
Adds n nonzero (idx, val)-pairs to rowVector with DataKey k.
void add(const LPRowBase< R > &row)
int number(const DataKey &k) const
Returns the number of the LPRowBase with DataKey k in LPRowSetBase.
SVectorBase< R > & rowVector_w(int i)
Returns a writable rowVector of the i 'th LPRowBase.
LPRowSetBase< R > & operator=(const LPRowSetBase< R > &rs)
Assignment operator.
void memRemax(int newmax)
Reallocates memory to be able to store newmax nonzeros.
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
int num() const
Returns the number of LPRowBases in LPRowSetBase.
const SVectorBase< R > & rowVector(int i) const
Returns the rowVector of the i 'th LPRowBase.
void xtend(int n, int newmax)
Extends row n to fit newmax nonzeros.
VectorBase< R > & obj_w()
Returns the vector of objective coefficients (writeable).
const VectorBase< R > & obj() const
Returns the vector of objective coefficients.
bool has(const DataKey &k) const
does DataKey k belong to LPRowSetBase ?
VectorBase< R > & lhs_w()
Returns the vector of lhs values.
void clear()
Removes all LPRowBases.
LPRowBase< R >::Type type(int i) const
Returns the inequalitiy type of the i 'th LPRowBase.
Equilibrium row/column scaling.
Geometric mean row/column scaling.
Generic Ids for LP rows or columns.
@ COL_ID
column identifier.
Exception class for things that should NEVER happen.
Saving LPs in a form suitable for SoPlex.
const VectorBase< R > & rhs() const
Returns right hand side vector.
void setOutstream(SPxOut &newOutstream)
SPxSense spxSense() const
Returns the optimization sense.
const VectorBase< R > & lhs() const
Returns left hand side vector.
SPxSense
Optimization sense.
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.
const R & upper(const SPxColId &id) const
Returns upper bound of column with identifier id.
void added2Set(SVSetBase< R > &set, const SVSetBase< R > &addset, int n)
void changeLower(int i, const S *newLower)
changes i 'th lower bound to newLower.
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
void getLowerUnscaled(VectorBase< R > &vec) const
Gets unscaled lower bound vector.
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 void addRow(const LPRowBase< R > &row, bool scale=false)
void changeBounds(int i, const S *newLower, const S *newUpper)
Changes bounds of column i to newLower and newUpper.
void changeObjOffset(const T &o)
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...
R obj(const SPxColId &id) const
Returns objective value of column with identifier id.
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...
void getRhsUnscaled(VectorBase< R > &vec) const
Gets unscaled right hand side vector.
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 removeRow(int i)
Removes i 'th row.
R upperUnscaled(const SPxColId &id) const
Returns unscaled upper bound of column with identifier id.
R lhsUnscaled(const SPxRowId &id) const
Returns left hand side of row with identifier id.
virtual void doRemoveRows(int perm[])
Internal helper method.
virtual void addedCols(int newcols)
Called after the last n columns have just been added.
virtual void writeMPS(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=nullptr, const bool writeZeroObjective=false) const
Writes a file in MPS format to out.
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.
void doAddCols(const LPColSetBase< R > &set, bool scale=false)
const LPColSetBase< R > * lpcolset() const
Returns the LP as an LPColSetBase.
void printProblemStatistics(std::ostream &os)
virtual bool readLPF(std::istream &in, NameSet *rowNames=nullptr, NameSet *colNames=nullptr, DIdxSet *intVars=nullptr)
Reads LP in LP format from input stream in.
bool _isScaled
true, if scaling has been performed
R lhsUnscaled(int i) const
Returns unscaled left hand side of row number i.
void getLhsUnscaled(VectorBase< R > &vec) const
Returns unscaled left hand side vector.
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 addCols(SPxColId id[], const LPColSetBase< R > &set, bool scale=false)
Adds all LPColBases of set to LPColSetBase.
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...
const VectorBase< R > & maxRowObj() const
virtual void addCol(const R &objValue, const R &lowerValue, const SVectorBase< R > &colVec, const R &upperValue, bool scale=false)
void getColVectorUnscaled(const SPxColId &id, DSVectorBase< R > &vec) const
Gets column vector of column with identifier id.
void unscaleLP()
unscales the lp and clears basis
virtual void writeFileLPBase(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const DIdxSet *p_intvars=nullptr, const bool writeZeroObjective=false) const
Write loaded LP to filename.
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)
void getRow(const SPxRowId &id, LPRowBase< R > &row) const
Gets row with identifier id.
R & maxRowObj_w(int i)
Returns objective function value of row i.
const R & maxObj(int i) const
Returns objective value of column i for maximization problem.
virtual void removeCol(int i)
Removes i 'th column.
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...
virtual void removeRowRange(int start, int end, int perm[]=nullptr)
Removes rows from start to end (including both).
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
int number(const SPxColId &id) const
Returns the column number of the column with identifier id.
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
const R & rhs(const SPxRowId &id) const
Returns right hand side of row with identifier id.
virtual void removeRow(SPxRowId id)
Removes row with identifier id.
bool isConsistent() const
Consistency check.
R & lhs_w(int i)
Returns left hand side of row i.
const R & maxObj(const SPxColId &id) const
Returns objective value of column with identifier id for maximization problem.
bool has(const SPxRowId &id) const
Returns the row number of the row with identifier id.
void getColVectorUnscaled(int i, DSVectorBase< R > &vec) const
Gets column vector of column i.
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 addCol(const LPColBase< R > &col, bool scale=false)
virtual void removeRows(int nums[], int n, int perm[]=nullptr)
Removes n LPRowBases.
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 addCol(SPxColId &id, const LPColBase< R > &col, bool scale=false)
Adds col to LPColSetVBase.
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...
const std::shared_ptr< Tolerances > tolerances() const
returns current tolerances
bool has(const SPxId &id) const
Returns the row or column number for identifier id.
virtual void clearRowObjs()
Clears row objective function values for all rows.
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...
R obj(int i) const
Returns objective value of column i.
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...
void getCol(int i, LPColBase< R > &col) const
Gets i 'th column.
virtual void removeCols(int perm[])
Removes multiple columns.
virtual void doRemoveRow(int j)
Internal helper method.
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...
SPxLPBase()
Default constructor.
bool isScaled() const
Returns true if and only if the LP is scaled.
virtual void addRows(const LPRowSetBase< R > &pset, bool scale=false)
virtual void addRow(SPxRowId &id, const LPRowBase< R > &row, bool scale=false)
Adds row to LPRowSetBase.
const R & maxRowObj(int i) const
const R & rhs(int i) const
Returns right hand side of row number i.
void getCol(const SPxColId &id, LPColBase< R > &col) const
Gets column with identifier id.
void addCol(const S *objValue, const S *lowerValue, const S *colValues, const int *colIndices, int colSize, const S *upperValue)
void getRowObj(VectorBase< R > &prowobj) const
Gets row objective function vector.
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...
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.
void getCols(int start, int end, LPColSetBase< R > &set) const
Gets columns start, ..., end.
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...
virtual R minAbsNzo(bool unscaled=true) const
Absolute smallest non-zero element in (possibly scaled) LP.
virtual void removeRows(int perm[])
Removes multiple rows.
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.
const SVectorBase< R > & rowVector(const SPxRowId &id) const
Gets row vector of row with identifier id.
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 getRhs(VectorBase< R > &vec) const
Gets (internal and possibly scaled) right hand side vector.
std::shared_ptr< Tolerances > _tolerances
R objUnscaled(int i) const
Returns unscaled objective value of column i.
virtual bool read(std::istream &in, NameSet *rowNames=nullptr, NameSet *colNames=nullptr, DIdxSet *intVars=nullptr)
Reads LP in LP or MPS format from input stream in.
SPxScaler< R > * lp_scaler
points to the scaler if the lp has been scaled, to nullptr otherwise
const R & lower(const SPxColId &id) const
Returns (internal and possibly scaled) lower bound of column with identifier id.
virtual void doRemoveCols(int perm[])
Internal helper method.
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...
SPxRowId rId(int n) const
Returns the row identifier for row n.
void doAddRows(const LPRowSetBase< R > &set, bool scale=false)
virtual void removeColRange(int start, int end, int perm[]=nullptr)
Removes columns from start to end (including both).
SVectorBase< R > & rowVector_w(int i)
R maxObjUnscaled(const SPxColId &id) const
Returns unscaled objective value of column with identifier id for maximization problem.
void getRowVectorUnscaled(int i, DSVectorBase< R > &vec) const
Gets unscaled row vector of row i.
virtual bool readMPS(std::istream &in, NameSet *rowNames=nullptr, NameSet *colNames=nullptr, DIdxSet *intVars=nullptr)
Reads an LP in MPS format from input stream in.
void getRow(int i, LPRowBase< R > &row) const
Gets i 'th row.
R maxObjUnscaled(int i) const
Returns unscaled objective value of column i for maximization problem.
void changeObj(int i, const S *newVal)
changes i 'th objective vector element to newVal.
virtual void changeMaxObj(const VectorBase< R > &newObj, bool scale=false)
Changes objective vector to newObj. scale determines whether the new data should be scaled.
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.
LPRowBase< R >::Type rowType(int i) const
Returns the inequality type of the i'th LPRow.
R & lower_w(int i)
Returns lower bound of column i.
const R & upper(int i) const
Returns upper bound of column i.
void getObjUnscaled(VectorBase< R > &pobj) const
Gets unscaled objective vector.
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.
virtual void removeCol(SPxColId id)
Removes column with identifier id.
R & upper_w(int i)
Returns upper bound of column i.
int nCols() const
Returns number of columns in LP.
R rowObj(const SPxRowId &id) const
Returns row objective function value of row with identifier id.
virtual void writeLPF(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=nullptr, const bool writeZeroObjective=false) const
SVectorBase< R > & colVector_w(int i)
Returns the LP as an LPRowBase<R>Set.
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...
int nNzos() const
Returns number of nonzeros in LP.
void changeLhs(int i, const S *newLhs)
Changes i 'th left hand side value to newLhs.
void maxObjUnscaled(VectorBase< R > &vec) const
Returns unscaled objective vector for maximization problem.
void changeRange(int i, const S *newLhs, const S *newRhs)
Changes left and right hand side of row i.
R rhsUnscaled(int i) const
Returns unscaled right hand side of row number i.
void changeMaxObj(int i, const S *newVal)
changes i 'th objective vector element to newVal.
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 getRows(int start, int end, LPRowSetBase< R > &set) const
Gets rows start, ... end.
R upperUnscaled(int i) const
Returns unscaled upper bound of column i.
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...
virtual void addCols(const LPColSetBase< R > &pset, bool scale=false)
virtual R maxAbsNzo(bool unscaled=true) const
Absolute biggest non-zero element in (in rational case possibly scaled) LP.
const R & lhs(const SPxRowId &id) const
Returns left hand side of row with identifier id.
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
const R & lower(int i) const
Returns (internal and possibly scaled) lower bound of column i.
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.
virtual void clear()
clears the LP.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
void getUpperUnscaled(VectorBase< R > &vec) const
Gets unscaled upper bound vector.
virtual bool readFile(const char *filename, NameSet *rowNames=nullptr, NameSet *colNames=nullptr, DIdxSet *intVars=nullptr)
Reads LP from a file.
virtual void setTolerances(std::shared_ptr< Tolerances > tolerances)
set tolerances
void setScalingInfo(bool scaled)
set whether the LP is scaled or not
virtual void buildDualProblem(SPxLPBase< R > &dualLP, SPxRowId primalRowIds[]=nullptr, SPxColId primalColIds[]=nullptr, SPxRowId dualRowIds[]=nullptr, SPxColId dualColIds[]=nullptr, int *nprimalrows=nullptr, int *nprimalcols=nullptr, int *ndualrows=nullptr, int *ndualcols=nullptr)
Building the dual problem from a given LP.
const R & lhs(int i) const
Returns left hand side of row number i.
virtual ~SPxLPBase()
Destructor.
void doAddRow(const LPRowBase< R > &row, bool scale=false)
const R & objOffset() const
Returns the objective function value offset.
R rhsUnscaled(const SPxRowId &id) const
Returns unscaled right hand side of row with identifier id.
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.
bool has(const SPxColId &id) const
Returns the column number of the column with identifier id.
void changeElement(int i, int j, const S *val)
Changes LP element (i, j) to val.
R offset
offset computed, e.g., in simplification step
const R & maxRowObj(const SPxRowId &id) const
Returns row objective function value of row with identifier id.
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 ...
SPxLPBase(const SPxLPBase< S > &old)
Copy constructor.
void getObj(VectorBase< R > &pobj) const
Gets objective vector.
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.
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 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 addRows(SPxRowId id[], const LPRowSetBase< R > &set, bool scale=false)
adds all LPRowBases of pset to LPRowSetBase.
R & maxObj_w(int i)
Returns objective value of column i for maximization problem.
virtual void changeSense(SPxSense sns)
Changes optimization sense to sns.
virtual void removeRows(SPxRowId id[], int n, int perm[]=nullptr)
const LPRowSetBase< R > * lprowset() const
Returns the LP as an LPRowSetBase.
SPxLPBase< R > & operator=(const SPxLPBase< R > &old)
Assignment operator.
LPRowBase< R >::Type rowType(const SPxRowId &id) const
Returns the inequality type of the row with identifier key.
void changeUpper(int i, const S *newUpper)
Changes i 'th upper bound to newUpper.
virtual void removeCols(int nums[], int n, int perm[]=nullptr)
Removes n LPCols.
R & rhs_w(int i)
Returns right hand side of row i.
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 doAddCol(const R &objValue, const R &lowerValue, const SVectorBase< R > &colVec, const R &upperValue, bool scale=false)
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...
virtual void addedRows(int newrows)
Called after the last n rows have just been added.
int number(const SPxId &id) const
Returns the row or column number for identifier id.
R lowerUnscaled(int i) const
Returns unscaled lower bound of column i.
SPxSense thesense
optimization sense.
SPxColId cId(int n) const
Returns the column identifier for column n.
const SVectorBase< R > & colVector(const SPxColId &id) const
Returns column vector of column with identifier id.
const VectorBase< R > & upper() const
Returns upper bound vector.
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)
int nRows() const
Returns number of rows in LP.
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 ...
R objUnscaled(const SPxColId &id) const
Returns unscaled objective value of column with identifier id.
virtual void removeCols(SPxColId id[], int n, int perm[]=nullptr)
virtual void addRow(const R &lhsValue, const SVectorBase< R > &rowVec, const R &rhsValue, bool scale=false)
virtual void doRemoveCol(int j)
Internal helper method.
void doAddCol(const LPColBase< R > &col, bool scale=false)
void addRow(const S *lhsValue, const S *rowValues, const int *rowIndices, int rowSize, const S *rhsValue)
void doAddRow(const R &lhsValue, const SVectorBase< R > &rowVec, const R &rhsValue, 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...
SPxLPBase(const SPxLPBase< R > &old)
Copy constructor.
R lowerUnscaled(const SPxColId &id) const
Returns unscaled lower bound of column with identifier id.
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
SPxLPBase< R > & operator=(const SPxLPBase< S > &old)
Assignment operator.
LP simplifier for removing uneccessary row/columns.
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
static void setFixed(std::ostream &stream, int precision=8)
Sets the precision of the stream to 8 and the floatfield to fixed.
LP scaler abstract base class.
ClassSet< DLPSV > set
set of SVectorBases
int num() const
Current number of SVectorBases.
int pos(int i) const
Position of index i.
int & index(int n)
Reference to index of n 'th nonzero.
void remove(int n, int m)
Remove nonzeros n thru m.
R & value(int n)
Reference to value of n 'th nonzero.
void clear()
Remove all indices.
int size() const
Number of used indices.
int dim() const
Dimension of vector.
VectorBase< R > & multSub(const S &x, const SVectorBase< T > &vec)
Subtraction of scaled vector.
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
Save arrays of data objects.
Entry identifier class for items of a DataSet.
Everything should be within this namespace.
boost::multiprecision::number< T > spxLdexp(boost::multiprecision::number< T, eto > x, int exp)
std::ifstream spxifstream
SOPLEX_THREADLOCAL const Real infinity
Debugging, floating point type and parameter definitions.
#define SPX_MSG_INCONSISTENT(name)
declaration of types for file output
Row and columns Id's SPxLP.