Go to the documentation of this file.
13 #ifndef OsiCpxSolverInterface_H
14 #define OsiCpxSolverInterface_H
17 #include "CoinWarmStartBasis.hpp"
115 virtual bool setWarmStart(
const CoinWarmStart *warmstart);
210 virtual bool isBinary(
int columnNumber)
const;
217 virtual bool isInteger(
int columnNumber)
const;
275 virtual std::vector< double * >
getDualRays(
int maxNumRays,
276 bool fullRay =
false)
const;
288 virtual std::vector< double * >
getPrimalRays(
int maxNumRays)
const;
307 virtual void setObjCoeff(
int elementIndex,
double elementValue);
311 const int *indexLast,
312 const double *coeffList);
317 virtual void setColLower(
int elementIndex,
double elementValue);
322 virtual void setColUpper(
int elementIndex,
double elementValue);
328 double lower,
double upper);
338 const int *indexLast,
339 const double *boundList);
343 virtual void setRowLower(
int elementIndex,
double elementValue);
347 virtual void setRowUpper(
int elementIndex,
double elementValue);
353 double lower,
double upper);
356 virtual void setRowType(
int index,
char sense,
double rightHandSide,
367 const int *indexLast,
368 const double *boundList);
380 const int *indexLast,
381 const char *senseList,
382 const double *rhsList,
383 const double *rangeList);
398 virtual void setInteger(
const int *indices,
int len);
436 virtual void addCol(
const CoinPackedVectorBase &vec,
437 const double collb,
const double colub,
442 virtual void addCols(
const int numcols,
443 const CoinPackedVectorBase *
const *cols,
444 const double *collb,
const double *colub,
447 virtual void deleteCols(
const int num,
const int *colIndices);
451 virtual void addRow(
const CoinPackedVectorBase &vec,
452 const double rowlb,
const double rowub);
454 virtual void addRow(
const CoinPackedVectorBase &vec,
455 const char rowsen,
const double rowrhs,
456 const double rowrng);
460 virtual void addRows(
const int numrows,
461 const CoinPackedVectorBase *
const *rows,
462 const double *rowlb,
const double *rowub);
464 virtual void addRows(
const int numrows,
465 const CoinPackedVectorBase *
const *rows,
466 const char *rowsen,
const double *rowrhs,
467 const double *rowrng);
469 virtual void deleteRows(
const int num,
const int *rowIndices);
496 double effectivenessLb = 0.0);
516 virtual void loadProblem(
const CoinPackedMatrix &matrix,
517 const double *collb,
const double *colub,
519 const double *rowlb,
const double *rowub);
529 double *&collb,
double *&colub,
double *&obj,
530 double *&rowlb,
double *&rowub);
544 virtual void loadProblem(
const CoinPackedMatrix &matrix,
545 const double *collb,
const double *colub,
547 const char *rowsen,
const double *rowrhs,
548 const double *rowrng);
558 double *&collb,
double *&colub,
double *&obj,
559 char *&rowsen,
double *&rowrhs,
564 virtual void loadProblem(
const int numcols,
const int numrows,
565 const int *start,
const int *index,
567 const double *collb,
const double *colub,
569 const double *rowlb,
const double *rowub);
573 virtual void loadProblem(
const int numcols,
const int numrows,
574 const int *start,
const int *index,
576 const double *collb,
const double *colub,
578 const char *rowsen,
const double *rowrhs,
579 const double *rowrng);
583 virtual int readMps(
const char *filename,
584 const char *extension =
"mps");
590 virtual void writeMps(
const char *filename,
591 const char *extension =
"mps",
592 double objSense = 0.0)
const;
665 virtual void reset();
724 virtual void getBInvARow(
int row,
double *z,
double *slack = NULL)
const;
727 virtual void getBInvRow(
int row,
double *z)
const;
730 virtual void getBInvACol(
int col,
double *vec)
const;
733 virtual void getBInvCol(
int col,
double *vec)
const;
740 virtual void getBasics(
int *index)
const;
826 mutable double *
obj_;
virtual void setObjCoeffSet(const int *indexFirst, const int *indexLast, const double *coeffList)
Set a a set of objective function coefficients.
CoinPackedMatrix * matrixByRow_
Pointer to row-wise copy of problem matrix coefficients.
@ KEEPCACHED_RESULTS
LP solution: primal and dual solution, reduced costs, row activities.
@ KEEPCACHED_ROW
row information: right hand sides, ranges and senses, lower and upper bounds for row
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 setColUpper(int elementIndex, double elementValue)=0
Set a single column upper bound.
virtual void enableSimplexInterface(bool doingPrimal)
Enables normal operation of subsequent functions.
friend void OsiCpxSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiCpxSolverInterface class.
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
virtual CoinWarmStart * getWarmStart() const
Get warmstarting information.
virtual bool isBinary(int colIndex) const
Return true if the variable is binary.
bool getIntParam(OsiIntParam key, int &value) const
Get an integer parameter.
void gutsOfDestructor()
The real work of the destructor.
virtual void disableFactorization() const
Useless function, defined only for compatibility with OsiSimplexInterface.
virtual int getNumRows() const
Get number of rows.
bool getStrParam(OsiStrParam key, std::string &value) const
Get a string parameter.
void freeCachedMatrix()
free cached matrices
virtual void setColSolution(const double *colsol)
Set the primal solution column values.
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
virtual int getNumCols() const
Get number of columns.
virtual double getObjValue() const
Get objective function value.
void switchToLP()
switches CPLEX to prob type LP
@ FREECACHED_RESULTS
free only cached LP solution information
virtual bool isIterationLimitReached() const
Iteration limit reached?
virtual void setColLower(int elementIndex, double elementValue)
Set a single column lower bound Use -COIN_DBL_MAX for -infinity.
virtual bool isInteger(int colIndex) const
Return true if the variable is integer.
virtual double getInfinity() const
Get solver's value for infinity.
virtual bool isAbandoned() const
Are there a numerical difficulties?
virtual void enableFactorization() const
Useless function, defined only for compatibility with OsiSimplexInterface.
OsiCpxSolverInterface & operator=(const OsiCpxSolverInterface &rhs)
Assignment operator.
virtual void applyColCut(const OsiColCut &cc)
Apply a column cut (bound adjustment).
virtual void setRowUpper(int elementIndex, double elementValue)
Set a single row upper 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 getBasics(int *index) const
Get indices of the pivot variable in each row (order of indices corresponds to the order of elements ...
double * rowsol_
Pointer to dual solution vector.
virtual void resolve()
Resolve an LP relaxation after problem modification.
void freeCachedResults()
free cached result vectors
virtual void deleteRows(const int num, const int *rowIndices)
Delete a set of rows (constraints) from the problem.
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)
Add a row (constraint) to the problem.
virtual const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of matrix.
virtual int readMps(const char *filename, const char *extension="mps")
Read a problem in MPS format from the given filename.
virtual const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
bool setIntParam(OsiIntParam key, int value)
Set an integer parameter.
virtual void getBInvCol(int col, double *vec) const
Get a column of the basis inverse.
void gutsOfCopy(const OsiCpxSolverInterface &source)
The real work of a copy constructor (used by copy and assignment)
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...
void freeAllMemory()
free all allocated memory
virtual int canDoSimplexInterface() const
Returns 1 if can just do getBInv etc 2 if has all OsiSimplex methods and 0 if it has none.
void freeCachedColRim()
free cached column rim vectors
virtual std::vector< double * > getPrimalRays(int maxNumRays) const
Get as many primal rays as the solver can provide.
double * rhs_
Pointer to dense vector of row right-hand side values.
void resizeColType(int minsize)
resizes coltype_ vector to be able to store at least minsize elements
virtual bool isFreeBinary(int colIndex) const
Return true if the variable is binary and not fixed.
void passInMessageHandler(CoinMessageHandler *handler)
Pass in a message handler It is the client's responsibility to destroy a message handler installed by...
virtual void branchAndBound()
Invoke solver's built-in enumeration algorithm.
virtual void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -COIN_DBL_MAX for -infinity.
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.
virtual const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of matrix.
virtual void enableSimplexInterface(int doingPrimal)
Useless function, defined only for compatibility with OsiSimplexInterface.
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use COIN_DBL_MAX for infinity.
virtual bool isProvenOptimal() const
Is optimality proven?
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
virtual void unmarkHotStart()
Delete the snapshot.
virtual void applyRowCut(const OsiRowCut &rc)
Apply a row cut. Return true if cut was applied.
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 void reset()
Resets as if default constructor.
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
bool setDblParam(OsiDblParam key, double value)
Set a double parameter.
virtual bool isIntegerNonBinary(int colIndex) const
Return true if the variable is general integer.
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 std::vector< double * > getDualRays(int maxNumRays, bool fullRay=false) const
Get as many dual rays as the solver can provide.
CPXENVptr getEnvironmentPtr()
Method to access CPLEX environment pointer.
virtual void getBInvACol(int col, double *vec) const
Get a column of the tableau.
virtual bool isContinuous(int colNumber) const
Return true if column is continuous.
@ FREECACHED_MATRIX
free only cached matrix and LP solution information
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)=0
Add a column (primal variable) to the problem.
const char * getCtype() const
return a vector of variable types (continous, binary, integer)
virtual void initialSolve()
Solve initial LP relaxation.
virtual void disableSimplexInterface()
Useless function, defined only for compatibility with OsiSimplexInterface.
virtual void getBasisStatus(int *cstat, int *rstat) const
Returns a basis status of the structural/artificial variables At present as warm start i....
CPXLPptr getMutableLpPtr() const
Get LP Pointer for const methods.
virtual int getNumElements() const
Get number of nonzero elements.
double * rowlower_
Pointer to dense vector of row lower bounds.
keepCachedFlag
Get pointer to CPLEX model and free all specified cached data entries (combined with logical or-opera...
bool domipstart
Whether to pass a column solution to CPLEX before starting MIP solve (copymipstart)
virtual bool basisIsAvailable() const
Returns true if a basis is available.
double * colupper_
Pointer to dense vector of variable lower bounds.
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 const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
char * rowsense_
Pointer to dense vector of row sense indicators.
std::vector< int > OsiVectorInt
Vector of int.
virtual ~OsiCpxSolverInterface()
Destructor.
void switchToMIP()
switches CPLEX to prob type MIP
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 * hotStartCStat_
Hotstart information.
virtual int readMps(const char *filename, const char *extension="mps")
Read an mps file from the given filename.
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 bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
@ FREECACHED_COLUMN
free only cached column and LP solution information
bool probtypemip_
Stores whether CPLEX' prob type is currently set to MIP.
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver.
int coltypesize_
Size of allocated memory for coltype_.
CPXENVptr env_
CPLEX environment used in this class instance.
CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
void OsiCpxSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiCpxSolverInterface class.
@ FREECACHED_ROW
free only cached row and LP solution information
char * coltype_
Pointer to dense vector of variable types (continous, binary, integer)
void setMipStart(bool value)
void gutsOfConstructor()
The real work of the constructor.
void freeColType()
frees colsize_ vector
virtual void setColBounds(int elementIndex, double lower, double upper)
Set a single column lower and upper bound The default implementation just invokes setColLower() and ...
@ KEEPCACHED_NONE
discard all cached data (default)
double * redcost_
Pointer to reduced cost vector.
CPXENVptr getMutableEnvironmentPtr() const
Get Environment Pointer for const methods.
double * rowrange_
Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows)
double * colsol_
Pointer to primal 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.
bool setStrParam(OsiStrParam key, const std::string &value)
Set a string parameter.
double * rowact_
Pointer to row activity (slack) vector.
bool disableadvbasis
Whether to disable use of advanced basis (if given)
int hotStartMaxIteration_
bool getDblParam(OsiDblParam key, double &value) const
Get a double parameter.
virtual void solveFromHotStart()
Optimize starting from the hotstart.
virtual void deleteCols(const int num, const int *colIndices)
Remove a set of columns (primal variables) from the problem.
virtual void getBInvRow(int row, double *z) const
Get a row of the basis inverse.
@ KEEPCACHED_COLUMN
column information: objective values, lower and upper bounds, variable types
virtual void setRowPrice(const double *rowprice)
Set dual solution vector.
CPXLPptr lp_
CPLEX model represented by this class instance.
virtual void getBInvARow(int row, double *z, double *slack=NULL) const
Get a row of the tableau (slack part in slack if not NULL)
void freeCachedRowRim()
free cached row rim vectors
virtual void setObjSense(double s)
Set objective function sense (1 for min (default), -1 for max,)
CPXLPptr getLpPtr(int keepCached=KEEPCACHED_NONE)
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
@ KEEPCACHED_PROBLEM
only discard cached LP solution
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
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 double getObjSense() const
Get objective function sense (1 for min (default), -1 for max)
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
@ KEEPCACHED_ALL
keep all cached data (similar to getMutableLpPtr())
double * collower_
Pointer to dense vector of variable lower bounds.
virtual OsiSolverInterface * clone(bool copyData=true) const
Clone.
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...
CoinPackedMatrix * matrixByCol_
Pointer to row-wise copy of problem matrix coefficients.
virtual void markHotStart()
Create a hotstart point of the optimization process.
struct cpxenv * CPXENVptr
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
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.
double * rowupper_
Pointer to dense vector of row upper bounds.
void freeCachedData(int keepCached=KEEPCACHED_NONE)
free all cached data (except specified entries, see getLpPtr())
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 setContinuous(int index)
Set the index-th variable to be a continuous variable.
OsiCpxSolverInterface()
Default Constructor.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)=0
Add a row (constraint) to the problem.
double * obj_
Pointer to objective vector.
@ KEEPCACHED_MATRIX
problem matrix: matrix ordered by column and by row
Abstract Base Class for describing an interface to a solver.
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
virtual const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
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 bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.