77 if(
theLP->SPxLP::lower(i) ==
theLP->SPxLP::upper(i))
102 for(i =
theLP->
dim() - 1; i >= 0; --i)
105 nzCount +=
matrix[i]->size();
125 MSG_DEBUG(std::cout <<
"IBASIS20 Dimension mismatch\n");
131 for(
int row = ds.
nRows() - 1; row >= 0; --row)
137 MSG_DEBUG(std::cout <<
"IBASIS21 Basic row " << row <<
" with incorrect dual status " <<
150 MSG_DEBUG(std::cout <<
"IBASIS22 Nonbasic row with incorrect status: lhs=" <<
theLP->SPxLP::lhs(
151 row) <<
", rhs=" <<
theLP->SPxLP::rhs(row) <<
", stat=" << ds.
rowstat[row] <<
"\n");
157 for(
int col = ds.
nCols() - 1; col >= 0; --col)
163 MSG_DEBUG(std::cout <<
"IBASIS23 Basic column " << col <<
" with incorrect dual status " <<
176 MSG_DEBUG(std::cout <<
"IBASIS24 Nonbasic column " << col <<
" with incorrect status: lower=" <<
177 theLP->SPxLP::lower(col) <<
", upper=" <<
theLP->SPxLP::upper(col) <<
", stat=" << ds.
colstat[col]
186 MSG_DEBUG(std::cout <<
"IBASIS25 Incorrect basis dimension " << basisdim <<
" != " <<
theLP->
nCols()
211 bool consistent =
true;
240 &&
theLP->SPxLP::lhs(i) !=
theLP->SPxLP::rhs(i))
253 assert(j <=
matrix.size());
265 nzCount +=
matrix[j++]->size();
277 &&
theLP->SPxLP::lower(i) !=
theLP->SPxLP::upper(i))
282 &&
theLP->SPxLP::maxObj(i) < 0.0))
291 assert(j <=
matrix.size());
303 nzCount +=
matrix[j++]->size();
420 const NameSet* rNames = rowNames;
421 const NameSet* cNames = colNames;
429 std::stringstream name;
432 p_colNames =
new(p_colNames)
NameSet();
433 p_colNames->
reMax(nCols);
435 for(
int j = 0; j < nCols; ++j)
439 p_colNames->
add(key, name.str().c_str());
448 std::stringstream name;
451 p_rowNames =
new(p_rowNames)
NameSet();
452 p_rowNames->
reMax(nRows);
454 for(
int i = 0; i < nRows; ++i)
458 p_rowNames->
add(key, name.str().c_str());
476 if(
theLP->SPxLP::lower(i) ==
theLP->SPxLP::upper(i))
495 if((mps.
field0() != 0) && !strcmp(mps.
field0(),
"ENDATA"))
511 if(!strcmp(mps.
field1(),
"XU"))
522 else if(!strcmp(mps.
field1(),
"XL"))
533 else if(!strcmp(mps.
field1(),
"UL"))
537 else if(!strcmp(mps.
field1(),
"LL"))
594 assert(idx < lp->nRows());
601 return (*rnames)[key];
621 assert(idx < lp->nCols());
628 return (*cnames)[key];
649 os.setf(std::ios::left);
650 os <<
"NAME soplex.bas\n";
655 os <<
"ENDATA" << std::endl;
726 os <<
"ENDATA" << std::endl;
734 for(
int i = 0; i <
matrix.size(); i++)
736 std::cout <<
"C" << i <<
"=" << *
matrix[i] << std::endl;
749 std::cout <<
"printing basis matrix to file " << filename <<
"\n";
751 basisfile = fopen(filename,
"w");
753 fprintf(basisfile,
"%%%%MatrixMarket matrix coordinate real general\n");
755 fprintf(basisfile,
"%d %d %d\n", dim, dim, nnz);
758 for(
int i = 0; i <
matrix.size(); ++i)
764 fprintf(basisfile,
"%d %d %.13" REAL_FORMAT "\n", i + 1, idx + 1, val);
781 assert(!
id.isValid() || (enterVec != 0));
787 if(
id.isValid() && i >= 0)
789 assert(enterVec != 0);
859 #ifdef MEASUREUPDATETIME 864 #ifdef MEASUREUPDATETIME 873 #ifdef MEASUREUPDATETIME
886 #ifdef MEASUREUPDATETIME 891 #ifdef MEASUREUPDATETIME 900 "IBASIS14 problems updating factorization; invalidating factorization" 903 #ifdef MEASUREUPDATETIME
967 MSG_ERROR(std::cerr <<
"EBASIS08 error: unknown status of factorization.\n";)
997 for(i = x.
dim() - 1; i >= 0; --i)
998 x[i] = *(
matrix[i]) * tmp;
1007 assert(x.
dim() == result.
dim());
1016 for(
int i = 0; i < x.
dim(); ++i)
1038 for(i = x.
dim() - 1; i >= 0; --i)
1051 assert(x.
dim() == result.
dim());
1062 for(
int i = 0; i < x.
size(); ++i)
1064 int idx = x.
index(i);
1070 for(
int i = 0; i < x.
dim(); ++i)
1083 int dimension =
matrix.size();
1110 norm1 = 1.0 / (
Real) dimension;
1112 for(i = 0; i < dimension; i++)
1118 for(c = 0; c < maxiters; ++c)
1127 if(c >= miniters &&
spxAbs(norm1 - norm2) < tolerance * norm1)
1132 norm2 = 1.0 / x.
length();
1141 norm1 = 1.0 / (
Real) dimension;
1143 for(i = 0; i < dimension; i++)
1149 for(c = 0; c < maxiters; ++c)
1159 if(c >= miniters &&
spxAbs(norm1 - norm2) < tolerance * norm1)
1165 norm2 = 1.0 / y.
length();
1171 return norm * norminv;
1197 std::cout <<
"DBASIS09 Basis entries:";
1204 if(basesize % 10 == 0)
1205 std::cout << std::endl <<
"DBASIS10 ";
1217 if(basesize % 10 == 0)
1218 std::cout << std::endl <<
"DBASIS11 ";
1226 std::cout << std::endl;
1228 assert(basesize ==
matrix.size());
1234 #ifdef ENABLE_CONSISTENCY_CHECKS 1279 #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.
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
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
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.