77 if (
theLP->SPxLP::lower(i) ==
theLP->SPxLP::upper(i))
96 MSG_INFO3( (*
spxout), (*
spxout) <<
"IBASIS01 loadMatrixVecs() invalidates factorization" << std::endl; )
100 for (i =
theLP->
dim() - 1; i >= 0; --i)
103 nzCount +=
matrix[i]->size();
121 MSG_DEBUG( std::cout <<
"IBASIS20 Dimension mismatch\n" );
126 for (
int row = ds.
nRows()-1; row >= 0; --row )
132 MSG_DEBUG( std::cout <<
"IBASIS21 Basic row " << row <<
" with incorrect dual status " <<
dualRowStatus(row) <<
"\n");
143 MSG_DEBUG( std::cout <<
"IBASIS22 Nonbasic row with incorrect status: lhs=" <<
theLP->SPxLP::lhs(row) <<
", rhs=" <<
theLP->SPxLP::rhs(row) <<
", stat=" << ds.
rowstat[row] <<
"\n");
149 for (
int col = ds.
nCols()-1; col >= 0; --col )
155 MSG_DEBUG( std::cout <<
"IBASIS23 Basic column " << col <<
" with incorrect dual status " << ds.
colstat[col] <<
" != " <<
dualColStatus(col) <<
"\n");
166 MSG_DEBUG( std::cout <<
"IBASIS24 Nonbasic column with incorrect status: lower=" <<
theLP->SPxLP::lower(col) <<
", upper=" <<
theLP->SPxLP::upper(col) <<
", stat=" << ds.
colstat[col] <<
"\n");
174 MSG_DEBUG( std::cout <<
"IBASIS25 Incorrect basis dimension " << basisdim <<
" != " <<
theLP->
nCols() <<
"\n" );
198 bool consistent =
true;
200 MSG_INFO3( (*
spxout), (*
spxout) <<
"IBASIS02 loading of Basis invalidates factorization" << std::endl; )
237 assert(j <=
matrix.size());
249 nzCount +=
matrix[j++]->size();
273 assert(j <=
matrix.size());
285 nzCount +=
matrix[j++]->size();
401 const NameSet* rNames = rowNames;
402 const NameSet* cNames = colNames;
410 std::stringstream name;
413 p_colNames =
new (p_colNames)
NameSet();
414 p_colNames->
reMax(nCols);
415 for (
int j = 0; j < nCols; ++j)
419 p_colNames->
add(key, name.str().c_str());
427 std::stringstream name;
430 p_rowNames =
new (p_rowNames)
NameSet();
431 p_rowNames->
reMax(nRows);
432 for (
int i = 0; i < nRows; ++i)
436 p_rowNames->
add(key, name.str().c_str());
453 if (
theLP->SPxLP::lower(i) ==
theLP->SPxLP::upper(i))
472 if ((mps.
field0() != 0) && !strcmp(mps.
field0(),
"ENDATA"))
487 if (!strcmp(mps.
field1(),
"XU"))
497 else if (!strcmp(mps.
field1(),
"XL"))
507 else if (!strcmp(mps.
field1(),
"UL"))
511 else if (!strcmp(mps.
field1(),
"LL"))
566 assert(idx < lp->nRows());
572 if (rnames->
has(key))
573 return (*rnames)[key];
592 assert(idx < lp->nCols());
598 if (cnames->
has(key))
599 return (*cnames)[key];
619 os.setf(std::ios::left);
620 os <<
"NAME soplex.bas\n";
625 os <<
"ENDATA" << std::endl;
632 for (
int col = 0; col <
theLP->
nCols(); col++)
691 os <<
"ENDATA" << std::endl;
699 for(
int i = 0; i <
matrix.size(); i++ )
701 std::cout <<
"C" << i <<
"=" << *
matrix[i] << std::endl;
714 std::cout <<
"printing basis matrix to file " << filename <<
"\n";
716 basisfile = fopen (filename,
"w");
718 fprintf(basisfile,
"%%%%MatrixMarket matrix coordinate real general\n");
720 fprintf(basisfile,
"%d %d %d\n", dim, dim, nnz );
722 for(
int i = 0; i <
matrix.size(); ++i )
728 fprintf(basisfile,
"%d %d %.13" REAL_FORMAT "\n",i+1,idx+1,val);
744 assert(!
id.isValid() || (enterVec != 0));
750 if (
id.isValid() && i >= 0)
752 assert(enterVec != 0);
822 #ifdef MEASUREUPDATETIME 827 #ifdef MEASUREUPDATETIME 836 #ifdef MEASUREUPDATETIME
848 #ifdef MEASUREUPDATETIME 853 #ifdef MEASUREUPDATETIME 861 MSG_INFO3( (*
spxout), (*
spxout) <<
"IBASIS14 problems updating factorization; invalidating factorization" 864 #ifdef MEASUREUPDATETIME
923 MSG_ERROR( std::cerr <<
"EBASIS08 error: unknown status of factorization.\n"; )
953 for (i = x.
dim() - 1; i >= 0; --i)
954 x[i] = *(
matrix[i]) * tmp;
963 assert(x.
dim() == result.
dim());
972 for(
int i = 0; i < x.
dim(); ++i )
993 for (i = x.
dim() - 1; i >= 0; --i)
1006 assert(x.
dim() == result.
dim());
1016 for(
int i = 0; i < x.
size(); ++i )
1018 int idx = x.
index(i);
1024 for(
int i = 0; i < x.
dim(); ++i )
1037 int dimension =
matrix.size();
1047 if( dimension == 0 )
1064 norm1 = 1.0 / (
Real) dimension;
1065 for( i = 0; i < dimension; i++ )
1070 for( c = 0; c < maxiters; ++c )
1079 if( c >= miniters &&
spxAbs(norm1 - norm2) < tolerance * norm1 )
1084 norm2 = 1.0 / x.
length();
1092 norm1 = 1.0 / (
Real) dimension;
1093 for( i = 0; i < dimension; i++ )
1098 for( c = 0; c < maxiters; ++c )
1108 if( c >= miniters &&
spxAbs(norm1 - norm2) < tolerance * norm1 )
1114 norm2 = 1.0 / y.
length();
1119 return norm * norminv;
1145 std::cout <<
"DBASIS09 Basis entries:";
1151 if(basesize % 10 == 0)
1152 std::cout << std::endl <<
"DBASIS10 ";
1163 if(basesize % 10 == 0)
1164 std::cout << std::endl <<
"DBASIS11 ";
1170 std::cout << std::endl;
1172 assert(basesize ==
matrix.size());
1178 #ifdef ENABLE_CONSISTENCY_CHECKS 1221 #endif // CONSISTENCY_CHECKS const VectorBase< R > & rhs() const
Returns right hand side vector.
int lastMem
memory needed after last fresh factorization
int iterDegenCheck
number of calls to change() since last degeneracy check
int nzCount
number of nonzeros in basis matrix
Rational spxAbs(const Rational &r)
Absolute.
virtual Real conditionEstimate(int type=0) const =0
return estimate for the condition number based on the diagonal of U
virtual Status change(int idx, const SVector &subst, const SSVector *eta=0)=0
Substitute column idx with subst.
int iteration() const
returns number of basis changes since last load().
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
Vector & multWithBase(Vector &x) const
Vector-basis product.
SPxRowId rId(int n) const
Returns the row identifier for row n.
Real fillFactor
allowed increase in relative fill before refactorization
bool isSetup() const
Returns setup status.
virtual Status load(const SVector *vec[], int dim)=0
loads dim column vectors vec into the solver.
Basis is not known to be dual nor primal feasible.
virtual void clear()=0
unloads any matrix.
primal variable is fixed to both bounds
SPxOut * spxout
message handler
primal or dual variable is undefined
const VectorBase< R > & upper() const
Returns upper bound vector.
Desc::Status dualColStatus(int i) const
dual Status for the i'th column variable of the loaded LP.
SPxOut * spxout
message handler
virtual void printMatrix() const
THREADLOCAL const Real infinity
bool isConsistent() const
consistency check.
int spxSnprintf(char *t, int len, const char *s,...)
safe version of snprintf
static const char * getRowName(const SPxLP *lp, int idx, const NameSet *rnames, char *buf)
void reMax(int newmax=0)
resets max() to newmax.
virtual void solveRight(Vector &x, const Vector &b)=0
Solves .
int size() const
Number of used indices.
int updateCount
number of calls to change() since last factorize()
Basis is optimal, i.e. dual and primal feasible.
virtual int dim() const =0
returns dimension of loaded matrix.
Exception classes for SoPlex.
Status & rowStatus(int i)
virtual bool isDescValid(const Desc &ds)
checks if a Descriptor is valid for the current LP w.r.t. its bounds
DataArray< Status > * stat
basis' status.
virtual ~SPxBasis()
destructor.
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
int lastNzCount
number of nonzeros in basis matrix after last fresh factorization
int dim() const
dimension of basis matrix.
Vector & multBaseWith(Vector &x) const
Basis-vector product.
Real getFastCondition(int type=0)
R & value(int n)
Reference to value of n 'th nonzero.
void dump() const
Prints out status.
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
Desc::Status dualStatus(const SPxColId &id) const
dual Status for the column variable with ID id of the loaded LP.
Real time() const
time spent in last call to method solve().
static const char * getColName(const SPxLP *lp, int idx, const NameSet *cnames, char *buf)
bool factorized
true iff factor = matrix .
virtual void writeBasis(std::ostream &os, const NameSet *rownames, const NameSet *colnames, const bool cpxFormat=false) const
void setRep()
sets descriptor representation according to loaded LP.
Sparse Linear Solver virtual base class.Class SLinSolver provides a class for solving sparse linear s...
Desc::Status dualRowStatus(int i) const
dual Status for the i'th row variable of the loaded LP.
Real memFactor
allowed total increase in memory consumption before refactorization
int lastIterCount
number of calls to change() before halting the simplex
SPxStatus thestatus
current status of the basis.
SPxColId cId(int n) const
Returns the column identifier for column n.
int nCols() const
returns number of columns.
Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ...
dual variable is left free, but unset
Wrapper for different output streams and verbosity levels.
int nRows() const
Returns number of rows in LP.
virtual void start()=0
start timer, resume accounting user, system and real time.
int dim() const
Dimension of VectorBase.
virtual Real stop()=0
stop timer, return accounted user time.
void spx_alloc(T &p, int n=1)
Allocate memory.
int maxUpdates
number of updates before refactorization.
primal variable is set to its upper bound
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
virtual Real stability() const =0
returns a stability number (0: singularity, 1: perfect stability).
SPxStatus status() const
returns current SPxStatus.
virtual Status status() const =0
returns the Status of the SLinSolver.
const SVector & baseVec(int i) const
returns the i'th basic vector.
void reDim()
resizes internal arrays.
virtual SLinSolver * clone() const =0
clone function for polymorphism
virtual void solveLeft(Vector &x, const Vector &b)=0
solves .
void setStatus(SPxStatus stat)
sets basis SPxStatus to stat.
Real lastFill
fill ratio that occured during last factorization
int & index(int n)
Reference to index of n 'th nonzero.
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
SPxColId colId(int i) const
ColId of i 'th column.
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
dual variable is set to its upper bound
virtual bool readBasis(std::istream &in, const NameSet *rowNames, const NameSet *colNames)
bool isBasic(SPxBasis::Desc::Status stat) const
does stat describe a basic index ?
primal variable is left free, but unset
const VectorBase< R > & lhs() const
Returns left hand side vector.
void clear()
Clears vector.
virtual void loadBasisSolver(SLinSolver *solver, const bool destroy=false)
sets up linear solver to use.
void add(const char *str)
SPxId lastout
lastLeft(): variable left the base last
Real minStab
minimum stability
SSVectorBase< R > & multAdd(S xx, const SVectorBase< T > &vec)
Addition of a scaled vector.
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
int index(int n) const
Returns index of the n 'th nonzero element.
Status & colStatus(int i)
DataArray< Status > rowstat
status of rows.
virtual bool isConsistent() const =0
consistency check.
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
void loadMatrixVecs()
loads matrix according to the SPxIds stored in theBaseId.
virtual void change(int i, SPxId &id, const SVector *enterVec, const SSVector *eta=0)
performs basis update.
Timer::TYPE timerType
type of timer (user or wallclock)
Debugging, floating point type and parameter definitions.
Simplex basis.Consider the linear program as provided from class SPxLP: where , and ...
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
void restoreInitialBasis()
Restores initial basis.
void dump()
output basis entries.
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Real condition(int maxiters=10, Real tolerance=1e-6)
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
int dim() const
Dimension of vector.
Exception base class.This class implements a base class for our SoPlex exceptions We provide a what()...
int size() const
Returns the number of nonzeros.
Desc thedesc
the basis' Descriptor
Everything should be within this namespace.
virtual int memory() const =0
returns current memory consumption.
void setOutstream(SPxOut &newOutstream)
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
SPxOut * spxout
message handler
SPxBasis & operator=(const SPxBasis &rhs)
assignment operator
DataArray< SPxId > theBaseId
SPxIds of basic vectors.
primal variable is set to its lower bound
int totalUpdateCount
number of updates
int lastidx
lastIndex(): basis index where last update was done
void setup()
Initializes nonzero indices for elements with absolute values above epsilon and sets all other elemen...
virtual void factorize()
factorizes the basis matrix.
void clear()
Set vector to 0.
dual variable is set to its lower bound
DataArray< Status > * costat
cobasis' status.
virtual void loadDesc(const Desc &)
sets up basis.
Real length() const
Floating point approximation of euclidian norm (without any approximation guarantee).
int nCols() const
Returns number of columns in LP.
DataArray< Status > colstat
status of columns.
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
dual variable has two bounds
Exception class for status exceptions during the computationsThis class is derived from the SoPlex ex...
The loaded matrix is singular.
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
#define MSGinconsistent(name)
const SVector & vector(int i) const
i 'th vector.
int nRows() const
returns number of rows.
virtual void load(SPxSolver *lp, bool initSlackBasis=true)
loads the LP lp to the basis.
SPxId lastin
lastEntered(): variable entered the base last
int number(const DataKey &pkey) const
returns number of name with DataKey pkey in NameSet.
int iterCount
number of calls to change() since last manipulation
Status
Status of a variable.
void add(int i, R x)
Adds nonzero (i, x) to SSVectorBase.
LP has been proven to be primal unbounded.
void printMatrixMTX(int number)
Timer * theTime
time spent in updates
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Real nonzeroFactor
allowed increase of nonzeros before refactorization.
SPxRowId rowId(int i) const
RowId of i 'th inequality.
SPxBasis(Timer::TYPE ttype=Timer::USER_TIME)
default constructor.
Representation rep() const
return the current basis representation.
bool freeSlinSolver
true iff factor should be freed inside of this object
void spx_free(T &p)
Release memory.
bool has(int pnum) const
does NameSet has a name with number pnum?
bool isConsistent() const
consistency check.
Basis is primal feasible.
bool matrixIsSetup
true iff the pointers in matrix are set up correctly.
LP has been proven to be primal infeasible.
No Problem has been loaded to the basis.
DataArray< const SVector *> matrix
pointers to the vectors of the basis matrix.