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
Rational spxAbs(const Rational &r)
Absolute.
int dim() const
dimension of basis matrix.
int coDim() const
codimension.
DataArray< Real > * weight
Real operator()(int i1, int i2) const
compares the weights
Desc::Status dualRowStatus(int i) const
dual Status for the i'th row variable of the loaded LP.
Safe arrays of data objects.Class DataArray provides safe arrays of Data Objects. For general C++ obj...
Representation rep() const
return the current basis representation.
primal variable is fixed to both bounds
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
static void initPrefs(DataArray< SPxId > &pref, const SPxSolver &base, const DataArray< Real > &rowWeight, const DataArray< Real > &colWeight)
Status & rowStatus(int i)
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
int size() const
Number of used indices.
const VectorBase< R > & lower() const
Returns lower bound vector.
UpdateVector & pVec() const
pricing vector.
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.
SPxId coId(int i) const
id of i 'th covector.
const VectorBase< R > & upper() const
Returns upper bound vector.
DataArray< Real > rowWeight
weight value for LP rows.
bool isConsistent() const
consistency check
virtual void setupWeights(SPxSolver &base)
sets up variable weights.
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.
Desc::Status dualColStatus(int i) const
dual Status for the i'th column variable of the loaded LP.
const T * get_const_ptr() const
get a const C pointer to the data.
SPxRowId rId(int n) const
Returns the row identifier for row n.
int nCols() const
Returns number of columns in LP.
void generate(SPxSolver &base)
generates start basis for loaded basis.
const SPxBasis & basis() const
Return current basis.
virtual bool isConsistent() const
consistency check.
int size() const
return nr. of elements.
primal variable is left free, but unset
void SPxQuicksort(T *keys, int end, COMPARATOR &compare, int start=0, bool type=true)
Generic QuickSort implementation.
int dim() const
Dimension of vector.
Type type() const
return current Type.
Status & colStatus(int i)
Generic QuickSort implementation.
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
Debugging, floating point type and parameter definitions.
virtual void loadBasis(const SPxBasis::Desc &)
set a start basis.
int nRows() const
Returns number of rows in LP.
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
const SVector & coVector(int i) const
i 'th covector of LP.
const VectorBase< R > & lhs() const
Returns left hand side vector.
Everything should be within this namespace.
SPxColId cId(int n) const
Returns the column identifier for column n.
primal variable is set to its lower bound
const SVector & vector(int i) const
i 'th vector.
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
Real epsilon() const
values are considered to be 0.
const Real * weight
the weights to compare
const VectorBase< R > & rhs() const
Returns right hand side vector.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
virtual void init()
intialize data structures.
DataArray< Real > * coWeight
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
static void setDualStatus(SPxBasis::Desc &desc, const SPxSolver &base, const SPxId &id)
DataArray< Real > colWeight
weight value for LP columns.
DataArray< int > forbidden
void setPrimalStatus(SPxBasis::Desc &, const SPxSolver &, const SPxId &)
void reSize(int newsize)
reset size to newsize.
DataArray< bool > colUp
set primal variable to upper bound.
columnwise representation.
DataArray< bool > rowRight
set variable to rhs?.