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 )
164 #ifndef SOPLEX_LEGACY 179 for(
int i = 0; i < lp.
nRows(); ++i )
183 int exp2 = rowscaleExp[i];
185 for(
int j = 0; j < vec.
size(); ++j)
187 exp1 = colscaleExp[vec.
index(j)];
199 MSG_DEBUG( std::cout <<
"DEBUG: rowscaleExp(" << i <<
"): " << exp2 << std::endl; )
202 for(
int i = 0; i < lp.
nCols(); ++i )
206 int exp2 = colscaleExp[i];
208 for(
int j = 0; j < vec.
size(); ++j)
210 exp1 = rowscaleExp[vec.
index(j)];
222 MSG_DEBUG( std::cout <<
"DEBUG: colscaleExp(" << i <<
"): " << exp2 << std::endl; )
237 for(
int i = 0; i < lp.
nRows(); ++i )
242 int exp2 = rowscaleExp[i];
244 for(
int j = 0; j < vec.
size(); ++j)
246 exp1 = colscaleExp[vec.
index(j)];
259 for(
int i = 0; i < lp.
nCols(); ++i )
264 int exp2 = colscaleExp[i];
266 for(
int j = 0; j < vec.
size(); ++j)
268 exp1 = rowscaleExp[vec.
index(j)];
303 assert(i < lp.
nCols());
308 vec = lp.LPColSet::colVector(i);
311 int exp2 = colscaleExp[i];
317 for(
int j = 0; j < col.
size(); j++ )
319 exp1 = rowscaleExp[col.
index(j)];
327 assert(i < lp.
nCols());
332 const SVector& colVec = lp.LPColSet::colVector(i);
336 int exp2 = colscaleExp[i];
338 for(
int j = 0; j < colVec.
size(); j++ )
340 exp1 = rowscaleExp[colVec.
index(j)];
352 assert(i < lp.
nCols());
357 const SVector& colVec = lp.LPColSet::colVector(i);
361 int exp2 = colscaleExp[i];
363 for(
int j = 0; j < colVec.
size(); j++ )
365 exp1 = rowscaleExp[colVec.
index(j)];
379 assert(i < lp.
nCols());
382 if( lp.LPColSet::upper(i) <
infinity )
385 return spxLdexp(lp.LPColSet::upper(i) , colscaleExp[i]);
388 return lp.LPColSet::upper(i);
396 assert(lp.LPColSet::upper().dim() == vec.
dim());
400 for(
int i = 0; i < lp.LPColSet::upper().dim(); i++)
401 vec[i] =
spxLdexp(lp.LPColSet::upper()[i], colscaleExp[i]);
409 assert(i < lp.
nCols());
412 if( lp.LPColSet::lower(i) > -
infinity )
415 return spxLdexp(lp.LPColSet::lower(i), colscaleExp[i]);
418 return lp.LPColSet::lower(i);
426 assert(lp.LPColSet::lower().dim() == vec.
dim());
430 for(
int i = 0; i < lp.LPColSet::lower().dim(); i++)
431 vec[i] =
spxLdexp(lp.LPColSet::lower()[i], colscaleExp[i]);
438 assert(i < lp.
nCols());
443 return spxLdexp(lp.LPColSet::maxObj(i) , -colscaleExp[i]);
451 assert(lp.LPColSet::maxObj().dim() == vec.
dim());
455 for(
int i = 0; i < lp.LPColSet::maxObj().dim(); i++)
456 vec[i] =
spxLdexp(lp.LPColSet::maxObj()[i], -colscaleExp[i]);
463 assert(i < lp.
nRows());
469 int exp2 = rowscaleExp[i];
475 for(
int j = 0; j < row.
size(); j++ )
477 exp1 = colscaleExp[row.
index(j)];
485 assert(i < lp.
nRows());
489 const SVector& rowVec = lp.LPRowSet::rowVector(i);
494 int exp2 = rowscaleExp[i];
496 for(
int j = 0; j < rowVec.
size(); j++ )
498 exp1 = colscaleExp[rowVec.
index(j)];
511 assert(i < lp.
nRows());
515 const SVector& rowVec = lp.LPRowSet::rowVector(i);
520 int exp2 = rowscaleExp[i];
522 for(
int j = 0; j < rowVec.
size(); j++ )
524 exp1 = colscaleExp[rowVec.
index(j)];
538 assert(i < lp.
nRows());
541 if( lp.LPRowSet::rhs(i) <
infinity )
544 return spxLdexp(lp.LPRowSet::rhs(i) , -rowscaleExp[i]);
547 return lp.LPRowSet::rhs(i);
555 assert(lp.LPRowSet::rhs().dim() == vec.
dim());
557 for(
int i = 0; i < lp.LPRowSet::rhs().dim(); i++)
560 vec[i] =
spxLdexp(lp.LPRowSet::rhs()[i], -rowscaleExp[i]);
569 assert(i < lp.
nRows());
572 if( lp.LPRowSet::lhs(i) > -
infinity )
575 return spxLdexp(lp.LPRowSet::lhs(i) , -rowscaleExp[i]);
578 return lp.LPRowSet::lhs(i);
585 assert(lp.LPRowSet::lhs().dim() == vec.
dim());
589 for(
int i = 0; i < lp.LPRowSet::lhs().dim(); i++)
590 vec[i] =
spxLdexp(lp.LPRowSet::lhs()[i], -rowscaleExp[i]);
597 assert(row < lp.
nRows());
598 assert(col < lp.
nCols());
612 assert(x.
dim() == colscaleExp.size());
614 for(
int j = 0; j < x.
dim(); ++j )
615 x[j] =
spxLdexp(x[j], colscaleExp[j]);
624 assert(s.
dim() == rowscaleExp.size());
626 for(
int i = 0; i < s.
dim(); ++i )
627 s[i] =
spxLdexp(s[i], -rowscaleExp[i]);
636 assert(pi.
dim() == rowscaleExp.size());
638 for(
int i = 0; i < pi.
dim(); ++i )
639 pi[i] =
spxLdexp(pi[i], rowscaleExp[i]);
648 assert(r.
dim() == colscaleExp.size());
650 for(
int j = 0; j < r.
dim(); ++j )
651 r[j] =
spxLdexp(r[j], -colscaleExp[j]);
660 assert(ray.
dim() == colscaleExp.size());
662 for(
int j = 0; j < ray.
dim(); ++j )
663 ray[j] =
spxLdexp(ray[j], colscaleExp[j]);
672 assert(ray.
dim() == rowscaleExp.size());
674 for(
int i = 0; i < ray.
dim(); ++i )
675 ray[i] =
spxLdexp(ray[i], rowscaleExp[i]);
684 for(
int i = 0; i < origObj.
dim(); ++i )
686 origObj[i] =
spxLdexp(origObj[i], colscaleExp[i]);
693 assert(i < lp.
nCols());
697 int exp = colscaleExp[i];
705 assert(col < lp.
nCols());
707 assert(row < lp.
nRows());
713 return spxLdexp(val, colscaleExp[col] + rowscaleExp[row]);
719 assert(col < lp.
nCols());
724 return spxLdexp(lower, -colscaleExp[col]);
730 assert(col < lp.
nCols());
735 return spxLdexp(upper, -colscaleExp[col]);
741 assert(row < lp.
nRows());
746 return spxLdexp(lhs, rowscaleExp[row]);
752 assert(row < lp.
nRows());
757 return spxLdexp(rhs, rowscaleExp[row]);
766 for(
int i = 0; i < colscaleExp.
size(); ++i )
779 for(
int i = 0; i < colscaleExp.
size(); ++i )
791 int mini = std::numeric_limits<int>::max();
793 for(
int i = 0; i < rowscaleExp.
size(); ++i )
794 if( rowscaleExp[i] < mini )
795 mini = rowscaleExp[i];
804 int maxi = std::numeric_limits<int>::min();
806 for(
int i = 0; i < rowscaleExp.
size(); ++i )
807 if( rowscaleExp[i] > maxi )
808 maxi = rowscaleExp[i];
822 for(
int i = 0; i < lp.
nCols(); ++i )
828 for(
int j = 0; j < vec.
size(); ++j)
843 Real p = maxi / mini;
860 for(
int i = 0; i < lp.
nRows(); ++i )
866 for(
int j = 0; j < vec.
size(); ++j)
881 Real p = maxi / mini;
891 assert(vec.size() == unsigned(vecExp.
size()));
893 for(
unsigned i = 0; i < vec.size(); ++i )
895 frexp(vec[i], &(vecExp[
int(i)]));
902 #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.