Go to the documentation of this file.
15 #ifndef OsiGrbSolverInterface_H
16 #define OsiGrbSolverInterface_H
123 virtual bool setWarmStart(
const CoinWarmStart *warmstart);
266 virtual std::vector< double * >
getDualRays(
int maxNumRays,
267 bool fullRay =
false)
const;
279 virtual std::vector< double * >
getPrimalRays(
int maxNumRays)
const;
291 virtual void setObjCoeff(
int elementIndex,
double elementValue);
294 virtual void setObjCoeffSet(
const int *indexFirst,
const int *indexLast,
295 const double *coeffList);
300 virtual void setColLower(
int elementIndex,
double elementValue);
305 virtual void setColUpper(
int elementIndex,
double elementValue);
310 virtual void setColBounds(
int elementIndex,
double lower,
double upper);
319 virtual void setColSetBounds(
const int *indexFirst,
const int *indexLast,
320 const double *boundList);
324 virtual void setRowLower(
int elementIndex,
double elementValue);
328 virtual void setRowUpper(
int elementIndex,
double elementValue);
333 virtual void setRowBounds(
int elementIndex,
double lower,
double upper);
336 virtual void setRowType(
int index,
char sense,
double rightHandSide,
346 virtual void setRowSetBounds(
const int *indexFirst,
const int *indexLast,
347 const double *boundList);
358 virtual void setRowSetTypes(
const int *indexFirst,
const int *indexLast,
359 const char *senseList,
const double *rhsList,
const double *rangeList);
374 virtual void setInteger(
const int *indices,
int len);
381 virtual void setRowName(
int ndx, std::string name);
384 virtual void setColName(
int ndx, std::string name);
422 virtual void addCol(
const CoinPackedVectorBase &vec,
const double collb,
423 const double colub,
const double obj);
427 virtual void addCols(
const int numcols,
428 const CoinPackedVectorBase *
const *cols,
const double *collb,
429 const double *colub,
const double *obj);
431 virtual void deleteCols(
const int num,
const int *colIndices);
435 virtual void addRow(
const CoinPackedVectorBase &vec,
const double rowlb,
438 virtual void addRow(
const CoinPackedVectorBase &vec,
const char rowsen,
439 const double rowrhs,
const double rowrng);
443 virtual void addRows(
const int numrows,
444 const CoinPackedVectorBase *
const *rows,
const double *rowlb,
445 const double *rowub);
447 virtual void addRows(
const int numrows,
448 const CoinPackedVectorBase *
const *rows,
const char *rowsen,
449 const double *rowrhs,
const double *rowrng);
451 virtual void deleteRows(
const int num,
const int *rowIndices);
470 virtual void loadProblem(
const CoinPackedMatrix &matrix,
const double *collb,
471 const double *colub,
const double *obj,
const double *rowlb,
472 const double *rowub);
481 virtual void assignProblem(CoinPackedMatrix *&matrix,
double *&collb,
482 double *&colub,
double *&obj,
double *&rowlb,
double *&rowub);
496 virtual void loadProblem(
const CoinPackedMatrix &matrix,
const double *collb,
497 const double *colub,
const double *obj,
const char *rowsen,
498 const double *rowrhs,
const double *rowrng);
507 virtual void assignProblem(CoinPackedMatrix *&matrix,
double *&collb,
508 double *&colub,
double *&obj,
char *&rowsen,
double *&rowrhs,
513 virtual void loadProblem(
const int numcols,
const int numrows,
514 const int *start,
const int *index,
const double *value,
515 const double *collb,
const double *colub,
const double *obj,
516 const double *rowlb,
const double *rowub);
520 virtual void loadProblem(
const int numcols,
const int numrows,
521 const int *start,
const int *index,
const double *value,
522 const double *collb,
const double *colub,
const double *obj,
523 const char *rowsen,
const double *rowrhs,
const double *rowrng);
527 virtual int readMps(
const char *filename,
const char *extension =
"mps");
533 virtual void writeMps(
const char *filename,
const char *extension =
"mps",
534 double objSense = 0.0)
const;
633 virtual void reset();
740 double effectivenessLb = 0.0);
840 mutable double *
obj_;
int auxcolindspace
Current length of auxcolind array.
virtual const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of matrix.
@ FREECACHED_ROW
free only cached row and LP solution information
void convertToRangedRow(int rowidx, double rhs, double range)
converts a normal row into a ranged row by adding an auxiliary variable
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
static GRBenv * globalenv_
Gurobi environment pointer.
virtual bool isAbandoned() const
Are there a numerical difficulties?
@ FREECACHED_COLUMN
free only cached column and LP solution information
virtual void setColUpper(int elementIndex, double elementValue)=0
Set a single column upper bound.
virtual void enableSimplexInterface(bool doingPrimal)
Enables normal operation of subsequent functions.
static unsigned int numInstances_
Number of instances using the global Gurobi environment.
double * obj_
Pointer to objective vector.
virtual void setObjSense(double s)
Set objective function sense (1 for min (default), -1 for max,)
void gutsOfDestructor()
The real work of the destructor.
virtual void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
virtual void setContinuous(int index)
Set the index-th variable to be a continuous variable.
GRBmodel * getLpPtr(int keepCached=KEEPCACHED_NONE)
bool probtypemip_
Stores whether we currently see the problem as a MIP.
double * rowupper_
Pointer to dense vector of row upper bounds.
virtual void enableFactorization() const
Useless function, defined only for compatibility with OsiSimplexInterface.
virtual bool isContinuous(int colNumber) const
Return true if column is continuous.
@ KEEPCACHED_PROBLEM
only discard cached LP solution
virtual void deleteCols(const int num, const int *colIndices)
Remove a set of columns (primal variables) from the problem.
bool getHintParam(OsiHintParam key, bool &yesNo, OsiHintStrength &strength, void *&otherInformation) const
Get a hint parameter (all information)
void freeAllMemory()
free all allocated memory
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...
virtual double getInfinity() const
Get solver's value for infinity.
void gutsOfCopy(const OsiGrbSolverInterface &source)
The real work of a copy constructor (used by copy and assignment)
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
virtual void disableSimplexInterface()
Useless function, defined only for compatibility with OsiSimplexInterface.
void setMipStart(bool value)
int * colmap_O2G
Maps variable indices from Osi to Gurobi Is NULL if there are no ranged rows! (assume identity mappin...
virtual void applyRowCut(const OsiRowCut &rc)
Apply a row cut. Return true if cut was applied.
CoinPackedMatrix * matrixByCol_
Pointer to row-wise copy of problem matrix coefficients.
virtual void initialSolve()
Solve initial LP relaxation.
virtual void branchAndBound()
Invoke solver's built-in enumeration algorithm.
char * rowsense_
Pointer to dense vector of row sense indicators.
virtual const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
virtual void setColName(int ndx, std::string name)
Set a column name.
static unsigned int getNumInstances()
Return the number of instances of instantiated objects using Gurobi services.
virtual void deleteRows(const int num, const int *rowIndices)
Delete a set of rows (constraints) from the problem.
virtual void solveFromHotStart()
Optimize starting from the hotstart.
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
virtual int readMps(const char *filename, const char *extension="mps")
Read a problem in MPS format from the given filename.
@ OsiHintTry
This means it is only a hint.
double * collower_
Pointer to dense vector of variable lower bounds.
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
virtual void setObjCoeffSet(const int *indexFirst, const int *indexLast, const double *coeffList)
Set a a set of objective function coefficients.
int nameDisc_
OSI name discipline.
static void setEnvironment(GRBenv *globalenv)
sets the global gurobi environment to a user given one
GRBmodel * lp_
Gurobi model represented by this class instance.
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 void reset()
Resets as if default constructor.
@ KEEPCACHED_NONE
discard all cached data (default)
int * auxcolind
Gives for each row the index of the corresponding auxiliary variable, if it is a ranged row.
virtual const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of matrix.
void gutsOfConstructor()
The real work of the constructor.
int hotStartMaxIteration_
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver.
char * coltype_
Pointer to dense vector of variable types (continous, binary, integer)
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 OsiSolverInterface * clone(bool copyData=true) const
Clone.
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.
static bool globalenv_is_ours
whether OsiGrb has created the global environment (and thus should free it)
void freeCachedData(int keepCached=KEEPCACHED_NONE)
free all cached data (except specified entries, see getLpPtr())
bool setDblParam(OsiDblParam key, double value)
Set a double parameter.
void resizeAuxColSpace(int minsize)
resizes colmap_G2O vector to be able to store at least minsize (auxiliary) elements
friend void OsiGrbSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiGrbSolverInterface class.
virtual CoinWarmStart * getWarmStart() const
Get warmstarting information.
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()...
virtual bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
bool getIntParam(OsiIntParam key, int &value) const
Get an integer parameter.
virtual int getNumCols() const
Get number of columns.
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
bool setIntParam(OsiIntParam key, int value)
Set an integer parameter.
virtual std::vector< double * > getDualRays(int maxNumRays, bool fullRay=false) const
Get as many dual rays as the solver can provide.
bool setHintParam(OsiHintParam key, bool yesNo=true, OsiHintStrength strength=OsiHintTry, void *=NULL)
Set a hint parameter.
bool setStrParam(OsiStrParam key, const std::string &value)
Set a string parameter.
int * colmap_G2O
Maps variable indices from Gurobi to Osi A negative value indicates that a variable is an auxiliary v...
CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)=0
Add a column (primal variable) to the problem.
bool getDblParam(OsiDblParam key, double &value) const
Get a double parameter.
virtual int getNumElements() const
Get number of nonzero elements.
virtual void setColSolution(const double *colsol)
Set the primal solution column values.
int colspace_
Size of allocated memory for coltype_, colmap_O2G, and (with offset auxcolspace) colmap_G2O.
void freeCachedColRim()
free cached column rim vectors
int auxcolspace
Size of allocated memory for colmap_G2O that exceeds colspace_.
@ KEEPCACHED_ALL
keep all cached data (similar to getMutableLpPtr())
double * rowrange_
Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows)
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
double * rowsol_
Pointer to dual solution vector.
int * hotStartCStat_
Hotstart information.
virtual void markHotStart()
Create a hotstart point of the optimization process.
keepCachedFlag
Get pointer to Gurobi model and free all specified cached data entries (combined with logical or-oper...
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...
@ KEEPCACHED_ROW
row information: right hand sides, ranges and senses, lower and upper bounds for row
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -COIN_DBL_MAX for -infinity.
virtual bool basisIsAvailable() const
Returns true if a basis is available.
@ KEEPCACHED_MATRIX
problem matrix: matrix ordered by column and by row
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
Internal class for obtaining status from the applyCuts method.
static void incrementInstanceCounter()
Gurobi has a context which must be created prior to all other Gurobi calls.
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
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.
void resizeColSpace(int minsize)
resizes coltype_, colmap_O2G, colmap_G2O vectors to be able to store at least minsize elements
virtual void setRowName(int ndx, std::string name)
Set a row name.
double * redcost_
Pointer to reduced cost vector.
double * colsol_
Pointer to primal solution vector.
double * rowact_
Pointer to row activity (slack) vector.
virtual double getObjSense() const
Get objective function sense (1 for min (default), -1 for max)
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.
virtual const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
bool getStrParam(OsiStrParam key, std::string &value) const
Get a string parameter.
virtual void applyColCut(const OsiColCut &cc)
Apply a column cut (bound adjustment).
GRBenv * localenv_
Gurobi environment used only by this class instance.
virtual void resolve()
Resolve an LP relaxation after problem modification.
void OsiGrbSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiGrbSolverInterface 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 bool isIterationLimitReached() const
Iteration limit reached?
virtual void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound Use COIN_DBL_MAX for infinity.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)
Add a row (constraint) to the problem.
double * colupper_
Pointer to dense vector of variable lower bounds.
virtual void unmarkHotStart()
Delete the snapshot.
const char * getCtype() const
return a vector of variable types (continous, binary, integer)
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use COIN_DBL_MAX for infinity.
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 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 * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
virtual void enableSimplexInterface(int doingPrimal)
Useless function, defined only for compatibility with OsiSimplexInterface.
virtual int canDoSimplexInterface() const
Returns 1 if can just do getBInv etc 2 if has all OsiSimplex methods and 0 if it has none.
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower 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.
void convertToNormalRow(int rowidx, char sense, double rhs)
converts a ranged row into a normal row by removing its auxiliary variable
void switchToMIP()
switches Gurobi to prob type MIP
void freeCachedResults()
free cached result vectors
void freeCachedRowRim()
free cached row rim vectors
virtual void setRowPrice(const double *rowprice)
Set dual solution vector.
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
bool isDemoLicense() const
Return whether the current Gurobi environment runs in demo mode.
virtual OsiSolverInterface::ApplyCutsReturnCode applyCuts(const OsiCuts &cs, double effectivenessLb=0.0)
Apply a collection of cuts.
GRBmodel * getMutableLpPtr() const
Get LP Pointer for const methods.
double * rowlower_
Pointer to dense vector of row lower bounds.
virtual void disableFactorization() const
Useless function, defined only for compatibility with OsiSimplexInterface.
@ FREECACHED_RESULTS
free only cached LP solution information
virtual void setColBounds(int elementIndex, double lower, double upper)
Set a single column lower and upper bound The default implementation just invokes setColLower() and ...
OsiGrbSolverInterface(bool use_local_env=false)
Default Constructor.
OsiGrbSolverInterface & operator=(const OsiGrbSolverInterface &rhs)
Assignment operator.
static void decrementInstanceCounter()
Gurobi has a context which should be deleted after Gurobi calls.
struct _GRBmodel GRBmodel
@ FREECACHED_MATRIX
free only cached matrix and LP solution information
void freeColSpace()
frees colsize_ vector
@ KEEPCACHED_COLUMN
column information: objective values, lower and upper bounds, variable types
virtual void setColLower(int elementIndex, double elementValue)
Set a single column lower bound Use -COIN_DBL_MAX for -infinity.
virtual double getObjValue() const
Get objective function value.
void resizeAuxColIndSpace()
resizes auxcolind vector to current number of rows and inits values to -1
void switchToLP()
switches Gurobi to prob type LP
int nauxcols
Number of auxiliary columns in Gurobi model for handling of ranged rows.
void freeCachedMatrix()
free cached matrices
@ KEEPCACHED_RESULTS
LP solution: primal and dual solution, reduced costs, row activities.
virtual void setColLower(int elementIndex, double elementValue)=0
Set a single column lower bound.
virtual int readMps(const char *filename, const char *extension="mps")
Read an mps file from the given filename.
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.
virtual void getBasisStatus(int *cstat, int *rstat) const
Returns a basis status of the structural/artificial variables At present as warm start i....
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)=0
Add a row (constraint) to the problem.
virtual bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.
double * rhs_
Pointer to dense vector of row right-hand side values.
virtual int getNumRows() const
Get number of rows.
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
GRBenv * getEnvironmentPtr() const
Method to access Gurobi environment pointer.
Abstract Base Class for describing an interface to a solver.
bool domipstart
Whether to pass a column solution to CPLEX before starting MIP solve (copymipstart)
virtual bool isProvenOptimal() const
Is optimality proven?
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
virtual ~OsiGrbSolverInterface()
Destructor.