Go to the documentation of this file.
10 #ifndef OsiGlpkSolverInterface_H
11 #define OsiGlpkSolverInterface_H
15 #include "CoinPackedMatrix.hpp"
16 #include "CoinWarmStartBasis.hpp"
27 #ifndef GLP_PROB_DEFINED
28 #define GLP_PROB_DEFINED
31 double _opaque_prob[100];
120 return (
dynamic_cast< CoinWarmStart *
>(
new CoinWarmStartBasis()));
126 virtual bool setWarmStart(
const CoinWarmStart *warmstart);
221 virtual bool isBinary(
int columnNumber)
const;
228 virtual bool isInteger(
int columnNumber)
const;
280 virtual std::vector< double * >
getDualRays(
int maxNumRays,
281 bool fullRay =
false)
const;
299 virtual std::vector< double * >
getPrimalRays(
int maxNumRays)
const;
318 virtual void setObjCoeff(
int elementIndex,
double elementValue);
323 virtual void setColLower(
int elementIndex,
double elementValue);
328 virtual void setColUpper(
int elementIndex,
double elementValue);
334 double lower,
double upper);
345 const int *indexLast,
346 const double *boundList);
350 virtual void setRowLower(
int elementIndex,
double elementValue);
354 virtual void setRowUpper(
int elementIndex,
double elementValue);
360 double lower,
double upper);
363 virtual void setRowType(
int index,
char sense,
double rightHandSide,
375 const int *indexLast,
376 const double *boundList);
389 const int *indexLast,
390 const char *senseList,
391 const double *rhsList,
392 const double *rangeList);
407 virtual void setInteger(
const int *indices,
int len);
446 virtual void addCol(
const CoinPackedVectorBase &vec,
447 const double collb,
const double colub,
452 virtual void addCols(
const int numcols,
453 const CoinPackedVectorBase *
const *cols,
454 const double *collb,
const double *colub,
457 virtual void deleteCols(
const int num,
const int *colIndices);
461 virtual void addRow(
const CoinPackedVectorBase &vec,
462 const double rowlb,
const double rowub);
464 virtual void addRow(
const CoinPackedVectorBase &vec,
465 const char rowsen,
const double rowrhs,
466 const double rowrng);
470 virtual void addRows(
const int numrows,
471 const CoinPackedVectorBase *
const *rows,
472 const double *rowlb,
const double *rowub);
474 virtual void addRows(
const int numrows,
475 const CoinPackedVectorBase *
const *rows,
476 const char *rowsen,
const double *rowrhs,
477 const double *rowrng);
479 virtual void deleteRows(
const int num,
const int *rowIndices);
506 double effectivenessLb = 0.0);
526 virtual void loadProblem(
const CoinPackedMatrix &matrix,
527 const double *collb,
const double *colub,
529 const double *rowlb,
const double *rowub);
539 double *&collb,
double *&colub,
double *&obj,
540 double *&rowlb,
double *&rowub);
554 virtual void loadProblem(
const CoinPackedMatrix &matrix,
555 const double *collb,
const double *colub,
557 const char *rowsen,
const double *rowrhs,
558 const double *rowrng);
568 double *&collb,
double *&colub,
double *&obj,
569 char *&rowsen,
double *&rowrhs,
574 virtual void loadProblem(
const int numcols,
const int numrows,
575 const CoinBigIndex *start,
const int *index,
577 const double *collb,
const double *colub,
579 const double *rowlb,
const double *rowub);
583 virtual void loadProblem(
const int numcols,
const int numrows,
584 const CoinBigIndex *start,
const int *index,
586 const double *collb,
const double *colub,
588 const char *rowsen,
const double *rowrhs,
589 const double *rowrng);
593 virtual int readMps(
const char *filename,
594 const char *extension =
"mps");
600 virtual void writeMps(
const char *filename,
601 const char *extension =
"mps",
602 double objSense = 0.0)
const;
709 virtual void reset();
909 #endif // OsiGlpkSolverInterface_H
CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
void setColName(int ndx, std::string name)
Set a column name.
@ KEEPCACHED_MATRIX
problem matrix: matrix ordered by column and by row
bool setIntParam(OsiIntParam key, int value)
Set an integer parameter.
virtual bool isIterationLimitReached() const
Iteration limit reached?
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -COIN_DBL_MAX for -infinity.
virtual void setRowType(int index, char sense, double rightHandSide, double range)
Set the type of a single row
virtual void setColUpper(int elementIndex, double elementValue)=0
Set a single column upper bound.
virtual void resolve()
Resolve an LP relaxation after problem modification.
LPX * getModelPtr()
Get pointer to GLPK model.
static unsigned int getNumInstances()
Return the number of LP/MIP instances of instantiated objects using the GLPK environment.
virtual void applyColCut(const OsiColCut &cc)
Apply a column cut (bound adjustment).
virtual int getNumCols() const
Get number of columns.
virtual bool isBinary(int colIndex) const
Return true if the variable is binary.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)
Add a row (constraint) to the problem.
virtual void deleteCols(const int num, const int *colIndices)
Remove a set of columns (primal variables) from the problem.
double * hotStartCVal_
primal variable values
double primalObjectiveLimit_
primal objective limit (measure of goodness; stop if we're better)
virtual int readMps(const char *filename, const char *extension="mps")
Read an mps file from the given filename.
virtual void setRowSetTypes(const int *indexFirst, const int *indexLast, const char *senseList, const double *rhsList, const double *rangeList)
Set the type of a number of rows simultaneously The default implementation just invokes setRowType()...
void freeCachedMatrix()
free cached matrices
void gutsOfCopy(const OsiGlpkSolverInterface &source)
The real work of a copy constructor (used by copy and assignment)
#define LPX
GPLK Solver Interface.
virtual bool isFeasible() const
(Integer) Feasible solution found?
bool isIterationLimitReached_
glpk stopped on iteration limit
void freeCachedData(int keepCached=KEEPCACHED_NONE)
free all cached data (except specified entries, see getLpPtr())
virtual void branchAndBound()
Invoke solver's built-in enumeration algorithm.
double * obj_
Pointer to objective vector.
virtual double getObjSense() const
Get objective function sense (1 for min (default), -1 for max)
int nameDisc_
OSI name discipline.
virtual bool isInteger(int colIndex) const
Return true if the variable is integer.
@ KEEPCACHED_COLUMN
column information: objective values, lower and upper bounds, variable types
bool isFeasible_
glpk declared the problem feasible
double * colsol_
Pointer to primal solution vector.
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
@ KEEPCACHED_PROBLEM
only discard cached LP solution
bool getStrParam(OsiStrParam key, std::string &value) const
Get a string parameter.
virtual double getObjValue() const
Get objective function value.
@ FREECACHED_MATRIX
free only cached matrix and LP solution information
virtual const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of matrix.
void printBounds()
Just for testing purposes.
LPX * getMutableModelPtr() const
Pointer to the model.
double objOffset_
constant offset for objective function
virtual void writeMps(const char *filename, const char *extension="mps", double objSense=0.0) const
Write the problem into an mps file of the given filename.
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
virtual void setColLower(int elementIndex, double elementValue)
Set a single column lower bound Use -COIN_DBL_MAX for -infinity.
bool setStrParam(OsiStrParam key, const std::string &value)
Set a string parameter.
LPX * lp_
GPLK model represented by this class instance.
virtual void loadProblem(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load in an problem by copying the arguments (the constraints on the rows are given by lower and upper...
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
bool isObjUpperLimitReached_
glpk stopped on upper objective limit
bool isPrimInfeasible_
glpk declared the problem primal infeasible
double * rowrange_
Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows)
virtual CoinWarmStart * getWarmStart() const
Get warmstarting information.
virtual int readMps(const char *filename, const char *extension="mps")
Read a problem in MPS format from the given filename.
double dualTolerance_
dual feasibility tolerance
void freeCachedColRim()
free cached column rim vectors
@ OsiHintTry
This means it is only a hint.
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver.
void freeCachedRowRim()
free cached row rim vectors
bool isDualInfeasible_
glpk declared the problem dual infeasible
virtual void markHotStart()
Create a hotstart point of the optimization process.
virtual std::vector< double * > getDualRays(int maxNumRays, bool fullRay=false) const
Get as many dual rays as the solver can provide.
virtual bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.
virtual bool isFreeBinary(int colIndex) const
Return true if the variable is binary and not fixed.
int iter_used_
Number of iterations.
void OsiGlpkSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiGlpkSolverInterface class.
int * hotStartCStat_
column status array
virtual void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound Use COIN_DBL_MAX for infinity.
int maxIteration_
simplex iteration limit (per call to solver)
Collections of row cuts and column cuts.
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub)
Add a set of rows (constraints) to the problem.
int hotStartCStatSize_
Hotstart information.
virtual bool isAbandoned() const
Are there a numerical difficulties?
virtual void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
static unsigned int numInstances_
number of GLPK instances currently in use (counts only those created by OsiGlpk)
double primalTolerance_
primal feasibility tolerance
double * rowlower_
Pointer to dense vector of row lower bounds.
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
virtual void setObjSense(double s)
Set objective function sense (1 for min (default), -1 for max,)
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
virtual bool isIntegerNonBinary(int colIndex) const
Return true if the variable is general integer.
@ KEEPCACHED_NONE
discard all cached data (default)
double * rhs_
Pointer to dense vector of row right-hand side values.
bool getDblParam(OsiDblParam key, double &value) const
Get a double parameter.
double * rowsol_
Pointer to dual solution vector.
@ FREECACHED_ROW
free only cached row and LP solution information
double * hotStartRVal_
row slack values
virtual const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of matrix.
virtual bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
OsiGlpkSolverInterface()
Default Constructor.
int hotStartRStatSize_
size of row status and value arrays
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)=0
Add a column (primal variable) to the problem.
virtual std::vector< double * > getPrimalRays(int maxNumRays) const
Get as many primal rays as the solver can provide.
char * ctype_
Pointer to dense vector of variable types (continous, binary, integer)
void gutsOfConstructor()
The real work of the constructor.
@ KEEPCACHED_RESULTS
LP solution: primal and dual solution, reduced costs, row activities.
virtual const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
@ FREECACHED_COLUMN
free only cached column and LP solution information
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use COIN_DBL_MAX for infinity.
virtual void applyRowCut(const OsiRowCut &rc)
Apply a row cut. Return true if cut was applied.
double * redcost_
Pointer to reduced cost vector.
double * collower_
Pointer to dense vector of variable lower bounds.
virtual bool isContinuous(int colNumber) const
Return true if column is continuous.
void setObjName(std::string name)
Set the objective function name.
virtual void setRowSetBounds(const int *indexFirst, const int *indexLast, const double *boundList)
Set the bounds on a number of rows simultaneously The default implementation just invokes setRowLowe...
char * rowsense_
Pointer to dense vector of row sense indicators.
double dualObjectiveLimit_
dual objective limit (measure of badness; stop if we're worse)
void gutsOfDestructor()
The real work of the destructor.
@ OsiLastHintParam
Just a marker, so that OsiSolverInterface can allocate a static sized array to store parameters.
virtual const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
std::vector< int > OsiVectorInt
Vector of int.
double * hotStartRDualVal_
row dual values
virtual void setColSolution(const double *colsol)
Set the primal solution column values.
@ KEEPCACHED_ROW
row information: right hand sides, ranges and senses, lower and upper bounds for row
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
bool setHintParam(OsiHintParam key, bool sense=true, OsiHintStrength strength=OsiHintTry, void *info=0)
Set a hint parameter.
bool isAbandoned_
glpk abandoned the problem
virtual const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
double * rowact_
Pointer to row activity (slack) vector.
@ KEEPCACHED_ALL
keep all cached data (similar to getMutableLpPtr())
bool getIntParam(OsiIntParam key, int &value) const
Get an integer parameter.
static void incrementInstanceCounter()
GLPK has a context which must be freed after all GLPK LPs (or MIPs) are freed.
@ FREECACHED_RESULTS
free only cached LP solution information
virtual void deleteRows(const int num, const int *rowIndices)
Delete a set of rows (constraints) from the problem.
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)
Add a column (primal variable) to the problem.
bool setDblParam(OsiDblParam key, double value)
Set a double parameter.
double * hotStartCDualVal_
dual variable values
virtual CoinBigIndex getNumElements() const
Get number of nonzero elements.
virtual bool isProvenOptimal() const
Is optimality proven?
double * colupper_
Pointer to dense vector of variable lower bounds.
virtual int getNumRows() const
Get number of rows.
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
virtual void assignProblem(CoinPackedMatrix *&matrix, double *&collb, double *&colub, double *&obj, double *&rowlb, double *&rowub)
Load in an problem by assuming ownership of the arguments (the constraints on the rows are given by l...
virtual OsiSolverInterface * clone(bool copyData=true) const
Clone.
void freeAllMemory()
free all allocated memory
virtual bool isTimeLimitReached() const
Time limit reached?
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
OsiGlpkSolverInterface & operator=(const OsiGlpkSolverInterface &rhs)
Assignment operator.
CoinPackedMatrix * matrixByCol_
Pointer to row-wise copy of problem matrix coefficients.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
virtual void setRowPrice(const double *rowprice)
Set dual solution vector.
virtual void addCols(const int numcols, const CoinPackedVectorBase *const *cols, const double *collb, const double *colub, const double *obj)
Add a set of columns (primal variables) to the problem.
void fillColBounds() const
Fill cached collumn bounds.
virtual void addCols(const int numcols, const CoinPackedVectorBase *const *cols, const double *collb, const double *colub, const double *obj)
Add a set of columns (primal variables) to the problem.
std::string probName_
Problem name.
void setRowName(int ndx, std::string name)
Set a row name.
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub)
Add a set of rows (constraints) to the problem.
virtual void setRowBounds(int elementIndex, double lower, double upper)
Set a single row lower and upper bound The default implementation just invokes setRowLower() and set...
virtual double getInfinity() const
Get solver's value for infinity.
virtual void solveFromHotStart()
Optimize starting from the hotstart.
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
static void decrementInstanceCounter()
GLPK has a context which must be freed after all GLPK LPs (or MIPs) are freed.
void freeCachedResults()
free cached result vectors
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
virtual OsiVectorInt getFractionalIndices(const double etol=1.e-05) const
Get vector of indices of primal variables which are integer variables but have fractional values in t...
virtual void setColLower(int elementIndex, double elementValue)=0
Set a single column lower bound.
virtual ApplyCutsReturnCode applyCuts(const OsiCuts &cs, double effectivenessLb=0.0)
Apply a collection of cuts.
virtual ~OsiGlpkSolverInterface()
Destructor.
int * hotStartRStat_
row status array
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)=0
Add a row (constraint) to the problem.
bool isTimeLimitReached_
glpk stopped on time limit
virtual void setContinuous(int index)
Set the index-th variable to be a continuous variable.
virtual void setColBounds(int elementIndex, double lower, double upper)
Set a single column lower and upper bound The default implementation just invokes setColLower() and ...
bool isObjLowerLimitReached_
glpk stopped on lower objective limit
virtual void initialSolve()
Solve initial LP relaxation.
virtual void reset()
Resets as if default constructor.
Abstract Base Class for describing an interface to a solver.
virtual void setColSetBounds(const int *indexFirst, const int *indexLast, const double *boundList)
Set the bounds on a number of columns simultaneously The default implementation just invokes setColL...
friend void OsiGlpkSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiGlpkSolverInterface class.
virtual void unmarkHotStart()
Delete the snapshot.
void * info_[OsiLastHintParam]
Array for info blocks associated with hints.
int hotStartMaxIteration_
simplex iteration limit (for hot start)
double * rowupper_
Pointer to dense vector of row upper bounds.