Scippy

SoPlex

Sequential object-oriented simPlex

Simplex basis.Consider the linear program as provided from class SPxLP:

\[ \begin{array}{rl} \hbox{max} & c^T x \\ \hbox{s.t.} & l_r \le Ax \le u_r \\ & l_c \le x \le u_c \end{array} \]

where $c, l_c, u_c, x \in {\bf R}^n$, $l_r, u_r \in {\bf R}^m$ and $A \in {\bf R}^{m \times n}$. Solving this LP with the simplex algorithm requires the definition of a basis. Such can be defined as a set of column vectors or a set of row vectors building a nonsingular matrix. We will refer to the first case as the columnwise representation and the latter case will be called the rowwise representation. In both cases, a basis is a set of vectors forming a nonsigular matrix. The dimension of the vectors is refered to as the basis' dimension, whereas the number of vectors belonging to the LP is called the basis' codimension. More...

#include <spxbasis.h>

Inheritance diagram for SPxBasis:

Classes

class  Desc
 Basis descriptor. More...
 

Public Types

enum  SPxStatus {
  NO_PROBLEM = -2, SINGULAR = -1, REGULAR = 0, DUAL = 1,
  PRIMAL = 2, OPTIMAL = 3, UNBOUNDED = 4, INFEASIBLE = 5
}
 basis status. More...
 

Public Member Functions

Status and Descriptor related Methods
SPxStatus status () const
 returns current SPxStatus. More...
 
void setStatus (SPxStatus stat)
 sets basis SPxStatus to stat. More...
 
void setMaxUpdates (int maxUp)
 change maximum number of iterations until a refactorization is performed More...
 
int getMaxUpdates () const
 returns maximum number of updates before a refactorization is performed More...
 
const Descdesc () const
 
Descdesc ()
 returns current basis Descriptor. More...
 
Desc::Status dualColStatus (int i) const
 dual Status for the i'th column variable of the loaded LP. More...
 
Desc::Status dualStatus (const SPxColId &id) const
 dual Status for the column variable with ID id of the loaded LP. More...
 
Desc::Status dualRowStatus (int i) const
 dual Status for the i'th row variable of the loaded LP. More...
 
Desc::Status dualStatus (const SPxRowId &id) const
 dual Status for the row variable with ID id of the loaded LP. More...
 
Desc::Status dualStatus (const SPxId &id) const
 dual Status for the variable with ID id of the loaded LP. More...
 
Inquiry Methods
SPxIdbaseId (int i)
 
SPxId baseId (int i) const
 returns the Id of the i'th basis vector. More...
 
const SVectorbaseVec (int i) const
 returns the i'th basic vector. More...
 
SPxId lastEntered () const
 returns SPxId of last vector included to the basis. More...
 
SPxId lastLeft () const
 returns SPxId of last vector that left the basis. More...
 
int lastIndex () const
 returns index in basis where last update was done. More...
 
int lastUpdate () const
 returns number of basis changes since last refactorization. More...
 
int iteration () const
 returns number of basis changes since last load(). More...
 
SPxSolversolver () const
 returns loaded solver. More...
 
Linear Algebra
VectormultBaseWith (Vector &x) const
 Basis-vector product. More...
 
void multBaseWith (SSVector &x, SSVector &result) const
 Basis-vector product. More...
 
VectormultWithBase (Vector &x) const
 Vector-basis product. More...
 
void multWithBase (SSVector &x, SSVector &result) const
 Vector-basis product. More...
 
Real condition (int maxiters=10, Real tolerance=1e-6)
 
Real getEstimatedCondition ()
 
Real getExactCondition ()
 
Real stability () const
 returns the stability of the basis matrix. More...
 
void solve (Vector &x, const Vector &rhs)
 
void solve (SSVector &x, const SVector &rhs)
 
void solve4update (SSVector &x, const SVector &rhs)
 solves linear system with basis matrix. More...
 
void solve4update (SSVector &x, Vector &y, const SVector &rhsx, SSVector &rhsy)
 solves two systems in one call. More...
 
void solve4update (SSVector &x, SSVector &y, const SVector &rhsx, SSVector &rhsy)
 solves two systems in one call using only sparse data structures More...
 
void solve4update (SSVector &x, Vector &y, Vector &y2, const SVector &rhsx, SSVector &rhsy, SSVector &rhsy2)
 solves three systems in one call. More...
 
void solve4update (SSVector &x, SSVector &y, SSVector &y2, const SVector &rhsx, SSVector &rhsy, SSVector &rhsy2)
 solves three systems in one call using only sparse data structures More...
 
void coSolve (Vector &x, const Vector &rhs)
 Cosolves linear system with basis matrix. More...
 
void coSolve (SSVector &x, const SVector &rhs)
 Sparse version of coSolve. More...
 
void coSolve (SSVector &x, Vector &y, const SVector &rhsx, SSVector &rhsy)
 solves two systems in one call. More...
 
void coSolve (SSVector &x, SSVector &y, const SVector &rhsx, SSVector &rhsy)
 Sparse version of solving two systems in one call. More...
 
void coSolve (SSVector &x, Vector &y, Vector &z, const SVector &rhsx, SSVector &rhsy, SSVector &rhsz)
 solves three systems in one call. May be improved by using just one pass through the basis. More...
 
void coSolve (SSVector &x, SSVector &y, SSVector &z, const SVector &rhsx, SSVector &rhsy, SSVector &rhsz)
 Sparse version of solving three systems in one call. More...
 
Modification notification.

These methods must be called after the loaded LP has been modified.

void addedRows (int n)
 inform SPxBasis, that n new rows had been added. More...
 
void removedRow (int i)
 inform SPxBasis that row i had been removed. More...
 
void removedRows (const int perm[])
 inform SPxBasis that rows in perm with negative entry were removed. More...
 
void addedCols (int n)
 inform SPxBasis that n new columns had been added. More...
 
void removedCol (int i)
 inform SPxBasis that column i had been removed. More...
 
void removedCols (const int perm[])
 inform SPxBasis that columns in perm with negative entry were removed. More...
 
void changedRow (int)
 inform SPxBasis that a row had been changed. More...
 
void changedCol (int)
 inform SPxBasis that a column had been changed. More...
 
void changedElement (int, int)
 inform SPxBasis that a matrix entry had been changed. More...
 
Miscellaneous
virtual void change (int i, SPxId &id, const SVector *enterVec, const SSVector *eta=0)
 performs basis update. More...
 
virtual bool readBasis (std::istream &in, const NameSet *rowNames, const NameSet *colNames)
 
virtual void writeBasis (std::ostream &os, const NameSet *rownames, const NameSet *colnames, const bool cpxFormat=false) const
 
virtual void printMatrix () const
 
void printMatrixMTX (int number)
 
virtual bool isDescValid (const Desc &ds)
 checks if a Descriptor is valid for the current LP w.r.t. its bounds More...
 
virtual void loadDesc (const Desc &)
 sets up basis. More...
 
virtual void loadSolver (SLinSolver *solver, const bool destroy=false)
 sets up linear solver to use. More...
 
virtual void load (SPxSolver *lp)
 loads the LP lp to the basis. More...
 
virtual void unLoad ()
 unloads the LP from the basis. More...
 
void invalidate ()
 invalidates actual basis. More...
 
void restoreInitialBasis ()
 Restores initial basis. More...
 
void dump ()
 output basis entries. More...
 
bool isConsistent () const
 consistency check. More...
 
Real getTotalUpdateTime () const
 time spent in updates More...
 
int getTotalUpdateCount () const
 number of updates performed More...
 
std::string statistics () const
 returns statistical information in form of a string. More...
 
void setOutstream (SPxOut &newOutstream)
 
Constructors / Destructors
 SPxBasis (Timer::TYPE ttype=Timer::USER_TIME)
 default constructor. More...
 
 SPxBasis (const SPxBasis &old)
 copy constructor More...
 
SPxBasisoperator= (const SPxBasis &rhs)
 assignment operator More...
 
virtual ~SPxBasis ()
 destructor. More...
 

Protected Member Functions

Protected helpers
void loadMatrixVecs ()
 loads matrix according to the SPxIds stored in theBaseId. More...
 
void reDim ()
 resizes internal arrays. More...
 
virtual void factorize ()
 factorizes the basis matrix. More...
 
void setRep ()
 sets descriptor representation according to loaded LP. More...
 

Protected Attributes

SPxSolvertheLP
 the LP More...
 
DataArray< SPxIdtheBaseId
 SPxIds of basic vectors. More...
 
DataArray< const SVector * > matrix
 pointers to the vectors of the basis matrix. More...
 
bool matrixIsSetup
 true iff the pointers in matrix are set up correctly. More...
 
SLinSolverfactor
 
bool factorized
 true iff factor = matrix $^{-1}$. More...
 
int maxUpdates
 number of updates before refactorization. More...
 
Real nonzeroFactor
 allowed increase of nonzeros before refactorization. More...
 
Real fillFactor
 allowed increase in realtive fill before refactorization More...
 
int iterCount
 number of calls to change() since last manipulation More...
 
int updateCount
 number of calls to change() since last factorize() More...
 
int totalUpdateCount
 number of updates More...
 
int nzCount
 number of nonzeros in basis matrix More...
 
int lastMem
 memory needed after last fresh factorization More...
 
Real lastFill
 fill ratio that occured during last factorization More...
 
int lastNzCount
 number of nonzeros in basis matrix after last fresh factorization More...
 
TimertheTime
 time spent in updates More...
 
Timer::TYPE timerType
 type of timer (user or wallclock) More...
 
SPxId lastin
 lastEntered(): variable entered the base last More...
 
SPxId lastout
 lastLeft(): variable left the base last More...
 
int lastidx
 lastIndex(): basis index where last update was done More...
 
Real minStab
 minimum stability More...
 

Private Attributes

SPxStatus thestatus
 current status of the basis. More...
 
Desc thedesc
 the basis' Descriptor More...
 
bool freeSlinSolver
 true iff factor should be freed inside of this object More...
 
SPxOutspxout
 message handler More...
 

Detailed Description

Simplex basis.

Consider the linear program as provided from class SPxLP:

\[ \begin{array}{rl} \hbox{max} & c^T x \\ \hbox{s.t.} & l_r \le Ax \le u_r \\ & l_c \le x \le u_c \end{array} \]

where $c, l_c, u_c, x \in {\bf R}^n$, $l_r, u_r \in {\bf R}^m$ and $A \in {\bf R}^{m \times n}$. Solving this LP with the simplex algorithm requires the definition of a basis. Such can be defined as a set of column vectors or a set of row vectors building a nonsingular matrix. We will refer to the first case as the columnwise representation and the latter case will be called the rowwise representation. In both cases, a basis is a set of vectors forming a nonsigular matrix. The dimension of the vectors is refered to as the basis' dimension, whereas the number of vectors belonging to the LP is called the basis' codimension.

Class SPxBasis is designed to represent a generic simplex basis, suitable for both representations. At any time the representation can be changed by calling method setRep().

Class SPxBasis provides methods for solving linear systems with the basis matrix. However, SPxBasis does not provide a linear solver by its own. Instead, a SLinSolver object must be loaded to a SPxBasis which will be called for solving linear systems.

Definition at line 82 of file spxbasis.h.

Member Enumeration Documentation

enum SPxStatus

basis status.

Each SPxBasis is assigned a status flag, which can take on of the above values.

Enumerator
NO_PROBLEM 

No Problem has been loaded to the basis.

SINGULAR 

Basis is singular.

REGULAR 

Basis is not known to be dual nor primal feasible.

DUAL 

Basis is dual feasible.

PRIMAL 

Basis is primal feasible.

OPTIMAL 

Basis is optimal, i.e. dual and primal feasible.

UNBOUNDED 

LP has been proven to be primal unbounded.

INFEASIBLE 

LP has been proven to be primal infeasible.

Definition at line 90 of file spxbasis.h.

Constructor & Destructor Documentation

default constructor.

Definition at line 1142 of file spxbasis.cpp.

References TimerFactory::createTimer(), SPxBasis::theTime, and SPxBasis::timerType.

SPxBasis ( const SPxBasis old)

copy constructor

Warning
Do not change the LP object. Only pointer to that object is copied. Hint: no problem, we use this function for copy constructor of SPxSolver

Definition at line 1175 of file spxbasis.cpp.

References SLinSolver::clone(), SPxBasis::factor, SPxBasis::freeSlinSolver, and SPxBasis::isConsistent().

~SPxBasis ( )
virtual

destructor.

Definition at line 1209 of file spxbasis.cpp.

References SPxBasis::factor, SPxBasis::freeSlinSolver, soplex::spx_free(), and SPxBasis::theTime.

Referenced by SPxBasis::setOutstream().

Member Function Documentation

SPxId baseId ( int  i) const

returns the Id of the i'th basis vector.

Definition at line 502 of file spxbasis.h.

const SVector& baseVec ( int  i) const

returns the i'th basic vector.

Definition at line 508 of file spxbasis.h.

Referenced by SPxSolver::enter(), SPxSolver::leave(), and SPxBasis::printMatrixMTX().

void change ( int  i,
SPxId id,
const SVector enterVec,
const SSVector eta = 0 
)
virtual

performs basis update.

Changes the i 'th vector of the basis with the vector associated to id. This includes:

The basis descriptor is not modified, since factor() cannot know about how to set up the status of the involved variables correctly.

A vector enterVec may be passed for a fast ETA update of the LU factorization associated to the basis. It must be initialized with the solution vector $x$ of the right linear system $Bx = b$ with the entering vector as right-hand side vector $b$, where $B$ denotes the basis matrix. This can be computed using method solve(). When using FAST updates, a vector eta may be passed for improved performance. It must be initialized by a call to factor->solveRightUpdate() as described in SLinSolver. The implementation hidden behind FAST updates depends on the SLinSolver implementation class.

Definition at line 715 of file spxbasis.cpp.

References SLinSolver::change(), SPxBasis::factor, SPxBasis::factorize(), SPxBasis::factorized, SPxBasis::iterCount, SPxBasis::lastFill, SPxBasis::lastidx, SPxBasis::lastin, SPxBasis::lastNzCount, SPxBasis::lastout, SPxBasis::matrix, SPxBasis::matrixIsSetup, SPxBasis::maxUpdates, SLinSolver::memory(), SPxBasis::minStab, MSG_INFO3, SPxBasis::nonzeroFactor, SPxBasis::nzCount, SLinSolver::OK, SPxBasis::REGULAR, SVectorBase< R >::size(), SPxBasis::spxout, SLinSolver::stability(), Timer::start(), SLinSolver::status(), SPxBasis::status(), Timer::stop(), SPxBasis::theBaseId, SPxBasis::theTime, SPxBasis::totalUpdateCount, and SPxBasis::updateCount.

Referenced by SPxBasis::coSolve(), SPxSolver::enter(), and SPxSolver::leave().

void changedCol ( int  )

inform SPxBasis that a column had been changed.

Todo:
is this correctly implemented?

Definition at line 474 of file spxchangebasis.cpp.

References SPxBasis::invalidate(), and SPxBasis::restoreInitialBasis().

Referenced by SPxSolver::changeCol(), and SPxBasis::coSolve().

void changedElement ( int  ,
int   
)

inform SPxBasis that a matrix entry had been changed.

Todo:
is this correctly implemented?

Definition at line 482 of file spxchangebasis.cpp.

References SPxBasis::invalidate(), and SPxBasis::restoreInitialBasis().

Referenced by SPxSolver::changeElement(), and SPxBasis::coSolve().

void changedRow ( int  )

inform SPxBasis that a row had been changed.

Todo:
Implement changedRow(), changedCol(), changedElement() in a more clever way. For instance, the basis won't be singular (but maybe infeasible) if the change doesn't affect the basis rows/columns.

The following methods (changedRow(), changedCol(), changedElement()) radically change the current basis to the original (slack) basis also present after loading the LP. The reason is that through the changes, the current basis may become singular. Going back to the initial basis is quite inefficient, but correct.

Todo:
is this correctly implemented?

Definition at line 466 of file spxchangebasis.cpp.

References SPxBasis::invalidate(), and SPxBasis::restoreInitialBasis().

Referenced by SPxSolver::changeRow(), and SPxBasis::coSolve().

void coSolve ( Vector x,
const Vector rhs 
)

Cosolves linear system with basis matrix.

Depending on the representation, for a SPxBasis B, B.coSolve(x) computes

  • $x \leftarrow rhs^TB^{-1}$ in the columnwise case and
  • $x \leftarrow B^{-1}rhs$ in the rowwise case.

Both can be seen uniformly as solving a linear system with the basis matrix B and a right handside vector x aligned the same way as the covectors of B.

Definition at line 678 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solveLeft().

Referenced by SPxSolver::addedRows(), SPxSolver::enter(), SPxSolver::factorize(), SoPlex::getBasisInverseColReal(), SoPlex::getBasisInverseRowReal(), SoPlex::getBasisInverseTimesVecReal(), SPxSolver::init(), SPxSteepPR::isConsistent(), SPxSolver::leave(), SPxSolver::reinitializeVecs(), SPxSteepPR::selectLeave(), SPxSteepPR::setupWeights(), SPxSolver::terminate(), and SPxSolver::testVecs().

void coSolve ( SSVector x,
const SVector rhs 
)

Sparse version of coSolve.

Definition at line 685 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solveLeft().

void coSolve ( SSVector x,
Vector y,
const SVector rhsx,
SSVector rhsy 
)

solves two systems in one call.

Definition at line 692 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solveLeft().

void coSolve ( SSVector x,
SSVector y,
const SVector rhsx,
SSVector rhsy 
)

Sparse version of solving two systems in one call.

Definition at line 699 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solveLeft().

void coSolve ( SSVector x,
Vector y,
Vector z,
const SVector rhsx,
SSVector rhsy,
SSVector rhsz 
)

solves three systems in one call. May be improved by using just one pass through the basis.

Definition at line 706 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solveLeft().

Desc& desc ( )

returns current basis Descriptor.

Definition at line 462 of file spxbasis.h.

References SPxBasis::dualColStatus(), SPxBasis::dualRowStatus(), SPxBasis::dualStatus(), and SPxBasis::thedesc.

SPxBasis::Desc::Status dualStatus ( const SPxColId id) const

dual Status for the column variable with ID id of the loaded LP.

Definition at line 34 of file spxbasis.cpp.

References SPxBasis::dualColStatus(), and SPxBasis::theLP.

Referenced by SPxBasis::desc(), SPxBasis::dualStatus(), SPxBoundFlippingRT::getData(), SPxFastRT::maxReLeave(), SPxFastRT::minReLeave(), SPxSolver::perturbMax(), and SPxSolver::perturbMin().

SPxBasis::Desc::Status dualStatus ( const SPxRowId id) const

dual Status for the row variable with ID id of the loaded LP.

Definition at line 40 of file spxbasis.cpp.

References SPxBasis::dualRowStatus(), and SPxBasis::theLP.

Desc::Status dualStatus ( const SPxId id) const

dual Status for the variable with ID id of the loaded LP.

It is automatically detected, whether the id is one of a row or a column variable, and the correct row or column status is returned.

Definition at line 484 of file spxbasis.h.

References SPxBasis::dualStatus().

Real getEstimatedCondition ( )

Definition at line 588 of file spxbasis.h.

References SPxBasis::condition().

Referenced by SoPlex::getEstimatedCondition().

Real getExactCondition ( )

Definition at line 594 of file spxbasis.h.

References SPxBasis::condition().

Referenced by SoPlex::getExactCondition().

int getMaxUpdates ( ) const

returns maximum number of updates before a refactorization is performed

Definition at line 451 of file spxbasis.h.

References SPxBasis::maxUpdates.

Referenced by SPxSolver::writeState().

int getTotalUpdateCount ( ) const

number of updates performed

Definition at line 853 of file spxbasis.h.

References SPxBasis::totalUpdateCount.

Referenced by SPxBasis::statistics().

Real getTotalUpdateTime ( ) const

time spent in updates

Definition at line 848 of file spxbasis.h.

References Timer::time().

Referenced by SPxBasis::statistics().

void invalidate ( )

invalidates actual basis.

This method makes the basis matrix and vectors invalid. The basis will be reinitialized if needed.

Todo:
is this correctly implemented?

Definition at line 398 of file spxchangebasis.cpp.

References SPxBasis::factorized, SPxBasis::matrixIsSetup, MSG_INFO3, and SPxBasis::spxout.

Referenced by SPxBasis::changedCol(), SPxBasis::changedElement(), SPxBasis::changedRow(), SPxBasis::setStatus(), and SPxBasis::unLoad().

SPxId lastEntered ( ) const

returns SPxId of last vector included to the basis.

Definition at line 515 of file spxbasis.h.

References SPxBasis::lastin.

Referenced by SPxSolver::solve().

int lastIndex ( ) const

returns index in basis where last update was done.

Definition at line 527 of file spxbasis.h.

References SPxBasis::lastidx.

Referenced by SPxSolver::solve().

SPxId lastLeft ( ) const

returns SPxId of last vector that left the basis.

Definition at line 521 of file spxbasis.h.

References SPxBasis::lastout.

Referenced by SPxSolver::solve().

int lastUpdate ( ) const
void load ( SPxSolver lp)
virtual

loads the LP lp to the basis.

This involves resetting all counters to 0 and setting up a regular default basis consisting of slacks, artificial variables or bounds.

Definition at line 305 of file spxbasis.cpp.

References SPxBasis::loadDesc(), SPxBasis::restoreInitialBasis(), SPxBasis::setOutstream(), SPxBasis::setRep(), SPxSolver::spxout, SPxBasis::thedesc, and SPxBasis::theLP.

Referenced by SPxBasis::coSolve(), SPxSolver::init(), SPxSolver::loadBasis(), SPxSolver::loadLP(), SPxBasis::readBasis(), SPxSolver::setBasis(), SPxSolver::setType(), and SPxSolver::solve().

void loadMatrixVecs ( )
protected

loads matrix according to the SPxIds stored in theBaseId.

This method must be called whenever there is a chance, that the vector pointers may have changed due to manipulations of the LP.

Definition at line 91 of file spxbasis.cpp.

References SPxBasis::baseId(), SLinSolver::clear(), SPxSolver::dim(), SPxBasis::factor, SPxBasis::factorized, SPxBasis::matrix, SPxBasis::matrixIsSetup, MSG_INFO3, SPxBasis::nzCount, SPxBasis::spxout, SPxBasis::theLP, and SPxSolver::vector().

Referenced by SPxBasis::addedCols(), SPxBasis::addedRows(), SPxBasis::restoreInitialBasis(), and SPxBasis::setOutstream().

void loadSolver ( SLinSolver solver,
const bool  destroy = false 
)
virtual

sets up linear solver to use.

If destroy is true, solver will be freed inside this object, e.g. in the destructor.

Definition at line 319 of file spxbasis.cpp.

References SLinSolver::clear(), SPxBasis::factor, SPxBasis::factorized, SPxBasis::freeSlinSolver, MSG_INFO3, SPxBasis::setOutstream(), SLinSolver::spxout, and SPxBasis::spxout.

Referenced by SPxBasis::coSolve(), and SPxSolver::setSolver().

Vector & multBaseWith ( Vector x) const

Basis-vector product.

Depending on the representation, for an SPxBasis B, B.multBaseWith(x) computes

  • $x \leftarrow Bx$ in the columnwise case, and
  • $x \leftarrow x^TB$ in the rowwise case.

Both can be seen uniformly as multiplying the basis matrix B with a vector x aligned the same way as the vectors of B.

Definition at line 931 of file spxbasis.cpp.

References VectorBase< R >::clear(), VectorBase< R >::dim(), SPxSolver::dim(), SPxBasis::matrix, SPxBasis::matrixIsSetup, VectorBase< R >::multAdd(), SPxBasis::SINGULAR, SPxBasis::status(), SPxBasis::thedesc, and SPxBasis::theLP.

Referenced by SPxBasis::condition(), SPxSolver::enter(), SPxSolver::factorize(), SPxSolver::leave(), SPxBasis::solver(), and SPxSolver::testVecs().

Vector & multWithBase ( Vector x) const

Vector-basis product.

Depending on the representation, for a SPxBasis B, B.multWithBase(x) computes

  • $x \leftarrow x^TB$ in the columnwise case and
  • $x \leftarrow Bx$ in the rowwise case.

Both can be seen uniformly as multiplying the basis matrix B with a vector x aligned the same way as the covectors of B.

Definition at line 894 of file spxbasis.cpp.

References VectorBase< R >::dim(), SPxSolver::dim(), SPxBasis::matrix, SPxBasis::matrixIsSetup, SPxBasis::SINGULAR, SPxBasis::status(), SPxBasis::thedesc, and SPxBasis::theLP.

Referenced by SPxBasis::condition(), SPxSolver::factorize(), SPxBasis::solver(), and SPxSolver::testVecs().

void printMatrix ( ) const
virtual

Definition at line 673 of file spxbasis.cpp.

References SPxBasis::matrix, and SPxBasis::matrixIsSetup.

Referenced by SPxBasis::coSolve().

void printMatrixMTX ( int  number)

Prints current basis matrix to a file using the MatrixMarket format: row col value The filename is basis/basis[number].mtx where number is a parameter.

Definition at line 684 of file spxbasis.cpp.

References SPxBasis::baseVec(), SVectorBase< R >::index(), SPxBasis::matrix, SPxBasis::nzCount, REAL_FORMAT, SVectorBase< R >::size(), and SVectorBase< R >::value().

Referenced by SPxBasis::coSolve().

bool readBasis ( std::istream &  is,
const NameSet rowNames,
const NameSet colNames 
)
virtual

Load basis from in in MPS format. If rowNames and colNames are NULL, default names are used for the constraints and variables.

The specification is taken from the

ILOG CPLEX 7.0 Reference Manual, Appendix E, Page 543.

This routine should read valid BAS format files.

Returns
true if the file was read correctly.

Here is a very brief outline of the format:

The format is in a form similar to an MPS file. The basic assumption is that all (column) variables are nonbasic at their lower bound and all row (variables) are basic; only the differences to this rule are given. Each data line contains an indicator, a variable name and possibly a row/constraint name. The following meaning applies with respect to the indicators:

  • XU: the variable is basic, the row is nonbasic at its upper bound
  • XL: the variable is basic, the row is nonbasic at its lower bound
  • UL: the variable is nonbasic and at its upper bound
  • LL: the variable is nonbasic and at its lower bound

The CPLEX format contains an additional indicator 'BS', but this is unsupported here.

Nonbasic variables without lower bound have the following default status for SoPlex:

  • at their upper bound if finite,
  • at zero if free.

Definition at line 372 of file spxbasis.cpp.

References NameSet::add(), SPxSolver::colId(), SPxBasis::Desc::colstat, SPxBasis::dualColStatus(), SPxBasis::dualRowStatus(), SPxBasis::Desc::dump(), MPSInput::ENDATA, LPRowBase< R >::EQUAL, MPSInput::field0(), MPSInput::field1(), MPSInput::field2(), MPSInput::field3(), LPRowBase< R >::GREATER_EQUAL, MPSInput::hasError(), soplex::infinity, LPRowBase< R >::LESS_EQUAL, SPxBasis::load(), SPxBasis::loadDesc(), MSG_DEBUG, SPxLPBase< R >::nCols(), SPxBasis::NO_PROBLEM, SPxLPBase< R >::nRows(), NameSet::number(), SPxBasis::Desc::P_FIXED, SPxBasis::Desc::P_FREE, SPxBasis::Desc::P_ON_LOWER, SPxBasis::Desc::P_ON_UPPER, MPSInput::readLine(), SPxBasis::REGULAR, NameSet::reMax(), SPxSolver::rowId(), SPxBasis::Desc::rowstat, MPSInput::section(), MPSInput::setSection(), SPxBasis::setStatus(), soplex::spx_alloc(), soplex::spx_free(), SPxBasis::status(), MPSInput::syntaxError(), SPxBasis::thedesc, SPxBasis::theLP, and NameSet::~NameSet().

Referenced by SPxBasis::coSolve(), and SPxSolver::readBasisFile().

void reDim ( )
protected

resizes internal arrays.

When a new LP is loaded, the basis matrix and vectors become invalid and possibly also of the wrong dimension. Hence, after loading an LP, reDim() is called to reset all arrays etc. accoriding to the dimensions of the loaded LP.

Definition at line 26 of file spxchangebasis.cpp.

References SPxSolver::dim(), SPxBasis::factorized, SPxBasis::matrix, SPxBasis::matrixIsSetup, MSG_DEBUG, MSG_INFO3, SPxLPBase< R >::nCols(), SPxLPBase< R >::nRows(), SPxBasis::Desc::reSize(), SPxBasis::spxout, SPxBasis::theBaseId, SPxBasis::thedesc, and SPxBasis::theLP.

Referenced by SPxBasis::addedCols(), SPxBasis::addedRows(), SPxSolver::clear(), SPxBasis::removedCol(), SPxBasis::removedCols(), SPxBasis::removedRow(), SPxBasis::removedRows(), SPxBasis::setOutstream(), and SPxBasis::setRep().

void restoreInitialBasis ( )

Restores initial basis.

This method changes the basis to that present just after loading the LP (see addedRows() and addedCols()). This may be necessary if a row or a column is changed, since then the current basis may become singular.

Create the initial slack basis descriptor and set up the basis matrix accordingly. This code has been adapted from SPxBasis::addedRows() and SPxBasis::addedCols().

Definition at line 415 of file spxchangebasis.cpp.

References SPxBasis::baseId(), SPxBasis::Desc::colStatus(), SPxSolver::COLUMN, SPxBasis::dualRowStatus(), SPxBasis::factorized, SPxBasis::loadMatrixVecs(), SPxBasis::matrixIsSetup, SPxLPBase< R >::nCols(), SPxBasis::NO_PROBLEM, SPxLPBase< R >::nRows(), soplex::primalColStatus(), SPxBasis::REGULAR, SPxSolver::rep(), SPxSolver::ROW, SPxBasis::Desc::rowStatus(), SPxBasis::setStatus(), SPxBasis::status(), SPxBasis::thedesc, and SPxBasis::theLP.

Referenced by SPxBasis::changedCol(), SPxBasis::changedElement(), SPxBasis::changedRow(), SPxBasis::load(), SPxBasis::loadDesc(), and SPxBasis::unLoad().

void setMaxUpdates ( int  maxUp)

change maximum number of iterations until a refactorization is performed

Definition at line 444 of file spxbasis.h.

Referenced by SoPlex::setIntParam().

void solve ( SSVector x,
const SVector rhs 
)

Definition at line 612 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solveRight().

void solve4update ( SSVector x,
const SVector rhs 
)

solves linear system with basis matrix.

Depending on the representation, for a SPxBasis B, B.solve(x) computes

  • $x \leftarrow B^{-1}rhs$ in the columnwise case and
  • $x \leftarrow rhs^TB^{-1}$ in the rowwise case.

Both can be seen uniformly as solving a linear system with the basis matrix B and a right handside vector x aligned the same way as the vectors of B.

Definition at line 628 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solveRight4update().

Referenced by SPxSolver::enter(), SPxSolver::leave(), and SPxSteepPR::selectEnter().

void solve4update ( SSVector x,
Vector y,
const SVector rhsx,
SSVector rhsy 
)

solves two systems in one call.

Definition at line 635 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solve2right4update().

void solve4update ( SSVector x,
SSVector y,
const SVector rhsx,
SSVector rhsy 
)

solves two systems in one call using only sparse data structures

Definition at line 642 of file spxbasis.h.

References SPxBasis::factorize(), and SLinSolver::solve2right4update().

void solve4update ( SSVector x,
Vector y,
Vector y2,
const SVector rhsx,
SSVector rhsy,
SSVector rhsy2 
)

solves three systems in one call.

Definition at line 649 of file spxbasis.h.

References SPxBasis::factorize(), SSVectorBase< R >::isSetup(), and SLinSolver::solve3right4update().

void solve4update ( SSVector x,
SSVector y,
SSVector y2,
const SVector rhsx,
SSVector rhsy,
SSVector rhsy2 
)

solves three systems in one call using only sparse data structures

Definition at line 659 of file spxbasis.h.

References SPxBasis::factorize(), SSVectorBase< R >::isSetup(), and SLinSolver::solve3right4update().

SPxSolver* solver ( ) const

returns loaded solver.

Definition at line 544 of file spxbasis.h.

References SPxBasis::condition(), SPxBasis::multBaseWith(), SPxBasis::multWithBase(), and SPxBasis::theLP.

Referenced by SPxBasis::coSolve(), and SPxSolver::init().

Real stability ( ) const

returns the stability of the basis matrix.

Definition at line 600 of file spxbasis.h.

References SLinSolver::stability().

Referenced by SPxFastRT::selectLeave().

std::string statistics ( ) const

returns statistical information in form of a string.

Definition at line 859 of file spxbasis.h.

References SPxBasis::getTotalUpdateCount(), SPxBasis::getTotalUpdateTime(), and SLinSolver::statistics().

SPxStatus status ( void  ) const

returns current SPxStatus.

Definition at line 419 of file spxbasis.h.

References SPxBasis::thestatus.

Referenced by SoPlex::_addColReal(), SoPlex::_addColsReal(), SoPlex::_addRowReal(), SoPlex::_addRowsReal(), SoPlex::_changeBoundsReal(), SoPlex::_changeColReal(), SoPlex::_changeElementReal(), SoPlex::_changeLhsReal(), SoPlex::_changeLowerReal(), SoPlex::_changeRangeReal(), SoPlex::_changeRhsReal(), SoPlex::_changeRowReal(), SoPlex::_changeUpperReal(), SoPlex::_ensureRealLPLoaded(), SoPlex::_evaluateSolutionReal(), SoPlex::_performOptIRStable(), SoPlex::_removeColReal(), SoPlex::_removeColsReal(), SoPlex::_removeRowReal(), SoPlex::_removeRowsReal(), SoPlex::_restoreLPReal(), SoPlex::_solveRational(), SoPlex::_storeSolutionReal(), SPxBasis::addedCols(), SPxSolver::addedCols(), SPxBasis::addedRows(), SPxSolver::addedRows(), SPxBasis::change(), SPxSolver::changeCol(), SPxSolver::changeElement(), SPxSolver::changeLhs(), SPxSolver::changeLower(), SPxSolver::changeRange(), SPxSolver::changeRhs(), SPxSolver::changeRow(), SPxSolver::changeUpper(), SPxBasis::condition(), SPxSolver::doRemoveCol(), SPxSolver::doRemoveCols(), SPxSolver::doRemoveRow(), SPxSolver::doRemoveRows(), SPxBasis::dump(), SPxBasis::factorize(), SPxSolver::factorize(), SPxSolver::getDualfarkas(), SoPlex::getEstimatedCondition(), SoPlex::getExactCondition(), SPxSolver::getPrimalray(), SPxSolver::init(), SPxSolver::initRep(), SPxBasis::isConsistent(), SPxBasis::isDescValid(), SPxSolver::loadBasis(), SPxBasis::loadDesc(), SPxBasis::multBaseWith(), SPxBasis::multWithBase(), SPxBasis::readBasis(), SoPlex::readBasisFile(), SPxBasis::removedCol(), SPxBasis::removedCols(), SPxBasis::removedRow(), SPxBasis::removedRows(), SPxBasis::restoreInitialBasis(), SoPlex::setBasis(), SPxSolver::setBasis(), SoPlexLegacy::solve(), SPxSolver::solve(), SPxSolver::status(), SPxSolver::terminate(), SPxSolver::testVecs(), and SPxBasis::writeBasis().

virtual void unLoad ( )
virtual
void writeBasis ( std::ostream &  os,
const NameSet rownames,
const NameSet colnames,
const bool  cpxFormat = false 
) const
virtual

Member Data Documentation

Real fillFactor
protected

allowed increase in realtive fill before refactorization

When the real relative fill is bigger than fillFactor times lastFill the Basis will be refactorized.

Definition at line 379 of file spxbasis.h.

Referenced by SPxBasis::factorize(), and SPxBasis::operator=().

bool freeSlinSolver
private

true iff factor should be freed inside of this object

Definition at line 408 of file spxbasis.h.

Referenced by SPxBasis::loadSolver(), SPxBasis::operator=(), SPxBasis::SPxBasis(), and SPxBasis::~SPxBasis().

int iterCount
protected

number of calls to change() since last manipulation

Definition at line 384 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::iteration(), SPxBasis::loadDesc(), SPxBasis::operator=(), SPxSolver::solve(), and SPxSolver::testBounds().

Real lastFill
protected

fill ratio that occured during last factorization

Definition at line 389 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::factorize(), and SPxBasis::operator=().

int lastidx
protected

lastIndex(): basis index where last update was done

Definition at line 397 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::lastIndex(), SPxBasis::loadDesc(), and SPxBasis::operator=().

SPxId lastin
protected

lastEntered(): variable entered the base last

Definition at line 395 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::lastEntered(), SPxBasis::loadDesc(), and SPxBasis::operator=().

int lastMem
protected

memory needed after last fresh factorization

Definition at line 388 of file spxbasis.h.

Referenced by SPxBasis::factorize().

int lastNzCount
protected

number of nonzeros in basis matrix after last fresh factorization

Definition at line 390 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::factorize(), and SPxBasis::operator=().

SPxId lastout
protected

lastLeft(): variable left the base last

Definition at line 396 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::lastLeft(), SPxBasis::loadDesc(), and SPxBasis::operator=().

int maxUpdates
protected

number of updates before refactorization.

When a vector of the basis matrix is exchanged by a call to method change(), the LU factorization of the matrix is updated accordingly. However, after atmost maxUpdates updates of the factorization, it is recomputed in order to regain numerical stability and reduce fill in.

Definition at line 366 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::getMaxUpdates(), and SPxBasis::operator=().

Real minStab
protected

minimum stability

Definition at line 398 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::factorize(), SPxBasis::operator=(), and SPxBasis::setRep().

Real nonzeroFactor
protected

allowed increase of nonzeros before refactorization.

When the number of nonzeros in LU factorization exceeds nonzeroFactor times the number of nonzeros in B, the basis matrix is refactorized.

Definition at line 373 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::factorize(), and SPxBasis::operator=().

int nzCount
protected
DataArray< SPxId > theBaseId
protected

SPxIds of basic vectors.

Definition at line 345 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::isConsistent(), SPxBasis::loadDesc(), SPxBasis::operator=(), and SPxBasis::reDim().

SPxStatus thestatus
private

current status of the basis.

Definition at line 406 of file spxbasis.h.

Referenced by SPxBasis::operator=(), and SPxBasis::status().

Timer* theTime
protected

time spent in updates

Definition at line 392 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::SPxBasis(), and SPxBasis::~SPxBasis().

Timer::TYPE timerType
protected

type of timer (user or wallclock)

Definition at line 393 of file spxbasis.h.

Referenced by SPxBasis::SPxBasis().

int totalUpdateCount
protected

number of updates

Definition at line 386 of file spxbasis.h.

Referenced by SPxBasis::change(), and SPxBasis::getTotalUpdateCount().

int updateCount
protected

number of calls to change() since last factorize()

Definition at line 385 of file spxbasis.h.

Referenced by SPxBasis::change(), SPxBasis::factorize(), SPxBasis::lastUpdate(), SPxBasis::loadDesc(), and SPxSolver::terminate().