29 #define STABLE 1e-3 // the sparsest row/column may only have a pivot of size STABLE*maxEntry 33 #ifdef ENABLE_CONSISTENCY_CHECKS 96 if(base.SPxLP::lower(n) <= -
infinity)
103 if(base.SPxLP::lower(n) <= -
infinity)
105 else if(base.SPxLP::lower(n) >= base.SPxLP::upper(n) - base.
epsilon())
146 return weight[i1] - weight[i2];
173 for(i = 0; i < base.
nRows(); ++i)
180 for(i = 0; i < base.
nCols(); ++i)
191 while(k < pref.
size())
193 if(rowWeight[row[i]] < colWeight[col[j]])
195 pref[k++] = base.
rId(row[i++]);
197 if(i >= base.
nRows())
198 while(k < pref.
size())
199 pref[k++] = base.
cId(col[j++]);
203 pref[k++] = base.
cId(col[j++]);
205 if(j >= base.
nCols())
206 while(k < pref.
size())
207 pref[k++] = base.
rId(row[i++]);
211 assert(i == base.
nRows());
212 assert(j == base.
nCols());
253 for(i = 0; i < base.
dim(); ++i)
269 int dim = base.
dim();
272 for(; i >= 0 && i < pref.size(); i += stepi)
281 int idx = vec.
index(0);
294 int minRowEntries = base.
nRows();
297 for(j = vec.
size(); --j >= 0;)
300 int k = vec.
index(j);
305 minRowEntries = nRowEntries;
317 std::cout <<
"DWEIST01 r" << base.
number(pref[i]);
319 std::cout <<
"DWEIST02 c" << base.
number(pref[i]);
330 for(j = vec.
size(); --j >= 0;)
333 int k = vec.
index(j);
348 for(i += stepi; i >= 0 && i < pref.size(); i += stepi)
360 for(i += stepi; i >= 0 && i < pref.size(); i += stepi)
400 for(i = pvec.
dim() - 1; i >= 0; --i)
418 std::cout <<
"changed basis\n";
422 std::cout <<
"nothing changed\n";
444 for(i = 0; i < base.
nCols(); i++)
453 for(i = 0; i < base.
nRows(); i++)
471 if(base.
rep() * base.
type() > 0)
474 const Real bx = 1.0 / maxabs;
476 const Real c_fixed = 1e+5;
477 const Real r_fixed = 0;
478 const Real c_dbl_bounded = 1e+1;
479 const Real r_dbl_bounded = 0;
480 const Real c_bounded = 1e+1;
481 const Real r_bounded = 0;
482 const Real c_free = -1e+4;
483 const Real r_free = -1e+5;
485 for(i = base.
nCols() - 1; i >= 0; i--)
488 Real x = ax * obj[i];
489 Real u = bx * up [i];
490 Real l = bx * low[i];
494 if(
spxAbs(low[i] - up[i]) < eps)
498 colWeight[i] = c_dbl_bounded + l - u + n;
534 for(i = base.
nRows() - 1; i >= 0; i--)
538 if(
spxAbs(lhs[i] - rhs[i]) < eps)
544 Real u = bx * rhs[i];
545 Real l = bx * lhs[i];
572 assert(base.
rep() * base.
type() < 0);
575 const Real bx = 1e-2 / maxabs;
576 const Real nne = 1e-4 * bx;
577 const Real c_fixed = 1e+5;
578 const Real r_fixed = 1e+4;
579 const Real c_dbl_bounded = 1;
580 const Real r_dbl_bounded = 0;
581 const Real c_bounded = 0;
582 const Real r_bounded = 0;
583 const Real c_free = -1e+4;
584 const Real r_free = -1e+5;
586 for(i = base.
nCols() - 1; i >= 0; i--)
589 Real x = ax * obj[i];
590 Real u = bx * up [i];
591 Real l = bx * low[i];
595 if(
spxAbs(low[i] - up[i]) < eps)
601 colWeight[i] = c_dbl_bounded + x - u + n;
606 colWeight[i] = c_dbl_bounded - x + l + n;
628 for(i = base.
nRows() - 1; i >= 0; i--)
632 Real u = bx * len1 * rhs[i];
633 Real l = bx * len1 * lhs[i];
638 if(
spxAbs(lhs[i] - rhs[i]) < eps)
644 rowWeight[i] = r_dbl_bounded + x - u + n;
649 rowWeight[i] = r_dbl_bounded - x + l + n;
676 for(i = 0; i < base.
nCols(); i++)
677 std::cout <<
"C i= " << i
678 <<
" up= " <<
colUp[i]
681 for(i = 0; i < base.
nRows(); i++)
682 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?.