#include <ogdf/lib/abacus/osiif.h>
Public Types | |
enum | SOLVERTYPE { Exact, Approx } |
The enumeration of possible solver types. More... | |
Public Types inherited from abacus::LP | |
enum | METHOD { Primal, Dual, BarrierAndCrossover, BarrierNoCrossover, Approximate } |
The solution method for the linear program. More... | |
enum | OPTSTAT { Optimal, Unoptimized, Error, Feasible, Infeasible, Unbounded, LimitReached } |
The optimization status of the linear program. More... | |
enum | SOLSTAT { Available, Missing } |
Describes if parts of the solution like x-values, reduced costs, etc. are available. More... | |
Public Member Functions | |
OsiIF (Master *master) | |
Constructor without initialization. More... | |
OsiIF (Master *master, OptSense sense, int nRow, int maxRow, int nCol, int maxCol, Array< double > &obj, Array< double > &lb, Array< double > &ub, Array< Row * > &rows) | |
A constructor with initialization. More... | |
virtual | ~OsiIF () |
The destructor. More... | |
SOLVERTYPE | currentSolverType () const |
OsiSolverInterface * | osiLP () |
Public Member Functions inherited from abacus::LP | |
LP (Master *master) | |
Creates a linear program. More... | |
virtual | ~LP () |
The destructor. More... | |
void | addCols (ArrayBuffer< Column * > &newCols) |
Adds columns to the linear program. More... | |
void | addRows (ArrayBuffer< Row * > &newRows) |
Adds rows to the linear program. More... | |
virtual double | barXVal (int i) const |
SOLSTAT | barXValStatus () const |
SOLSTAT | basisStatus () const |
virtual void | changeLBound (int i, double newLb) |
Changes the lower bound of a single column. More... | |
void | changeRhs (Array< double > &newRhs) |
Changes the complete right hand side of the linear program. More... | |
virtual void | changeUBound (int i, double newUb) |
Changes the upper bound of a single column. More... | |
void | colRealloc (int newSize) |
Performs a reallocation of the column space of the linear program. More... | |
virtual int | getInfeas (int &infeasRow, int &infeasCol, double *bInvRow) const |
Can be called if the last linear program has been solved with the dual simplex method and is infeasible and all inactive variables price out correctly. More... | |
int | getSimplexIterationLimit (int &limit) const |
virtual bool | infeasible () const |
void | initialize (OptSense sense, int nRow, int maxRow, int nCol, int maxCol, Array< double > &obj, Array< double > &lBound, Array< double > &uBound, Array< Row * > &rows) |
Loads the linear program defined by its arguments. More... | |
void | initialize (OptSense sense, int nRow, int maxRow, int nCol, int maxCol, Array< double > &obj, Array< double > &lBound, Array< double > &uBound, Array< Row * > &rows, Array< LPVARSTAT::STATUS > &lpVarStat, Array< SlackStat::STATUS > &slackStat) |
This version of the function initialize() performs like its previous version, but also initializes the basis with the arguments: More... | |
double | lBound (int i) const |
virtual void | loadBasis (Array< LPVARSTAT::STATUS > &lpVarStat, Array< SlackStat::STATUS > &slackStat) |
Loads a new basis for the linear program. More... | |
ogdf::StopwatchCPU * | lpSolverTime () |
virtual LPVARSTAT::STATUS | lpVarStat (int i) const |
int | maxCol () const |
int | maxRow () const |
int | nCol () const |
int | nnz () const |
int | nOpt () const |
int | nRow () const |
double | obj (int i) const |
virtual OPTSTAT | optimize (METHOD method) |
Performs the optimization of the linear program. More... | |
virtual int | pivotSlackVariableIn (ArrayBuffer< int > &rows) |
Pivots the slack variables stored in the buffer rows into the basis. More... | |
virtual double | reco (int i) const |
SOLSTAT | recoStatus () const |
void | remCols (ArrayBuffer< int > &cols) |
Removes columns from the linear program. More... | |
void | remRows (ArrayBuffer< int > &ind) |
Removes rows of the linear program. More... | |
double | rhs (int i) const |
void | row (int i, Row &r) const |
void | rowRealloc (int newSize) |
Performs a reallocation of the row space of the linear program. More... | |
OptSense | sense () const |
void | sense (const OptSense &newSense) |
int | setSimplexIterationLimit (int limit) |
Changes the iteration limit of the Simplex algorithm. More... | |
virtual double | slack (int c) const |
virtual SlackStat::STATUS | slackStat (int i) const |
SOLSTAT | slackStatus () const |
double | uBound (int i) const |
virtual double | value () const |
int | writeBasisMatrix (const char *fileName) |
Writes the complete basis of an optimal linear program to a file. More... | |
virtual double | xVal (int i) const |
SOLSTAT | xValStatus () const |
virtual double | yVal (int c) const |
SOLSTAT | yValStatus () const |
Public Member Functions inherited from abacus::AbacusRoot | |
virtual | ~AbacusRoot () |
The destructor. More... | |
Private Member Functions | |
OsiIF (const OsiIF &rhs) | |
virtual void | _addCols (ArrayBuffer< Column * > &newVars) override |
Adds the columns newCols to the linear program. More... | |
virtual void | _addRows (ArrayBuffer< Row * > &newRows) override |
Adds the rows to the linear program. More... | |
virtual OPTSTAT | _approx () override |
Calls an approximate method. More... | |
virtual OPTSTAT | _barrier (bool doCrossover) override |
Calls the barrier method. More... | |
virtual double | _barXVal (int i) const override |
Returns the value of the column i. More... | |
virtual void | _changeLBound (int i, double newLb) override |
Sets the lower bound of column i to newLb. More... | |
virtual void | _changeRhs (Array< double > &newRhs) override |
Sets the right hand side of the linear program to newRhs. More... | |
virtual void | _changeUBound (int i, double newUb) override |
Sets the upper bound of column i to newLb. More... | |
void | _colRealloc (int newSize) override |
Reallocates the internal memory such that newSize columns can be stored. More... | |
virtual OPTSTAT | _dualSimplex () override |
Calls the dual simplex method. More... | |
virtual int | _getInfeas (int &infeasRow, int &infeasCol, double *bInvRow) const override |
Can be called if the last linear program has been solved with the dual simplex method and is infeasible. More... | |
virtual int | _getSimplexIterationLimit (int &limit) const override |
Defines a pure virtual function of the base class LP. More... | |
virtual void | _initialize (OptSense sense, int nRow, int maxRow, int nCol, int maxCol, Array< double > &obj, Array< double > &lBound, Array< double > &uBound, Array< Row * > &rows) override |
Loads the linear program defined by the following arguments to the solver. More... | |
virtual double | _lBound (int i) const override |
Returns the lower bound of column i. More... | |
virtual void | _loadBasis (Array< LPVARSTAT::STATUS > &lpVarStat, Array< SlackStat::STATUS > &slackStat) override |
Loads a basis to the solver. More... | |
virtual LPVARSTAT::STATUS | _lpVarStat (int i) const override |
Returns the status of the column i. More... | |
virtual int | _maxCol () const override |
Returns the maximal number of columns of the linear program. More... | |
virtual int | _maxRow () const override |
Returns the maximal number of rows of the linear program. More... | |
virtual int | _nCol () const override |
Returns the number of columns of the linear program. More... | |
virtual int | _nnz () const override |
Returns the number of nonzero elements in the constraint matrix (not including the right hand side). More... | |
virtual int | _nRow () const override |
Returns the number of rows of the linear program. More... | |
virtual double | _obj (int i) const override |
Returns the objective function coefficient of column i. More... | |
virtual int | _pivotSlackVariableIn (ArrayBuffer< int > &rows) override |
Pivots the slack variables stored in the buffer rows into the basis. More... | |
virtual OPTSTAT | _primalSimplex () override |
Calls the primal simplex method. More... | |
virtual double | _reco (int i) const override |
Returns the reduced cost of the column i. More... | |
virtual void | _remCols (ArrayBuffer< int > &vars) override |
Removes the columns listed in vars. More... | |
virtual void | _remRows (ArrayBuffer< int > &ind) override |
Removes the rows listed in ind. More... | |
virtual double | _rhs (int i) const override |
Returns the right hand side of row i. More... | |
virtual void | _row (int i, Row &r) const override |
Stores a copy of row i in r. More... | |
void | _rowRealloc (int newSize) override |
Reallocates the internal memory such that newSize rows can be stored. More... | |
virtual OptSense | _sense () const override |
Returns the sense of the optimization. More... | |
virtual void | _sense (const OptSense &newSense) override |
Changes the sense of the optimization to newSense. More... | |
virtual int | _setSimplexIterationLimit (int limit) override |
Changes the iteration limit of the Simplex algorithm. More... | |
virtual double | _slack (int i) const override |
Returns the value of the slack column of the row i. More... | |
virtual SlackStat::STATUS | _slackStat (int i) const override |
Returns the status of the slack column i. More... | |
virtual double | _uBound (int i) const override |
Returns the upper bound of column i. More... | |
virtual double | _value () const override |
Returns the optimum value of the linear program. More... | |
virtual double | _xVal (int i) const override |
Returns the value of the column i. More... | |
virtual double | _yVal (int i) const override |
Returns the value of the dual column of the row i. More... | |
void | convertSenseToBound (double inf, const char sense, const double right, const double range, double &lower, double &upper) const |
char | csense2osi (CSense *sense) const |
Converts the ABACUS representation of the row sense to the Osi representation. More... | |
void | freeChar (char *&ptr) |
void | freeChar (const char *&ptr) |
void | freeDouble (const double *&ptr) |
void | freeDouble (double *&ptr) |
void | freeInt (int *&ptr) |
void | freeStatus (CoinWarmStartBasis::Status *&) |
OsiSolverInterface * | getDefaultInterface () |
Allocates an Open Solver Interface of type defaultOsiSolver. More... | |
void | getSol () |
Extracts the solution. More... | |
void | loadDummyRow (OsiSolverInterface *s2, const double *lbounds, const double *ubounds, const double *objectives) |
Initializes the problem with a dummy row. More... | |
CoinWarmStartBasis::Status | lpVarStat2osi (LPVARSTAT::STATUS stat) const |
Converts the ABACUS variable status to OSI format. More... | |
const OsiIF & | operator= (const OsiIF &rhs) |
CSense::SENSE | osi2csense (char sense) const |
Converts the OSI representation of the row sense to the ABACUS representation. More... | |
LPVARSTAT::STATUS | osi2lpVarStat (CoinWarmStartBasis::Status stat) const |
Converts the OSI variable status to ABACUS format. More... | |
SlackStat::STATUS | osi2slackStat (CoinWarmStartBasis::Status stat) const |
Converts the OSI slack status to ABACUS format. More... | |
CoinWarmStartBasis::Status | slackStat2osi (SlackStat::STATUS stat) const |
Converts the ABACUS slack status to OSI format. More... | |
OsiSolverInterface * | switchInterfaces (SOLVERTYPE newMethod) |
Switches between exact and approximate solvers. More... | |
Private Attributes | |
const double * | barXVal_ |
const double * | collower_ |
An array storing the column lower bounds of the linear program. More... | |
const double * | colupper_ |
An array storing the column upper bounds of the linear program. More... | |
char * | cStat_ |
An array storing the statuses of the variables after the linear program has been optimized. More... | |
SOLVERTYPE | currentSolverType_ |
The type of the current solver interface. More... | |
LpMasterOsi * | lpMasterOsi_ |
int | numCols_ |
The number of columns currently used in the LP. More... | |
int | numRows_ |
The number of rows currently used in the LP. More... | |
const double * | objcoeff_ |
An array storing the objective function coefficients of the linear program. More... | |
OsiSolverInterface * | osiLP_ |
Pointer to the Osi solver interface. More... | |
double * | reco_ |
An array storing the values of the reduced costs after the linear program has been optimized. More... | |
const double * | rhs_ |
An array storing the right hand sides of the linear program. More... | |
double * | rowactivity_ |
An array storing the row activity of the linear program. More... | |
const char * | rowsense_ |
An array storing the row senses of the linear program. More... | |
char * | rStat_ |
An array storing the statuses of the slack variables after the linear program has been optimized. More... | |
double | value_ |
The value of the optimal solution. More... | |
CoinWarmStartBasis * | ws_ |
A warm start object storing information about a basis of the linear program. More... | |
double * | xVal_ |
An array storing the values of the variables after the linear program has been optimized. More... | |
double * | yVal_ |
An array storing the values of the dual variables after the linear program has been optimized. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from abacus::AbacusRoot | |
static bool | ascii2bool (const string &str) |
Converts the string str to a boolean value. More... | |
static bool | endsWith (const string &str, const string &end) |
Returns true if str ends with end, false otherwise. More... | |
static double | fracPart (double x) |
Returns the absolute value of the fractional part of x. More... | |
static const char * | onOff (bool value) |
Converts a boolean variable to the strings "on" and "off". More... | |
Protected Member Functions inherited from abacus::LP | |
void | colRangeCheck (int i) const |
Terminates the program if there is no column with index i. More... | |
void | colsNnz (int nRow, Array< Row * > &rows, Array< int > &nnz) |
Computes the number of nonzero elements in each column of a given set of rows. More... | |
void | rowRangeCheck (int r) const |
Terminates the program if there is no row with index r. More... | |
void | rows2cols (int nRow, Array< Row * > &rows, Array< SparVec * > &cols) |
Computes the columnwise representation of the row matrix. More... | |
Protected Attributes inherited from abacus::LP | |
SOLSTAT | barXValStatus_ |
SOLSTAT | basisStatus_ |
This member becomes Available if the status of the variables and the slack variables of the optimal solution can be accessed with the functions lpVarStat() and slackStat(), otherwise it has the value Missing. More... | |
ogdf::StopwatchCPU | lpSolverTime_ |
Master * | master_ |
A pointer to the corresponding master of the optimization. More... | |
int | nOpt_ |
The number of optimizations of the linear program. More... | |
OPTSTAT | optStat_ |
The status of the linear program. More... | |
SOLSTAT | recoStatus_ |
This member becomes Available if the reduced costs of the optimal solution can be accessed with the function reco(), otherwise it has the value Missing. More... | |
SOLSTAT | slackStatus_ |
This member becomes Available if the values of the slack variables of the optimal solution can be accessed with the function slack(), otherwise it has the value Missing. More... | |
SOLSTAT | xValStatus_ |
This member becomes Available if the \(x\)-values of the optimal solution can be accessed with the function xVal(), otherwise it has the value Missing. More... | |
SOLSTAT | yValStatus_ |
This member becomes Available if the values of the dual variables of the optimal solution can be accessed with the function yVal(), otherwise it has the value Missing/. More... | |
abacus::OsiIF::OsiIF | ( | Master * | master | ) |
Constructor without initialization.
This constructor does not initialize the problem data of the linear program. It must be loaded later with the function initialize().
master | A pointer to the corresponding master of the optimization. |
abacus::OsiIF::OsiIF | ( | Master * | master, |
OptSense | sense, | ||
int | nRow, | ||
int | maxRow, | ||
int | nCol, | ||
int | maxCol, | ||
Array< double > & | obj, | ||
Array< double > & | lb, | ||
Array< double > & | ub, | ||
Array< Row * > & | rows | ||
) |
A constructor with initialization.
master | A pointer to the corresponding master of the optimization. |
sense | The sense of the objective function. |
nCol | The number of columns (variables). |
maxCol | The maximal number of columns. |
nRow | The number of rows. |
maxRow | The maximal number of rows. |
obj | An array with the objective function coefficients. |
lb | An array with the lower bounds of the columns. |
ub | An array with the upper bounds of the columns. |
rows | An array storing the rows of the problem. |
|
virtual |
The destructor.
|
private |
|
overrideprivatevirtual |
Adds the columns newCols to the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Adds the rows to the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Calls an approximate method.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Calls the barrier method.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Returns the value of the column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Sets the lower bound of column i to newLb.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Sets the right hand side of the linear program to newRhs.
This array must have at least length of the number of rows. This function implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Sets the upper bound of column i to newLb.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Reallocates the internal memory such that newSize columns can be stored.
This function is obsolete, as memory management is completely handled by Osi.
It implements the corresponding pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Calls the dual simplex method.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Can be called if the last linear program has been solved with the dual simplex method and is infeasible.
This function is currently not supported by the interface.
In this case it computes the infeasible basic variable or constraint and the corresponding row nInvRow of the basis inverse. Either infeasRow or infeasCol is nonnegative. Then this number refers to an infeasible variable or slack variable, respectively. The function returns 0 if it is successful, 1 otherwise.
Currently this featureis not supported by the Open Solver Interface, therefore a call to this function always returns an error status.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Defines a pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Loads the linear program defined by the following arguments to the solver.
sense | The sense of the objective function. |
nRow | The number of rows. |
maxRow | The maximal number of rows. |
nCol | The number of columns (variables). |
maxCol | The maximal number of columns. |
obj | An array with the objective function coefficients. |
lBound | An array with the lower bounds of the columns. |
uBound | An array with the upper bounds of the columns. |
rows | An array storing the rows of the problem. |
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the lower bound of column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Loads a basis to the solver.
lpVarStat | An array storing the status of the columns. |
slackStat | An array storing the status of the slack variables. |
Implements abacus::LP.
|
overrideprivatevirtual |
Returns the status of the column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the maximal number of columns of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the maximal number of rows of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the number of columns of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the number of nonzero elements in the constraint matrix (not including the right hand side).
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the number of rows of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the objective function coefficient of column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Pivots the slack variables stored in the buffer rows into the basis.
This function defines the pure virtual function of the base class LP. This function is currently not supported by the interface.
rows | The numbers of the slack variables that should be pivoted in. |
Implements abacus::LP.
|
overrideprivatevirtual |
Calls the primal simplex method.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the reduced cost of the column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Removes the columns listed in vars.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Removes the rows listed in ind.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the right hand side of row i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Stores a copy of row i in r.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Reallocates the internal memory such that newSize rows can be stored.
This function is obsolete, as memory management is completely handled by Osi.
It implements the corresponding pure virtual function of the base class LP. If a reallocation is performed in the base class LP, we reinitialize the internal data structure. Actually this reinitialization is redundant since it would be performed automatically if addRows() or addCols() fail. However, to be consistent, and if a reallocation is performed to decrease the size of the arrays we call reinitialize().
Implements abacus::LP.
|
overrideprivatevirtual |
Returns the sense of the optimization.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Changes the sense of the optimization to newSense.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Changes the iteration limit of the Simplex algorithm.
This function defines a pure virtual function of the base class LP.
limit | The new value of the iteration limit. |
Implements abacus::LP.
|
overrideprivatevirtual |
Returns the value of the slack column of the row i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
overrideprivatevirtual |
Returns the status of the slack column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the upper bound of column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the optimum value of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the value of the column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineoverrideprivatevirtual |
Returns the value of the dual column of the row i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
|
inlineprivate |
|
private |
Converts the ABACUS representation of the row sense to the Osi representation.
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
private |
|
private |
Allocates an Open Solver Interface of type defaultOsiSolver.
|
private |
Extracts the solution.
I.e., the value, the status, the values of the variables, slack variables, and dual variables, the reduced costs, and the statuses of the variables and slack variables form the internal solver data structure.
|
private |
Initializes the problem with a dummy row.
To be used with CPLEX if there are no rows.
|
private |
Converts the ABACUS variable status to OSI format.
|
private |
Converts the OSI representation of the row sense to the ABACUS representation.
|
private |
Converts the OSI variable status to ABACUS format.
|
private |
Converts the OSI slack status to ABACUS format.
|
private |
Converts the ABACUS slack status to OSI format.
|
private |
Switches between exact and approximate solvers.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Pointer to the Osi solver interface.
It is later typecast to a pointer to an object of a solver specific derived class. See osiif.cc, OsiIF::_initialize.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |