#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. | |
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. | |
virtual | ~OsiIF () |
The destructor. | |
SOLVERTYPE | currentSolverType () const |
OsiSolverInterface * | osiLP () |
Public Member Functions inherited from abacus::LP | |
LP (Master *master) | |
Creates a linear program. | |
virtual | ~LP () |
The destructor. | |
void | addCols (ArrayBuffer< Column * > &newCols) |
Adds columns to the linear program. | |
void | addRows (ArrayBuffer< Row * > &newRows) |
Adds rows to the linear program. | |
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. | |
void | changeRhs (Array< double > &newRhs) |
Changes the complete right hand side of the linear program. | |
virtual void | changeUBound (int i, double newUb) |
Changes the upper bound of a single column. | |
void | colRealloc (int newSize) |
Performs a reallocation of the column space of the linear program. | |
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. | |
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. | |
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: | |
double | lBound (int i) const |
virtual void | loadBasis (Array< LPVARSTAT::STATUS > &lpVarStat, Array< SlackStat::STATUS > &slackStat) |
Loads a new basis for the linear program. | |
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. | |
virtual int | pivotSlackVariableIn (ArrayBuffer< int > &rows) |
Pivots the slack variables stored in the buffer rows into the basis. | |
virtual double | reco (int i) const |
SOLSTAT | recoStatus () const |
void | remCols (ArrayBuffer< int > &cols) |
Removes columns from the linear program. | |
void | remRows (ArrayBuffer< int > &ind) |
Removes rows of the linear program. | |
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. | |
OptSense | sense () const |
void | sense (const OptSense &newSense) |
int | setSimplexIterationLimit (int limit) |
Changes the iteration limit of the Simplex algorithm. | |
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. | |
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. | |
Private Member Functions | |
OsiIF (const OsiIF &rhs) | |
virtual void | _addCols (ArrayBuffer< Column * > &newVars) override |
Adds the columns newCols to the linear program. | |
virtual void | _addRows (ArrayBuffer< Row * > &newRows) override |
Adds the rows to the linear program. | |
virtual OPTSTAT | _approx () override |
Calls an approximate method. | |
virtual OPTSTAT | _barrier (bool doCrossover) override |
Calls the barrier method. | |
virtual double | _barXVal (int i) const override |
Returns the value of the column i. | |
virtual void | _changeLBound (int i, double newLb) override |
Sets the lower bound of column i to newLb. | |
virtual void | _changeRhs (Array< double > &newRhs) override |
Sets the right hand side of the linear program to newRhs. | |
virtual void | _changeUBound (int i, double newUb) override |
Sets the upper bound of column i to newLb. | |
void | _colRealloc (int newSize) override |
Reallocates the internal memory such that newSize columns can be stored. | |
virtual OPTSTAT | _dualSimplex () override |
Calls the dual simplex method. | |
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. | |
virtual int | _getSimplexIterationLimit (int &limit) const override |
Defines a pure virtual function of the base class LP. | |
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. | |
virtual double | _lBound (int i) const override |
Returns the lower bound of column i. | |
virtual void | _loadBasis (Array< LPVARSTAT::STATUS > &lpVarStat, Array< SlackStat::STATUS > &slackStat) override |
Loads a basis to the solver. | |
virtual LPVARSTAT::STATUS | _lpVarStat (int i) const override |
Returns the status of the column i. | |
virtual int | _maxCol () const override |
Returns the maximal number of columns of the linear program. | |
virtual int | _maxRow () const override |
Returns the maximal number of rows of the linear program. | |
virtual int | _nCol () const override |
Returns the number of columns of the linear program. | |
virtual int | _nnz () const override |
Returns the number of nonzero elements in the constraint matrix (not including the right hand side). | |
virtual int | _nRow () const override |
Returns the number of rows of the linear program. | |
virtual double | _obj (int i) const override |
Returns the objective function coefficient of column i. | |
virtual int | _pivotSlackVariableIn (ArrayBuffer< int > &rows) override |
Pivots the slack variables stored in the buffer rows into the basis. | |
virtual OPTSTAT | _primalSimplex () override |
Calls the primal simplex method. | |
virtual double | _reco (int i) const override |
Returns the reduced cost of the column i. | |
virtual void | _remCols (ArrayBuffer< int > &vars) override |
Removes the columns listed in vars. | |
virtual void | _remRows (ArrayBuffer< int > &ind) override |
Removes the rows listed in ind. | |
virtual double | _rhs (int i) const override |
Returns the right hand side of row i. | |
virtual void | _row (int i, Row &r) const override |
Stores a copy of row i in r. | |
void | _rowRealloc (int newSize) override |
Reallocates the internal memory such that newSize rows can be stored. | |
virtual OptSense | _sense () const override |
Returns the sense of the optimization. | |
virtual void | _sense (const OptSense &newSense) override |
Changes the sense of the optimization to newSense. | |
virtual int | _setSimplexIterationLimit (int limit) override |
Changes the iteration limit of the Simplex algorithm. | |
virtual double | _slack (int i) const override |
Returns the value of the slack column of the row i. | |
virtual SlackStat::STATUS | _slackStat (int i) const override |
Returns the status of the slack column i. | |
virtual double | _uBound (int i) const override |
Returns the upper bound of column i. | |
virtual double | _value () const override |
Returns the optimum value of the linear program. | |
virtual double | _xVal (int i) const override |
Returns the value of the column i. | |
virtual double | _yVal (int i) const override |
Returns the value of the dual column of the row i. | |
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. | |
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. | |
void | getSol () |
Extracts the solution. | |
void | loadDummyRow (OsiSolverInterface *s2, const double *lbounds, const double *ubounds, const double *objectives) |
Initializes the problem with a dummy row. | |
CoinWarmStartBasis::Status | lpVarStat2osi (LPVARSTAT::STATUS stat) const |
Converts the ABACUS variable status to OSI format. | |
const OsiIF & | operator= (const OsiIF &rhs) |
CSense::SENSE | osi2csense (char sense) const |
Converts the OSI representation of the row sense to the ABACUS representation. | |
LPVARSTAT::STATUS | osi2lpVarStat (CoinWarmStartBasis::Status stat) const |
Converts the OSI variable status to ABACUS format. | |
SlackStat::STATUS | osi2slackStat (CoinWarmStartBasis::Status stat) const |
Converts the OSI slack status to ABACUS format. | |
CoinWarmStartBasis::Status | slackStat2osi (SlackStat::STATUS stat) const |
Converts the ABACUS slack status to OSI format. | |
OsiSolverInterface * | switchInterfaces (SOLVERTYPE newMethod) |
Switches between exact and approximate solvers. | |
Private Attributes | |
const double * | barXVal_ |
const double * | collower_ |
An array storing the column lower bounds of the linear program. | |
const double * | colupper_ |
An array storing the column upper bounds of the linear program. | |
char * | cStat_ |
An array storing the statuses of the variables after the linear program has been optimized. | |
SOLVERTYPE | currentSolverType_ |
The type of the current solver interface. | |
LpMasterOsi * | lpMasterOsi_ |
int | numCols_ |
The number of columns currently used in the LP. | |
int | numRows_ |
The number of rows currently used in the LP. | |
const double * | objcoeff_ |
An array storing the objective function coefficients of the linear program. | |
OsiSolverInterface * | osiLP_ |
Pointer to the Osi solver interface. | |
double * | reco_ |
An array storing the values of the reduced costs after the linear program has been optimized. | |
const double * | rhs_ |
An array storing the right hand sides of the linear program. | |
double * | rowactivity_ |
An array storing the row activity of the linear program. | |
const char * | rowsense_ |
An array storing the row senses of the linear program. | |
char * | rStat_ |
An array storing the statuses of the slack variables after the linear program has been optimized. | |
double | value_ |
The value of the optimal solution. | |
CoinWarmStartBasis * | ws_ |
A warm start object storing information about a basis of the linear program. | |
double * | xVal_ |
An array storing the values of the variables after the linear program has been optimized. | |
double * | yVal_ |
An array storing the values of the dual variables after the linear program has been optimized. | |
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. | |
static bool | endsWith (const string &str, const string &end) |
Returns true if str ends with end, false otherwise. | |
static double | fracPart (double x) |
Returns the absolute value of the fractional part of x. | |
static const char * | onOff (bool value) |
Converts a boolean variable to the strings "on" and "off". | |
Protected Member Functions inherited from abacus::LP | |
void | colRangeCheck (int i) const |
Terminates the program if there is no column with index i. | |
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. | |
void | rowRangeCheck (int r) const |
Terminates the program if there is no row with index r. | |
void | rows2cols (int nRow, Array< Row * > &rows, Array< SparVec * > &cols) |
Computes the columnwise representation of the row matrix. | |
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. | |
ogdf::StopwatchCPU | lpSolverTime_ |
Master * | master_ |
A pointer to the corresponding master of the optimization. | |
int | nOpt_ |
The number of optimizations of the linear program. | |
OPTSTAT | optStat_ |
The status of the linear program. | |
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. | |
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. | |
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. | |
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/. | |
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.
|
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.
Calls an approximate method.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Calls the barrier method.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Returns the value of the column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Sets the lower bound of column i to newLb.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
Sets the upper bound of column i to newLb.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
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.
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.
Returns the maximal number of columns of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Returns the maximal number of rows of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Returns the number of columns of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
Returns the number of rows of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
Calls the primal simplex method.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
Returns the right hand side of row i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Stores a copy of row i in r.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
Returns the sense of the optimization.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Changes the sense of the optimization to newSense.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
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.
Returns the upper bound of column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Returns the optimum value of the linear program.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
Returns the value of the column i.
It implements the pure virtual function of the base class LP.
Implements abacus::LP.
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.
Converts the ABACUS representation of the row sense to the Osi representation.
|
inline |
|
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.
|
inline |
|
private |
Converts the ABACUS slack status to OSI format.
|
private |
Switches between exact and approximate solvers.
|
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 |