Go to the documentation of this file.
6 #ifndef OsiCbcSolverInterface_H
7 #define OsiCbcSolverInterface_H
13 #include "CoinPackedMatrix.hpp"
14 #include "OsiSolverInterface.hpp"
16 #include "CoinWarmStartBasis.hpp"
19 class OsiClpSolverInterface;
31 virtual public OsiSolverInterface {
78 OsiHintStrength strength=OsiHintTry,
79 void * otherInformation=NULL);
82 OsiHintStrength& strength,
83 void *& otherInformation)
const;
85 using OsiSolverInterface::getHintParam ;
88 OsiHintStrength& strength)
const;
272 bool fullRay =
false)
const;
300 int ndx,
unsigned digits = 7)
const ;
304 virtual std::string
getObjName (
unsigned maxLen = std::string::npos)
const ;
313 unsigned maxLen = std::string::npos)
const ;
326 int srcStart,
int len,
int tgtStart) ;
335 unsigned maxLen = std::string::npos)
const ;
348 int srcStart,
int len,
int tgtStart) ;
365 virtual void setObjCoeff(
int elementIndex,
double elementValue );
367 using OsiSolverInterface::setColLower ;
370 virtual void setColLower(
int elementIndex,
double elementValue );
372 using OsiSolverInterface::setColUpper ;
375 virtual void setColUpper(
int elementIndex,
double elementValue );
379 double lower,
double upper );
390 const int* indexLast,
391 const double* boundList);
395 virtual void setRowLower(
int elementIndex,
double elementValue );
399 virtual void setRowUpper(
int elementIndex,
double elementValue ) ;
403 double lower,
double upper ) ;
406 virtual void setRowType(
int index,
char sense,
double rightHandSide,
418 const int* indexLast,
419 const double* boundList);
432 const int* indexLast,
433 const char* senseList,
434 const double* rhsList,
435 const double* rangeList);
486 using OsiSolverInterface::addCol ;
488 virtual void addCol(
const CoinPackedVectorBase& vec,
489 const double collb,
const double colub,
492 virtual void addCol(
int numberElements,
const int * rows,
const double * elements,
493 const double collb,
const double colub,
496 using OsiSolverInterface::addCols ;
499 const CoinPackedVectorBase *
const * cols,
500 const double* collb,
const double* colub,
503 virtual void deleteCols(
const int num,
const int * colIndices);
505 using OsiSolverInterface::addRow ;
507 virtual void addRow(
const CoinPackedVectorBase& vec,
508 const double rowlb,
const double rowub);
510 virtual void addRow(
const CoinPackedVectorBase& vec,
511 const char rowsen,
const double rowrhs,
512 const double rowrng);
514 using OsiSolverInterface::addRows ;
517 const CoinPackedVectorBase *
const * rows,
518 const double* rowlb,
const double* rowub);
521 const CoinPackedVectorBase *
const * rows,
522 const char* rowsen,
const double* rowrhs,
523 const double* rowrng);
525 virtual void deleteRows(
const int num,
const int * rowIndices);
558 const double* collb,
const double* colub,
560 const double* rowlb,
const double* rowub);
570 double*& collb,
double*& colub,
double*& obj,
571 double*& rowlb,
double*& rowub);
586 const double* collb,
const double* colub,
588 const char* rowsen,
const double* rowrhs,
589 const double* rowrng);
599 double*& collb,
double*& colub,
double*& obj,
600 char*& rowsen,
double*& rowrhs,
606 const CoinBigIndex * start,
const int* index,
608 const double* collb,
const double* colub,
610 const double* rowlb,
const double* rowub);
615 const CoinBigIndex * start,
const int* index,
617 const double* collb,
const double* colub,
619 const char* rowsen,
const double* rowrhs,
620 const double* rowrng);
622 using OsiSolverInterface::readMps ;
626 const char *extension =
"mps") ;
633 const char *extension =
"mps",
634 double objSense=0.0)
const;
644 const char ** rowNames,
const char ** columnNames,
645 int formatType=0,
int numberAcross=2,
646 double objSense=0.0)
const ;
722 virtual OsiSolverInterface *
clone(
bool copyData =
true)
const;
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
virtual void assignProblem(CoinPackedMatrix *&matrix, double *&collb, double *&colub, double *&obj, char *&rowsen, double *&rowrhs, double *&rowrng)
Load in an problem by assuming ownership of the arguments (the constraints on the rows are given by s...
void setMaximumSolutions(int value)
Set the CbcModel::CbcMaxNumSol maximum number of solutions.
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 setRowName(int ndx, std::string name)
Set a row name.
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
virtual std::string dfltRowColName(char rc, int ndx, unsigned digits=7) const
Generate a standard name of the form Rnnnnnnn or Cnnnnnnn.
int getNodeCount() const
Get how many Nodes it took to solve the problem (including those in complete fathoming B&B inside CLP...
virtual void setRowNames(OsiNameVec &srcNames, int srcStart, int len, int tgtStart)
Set multiple row names.
virtual void addRow(const CoinPackedVectorBase &vec, const char rowsen, const double rowrhs, const double rowrng)
virtual bool isContinuous(int colNumber) const
Return true if column is continuous.
void newLanguage(CoinMessages::Language language)
Set language.
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -DBL_MAX for -infinity.
virtual void applyRowCut(const OsiRowCut &rc)
Apply a row cut (append to constraint matrix).
bool setMaximumNodes(int value)
Set the maximum node limit .
int getMaximumSolutions() const
Get the CbcModel::CbcMaxNumSol maximum number of solutions.
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
virtual void addRow(const CoinPackedVectorBase &vec, const double rowlb, const double rowub)
virtual void setColBounds(int elementIndex, double lower, double upper)
Set a single column lower and upper bound.
virtual bool isAbandoned() const
Are there a numerical difficulties?
int getMaximumSolutions() const
Get the maximum number of solutions desired.
virtual double getObjValue() const
Get objective function value.
bool getIntParam(OsiIntParam key, int &value) const
bool setDblParam(OsiDblParam key, double value)
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
double getMaximumSeconds() const
Get the CbcModel::CbcMaximumSeconds maximum number of seconds.
CbcModel * getModelPtr() const
Get pointer to Cbc model.
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 passInMessageHandler(CoinMessageHandler *handler)
Pass in a message handler.
virtual void setColName(int ndx, std::string name)
Set a column name.
virtual void setRowType(int index, char sense, double rightHandSide, double range)
Set the type of a single row
bool isSolutionLimitReached() const
Solution limit reached?
virtual std::vector< double * > getPrimalRays(int maxNumRays) const
Get as many primal rays as the solver can provide.
virtual double getObjSense() const
Get objective function sense (1 for min (default), -1 for max)
OsiCbcSolverInterface(const OsiCbcSolverInterface &)
Copy constructor.
void setCutoff(double value)
Set cutoff bound on the objective function.
virtual void setObjSense(double s)
Set objective function sense (1 for min (default), -1 for max,)
virtual void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound Use DBL_MAX for infinity.
bool getDblParam(OsiDblParam key, double &value) const
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
virtual void solveFromHotStart()
Optimize starting from the hotstart.
void setCutoff(double value)
Set cutoff bound on the objective function.
virtual int readMps(const char *filename, const char *extension="mps")
Read an mps file from the given filename (defaults to Osi reader) - returns number of errors (see Osi...
virtual void setColNames(OsiNameVec &srcNames, int srcStart, int len, int tgtStart)
Set multiple column names.
virtual CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
virtual bool getHintParam(OsiHintParam key, bool &yesNo, OsiHintStrength &strength, void *&otherInformation) const
Get a hint parameter.
virtual int writeMpsNative(const char *filename, const char **rowNames, const char **columnNames, int formatType=0, int numberAcross=2, double objSense=0.0) const
Write the problem into an mps file of the given filename, names may be null.
virtual std::string getColName(int colIndex, unsigned maxLen=std::string::npos) const
Return the name of the column.
virtual CoinWarmStart * getWarmStart() const
Get warmstarting information.
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
void setMaximumNodes(int value)
Set the CbcModel::CbcMaxNumNode maximum node limit.
virtual void unmarkHotStart()
Delete the snapshot.
bool isNodeLimitReached() const
Node limit reached?
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
int status() const
Final status of problem Some of these can be found out by is......
OsiSolverInterface * solver() const
Returns solver - has current state.
virtual void markHotStart()
Create a hotstart point of the optimization process.
virtual void setRowBounds(int elementIndex, double lower, double upper)
Set a single row lower and upper bound.
virtual double getInfinity() const
Get solver's value for infinity.
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const char *rowsen, const double *rowrhs, const double *rowrng)
virtual void setInteger(const int *indices, int len)
Set the variables listed in indices (which is of length len) to be integer variables.
int getMaximumNodes() const
Get the CbcModel::CbcMaxNumNode maximum node limit.
virtual void loadProblem(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng)
Load in an problem by copying the arguments (the constraints on the rows are given by sense/rhs/range...
virtual bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
virtual void setContinuous(int index)
Set the index-th variable to be a continuous variable.
OsiCbcSolverInterface(OsiSolverInterface *solver=NULL, CbcStrategy *strategy=NULL)
Default Constructor.
virtual void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
Simple Branch and bound class.
bool getStrParam(OsiStrParam key, std::string &value) const
virtual OsiSolverInterface * clone(bool copyData=true) const
Clone.
virtual bool isProvenOptimal() const
Is optimality proven?
virtual void deleteColNames(int tgtStart, int len)
Delete len column names starting at index tgtStart.
bool setStrParam(OsiStrParam key, const std::string &value)
virtual int getNumElements() const
Get number of nonzero elements.
virtual std::string getRowName(int rowIndex, unsigned maxLen=std::string::npos) const
Return the name of the row.
virtual void resolve()
Resolve an LP relaxation after problem modification.
virtual bool getHintParam(OsiHintParam key, bool &yesNo, OsiHintStrength &strength) const
Get a hint parameter.
virtual void deleteRowNames(int tgtStart, int len)
Delete len row names starting at index tgtStart.
virtual void setRowPrice(const double *rowprice)
Set dual solution vector.
void OsiCbcSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiCbcSolverInterface class.
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
bool setMaximumSeconds(double value)
Set the maximum number of seconds desired.
virtual int getNumRows() const
Get number of rows.
virtual bool isIterationLimitReached() const
Iteration limit reached?
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...
int getNodeCount() const
Get how many Nodes it took to solve the problem.
virtual void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)
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 std::vector< double * > getDualRays(int maxNumRays, bool fullRay=false) const
Get as many dual rays as the solver can provide.
virtual int getNumCols() const
Get number of columns.
bool isNodeLimitReached() const
Node limit reached?
virtual ~OsiCbcSolverInterface()
Destructor.
bool setIntParam(OsiIntParam key, int value)
virtual void setObjName(std::string name)
Set the name of the objective function.
int getMaximumNodes() const
Get the maximum node limit .
double getCutoff() const
Get the cutoff bound on the objective function - always as minimize.
virtual void branchAndBound()
Invoke solver's built-in enumeration algorithm.
virtual void applyRowCuts(int numberCuts, const OsiRowCut *cuts)
Apply a collection of row cuts which are all effective.
void setLanguage(CoinMessages::Language language)
virtual void loadProblem(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng)
Just like the other loadProblem() methods except that the matrix is given in a standard column major ...
friend void OsiCbcSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir)
A function that tests the methods in the OsiCbcSolverInterface class.
OsiCbcSolverInterface & operator=(const OsiCbcSolverInterface &rhs)
Assignment operator.
CbcModel * modelPtr_
Cbc model represented by this class instance.
int status() const
Final status of problem - 0 finished, 1 stopped, 2 difficulties.
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...
void setMaximumSeconds(double value)
Set the CbcModel::CbcMaximumSeconds maximum number of seconds.
virtual void applyRowCuts(int numberCuts, const OsiRowCut **cuts)
Apply a collection of row cuts which are all effective.
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
virtual void deleteCols(const int num, const int *colIndices)
virtual void setContinuous(const int *indices, int len)
Set the variables listed in indices (which is of length len) to be continuous variables.
virtual void initialSolve()
Solve initial LP relaxation.
virtual const OsiNameVec & getColNames()
Return a pointer to a vector of column names.
virtual void addCol(int numberElements, const int *rows, const double *elements, const double collb, const double colub, const double obj)
Add a column (primal variable) to the problem.
virtual void setColSolution(const double *colsol)
Set the primal solution column values.
virtual const double * getObjCoefficients() const
Get pointer to array[getNumCols()] of objective function coefficients.
virtual void loadProblem(const int numcols, const int numrows, const CoinBigIndex *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Just like the other loadProblem() methods except that the matrix is given in a standard column major ...
static const double OsiCbcInfinity
bool setMaximumSolutions(int value)
Set the maximum number of solutions desired.
bool isSolutionLimitReached() const
Solution limit reached?
virtual std::string getObjName(unsigned maxLen=std::string::npos) const
Return the name of the objective function.
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver.
double getMaximumSeconds() const
Get the maximum number of seconds desired.
virtual const CoinPackedMatrix * getMatrixByRow() const
Get pointer to row-wise copy of matrix.
virtual void deleteRows(const int num, const int *rowIndices)
OsiSolverInterface * getRealSolverPtr() const
Get pointer to underlying solver.
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use DBL_MAX for infinity.
virtual bool setHintParam(OsiHintParam key, bool yesNo=true, OsiHintStrength strength=OsiHintTry, void *otherInformation=NULL)
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 const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
virtual void addCols(const int numcols, const CoinPackedVectorBase *const *cols, const double *collb, const double *colub, const double *obj)
double getCutoff() const
Get the cutoff bound on the objective function - always as minimize.
virtual const CoinPackedMatrix * getMatrixByCol() const
Get pointer to column-wise copy of matrix.
virtual void setColLower(int elementIndex, double elementValue)
Set a single column lower bound Use -DBL_MAX for -infinity.
virtual const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
virtual void addRows(const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub)
virtual bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.
virtual const OsiNameVec & getRowNames()
Return a pointer to a vector of row names.
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
virtual void applyColCut(const OsiColCut &cc)
Apply a column cut (adjust one or more bounds).