38 s << sc.
getName() <<
" scaler:" << std::endl;
40 for(
int ci = 0; ci < colscaleExp.
size(); ++ci )
41 s << colscaleExp[ci] <<
" ";
42 s <<
"]" << std::endl;
45 for(
int ri = 0; ri < rowccaleExp.
size(); ++ri )
46 s << rowccaleExp[ri] <<
" ";
47 s <<
"]" << std::endl;
59 , m_activeColscaleExp(0)
60 , m_activeRowscaleExp(0)
61 , m_colFirst(colFirst)
129 m_activeColscaleExp->reSize(lp.
nCols());
132 for(
int i = 0; i < lp.
nCols(); ++i)
133 (*m_activeColscaleExp)[i] = 0;
134 for(
int i = 0; i < lp.
nRows(); ++i)
145 for(
int i = 0; i < vec.
size(); ++i )
177 for(
int i = 0; i < lp.
nRows(); ++i )
181 int exp2 = rowscaleExp[i];
183 for(
int j = 0; j < vec.
size(); ++j)
185 exp1 = colscaleExp[vec.
index(j)];
197 MSG_DEBUG( std::cout <<
"DEBUG: rowscaleExp(" << i <<
"): " << exp2 << std::endl; )
200 for(
int i = 0; i < lp.
nCols(); ++i )
204 int exp2 = colscaleExp[i];
206 for(
int j = 0; j < vec.
size(); ++j)
208 exp1 = rowscaleExp[vec.
index(j)];
220 MSG_DEBUG( std::cout <<
"DEBUG: colscaleExp(" << i <<
"): " << exp2 << std::endl; )
235 for(
int i = 0; i < lp.
nRows(); ++i )
240 int exp2 = rowscaleExp[i];
242 for(
int j = 0; j < vec.
size(); ++j)
244 exp1 = colscaleExp[vec.
index(j)];
257 for(
int i = 0; i < lp.
nCols(); ++i )
262 int exp2 = colscaleExp[i];
264 for(
int j = 0; j < vec.
size(); ++j)
266 exp1 = rowscaleExp[vec.
index(j)];
301 assert(i < lp.
nCols());
306 vec = lp.LPColSet::colVector(i);
309 int exp2 = colscaleExp[i];
315 for(
int j = 0; j < col.
size(); j++ )
317 exp1 = rowscaleExp[col.
index(j)];
325 assert(i < lp.
nCols());
330 const SVector& colVec = lp.LPColSet::colVector(i);
334 int exp2 = colscaleExp[i];
336 for(
int j = 0; j < colVec.
size(); j++ )
338 exp1 = rowscaleExp[colVec.
index(j)];
350 assert(i < lp.
nCols());
355 const SVector& colVec = lp.LPColSet::colVector(i);
359 int exp2 = colscaleExp[i];
361 for(
int j = 0; j < colVec.
size(); j++ )
363 exp1 = rowscaleExp[colVec.
index(j)];
377 assert(i < lp.
nCols());
380 if( lp.LPColSet::upper(i) <
infinity )
383 return spxLdexp(lp.LPColSet::upper(i) , colscaleExp[i]);
386 return lp.LPColSet::upper(i);
394 assert(lp.LPColSet::upper().dim() == vec.
dim());
398 for(
int i = 0; i < lp.LPColSet::upper().dim(); i++)
399 vec[i] =
spxLdexp(lp.LPColSet::upper()[i], colscaleExp[i]);
407 assert(i < lp.
nCols());
410 if( lp.LPColSet::lower(i) > -
infinity )
413 return spxLdexp(lp.LPColSet::lower(i), colscaleExp[i]);
416 return lp.LPColSet::lower(i);
424 assert(lp.LPColSet::lower().dim() == vec.
dim());
428 for(
int i = 0; i < lp.LPColSet::lower().dim(); i++)
429 vec[i] =
spxLdexp(lp.LPColSet::lower()[i], colscaleExp[i]);
436 assert(i < lp.
nCols());
441 return spxLdexp(lp.LPColSet::maxObj(i) , -colscaleExp[i]);
449 assert(lp.LPColSet::maxObj().dim() == vec.
dim());
453 for(
int i = 0; i < lp.LPColSet::maxObj().dim(); i++)
454 vec[i] =
spxLdexp(lp.LPColSet::maxObj()[i], -colscaleExp[i]);
461 assert(i < lp.
nRows());
467 int exp2 = rowscaleExp[i];
473 for(
int j = 0; j < row.
size(); j++ )
475 exp1 = colscaleExp[row.
index(j)];
483 assert(i < lp.
nRows());
487 const SVector& rowVec = lp.LPRowSet::rowVector(i);
492 int exp2 = rowscaleExp[i];
494 for(
int j = 0; j < rowVec.
size(); j++ )
496 exp1 = colscaleExp[rowVec.
index(j)];
509 assert(i < lp.
nRows());
513 const SVector& rowVec = lp.LPRowSet::rowVector(i);
518 int exp2 = rowscaleExp[i];
520 for(
int j = 0; j < rowVec.
size(); j++ )
522 exp1 = colscaleExp[rowVec.
index(j)];
536 assert(i < lp.
nRows());
539 if( lp.LPRowSet::rhs(i) <
infinity )
542 return spxLdexp(lp.LPRowSet::rhs(i) , -rowscaleExp[i]);
545 return lp.LPRowSet::rhs(i);
553 assert(lp.LPRowSet::rhs().dim() == vec.
dim());
555 for(
int i = 0; i < lp.LPRowSet::rhs().dim(); i++)
558 vec[i] =
spxLdexp(lp.LPRowSet::rhs()[i], -rowscaleExp[i]);
567 assert(i < lp.
nRows());
570 if( lp.LPRowSet::lhs(i) > -
infinity )
573 return spxLdexp(lp.LPRowSet::lhs(i) , -rowscaleExp[i]);
576 return lp.LPRowSet::lhs(i);
583 assert(lp.LPRowSet::lhs().dim() == vec.
dim());
587 for(
int i = 0; i < lp.LPRowSet::lhs().dim(); i++)
588 vec[i] =
spxLdexp(lp.LPRowSet::lhs()[i], -rowscaleExp[i]);
595 assert(row < lp.
nRows());
596 assert(col < lp.
nCols());
610 assert(x.
dim() == colscaleExp.size());
612 for(
int j = 0; j < x.
dim(); ++j )
613 x[j] =
spxLdexp(x[j], colscaleExp[j]);
622 assert(s.
dim() == rowscaleExp.size());
624 for(
int i = 0; i < s.
dim(); ++i )
625 s[i] =
spxLdexp(s[i], -rowscaleExp[i]);
634 assert(pi.
dim() == rowscaleExp.size());
636 for(
int i = 0; i < pi.
dim(); ++i )
637 pi[i] =
spxLdexp(pi[i], rowscaleExp[i]);
646 assert(r.
dim() == colscaleExp.size());
648 for(
int j = 0; j < r.
dim(); ++j )
649 r[j] =
spxLdexp(r[j], -colscaleExp[j]);
658 assert(ray.
dim() == colscaleExp.size());
660 for(
int j = 0; j < ray.
dim(); ++j )
661 ray[j] =
spxLdexp(ray[j], colscaleExp[j]);
670 assert(ray.
dim() == rowscaleExp.size());
672 for(
int i = 0; i < ray.
dim(); ++i )
673 ray[i] =
spxLdexp(ray[i], rowscaleExp[i]);
682 for(
int i = 0; i < origObj.
dim(); ++i )
684 origObj[i] =
spxLdexp(origObj[i], colscaleExp[i]);
691 assert(i < lp.
nCols());
695 int exp = colscaleExp[i];
703 assert(col < lp.
nCols());
705 assert(row < lp.
nRows());
711 return spxLdexp(val, colscaleExp[col] + rowscaleExp[row]);
717 assert(col < lp.
nCols());
722 return spxLdexp(lower, -colscaleExp[col]);
728 assert(col < lp.
nCols());
733 return spxLdexp(upper, -colscaleExp[col]);
739 assert(row < lp.
nRows());
744 return spxLdexp(lhs, rowscaleExp[row]);
750 assert(row < lp.
nRows());
755 return spxLdexp(rhs, rowscaleExp[row]);
764 for(
int i = 0; i < colscaleExp.
size(); ++i )
777 for(
int i = 0; i < colscaleExp.
size(); ++i )
789 int mini = std::numeric_limits<int>::max();
791 for(
int i = 0; i < rowscaleExp.
size(); ++i )
792 if( rowscaleExp[i] < mini )
793 mini = rowscaleExp[i];
802 int maxi = std::numeric_limits<int>::min();
804 for(
int i = 0; i < rowscaleExp.
size(); ++i )
805 if( rowscaleExp[i] > maxi )
806 maxi = rowscaleExp[i];
820 for(
int i = 0; i < lp.
nCols(); ++i )
826 for(
int j = 0; j < vec.
size(); ++j)
841 Real p = maxi / mini;
858 for(
int i = 0; i < lp.
nRows(); ++i )
864 for(
int j = 0; j < vec.
size(); ++j)
879 Real p = maxi / mini;
889 assert(vec.size() == unsigned(vecExp.
size()));
891 for(
unsigned i = 0; i < vec.size(); ++i )
893 frexp(vec[i], &(vecExp[
int(i)]));
900 #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.