29 #define STABLE 1e-3 // the sparsest row/column may only have a pivot of size STABLE*maxEntry 33 #ifdef ENABLE_CONSISTENCY_CHECKS 93 if (base.SPxLP::upper(n) >=
infinity)
95 if (base.SPxLP::lower(n) <= -
infinity)
102 if (base.SPxLP::lower(n) <= -
infinity)
104 else if (base.SPxLP::lower(n) >= base.SPxLP::upper(n) - base.
epsilon())
145 return weight[i1] - weight[i2];
172 for(i = 0; i < base.
nRows(); ++i)
179 for(i = 0; i < base.
nCols(); ++i)
190 while(k < pref.
size())
192 if (rowWeight[row[i]] < colWeight[col[j]])
194 pref[k++] = base.
rId(row[i++]);
196 if (i >= base.
nRows())
197 while (k < pref.
size())
198 pref[k++] = base.
cId(col[j++]);
202 pref[k++] = base.
cId(col[j++]);
204 if (j >= base.
nCols())
205 while (k < pref.
size())
206 pref[k++] = base.
rId(row[i++]);
209 assert(i == base.
nRows());
210 assert(j == base.
nCols());
250 for(i = 0; i < base.
dim(); ++i)
266 int dim = base.
dim();
269 for (; i >= 0 && i < pref.size(); i += stepi)
278 int idx = vec.
index(0);
291 int minRowEntries = base.
nRows();
294 for (j = vec.
size(); --j >= 0;)
297 int k = vec.
index(j);
302 minRowEntries = nRowEntries;
313 std::cout <<
"DWEIST01 r" << base.
number(pref[i]);
315 std::cout <<
"DWEIST02 c" << base.
number(pref[i]);
326 for (j = vec.
size(); --j >= 0;)
329 int k = vec.
index(j);
344 for (i += stepi; i >= 0 && i < pref.size(); i += stepi)
356 for (i += stepi; i >= 0 && i < pref.size(); i += stepi)
390 for (i = pvec.
dim() - 1; i >= 0; --i)
408 std::cout <<
"changed basis\n";
412 std::cout <<
"nothing changed\n";
433 for (i = 0; i < base.
nCols(); i++)
441 for (i = 0; i < base.
nRows(); i++)
459 if (base.
rep() * base.
type() > 0)
462 const Real bx = 1.0 / maxabs;
464 const Real c_fixed = 1e+5;
465 const Real r_fixed = 0;
466 const Real c_dbl_bounded = 1e+1;
467 const Real r_dbl_bounded = 0;
468 const Real c_bounded = 1e+1;
469 const Real r_bounded = 0;
470 const Real c_free = -1e+4;
471 const Real r_free = -1e+5;
473 for (i = base.
nCols() - 1; i >= 0; i--)
476 Real x = ax * obj[i];
477 Real u = bx * up [i];
478 Real l = bx * low[i];
482 if (
spxAbs(low[i] - up[i]) < eps)
486 colWeight[i] = c_dbl_bounded + l - u + n;
522 for (i = base.
nRows() - 1; i >= 0; i--)
526 if (
spxAbs(lhs[i] - rhs[i]) < eps)
532 Real u = bx * rhs[i];
533 Real l = bx * lhs[i];
560 assert(base.
rep() * base.
type() < 0);
563 const Real bx = 1e-2 / maxabs;
564 const Real nne = 1e-4 * bx;
565 const Real c_fixed = 1e+5;
566 const Real r_fixed = 1e+4;
567 const Real c_dbl_bounded = 1;
568 const Real r_dbl_bounded = 0;
569 const Real c_bounded = 0;
570 const Real r_bounded = 0;
571 const Real c_free = -1e+4;
572 const Real r_free = -1e+5;
574 for (i = base.
nCols() - 1; i >= 0; i--)
577 Real x = ax * obj[i];
578 Real u = bx * up [i];
579 Real l = bx * low[i];
583 if (
spxAbs(low[i] - up[i]) < eps)
589 colWeight[i] = c_dbl_bounded + x - u + n;
594 colWeight[i] = c_dbl_bounded - x + l + n;
616 for (i = base.
nRows() - 1; i >= 0; i--)
620 Real u = bx * len1 * rhs[i];
621 Real l = bx * len1 * lhs[i];
626 if (
spxAbs(lhs[i] - rhs[i]) < eps)
632 rowWeight[i] = r_dbl_bounded + x - u + n;
637 rowWeight[i] = r_dbl_bounded - x + l + n;
663 for(i = 0; i < base.
nCols(); i++)
664 std::cout <<
"C i= " << i
665 <<
" up= " <<
colUp[i]
668 for(i = 0; i < base.
nRows(); i++)
669 std::cout <<
"R i= " << i
const VectorBase< R > & rhs() const
Returns right hand side vector.
Rational spxAbs(const Rational &r)
Absolute.
SPxId coId(int i) const
id of i 'th covector.
DataArray< Real > * weight
SPxRowId rId(int n) const
Returns the row identifier for row n.
Safe arrays of data objects.Class DataArray provides safe arrays of Data Objects. For general C++ obj...
bool isConsistent() const
consistency check
const SVector & coVector(int i) const
i 'th covector of LP.
primal variable is fixed to both bounds
const VectorBase< R > & upper() const
Returns upper bound vector.
Desc::Status dualColStatus(int i) const
dual Status for the i'th column variable of the loaded LP.
THREADLOCAL const Real infinity
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
static void initPrefs(DataArray< SPxId > &pref, const SPxSolver &base, const DataArray< Real > &rowWeight, const DataArray< Real > &colWeight)
int size() const
Number of used indices.
Status & rowStatus(int i)
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
int dim() const
dimension of basis matrix.
R & value(int n)
Reference to value of n 'th nonzero.
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
Compare class for row weights, used for sorting.
Desc::Status dualRowStatus(int i) const
dual Status for the i'th row variable of the loaded LP.
DataArray< Real > rowWeight
weight value for LP rows.
SPxColId cId(int n) const
Returns the column identifier for column n.
virtual void setupWeights(SPxSolver &base)
sets up variable weights.
int nRows() const
Returns number of rows in LP.
primal variable is set to its upper bound
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
int & index(int n)
Reference to index of n 'th nonzero.
void generate(SPxSolver &base)
generates start basis for loaded basis.
const T * get_const_ptr() const
get a const C pointer to the data.
primal variable is left free, but unset
const VectorBase< R > & lhs() const
Returns left hand side vector.
void SPxQuicksort(T *keys, int end, COMPARATOR &compare, int start=0, bool type=true)
Generic QuickSort implementation.
Status & colStatus(int i)
Generic QuickSort implementation.
Real epsilon() const
values are considered to be 0.
Debugging, floating point type and parameter definitions.
virtual void loadBasis(const SPxBasis::Desc &)
set a start basis.
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
UpdateVector & pVec() const
pricing vector.
Real operator()(int i1, int i2) const
compares the weights
int dim() const
Dimension of vector.
Everything should be within this namespace.
primal variable is set to its lower bound
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
const Real * weight
the weights to compare
int size() const
return nr. of elements.
Type type() const
return current Type.
int coDim() const
codimension.
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
int nCols() const
Returns number of columns in LP.
virtual void init()
intialize data structures.
DataArray< Real > * coWeight
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
const SVector & vector(int i) const
i 'th vector.
static void setDualStatus(SPxBasis::Desc &desc, const SPxSolver &base, const SPxId &id)
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
DataArray< Real > colWeight
weight value for LP columns.
const SPxBasis & basis() const
Return current basis.
DataArray< int > forbidden
void setPrimalStatus(SPxBasis::Desc &, const SPxSolver &, const SPxId &)
void reSize(int newsize)
reset size to newsize.
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
DataArray< bool > colUp
set primal variable to upper bound.
virtual bool isConsistent() const
consistency check.
Representation rep() const
return the current basis representation.
columnwise representation.
DataArray< bool > rowRight
set variable to rhs?.