38 s << sc.
getName() <<
" scaler:" << std::endl;
41 for(
int ci = 0; ci < colscaleExp.
size(); ++ci)
42 s << colscaleExp[ci] <<
" ";
44 s <<
"]" << std::endl;
48 for(
int ri = 0; ri < rowccaleExp.
size(); ++ri)
49 s << rowccaleExp[ri] <<
" ";
51 s <<
"]" << std::endl;
63 , m_activeColscaleExp(0)
64 , m_activeRowscaleExp(0)
65 , m_colFirst(colFirst)
134 m_activeColscaleExp->reSize(lp.
nCols());
137 for(
int i = 0; i < lp.
nCols(); ++i)
138 (*m_activeColscaleExp)[i] = 0;
140 for(
int i = 0; i < lp.
nRows(); ++i)
151 for(
int i = 0; i < vec.
size(); ++i)
185 for(
int i = 0; i < lp.
nRows(); ++i)
189 int exp2 = rowscaleExp[i];
191 for(
int j = 0; j < vec.
size(); ++j)
193 exp1 = colscaleExp[vec.
index(j)];
205 MSG_DEBUG(std::cout <<
"DEBUG: rowscaleExp(" << i <<
"): " << exp2 << std::endl;)
208 for(
int i = 0; i < lp.
nCols(); ++i)
212 int exp2 = colscaleExp[i];
214 for(
int j = 0; j < vec.
size(); ++j)
216 exp1 = rowscaleExp[vec.
index(j)];
228 MSG_DEBUG(std::cout <<
"DEBUG: colscaleExp(" << i <<
"): " << exp2 << std::endl;)
243 for(
int i = 0; i < lp.
nRows(); ++i)
248 int exp2 = rowscaleExp[i];
250 for(
int j = 0; j < vec.
size(); ++j)
252 exp1 = colscaleExp[vec.
index(j)];
265 for(
int i = 0; i < lp.
nCols(); ++i)
270 int exp2 = colscaleExp[i];
272 for(
int j = 0; j < vec.
size(); ++j)
274 exp1 = rowscaleExp[vec.
index(j)];
309 assert(i < lp.
nCols());
314 vec = lp.LPColSet::colVector(i);
317 int exp2 = colscaleExp[i];
323 for(
int j = 0; j < col.
size(); j++)
325 exp1 = rowscaleExp[col.
index(j)];
333 assert(i < lp.
nCols());
338 const SVector& colVec = lp.LPColSet::colVector(i);
342 int exp2 = colscaleExp[i];
344 for(
int j = 0; j < colVec.
size(); j++)
346 exp1 = rowscaleExp[colVec.
index(j)];
359 assert(i < lp.
nCols());
364 const SVector& colVec = lp.LPColSet::colVector(i);
368 int exp2 = colscaleExp[i];
370 for(
int j = 0; j < colVec.
size(); j++)
372 exp1 = rowscaleExp[colVec.
index(j)];
387 assert(i < lp.
nCols());
390 if(lp.LPColSet::upper(i) <
infinity)
393 return spxLdexp(lp.LPColSet::upper(i), colscaleExp[i]);
396 return lp.LPColSet::upper(i);
404 assert(lp.LPColSet::upper().dim() == vec.
dim());
408 for(
int i = 0; i < lp.LPColSet::upper().dim(); i++)
409 vec[i] =
spxLdexp(lp.LPColSet::upper()[i], colscaleExp[i]);
417 assert(i < lp.
nCols());
420 if(lp.LPColSet::lower(i) > -
infinity)
423 return spxLdexp(lp.LPColSet::lower(i), colscaleExp[i]);
426 return lp.LPColSet::lower(i);
434 assert(lp.LPColSet::lower().dim() == vec.
dim());
438 for(
int i = 0; i < lp.LPColSet::lower().dim(); i++)
439 vec[i] =
spxLdexp(lp.LPColSet::lower()[i], colscaleExp[i]);
446 assert(i < lp.
nCols());
451 return spxLdexp(lp.LPColSet::maxObj(i), -colscaleExp[i]);
459 assert(lp.LPColSet::maxObj().dim() == vec.
dim());
463 for(
int i = 0; i < lp.LPColSet::maxObj().dim(); i++)
464 vec[i] =
spxLdexp(lp.LPColSet::maxObj()[i], -colscaleExp[i]);
471 assert(i < lp.
nRows());
477 int exp2 = rowscaleExp[i];
483 for(
int j = 0; j < row.
size(); j++)
485 exp1 = colscaleExp[row.
index(j)];
493 assert(i < lp.
nRows());
497 const SVector& rowVec = lp.LPRowSet::rowVector(i);
502 int exp2 = rowscaleExp[i];
504 for(
int j = 0; j < rowVec.
size(); j++)
506 exp1 = colscaleExp[rowVec.
index(j)];
519 assert(i < lp.
nRows());
523 const SVector& rowVec = lp.LPRowSet::rowVector(i);
528 int exp2 = rowscaleExp[i];
530 for(
int j = 0; j < rowVec.
size(); j++)
532 exp1 = colscaleExp[rowVec.
index(j)];
546 assert(i < lp.
nRows());
552 return spxLdexp(lp.LPRowSet::rhs(i), -rowscaleExp[i]);
555 return lp.LPRowSet::rhs(i);
563 assert(lp.LPRowSet::rhs().dim() == vec.
dim());
565 for(
int i = 0; i < lp.LPRowSet::rhs().dim(); i++)
568 vec[i] =
spxLdexp(lp.LPRowSet::rhs()[i], -rowscaleExp[i]);
577 assert(i < lp.
nRows());
583 return spxLdexp(lp.LPRowSet::lhs(i), -rowscaleExp[i]);
586 return lp.LPRowSet::lhs(i);
593 assert(lp.LPRowSet::lhs().dim() == vec.
dim());
597 for(
int i = 0; i < lp.LPRowSet::lhs().dim(); i++)
598 vec[i] =
spxLdexp(lp.LPRowSet::lhs()[i], -rowscaleExp[i]);
605 assert(row < lp.
nRows());
606 assert(col < lp.
nCols());
620 assert(x.
dim() == colscaleExp.size());
622 for(
int j = 0; j < x.
dim(); ++j)
623 x[j] =
spxLdexp(x[j], colscaleExp[j]);
632 assert(s.
dim() == rowscaleExp.size());
634 for(
int i = 0; i < s.
dim(); ++i)
635 s[i] =
spxLdexp(s[i], -rowscaleExp[i]);
644 assert(pi.
dim() == rowscaleExp.size());
646 for(
int i = 0; i < pi.
dim(); ++i)
647 pi[i] =
spxLdexp(pi[i], rowscaleExp[i]);
656 assert(r.
dim() == colscaleExp.size());
658 for(
int j = 0; j < r.
dim(); ++j)
659 r[j] =
spxLdexp(r[j], -colscaleExp[j]);
668 assert(ray.
dim() == colscaleExp.size());
670 for(
int j = 0; j < ray.
dim(); ++j)
671 ray[j] =
spxLdexp(ray[j], colscaleExp[j]);
680 assert(ray.
dim() == rowscaleExp.size());
682 for(
int i = 0; i < ray.
dim(); ++i)
683 ray[i] =
spxLdexp(ray[i], rowscaleExp[i]);
692 for(
int i = 0; i < origObj.
dim(); ++i)
694 origObj[i] =
spxLdexp(origObj[i], colscaleExp[i]);
701 assert(i < lp.
nCols());
705 int exp = colscaleExp[i];
713 assert(col < lp.
nCols());
715 assert(row < lp.
nRows());
721 return spxLdexp(val, colscaleExp[col] + rowscaleExp[row]);
727 assert(col < lp.
nCols());
732 return spxLdexp(lower, -colscaleExp[col]);
738 assert(col < lp.
nCols());
743 return spxLdexp(upper, -colscaleExp[col]);
749 assert(row < lp.
nRows());
754 return spxLdexp(lhs, rowscaleExp[row]);
760 assert(row < lp.
nRows());
765 return spxLdexp(rhs, rowscaleExp[row]);
774 for(
int i = 0; i < colscaleExp.
size(); ++i)
787 for(
int i = 0; i < colscaleExp.
size(); ++i)
799 int mini = std::numeric_limits<int>::max();
801 for(
int i = 0; i < rowscaleExp.
size(); ++i)
802 if(rowscaleExp[i] < mini)
803 mini = rowscaleExp[i];
812 int maxi = std::numeric_limits<int>::min();
814 for(
int i = 0; i < rowscaleExp.
size(); ++i)
815 if(rowscaleExp[i] > maxi)
816 maxi = rowscaleExp[i];
830 for(
int i = 0; i < lp.
nCols(); ++i)
836 for(
int j = 0; j < vec.
size(); ++j)
853 Real p = maxi / mini;
871 for(
int i = 0; i < lp.
nRows(); ++i)
877 for(
int j = 0; j < vec.
size(); ++j)
894 Real p = maxi / mini;
905 assert(vec.size() == unsigned(vecExp.
size()));
907 for(
unsigned i = 0; i < vec.size(); ++i)
909 frexp(vec[i], &(vecExp[
int(i)]));
916 #ifdef ENABLE_CONSISTENCY_CHECKS const VectorBase< R > & rhs() const
Returns right hand side vector.
Rational spxAbs(const Rational &r)
Absolute.
virtual void unscaleDualray(const SPxLPBase< Real > &lp, Vector &ray) const
unscale dual ray given in ray.
virtual void setup(SPxLPBase< Real > &lp)
clear and setup scaling arrays in the LP
virtual void setBoth(bool both)
set wether column and row scaling should be performed
virtual void setOrder(bool colFirst)
set scaling order
bool isConsistent() const
consistency check
virtual void unscalePrimal(const SPxLPBase< Real > &lp, Vector &x) const
unscale dense primal solution vector given in x.
const VectorBase< R > & upper() const
Returns upper bound vector.
THREADLOCAL const Real infinity
bool _isScaled
true, if scaling has been performed
virtual Real lhsUnscaled(const SPxLPBase< Real > &lp, int i) const
returns unscaled left hand side i of lp
virtual void getRowUnscaled(const SPxLPBase< Real > &lp, int i, DSVector &vec) const
returns unscaled row i
virtual Real scaleElement(const SPxLPBase< Real > &lp, int row, int col, Real val) const
returns scaled LP element in row and col.
R & maxObj_w(int i)
Returns objective value of column i for maximization problem.
int size() const
Number of used indices.
bool isScaled() const
Returns true if and only if the LP is scaled.
bool LT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a < b + eps
virtual void getLhsUnscaled(const SPxLPBase< Real > &lp, Vector &vec) const
returns unscaled left hand side vector of lp
virtual void unscaleRedCost(const SPxLPBase< Real > &lp, Vector &r) const
unscale dense reduced cost vector given in r.
virtual Real maxRowRatio(const SPxLPBase< Real > &lp) const
maximum ratio between absolute biggest and smallest element in any row.
virtual void unscaleDual(const SPxLPBase< Real > &lp, Vector &pi) const
unscale dense dual solution vector given in pi.
virtual Real scaleUpper(const SPxLPBase< Real > &lp, int col, Real upper) const
returns scaled upper bound of column col.
R & value(int n)
Reference to value of n 'th nonzero.
virtual ~SPxScaler()
destructor.
virtual bool isConsistent() const
consistency check
R & rhs_w(int i)
Returns right hand side of row i.
virtual Real getRowMaxAbsUnscaled(const SPxLPBase< Real > &lp, int i) const
returns maximum absolute value of unscaled row i
virtual void getUpperUnscaled(const SPxLPBase< Real > &lp, Vector &vec) const
returns unscaled upper bound vector of lp
virtual Real scaleLhs(const SPxLPBase< Real > &lp, int row, Real lhs) const
returns scaled left hand side of row row.
SVectorBase< R > & rowVector_w(int i)
Real spxFrexp(Real y, int *exp)
int nRows() const
Returns number of rows in LP.
void add(const SVectorBase< S > &vec)
Append nonzeros of sv.
DataArray< int > * m_activeColscaleExp
pointer to currently active column scaling factors
virtual void applyScaling(SPxLPBase< Real > &lp)
applies m_colscale and m_rowscale to the lp.
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
virtual void unscale(SPxLPBase< Real > &lp)
unscale SPxLP
SPxOut * spxout
message handler
bool GT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a > b + eps
int & index(int n)
Reference to index of n 'th nonzero.
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
virtual Real upperUnscaled(const SPxLPBase< Real > &lp, int i) const
returns unscaled upper bound i
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
virtual void getLowerUnscaled(const SPxLPBase< Real > &lp, Vector &vec) const
gets unscaled lower bound vector
const VectorBase< R > & lhs() const
Returns left hand side vector.
R & lower_w(int i)
Returns lower bound of column i.
virtual Real maxAbsColscale() const
absolute biggest column scaling factor
virtual int getColScaleExp(int i) const
returns scaling factor for column i
virtual void scaleObj(const SPxLPBase< Real > &lp, VectorReal &origObj) const
apply scaling to objective function vector origObj.
LPColSetBase(int pmax=-1, int pmemmax=-1)
Default constructor.
virtual void getRhsUnscaled(const SPxLPBase< Real > &lp, Vector &vec) const
gets unscaled right hand side vector
virtual Real minAbsColscale() const
absolute smallest column scaling factor
virtual void setRealParam(Real param, const char *name="realparam")
set real parameter
const VectorBase< R > & maxRowObj() const
virtual Real maxObjUnscaled(const SPxLPBase< Real > &lp, int i) const
returns unscaled objective function coefficient of i
void computeExpVec(const std::vector< Real > &vec, DataArray< int > &vecExp)
round vector entries to power of 2
DataArray< int > * m_activeRowscaleExp
pointer to currently active row scaling factors
void setScalingInfo(bool scaled)
set whether the LP is scaled or not
R & maxRowObj_w(int i)
Returns objective function value of row i.
virtual const char * getName() const
get name of scaler
virtual Real minAbsRowscale() const
absolute smallest row scaling factor
virtual Real scaleLower(const SPxLPBase< Real > &lp, int col, Real lower) const
returns scaled lower bound of column col.
int dim() const
Dimension of vector.
Everything should be within this namespace.
virtual Real lowerUnscaled(const SPxLPBase< Real > &lp, int i) const
returns unscaled lower bound i
virtual Real rhsUnscaled(const SPxLPBase< Real > &lp, int i) const
returns unscaled right hand side i
void clear()
Remove all indices.
virtual Real getColMinAbsUnscaled(const SPxLPBase< Real > &lp, int i) const
returns minumum absolute value of unscaled column i
R & upper_w(int i)
Returns upper bound of column i.
SPxScaler * lp_scaler
points to the scaler if the lp has been scaled, to 0 otherwise
bool m_colFirst
do column scaling first
SPxScaler(const char *name, bool colFirst=false, bool doBoth=true, SPxOut *spxout=NULL)
constructor
Saving LPs in a form suitable for SoPlex.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
LP scaler abstract base class.Instances of classes derived from SPxScaler may be loaded to SoPlex in ...
LPRowSetBase(int pmax=-1, int pmemmax=-1)
Default constructor.
virtual Real getRowMinAbsUnscaled(const SPxLPBase< Real > &lp, int i) const
returns minimum absolute value of unscaled row i
virtual Real maxAbsRowscale() const
absolute biggest row scaling factor
int size() const
return nr. of elements.
bool isConsistent() const
Consistency check.
virtual int getRowScaleExp(int i) const
returns scaling factor for row i
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
virtual void getColUnscaled(const SPxLPBase< Real > &lp, int i, DSVector &vec) const
gets unscaled column i
int nCols() const
Returns number of columns in LP.
virtual Real getCoefUnscaled(const SPxLPBase< Real > &lp, int row, int col) const
returns unscaled coefficient of lp
bool isZero(Real a, Real eps=Param::epsilon())
returns true iff |a| <= eps
bool m_doBoth
do columns and rows
virtual Real maxColRatio(const SPxLPBase< Real > &lp) const
maximum ratio between absolute biggest and smallest element in any column.
virtual Real scaleRhs(const SPxLPBase< Real > &lp, int row, Real rhs) const
returns scaled right hand side of row row.
SVectorBase< R > & colVector_w(int i)
Returns the LP as an LPRowSet.
virtual void unscaleSlacks(const SPxLPBase< Real > &lp, Vector &s) const
unscale dense slack vector given in s.
virtual void unscalePrimalray(const SPxLPBase< Real > &lp, Vector &ray) const
unscale primal ray given in ray.
virtual Real getColMaxAbsUnscaled(const SPxLPBase< Real > &lp, int i) const
returns maximum absolute value of unscaled column i
virtual void getMaxObjUnscaled(const SPxLPBase< Real > &lp, Vector &vec) const
gets unscaled objective function
void reSize(int newsize)
reset size to newsize.
const char * m_name
Name of the scaler.
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
virtual void setIntParam(int param, const char *name="intparam")
set int parameter
SPxScaler & operator=(const SPxScaler &)
assignment operator
void setMax(int newmax=1)
Reset nonzero memory to >= newmax.
R & lhs_w(int i)
Returns left hand side of row i.