44 assert(psccurr != NULL);
45 assert(pscprev != NULL);
46 assert(qcurr * qprev != 0.0);
48 Real fac = -(eprev1 * eprev2);
61 *pscprev *= 1.0 / (qcurr * qprev);
82 assert(psccurr != NULL);
83 assert(pscprev != NULL);
85 Real fac = -(eprev1 * eprev2);
110 assert(qcurr != 0.0);
121 resvec *= (-1.0 / qcurr);
133 assert(vecset != NULL);
135 const int nvec = vecset->
num();
137 for(
int k = 0; k < nvec; ++k)
142 const SVector& lpvec = (*vecset)[k];
143 const int size = lpvec.
size();
145 for(
int i = 0; i < size; ++i)
151 logsum += log2(
double(
spxAbs(a)));
169 veclogs.
add(k, logsum);
170 vecnnzinv.
add(k, nnzinv);
175 for(
int i = 0; i < size; ++i)
191 return "Least squares";
215 assert(param >= 1.0);
232 const int nrows = lp.
nRows();
233 const int ncols = lp.
nCols();
234 const int lpnnz = lp.
nNzos();
241 SVSet facnrows(nrows, nrows, 1.1, 1.2);
242 SVSet facncols(ncols, ncols, 1.1, 1.2);
293 std::array<Real, 3> eprev;
313 rowscale2 = rowscale1;
322 const Real sprev = scurr;
329 updateScale(rownnzinv, resnrows, tmprows, rsccurr, rscprev, qcurr, qprev, eprev[1], eprev[2]);
331 updateRes(facncols, resncols, resnrows, tmprows, eprev[0], qcurr);
337 updateScale(colnnzinv, resncols, tmpcols, csccurr, cscprev, qcurr, qprev, eprev[1], eprev[2]);
339 updateRes(facnrows, resnrows, resncols, tmpcols, eprev[0], qcurr);
344 for(
unsigned l = 2; l > 0; --l)
345 eprev[l] = eprev[l - 1];
347 eprev[0] = (qcurr * scurr) / sprev;
349 const Real tmp = qcurr;
350 qcurr = 1.0 - eprev[0];
362 updateScaleFinal(colnnzinv, resncols, tmpcols, csccurr, cscprev, qprev, eprev[1], eprev[2]);
367 updateScaleFinal(rownnzinv, resnrows, tmprows, rsccurr, rscprev, qprev, eprev[1], eprev[2]);
372 const SSVector& rowscale = *rsccurr;
373 const SSVector& colscale = *csccurr;
378 for(k = 0; k < nrows; ++k)
379 rowscaleExp[k] = -
int(rowscale[k] + ((rowscale[k] >= 0.0) ? (+0.5) : (-0.5)));
381 for(k = 0; k < ncols; ++k)
382 colscaleExp[k] = -
int(colscale[k] + ((colscale[k] >= 0.0) ? (+0.5) : (-0.5)));
Rational spxAbs(const Rational &r)
Absolute.
virtual void setup(SPxLPBase< Real > &lp)
clear and setup scaling arrays in the LP
bool isSetup() const
Returns setup status.
virtual R minAbsNzo(bool unscaled=true) const
Absolute smallest non-zero element in (possibly scaled) LP.
static const char * makename(bool doBoth)
int size() const
Number of used indices.
static void updateRes(const SVSet facset, const SSVector resvecprev, SSVector &resvec, SSVector &tmpvec, Real eprev, Real qcurr)
Least squares scaling.This SPxScaler implementation performs least squares scaling as suggested by Cu...
virtual Real maxRowRatio(const SPxLPBase< Real > &lp) const
maximum ratio between absolute biggest and smallest element in any row.
SVectorBase< R > * create(int idxmax=0)
Creates new SVectorBase in set.
R & value(int n)
Reference to value of n 'th nonzero.
SPxLeastSqSC()
default constructor (this scaler makes no use of inherited member m_colFirst)
static void updateScale(const SSVector vecnnzeroes, const SSVector resnvec, SSVector &tmpvec, SSVector *&psccurr, SSVector *&pscprev, Real qcurr, Real qprev, Real eprev1, Real eprev2)
Wrapper for different output streams and verbosity levels.
int nRows() const
Returns number of rows in LP.
DataArray< int > * m_activeColscaleExp
pointer to currently active column scaling factors
int nNzos() const
Returns number of nonzeros in LP.
virtual void applyScaling(SPxLPBase< Real > &lp)
applies m_colscale and m_rowscale to the lp.
virtual void scale(SPxLP &lp, bool persistent=true)
Scale the loaded SPxLP.
static void initConstVecs(const SVSet *vecset, SVSet &facset, SSVector &veclogs, SSVector &vecnnzinv)
SPxOut * spxout
message handler
int & index(int n)
Reference to index of n 'th nonzero.
#define MSG_INFO2(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO2.
void clear()
Clears vector.
virtual Real maxAbsColscale() const
absolute biggest column scaling factor
virtual Real minAbsColscale() const
absolute smallest column scaling factor
virtual void setIntParam(int param, const char *name)
set int param (maximal conjugate gradient rounds)
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
DataArray< int > * m_activeRowscaleExp
pointer to currently active row scaling factors
void add(int i, const R &v)
Append one nonzero (i,v).
virtual Real minAbsRowscale() const
absolute smallest row scaling factor
LP least squares scaling.
Collection of dense, sparse, and semi-sparse vectors.
static void updateScaleFinal(const SSVector vecnnzeroes, const SSVector resnvec, SSVector &tmpvec, SSVector *&psccurr, SSVector *&pscprev, Real q, Real eprev1, Real eprev2)
Everything should be within this namespace.
SPxLeastSqSC & operator=(const SPxLeastSqSC &)
assignment operator
void setup()
Initializes nonzero indices for elements with absolute values above epsilon and sets all other elemen...
virtual void setRealParam(Real param, const char *name)
set real param (conjugate gradient accuracy)
LP scaler abstract base class.Instances of classes derived from SPxScaler may be loaded to SoPlex in ...
void sort()
Sort nonzeros to increasing indices.
virtual Real maxAbsRowscale() const
absolute biggest row scaling factor
#define MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO1.
int nCols() const
Returns number of columns in LP.
SSVectorBase< R > & assignPWproduct4setup(const SSVectorBase< S > &x, const SSVectorBase< T > &y)
Assigns pair wise vector product to SSVectorBase.
const SVSetBase< R > * colSet() const
Returns the complete SVSetBase.
bool isZero(Real a, Real eps=Param::epsilon())
returns true iff |a| <= eps
virtual Real maxColRatio(const SPxLPBase< Real > &lp) const
maximum ratio between absolute biggest and smallest element in any column.
const SVSetBase< R > * rowSet() const
Returns the complete SVSet.
void add(int i, R x)
Adds nonzero (i, x) to SSVectorBase.
int num() const
Current number of SVectorBases.
virtual R maxAbsNzo(bool unscaled=true) const
Absolute biggest non-zero element in (in rational case possibly scaled) LP.
SPxScaler & operator=(const SPxScaler &)
assignment operator
SSVectorBase< R > & assign2product4setup(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assigns SSVectorBase to for a setup x.