33#define SOPLEX_DEBUG_SPXBASIS
211 template <
class T>
friend std::ostream&
operator<< (std::ostream& os,
448 SPxOut::debug(
this,
"DBSTAT01 SPxBasisBase<R>::setStatus(): status: {} ({}) -> {} ({})\n",
502 return id.isSPxRowId()
638 return factor->stability();
652 factor->solveRight(x, rhs);
666 factor->solveRight(x, rhs);
689 factor->solveRight4update(x, rhs);
698 factor->solve2right4update(x, y, rhsx, rhsy);
707 factor->solve2right4update(x, y, rhsx, rhsy);
718 factor->solve3right4update(x, y, y2, rhsx, rhsy, rhsy2);
729 factor->solve3right4update(x, y, y2, rhsx, rhsy, rhsy2);
752 factor->solveLeft(x, rhs);
766 factor->solveLeft(x, rhs);
775 factor->solveLeft(x, y, rhsx, rhsy);
784 factor->solveLeft(x, y, rhsx, rhsy);
793 factor->solveLeft(x, y, z, rhsx, rhsy, rhsz);
802 factor->solveLeft(x, y, z, rhsx, rhsy, rhsz);
875 const NameSet* rownames,
const NameSet* colnames,
const bool cpxFormat =
false)
const;
948#ifdef SOPLEX_MEASUREUPDATETIME
1022#include "spxbasis.hpp"
1023#include "spxdesc.hpp"
1027#ifdef SOPLEX_DEBUG_SPXBASIS
1029#undef SOPLEX_DEBUG_SPXBASIS
const T * get_const_ptr() const
get a const C pointer to the data.
int size() const
return nr. of elements.
Sparse Linear Solver virtual base class.
Status & rowStatus(int i)
DataArray< Status > * stat
basis' status.
friend std::ostream & operator<<(std::ostream &os, const Status &stat)
bool isConsistent() const
consistency check.
int coDim() const
returns codimension.
Desc(const SPxSolverBase< R > &base)
const Status * coStatus(void) const
returns the array of covariable Statuses.
const Status * rowStatus(void) const
returns the array of row Statuses.
void reSize(int rowDim, int colDim)
resets dimensions.
@ P_FIXED
primal variable is fixed to both bounds
@ D_UNDEFINED
primal or dual variable is undefined
@ D_ON_UPPER
dual variable is set to its upper bound
@ P_ON_UPPER
primal variable is set to its upper bound
@ D_ON_LOWER
dual variable is set to its lower bound
@ P_FREE
primal variable is left free, but unset
@ D_FREE
dual variable is left free, but unset
@ P_ON_LOWER
primal variable is set to its lower bound
@ D_ON_BOTH
dual variable has two bounds
Status status(int i) const
returns status of variable i.
Status colStatus(int i) const
returns status of column i.
const Status * status(void) const
returns the array of variable Statuses.
DataArray< Status > rowstat
status of rows.
Status rowStatus(int i) const
returns status of row i.
Status & colStatus(int i)
DataArray< Status > colstat
status of columns.
DataArray< Status > * costat
cobasis' status.
int dim() const
returns dimension.
Desc(const Desc &old)
copy constructor
Desc & operator=(const Desc &rhs)
assignment operator
int nRows() const
returns number of rows.
const Status * colStatus(void) const
returns the array of column Statuses.
Status coStatus(int i) const
returns status of covariable i.
void changedRow(int)
inform SPxBasisBase that a row had been changed.
void setOutstream(SPxOut &newOutstream)
int lastMem
memory needed after last fresh factorization
R condition(int maxiters=10, R tolerance=1e-6)
int nzCount
number of nonzeros in basis matrix
void coSolve(SSVectorBase< R > &x, VectorBase< R > &y, VectorBase< R > &z, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy, SSVectorBase< R > &rhsz)
solves three systems in one call. May be improved by using just one pass through the basis.
const SVectorBase< R > & baseVec(int i) const
returns the i'th basic vector.
SPxSolverBase< R > * theLP
the LP
void removedRows(const int perm[])
inform SPxBasisBase that rows in perm with negative entry were removed.
virtual bool readBasis(std::istream &in, const NameSet *rowNames, const NameSet *colNames)
SPxBasisBase< R > & operator=(const SPxBasisBase< R > &rhs)
assignment operator
int totalUpdateCount
number of updates
DataArray< SPxId > theBaseId
SPxIds of basic vectors.
const Desc & desc() const
int lastDegenCheck() const
returns the number of iterations since the last degeneracy check
void printMatrixMTX(int number)
int iterDegenCheck
number of calls to change() since last degeneracy check
SPxStatus thestatus
current status of the basis.
void solve(SSVectorBase< R > &x, const SVectorBase< R > &rhs)
Desc::Status dualStatus(const SPxId &id) const
dual Status for the variable with ID id of the loaded LP.
int lastNzCount
number of nonzeros in basis matrix after last fresh factorization
void solve4update(SSVectorBase< R > &x, SSVectorBase< R > &y, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy)
solves two systems in one call using only sparse data structures
void solve(VectorBase< R > &x, const VectorBase< R > &rhs)
void coSolve(VectorBase< R > &x, const VectorBase< R > &rhs)
Cosolves linear system with basis matrix.
void reDim()
resizes internal arrays.
int lastIndex() const
returns index in basis where last update was done.
void removedCol(int i)
inform SPxBasisBase that column i had been removed.
Desc & desc()
returns current basis Descriptor.
bool factorized
true iff factor = matrix .
bool isConsistent() const
consistency check.
Desc::Status dualStatus(const SPxColId &id) const
dual Status for the column variable with ID id of the loaded LP.
int getTotalUpdateCount() const
number of updates performed
void removedCols(const int perm[])
inform SPxBasisBase that columns in perm with negative entry were removed.
bool freeSlinSolver
true iff factor should be freed inside of this object
void removedRow(int i)
inform SPxBasisBase that row i had been removed.
void coSolve(SSVectorBase< R > &x, SSVectorBase< R > &y, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy)
Sparse version of solving two systems in one call.
SPxOut * spxout
message handler
VectorBase< R > & multBaseWith(VectorBase< R > &x) const
Basis-vector product.
int lastidx
lastIndex(): basis index where last update was done
void addedRows(int n)
inform SPxBasisBase, that n new rows had been added.
R fillFactor
allowed increase in relative fill before refactorization
virtual bool isDescValid(const Desc &ds)
checks if a Descriptor is valid for the current LP w.r.t. its bounds
void setStatus(SPxStatus stat)
sets basis SPxStatus to stat.
void solve4update(SSVectorBase< R > &x, SSVectorBase< R > &y, SSVectorBase< R > &y2, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy, SSVectorBase< R > &rhsy2)
solves three systems in one call using only sparse data structures
R lastFill
fill ratio that occured during last factorization
R memFactor
allowed total increase in memory consumption before refactorization
int getMaxUpdates() const
returns maximum number of updates before a refactorization is performed
virtual void writeBasis(std::ostream &os, const NameSet *rownames, const NameSet *colnames, const bool cpxFormat=false) const
Timer * theTime
time spent in updates
SPxBasisBase(Timer::TYPE ttype=Timer::USER_TIME)
default constructor.
virtual void load(SPxSolverBase< R > *lp, bool initSlackBasis=true)
loads the LP lp to the basis.
DataArray< const SVectorBase< R > * > matrix
pointers to the vectors of the basis matrix.
Desc thedesc
the basis' Descriptor
virtual void factorize()
factorizes the basis matrix.
virtual void loadDesc(const Desc &)
sets up basis.
virtual void loadBasisSolver(SLinSolver< R > *solver, const bool destroy=false)
sets up linear solver to use.
void coSolve(SSVectorBase< R > &x, SSVectorBase< R > &y, SSVectorBase< R > &z, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy, SSVectorBase< R > &rhsz)
Sparse version of solving three systems in one call.
void restoreInitialBasis()
Restores initial basis.
int iterCount
number of calls to change() since last manipulation
SPxId lastEntered() const
returns SPxId of last VectorBase<R> included to the basis.
void invalidate()
invalidates actual basis.
Timer::TYPE timerType
type of timer (user or wallclock)
int iteration() const
returns number of basis changes since last load().
Desc::Status dualStatus(const SPxRowId &id) const
dual Status for the row variable with ID id of the loaded LP.
void multBaseWith(SSVectorBase< R > &x, SSVectorBase< R > &result) const
Basis-vector product.
bool matrixIsSetup
true iff the pointers in matrix are set up correctly.
int maxUpdates
number of updates before refactorization.
void coSolve(SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy)
solves two systems in one call.
SPxId lastLeft() const
returns SPxId of last vector that left the basis.
R getEstimatedCondition()
SPxId lastin
lastEntered(): variable entered the base last
void coSolve(SSVectorBase< R > &x, const SVectorBase< R > &rhs)
Sparse version of coSolve.
int prevIteration() const
returns the number of iterations prior to the last break in execution
SPxId baseId(int i) const
returns the Id of the i'th basis vector.
virtual ~SPxBasisBase()
destructor.
void changedElement(int, int)
inform SPxBasisBase that a matrix entry had been changed.
SPxStatus status() const
returns current SPxStatus.
R getMatrixMetric(int type=0)
int updateCount
number of calls to change() since last factorize()
virtual void unLoad()
unloads the LP from the basis.
R nonzeroFactor
allowed increase of nonzeros before refactorization.
int lastUpdate() const
returns number of basis changes since last refactorization.
@ OPTIMAL
Basis is optimal, i.e. dual and primal feasible.
@ INFEASIBLE
LP has been proven to be primal infeasible.
@ NO_PROBLEM
No Problem has been loaded to the basis.
@ UNBOUNDED
LP has been proven to be primal unbounded.
@ DUAL
Basis is dual feasible.
@ PRIMAL
Basis is primal feasible.
@ SINGULAR
Basis is singular.
@ REGULAR
Basis is not known to be dual nor primal feasible.
void solve4update(SSVectorBase< R > &x, const SVectorBase< R > &rhs)
solves linear system with basis matrix.
void dump()
output basis entries.
SPxId lastout
lastLeft(): variable left the base last
void loadMatrixVecs()
loads matrix according to the SPxIds stored in theBaseId.
std::string statistics() const
returns statistical information in form of a string.
SPxBasisBase(const SPxBasisBase< R > &old)
copy constructor
R stability() const
returns the stability of the basis matrix.
Real getTotalUpdateTime() const
time spent in updates
void solve4update(SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy)
solves two systems in one call.
virtual void change(int i, SPxId &id, const SVectorBase< R > *enterVec, const SSVectorBase< R > *eta=nullptr)
performs basis update.
virtual void printMatrix() const
VectorBase< R > & multWithBase(VectorBase< R > &x) const
Vector-basis product.
void addedCols(int n)
inform SPxBasisBase that n new columns had been added.
int lastIterCount
number of calls to change() before halting the simplex
void setRep()
sets descriptor representation according to loaded LP.
void setMaxUpdates(int maxUp)
change maximum number of iterations until a refactorization is performed
void multWithBase(SSVectorBase< R > &x, SSVectorBase< R > &result) const
VectorBase<R>-basis product.
Desc::Status dualColStatus(int i) const
dual Status for the i'th column variable of the loaded LP.
Desc::Status dualRowStatus(int i) const
dual Status for the i'th row variable of the loaded LP.
R minStab
minimum stability
void solve4update(SSVectorBase< R > &x, VectorBase< R > &y, VectorBase< R > &y2, const SVectorBase< R > &rhsx, SSVectorBase< R > &rhsy, SSVectorBase< R > &rhsy2)
solves three systems in one call.
SPxSolverBase< R > * solver() const
returns loaded solver.
void changedCol(int)
inform SPxBasisBase that a column had been changed.
Generic Ids for LP rows or columns.
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
static void debug(const T *, Args &&... args)
Sequential object-oriented SimPlex.
void clear()
Clears vector.
bool isSetup() const
Returns setup status.
int size() const
Number of used indices.
Wrapper for the system time query methods.
virtual Real time() const =0
int dim() const
Dimension of vector.
void clear()
Set vector to contain all-zeros (keeping the same length)
Save arrays of data objects.
Everything should be within this namespace.
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
SPxBasisBase< Real > SPxBasis
Sparse Linear Solver virtual base class.
Debugging, floating point type and parameter definitions.
Saving LPs in a form suitable for SoPlex.
Wrapper for different output streams and verbosity levels.