10 #ifndef OsiGlpkSolverInterface_H
11 #define OsiGlpkSolverInterface_H
27 #ifndef GLP_PROB_DEFINED
28 #define GLP_PROB_DEFINED
30 typedef struct {
double _opaque_prob[100]; }
glp_prob;
218 virtual bool isBinary(
int columnNumber)
const;
225 virtual bool isInteger(
int columnNumber)
const;
277 virtual std::vector<double*>
getDualRays(
int maxNumRays,
278 bool fullRay=
false)
const;
296 virtual std::vector<double*>
getPrimalRays(
int maxNumRays)
const;
315 virtual void setObjCoeff(
int elementIndex,
double elementValue );
320 virtual void setColLower(
int elementIndex,
double elementValue );
325 virtual void setColUpper(
int elementIndex,
double elementValue );
331 double lower,
double upper );
342 const int* indexLast,
343 const double* boundList);
347 virtual void setRowLower(
int elementIndex,
double elementValue );
351 virtual void setRowUpper(
int elementIndex,
double elementValue );
357 double lower,
double upper );
360 virtual void setRowType(
int index,
char sense,
double rightHandSide,
372 const int* indexLast,
373 const double* boundList);
386 const int* indexLast,
387 const char* senseList,
388 const double* rhsList,
389 const double* rangeList);
404 virtual void setInteger(
const int* indices,
int len);
444 const double collb,
const double colub,
449 virtual void addCols(
const int numcols,
451 const double* collb,
const double* colub,
454 virtual void deleteCols(
const int num,
const int * colIndices);
459 const double rowlb,
const double rowub);
462 const char rowsen,
const double rowrhs,
463 const double rowrng);
467 virtual void addRows(
const int numrows,
469 const double* rowlb,
const double* rowub);
471 virtual void addRows(
const int numrows,
473 const char* rowsen,
const double* rowrhs,
474 const double* rowrng);
476 virtual void deleteRows(
const int num,
const int * rowIndices);
503 double effectivenessLb = 0.0);
524 const double* collb,
const double* colub,
526 const double* rowlb,
const double* rowub);
536 double*& collb,
double*& colub,
double*& obj,
537 double*& rowlb,
double*& rowub);
552 const double* collb,
const double* colub,
554 const char* rowsen,
const double* rowrhs,
555 const double* rowrng);
565 double*& collb,
double*& colub,
double*& obj,
566 char*& rowsen,
double*& rowrhs,
571 virtual void loadProblem(
const int numcols,
const int numrows,
572 const int* start,
const int* index,
574 const double* collb,
const double* colub,
576 const double* rowlb,
const double* rowub);
580 virtual void loadProblem(
const int numcols,
const int numrows,
581 const int* start,
const int* index,
583 const double* collb,
const double* colub,
585 const char* rowsen,
const double* rowrhs,
586 const double* rowrng);
590 virtual int readMps(
const char *filename,
591 const char *extension =
"mps");
597 virtual void writeMps(
const char *filename,
598 const char *extension =
"mps",
599 double objSense=0.0)
const;
708 virtual void reset();
912 #endif // OsiGlpkSolverInterface_H
virtual void markHotStart()
Create a hotstart point of the optimization process.
void freeCachedRowRim()
free cached row rim vectors
double primalObjectiveLimit_
primal objective limit (measure of goodness; stop if we're better)
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
virtual const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of matrix.
virtual void setColLower(int elementIndex, double elementValue)=0
Set a single column lower bound.
free only cached matrix and LP solution information
keep all cached data (similar to getMutableLpPtr())
virtual int getNumCols() const
Get number of columns.
bool setIntParam(OsiIntParam key, int value)
Set an integer parameter.
bool isIterationLimitReached_
glpk stopped on iteration limit
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()...
keepCachedFlag
Get pointer to GLPK model.
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
int hotStartRStatSize_
size of row status and value arrays
bool isPrimInfeasible_
glpk declared the problem primal infeasible
double * colupper_
Pointer to dense vector of variable lower bounds.
double * hotStartRDualVal_
row dual values
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...
int maxIteration_
simplex iteration limit (per call to solver)
virtual CoinWarmStart * getWarmStart() const
Get warmstarting information.
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 void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)=0
Add a column (primal variable) to the problem.
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
std::string probName_
Problem name.
virtual bool isContinuous(int colNumber) const
Return true if column is continuous.
void gutsOfConstructor()
The real work of the constructor.
virtual void deleteRows(const int num, const int *rowIndices)
Delete a set of rows (constraints) from the problem.
double * rowlower_
Pointer to dense vector of row lower bounds.
virtual int getNumElements() const
Get number of nonzero elements.
static unsigned int getNumInstances()
Return the number of LP/MIP instances of instantiated objects using the GLPK environment.
virtual const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
virtual void setRowPrice(const double *rowprice)
Set dual solution vector.
virtual double getObjValue() const
Get objective function value.
virtual void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound Use COIN_DBL_MAX for infinity.
double * rowsol_
Pointer to dual solution vector.
virtual void setColLower(int elementIndex, double elementValue)
Set a single column lower bound Use -COIN_DBL_MAX for -infinity.
void gutsOfCopy(const OsiGlpkSolverInterface &source)
The real work of a copy constructor (used by copy and assignment)
void gutsOfDestructor()
The real work of the destructor.
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 int getNumRows() const
Get number of rows.
double * hotStartRVal_
row slack values
static void incrementInstanceCounter()
GLPK has a context which must be freed after all GLPK LPs (or MIPs) are freed.
LPX * getMutableModelPtr() const
Pointer to the model.
free only cached row and LP solution information
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
OsiGlpkSolverInterface()
Default Constructor.
int nameDisc_
OSI name discipline.
virtual bool isAbandoned() const
Are there a numerical difficulties?
void printBounds()
Just for testing purposes.
virtual void initialSolve()
Solve initial LP relaxation.
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
void freeAllMemory()
free all allocated memory
Sparse Matrix Base Class.
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)
Add a column (primal variable) to the problem.
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub)
virtual void setColSolution(const double *colsol)
Set the primal solution column values.
double * hotStartCVal_
primal variable values
double * hotStartCDualVal_
dual variable values
LPX * lp_
GPLK model represented by this class instance.
double * collower_
Pointer to dense vector of variable lower bounds.
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
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...
double primalTolerance_
primal feasibility tolerance
#define LPX
GPLK Solver Interface.
Collections of row cuts and column cuts.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)
Add a row (constraint) to the problem.
problem matrix: matrix ordered by column and by row
virtual int readMps(const char *filename, const char *extension="mps")
Read a problem in MPS format from the given filename.
virtual bool isIterationLimitReached() const
Iteration limit reached?
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
virtual void setColUpper(int elementIndex, double elementValue)=0
Set a single column upper bound.
virtual void branchAndBound()
Invoke solver's built-in enumeration algorithm.
virtual bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
Just a marker, so that OsiSolverInterface can allocate a static sized array to store parameters...
Abstract base class for various sparse vectors.
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.
discard all cached data (default)
static void decrementInstanceCounter()
GLPK has a context which must be freed after all GLPK LPs (or MIPs) are freed.
std::vector< int > OsiVectorInt
Vector of int.
void * info_[OsiLastHintParam]
Array for info blocks associated with hints.
virtual void applyRowCut(const OsiRowCut &rc)
Apply a row cut. Return true if cut was applied.
void setObjName(std::string name)
Set the objective function name.
bool isFeasible_
glpk declared the problem feasible
double * obj_
Pointer to objective vector.
virtual bool isFeasible() const
(Integer) Feasible solution found?
virtual void setContinuous(int index)
Set the index-th variable to be a continuous variable.
virtual double getObjSense() const
Get objective function sense (1 for min (default), -1 for max)
double * redcost_
Pointer to reduced cost vector.
int hotStartCStatSize_
Hotstart information.
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...
void setRowName(int ndx, std::string name)
Set a row name.
virtual int readMps(const char *filename, const char *extension="mps")
Read an mps file from the given filename.
bool getIntParam(OsiIntParam key, int &value) const
Get an integer parameter.
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -COIN_DBL_MAX for -infinity.
CoinPackedMatrix * matrixByCol_
Pointer to row-wise copy of problem matrix coefficients.
virtual bool isProvenOptimal() const
Is optimality proven?
virtual const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of matrix.
row information: right hand sides, ranges and senses, lower and upper bounds for row ...
LP solution: primal and dual solution, reduced costs, row activities.
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.
double * rowupper_
Pointer to dense vector of row upper bounds.
free only cached LP solution information
double dualObjectiveLimit_
dual objective limit (measure of badness; stop if we're worse)
virtual void reset()
Resets as if default constructor.
char * ctype_
Pointer to dense vector of variable types (continous, binary, integer)
column information: objective values, lower and upper bounds, variable types
int iter_used_
Number of iterations.
virtual bool isBinary(int colIndex) const
Return true if the variable is binary.
virtual std::vector< double * > getDualRays(int maxNumRays, bool fullRay=false) const
Get as many dual rays as the solver can provide.
bool setDblParam(OsiDblParam key, double value)
Set a double parameter.
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub)
bool isDualInfeasible_
glpk declared the problem dual infeasible
void setColName(int ndx, std::string name)
Set a column name.
free only cached column and LP solution information
Abstract Base Class for describing an interface to a solver.
virtual void deleteCols(const int num, const int *colIndices)
Remove a set of columns (primal variables) from the problem.
double * rhs_
Pointer to dense vector of row right-hand side values.
virtual void solveFromHotStart()
Optimize starting from the hotstart.
void OsiGlpkSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiGlpkSolverInterface class.
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...
double * rowact_
Pointer to row activity (slack) vector.
bool isObjLowerLimitReached_
glpk stopped on lower objective limit
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 setHintParam(OsiHintParam key, bool sense=true, OsiHintStrength strength=OsiHintTry, void *info=0)
Set a hint parameter.
virtual const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
virtual void resolve()
Resolve an LP relaxation after problem modification.
int * hotStartCStat_
column status array
virtual void applyColCut(const OsiColCut &cc)
Apply a column cut (bound adjustment).
void freeCachedResults()
free cached result vectors
virtual void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
only discard cached LP solution
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)=0
Add a row (constraint) to the problem.
Abstract base class for warm start information.
bool setStrParam(OsiStrParam key, const std::string &value)
Set a string parameter.
virtual void unmarkHotStart()
Delete the snapshot.
bool isObjUpperLimitReached_
glpk stopped on upper objective limit
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver...
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...
virtual void setObjSense(double s)
Set objective function sense (1 for min (default), -1 for max,)
virtual bool isTimeLimitReached() const
Time limit reached?
virtual OsiSolverInterface * clone(bool copyData=true) const
Clone.
OsiGlpkSolverInterface & operator=(const OsiGlpkSolverInterface &rhs)
Assignment operator.
char * rowsense_
Pointer to dense vector of row sense indicators.
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
bool isAbandoned_
glpk abandoned the problem
virtual bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
int hotStartMaxIteration_
simplex iteration limit (for hot start)
virtual bool isInteger(int colIndex) const
Return true if the variable is integer.
int bbWasLast_
GPLK model represented by this class instance.
static unsigned int numInstances_
number of GLPK instances currently in use (counts only those created by OsiGlpk)
double * rowrange_
Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows) ...
virtual bool isFreeBinary(int colIndex) const
Return true if the variable is binary and not fixed.
friend void OsiGlpkSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiGlpkSolverInterface class.
bool getDblParam(OsiDblParam key, double &value) const
Get a double parameter.
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use COIN_DBL_MAX for infinity.
double objOffset_
constant offset for objective function
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
LPX * getModelPtr()
Get pointer to GLPK model.
This means it is only a hint.
virtual const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
double * colsol_
Pointer to primal solution vector.
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
void freeCachedColRim()
free cached column rim vectors
virtual ApplyCutsReturnCode applyCuts(const OsiCuts &cs, double effectivenessLb=0.0)
Apply a collection of cuts.
CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
double dualTolerance_
dual feasibility tolerance
virtual void setRowType(int index, char sense, double rightHandSide, double range)
Set the type of a single row
virtual std::vector< double * > getPrimalRays(int maxNumRays) const
Get as many primal rays as the solver can provide.
void fillColBounds() const
Fill cached collumn bounds.
virtual double getInfinity() const
Get solver's value for infinity.
int * hotStartRStat_
row status array
virtual ~OsiGlpkSolverInterface()
Destructor.
virtual bool isIntegerNonBinary(int colIndex) const
Return true if the variable is general integer.
void freeCachedData(int keepCached=KEEPCACHED_NONE)
free all cached data (except specified entries, see getLpPtr())
The default COIN simplex (basis-oriented) warm start class.
void freeCachedMatrix()
free cached matrices
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
bool getStrParam(OsiStrParam key, std::string &value) const
Get a string parameter.
bool isTimeLimitReached_
glpk stopped on time limit