1 #ifndef OsiDylpSolverInterface_H
2 #define OsiDylpSolverInterface_H
28 #include "OsiConfig.h"
29 #include <CoinPackedMatrix.hpp>
30 #include <OsiSolverInterface.hpp>
31 #include <CoinWarmStart.hpp>
32 #include <CoinMessageHandler.hpp>
33 #include <CoinMpsIO.hpp>
34 #include <CoinPresolveMatrix.hpp>
110 const std::string &netLibDir) ;
133 OsiSolverInterface*
clone(
bool copyData =
true)
const ;
156 int readMps(
const char *filename,
const char *extension =
"mps") ;
162 int readMps(
const char *filename,
const char *extension,
163 int &numberSets, CoinSet **&sets) ;
173 const char *extension =
"mps",
174 double objsense = 0.0)
const ;
180 const double *collb,
const double *colub,
const double *obj,
181 const char *rowsen,
const double *rowrhs,
182 const double *rowrng) ;
188 const double *collb,
const double *colub,
const double *obj,
189 const double *rowlb,
const double *rowub) ;
195 const int *start,
const int *index,
const double *value,
196 const double *collb,
const double *colub,
const double *obj,
197 const char *sense,
const double *rhsin,
const double *range) ;
203 const int *start,
const int *index,
const double *value,
204 const double *collb,
const double *colub,
const double *obj,
205 const double *row_lower,
const double *row_upper) ;
211 double *&collb,
double *&colub,
double *&obj,
212 char *&rowsen,
double *&rowrhs,
double *&rowrng) ;
218 double *&collb,
double *&colub,
double *&obj,
219 double *&rowlb,
double *&rowub) ;
343 using OsiSolverInterface::setContinuous ;
348 using OsiSolverInterface::setInteger ;
353 using OsiSolverInterface::setColLower ;
358 using OsiSolverInterface::setColUpper ;
370 void setRowType(
int index,
char rowsen,
double rowrhs,
double rowrng) ;
398 using OsiSolverInterface::addCol ;
402 void addCol(
const CoinPackedVectorBase &vec,
403 const double collb,
const double colub,
const double obj) ;
411 using OsiSolverInterface::addRow ;
415 void addRow(
const CoinPackedVectorBase &row,
416 const double rowlb,
const double rowub) ;
420 void addRow(
const CoinPackedVectorBase &row,
421 const char rowsen,
const double rowrhs,
const double rowrng) ;
544 OsiHintStrength strength = OsiHintTry,
void *info = 0) ;
560 using OsiSolverInterface::getHintParam ;
565 OsiHintStrength &strength,
void *&info)
const ;
610 std::vector<double *>
getDualRays(
int maxNumRays,
bool fullRay)
const ;
672 double *duals,
const double *c)
const ;
687 virtual void getBInvARow(
int row,
double *abari,
double *betai = 0)
const ;
714 bool keepContinuous =
false) ;
716 # if ODSI_PARANOIA >= 1
726 void indexCheck (
int k,
bool isCol, std::string rtnnme) ;
737 const bool mustexist =
true) ;
883 mutable void *
info_[OsiLastHintParam] ;
1097 const double *rowlb,
const double *rowub) ;
1100 const char *sense,
const double *rhsin,
const double *range) ;
1103 const double* col_lower,
const double* col_upper,
const double* obj,
1104 const contyp_enum *ctyp,
const double* rhs,
const double* rhslow) ;
1106 const int *start,
const int *lens,
1107 const int *index,
const double *value,
1108 const double* col_lower,
const double* col_upper,
const double* obj,
1109 const contyp_enum *ctyp,
const double* rhs,
const double* rhslow) ;
1141 void add_col(
const CoinPackedVectorBase& coin_coli,
1143 double vubi,
double obji,
const std::string *nme) ;
1144 void add_row(
const CoinPackedVectorBase& coin_rowi,
1146 double rhsi,
double rhslowi,
const std::string *nme) ;
1150 char sensei,
double rhsini,
double rangei) ;
1152 double rowlbi,
double rowubi) ;
1154 OsiHintStrength hintStrength,
const char *msgString) ;
1172 template<
class T>
static void copy(
const T* src, T* dst,
int n) ;
1173 template<
class T>
static T*
copy(
const T* src,
int n) ;
1174 template<
class T>
static T*
copy(
const T* src) ;
1192 int n,
bool exact) ;
1221 template<
class T>
inline static T*
idx_vec (T* vec) {
return (vec-1) ; }
1224 inline static int idx (
int i) {
return (i+1) ; }
1231 template<
class T>
inline static T*
inv_vec (T* vec) {
return (vec+1) ; }
1234 inline static int inv (
int i) {
return (i-1) ; }
1237 const CoinShallowPackedVector vector,
int dimension) ;
1239 const CoinShallowPackedVector vector,
int dimension,
pkvec_struct *dst) ;
1245 const char *ext1,
const char *ext2) ;
1262 void OsiDylpSolverInterfaceUnitTest(
const std::string & mpsDir,
1263 const std::string &netLibDir) ;
ODSI_start_enum
Enum to specify cold/warm/hot start.
bool isDualObjectiveLimitReached() const
Is the dual objective limit reached?
static char type_to_sense(contyp_enum type)
CoinPostsolveMatrix * initialisePostsolve(CoinPresolveMatrix *&preObj)
Create and load a postsolve object.
bool isInteger(int colIndex) const
Return true if the variable is integer (general or binary)
bool setHintParam(OsiHintParam key, bool sense=true, OsiHintStrength strength=OsiHintTry, void *info=0)
Set an OSI hint.
void unmarkHotStart()
Delete the hot start snapshot.
bool initial_gtxecho
Controls output of log information to stdout during initialSolve()
int canDoSimplexInterface() const
Return the simplex implementation level.
virtual void getBInvRow(int row, double *betai) const
Get a row of the basis inverse.
bool isProvenOptimal() const
True if dylp reported an optimal solution.
void setBasisInLpprob(const OsiDylpWarmStartBasis *wsb, lpprob_struct *lpprob) const
Install a basis in the lp problem structure.
const double * getRowLower() const
Get the row (constraint) lower bound vector.
bool evalPresolve()
Decide whether presolve was effective enough to use.
void setColLower(int index, double value)
Set the lower bound on a column (variable)
void loadProblem(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng)
Load a problem description (OSI packed matrix, row sense, parameters unaffected).
const double * getRowRange() const
Get the row (constraint) range vector.
void dylp_printsoln(bool wantSoln, bool wantStats)
Print the solution and/or statistics to the output file.
double obj_sense
Objective function sense for this ODSI instance.
bool isProvenPrimalInfeasible() const
True if dylp reported the problem to be primal infeasible.
static basis_struct * copy_basis(const basis_struct *src, int dstsze)
void applyColCut(const OsiColCut &cut)
Apply a column (variable) cut (adjust one or more bounds)
const double * getColSolution() const
Return the vector of primal variables for the solution.
static void assert_same(const T *t1, const T *t2, int n, bool exact)
void setLanguage(CoinMessages::Language language)
An alias for OsiDylpSolverInterface::newLanguage.
const std::string solvername
Solver name (dylp).
static contyp_enum sense_to_type(char type)
static void assert_same(double d1, double d2, bool exact)
void setRowName(int ndx, std::string name)
Set a row name.
bool isBinary(int colIndex) const
Return true if the variable is binary.
double getObjSense() const
Get the objective function sense (min/max)
bool isIntegerNonBinary(int colIndex) const
Return true if the variable is general integer.
static bool basis_ready
Basis maintenance package is initialised.
void assignProblem(CoinPackedMatrix *&matrix, double *&collb, double *&colub, double *&obj, double *&rowlb, double *&rowub)
Load a problem description (OSI packed matrix, row bounds, parameters destroyed).
const CoinPresolveAction * postActions_
List of postsolve actions.
void setObjective(const double *array)
Set the objective coefficients for all columns.
void dylp_controlfile(const char *name, const bool silent, const bool mustexist=true)
Process an options (.spc) file.
void destruct_problem(bool preserve_interface)
double * saved_col_obj
Saved pointers to cached structural vectors.
const double * getRowUpper() const
Get the row (constraint) upper bound vector.
OsiSolverInterface * clone(bool copyData=true) const
Clone the solver object.
static int reference_count
Number of outstanding ODSI objects.
void deleteCols(const int num, const int *colIndices)
Remove column(s) (variable(s)) from the problem.
double getInfinity() const
Get dylp's value for infinity.
void gen_rowparms(int rowcnt, double *rhs, double *rhslow, contyp_enum *ctyp, const double *rowlb, const double *rowub)
int getNumCols() const
Get the number of columns (variables)
bool setDblParam(OsiDblParam key, double value)
Set an OSI double parameter.
bool isProvenDualInfeasible() const
True if dylp reported the problem to be dual infeasible (primal unbounded)
virtual void getBasics(int *index) const
Get indices of basic variables.
static void copy_basis(const basis_struct *src, basis_struct *dst)
static std::string make_filename(const char *filename, const char *ext1, const char *ext2)
static void assert_same(const T &t1, const T &t2, bool exact)
bool solnIsFresh
The most recent solution from dylp is valid.
void writeMps(const char *basename, const char *extension="mps", double objsense=0.0) const
Write the problem into the specified file in MPS format.
void addRow(const CoinPackedVectorBase &row, const double rowlb, const double rowub)
Add a row (constraint) to the problem.
static void assert_same(const consys_struct &c1, const consys_struct &c2, bool exact)
virtual void getReducedGradient(double *columnReducedCosts, double *duals, const double *c) const
Calculate duals and reduced costs for the given objective coefficients.
void destruct_primal_cache()
bool isContinuous(int colIndex) const
Return true if the variable is continuous.
bool resolve_gtxecho
Controls output of log information to stdout during resolve() and solveFromHotStart()
const double * getRightHandSide() const
Get the row (constraint) right-hand-side vector.
void saveOriginalSys()
Save the original problem.
OsiDylpSolverInterface & operator=(const OsiDylpSolverInterface &rhs)
Assignment.
lpopts_struct * resolveOptions
Solver options for a resolve.
lpprob_struct * lpprob
The lp problem.
void destruct_row_cache(bool structure)
lpopts_struct * initialSolveOptions
Solver options for an initial solve.
void load_problem(const CoinMpsIO &mps)
static int inv(int i)
Convert 1-based index to 0-based index.
void enableFactorization() const
Prepare the solver for the use of tableau access methods.
const double * getColUpper() const
Get the column (variable) upper bound vector.
lpret_enum lp_retval
Result of last call to solver for this ODSI instance.
const double * getRowPrice() const
Return the vector of dual variables for the solution.
void setColName(int ndx, std::string name)
Set a column name.
bool getIntParam(OsiIntParam key, int &value) const
Get an OSI integer parameter.
CoinPackedMatrix * _matrix_by_row
static T * copy(const T *src)
void disableFactorization() const
Undo the effects of enableFactorization.
void setColUpper(int index, double value)
Set the upper bound on a column (variable)
basisCondition
Codes for basis condition.
std::vector< double * > getDualRays(int maxNumRays, bool fullRay) const
Get as many dual rays as the solver can provide.
void installPresolve()
Load the presolved problem into the ODSI object.
const double * getRowActivity() const
Return the vector of row activity for the solution.
const CoinPackedMatrix * getMatrixByRow() const
Get a pointer to a row-major copy of the constraint matrix.
void activateRowCutDebugger(const char *modelName)
Activate the row cut debugger.
bool setStrParam(OsiStrParam key, const std::string &value)
Set an OSI string parameter.
double odsiInfinity
The value of infinity.
void unimp_hint(bool dylpSense, bool hintSense, OsiHintStrength hintStrength, const char *msgString)
lpstats_struct * statistics
The statistics structure.
void markHotStart()
Create a hot start snapshot.
int setBasisStatus(const int *archStatus, const int *logStatus)
Set a basis and update the factorization and solution.
int readMps(const char *filename, const char *extension="mps")
Read a problem description in MPS format from a file.
bool ensureOwnership() const
Ensure that the solver is ready for simplex operations.
CoinPackedMatrix * saved_matrix_by_row
void destruct_col_cache(bool structure)
std::vector< double * > getPrimalRays(int maxNumRays) const
Get as many primal rays as the solver can provide.
bool isIterationLimitReached() const
True if dylp reached the iteration limit.
void setColSolution(const double *colsol)
Set the value of the primal variables in the problem solution.
CoinWarmStart * getEmptyWarmStart() const
Get an empty OsiDylpWarmStartBasis object.
friend void OsiDylpSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netLibDir)
Unit test for OsiDylpSolverInterface.
void branchAndBound()
Invoke the solver's built-in branch-and-bound algorithm.
void reset()
Reset the solver object to the state produced by the default constructor.
static lpprob_struct * copy_lpprob(const lpprob_struct *src)
void add_col(const CoinPackedVectorBase &coin_coli, vartyp_enum vtypi, double vlbi, double vubi, double obji, const std::string *nme)
CoinPackedMatrix * _matrix_by_col
lptols_struct * tolerances
Solver numeric tolerances.
static pkvec_struct * packed_vector(const CoinShallowPackedVector vector, int dimension)
void addRow(const CoinPackedVectorBase &row, const char rowsen, const double rowrhs, const double rowrng)
Add a row (constraint) to the problem.
void load_problem(const int colcnt, const int rowcnt, const int *start, const int *lens, const int *index, const double *value, const double *col_lower, const double *col_upper, const double *obj, const contyp_enum *ctyp, const double *rhs, const double *rhslow)
void addCol(const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj)
Add a column (variable) to the problem.
void setObjSense(double sense)
Set the sense (min/max) of the objective.
bool setWarmStart(const CoinWarmStart *warmStart)
Apply a warm start object.
void setObjCoeff(int index, double value)
Set an objective function coefficient.
void doPostsolve()
Apply the postsolve transforms from postActions_.
CoinWarmStart * hotstart_fallback
Warm start object used as a fallback for hot start.
bool basisIsAvailable() const
Check if an optimal basis is available.
static T * copy(const T *src, int n)
static T * inv_vec(T *vec)
Convert 1-based vector pointer to 0-based vector pointer.
void loadProblem(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load a problem description (OSI packed matrix, row bounds, parameters unaffected).
void loadProblem(const int colcnt, const int rowcnt, const int *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const double *row_lower, const double *row_upper)
Load a problem description (standard column-major packed matrix, row bounds, parameters unaffected)
static void assert_same(const basis_struct &b1, const basis_struct &b2, bool exact)
void loadProblem(const int colcnt, const int rowcnt, const int *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const char *sense, const double *rhsin, const double *range)
Load a problem description (standard column-major packed matrix, row sense, parameters unaffected)
bool keepIntegers_
true if presolve should consider integrality
ioid local_logchn
Log stream for this ODSI instance.
void gen_rowiparms(contyp_enum *ctypi, double *rhsi, double *rhslowi, double rowlbi, double rowubi)
void setOsiDylpMessages(CoinMessages::Language local_language)
Set the language for messages.
double getObjValue() const
Get the objective function value for the solution.
contyp_enum bound_to_type(double lower, double upper)
void getBasisStatus(int *archStatus, int *logStatus) const
Retrieve status information for architectural and logical variables.
void resolve()
Call dylp to reoptimize (warm start).
void setObjName(std::string name)
Set the objective function name.
void activateRowCutDebugger(const double *solution, bool keepContinuous=false)
Activate the row cut debugger.
void assignProblem(CoinPackedMatrix *&matrix, double *&collb, double *&colub, double *&obj, char *&rowsen, double *&rowrhs, double *&rowrng)
Load a problem description (OSI packed matrix, row sense, parameters destroyed).
void setRowLower(int index, double value)
Set the lower bound on a row (constraint)
void load_problem(const CoinPackedMatrix &matrix, const double *col_lower, const double *col_upper, const double *obj, const contyp_enum *ctyp, const double *rhs, const double *rhslow)
void destruct_dual_cache()
void setInteger(int index)
Set a single variable to be integer.
bool mps_debug
Allow messages from CoinMpsIO package.
const char * getRowSense() const
Get the row sense (constraint type) vector.
const double * getColLower() const
Get the column (variable) lower bound vector.
consys_struct * consys
The constraint system.
OsiDylpSolverInterface(const OsiDylpSolverInterface &src)
Copy constructor.
void setRowPrice(const double *)
Set the value of the dual variables in the problem solution.
static void assert_same(const conbnd_struct &c1, const conbnd_struct &c2, bool exact)
CoinPostsolveMatrix * postObj_
The postsolve object.
void destruct_presolve()
Delete presolve information.
CoinWarmStart * getWarmStart() const
Build a warm start object for the current lp solution.
void setContinuous(int index)
Set a single variable to be continuous.
const CoinPackedMatrix * getMatrixByCol() const
Get a pointer to a column-major copy of the constraint matrix.
void setRowUpper(int index, double value)
Set the upper bound on a row (constraint)
int getNumIntegers() const
Get the number of integer variables.
int getNumElements() const
Get the number of non-zero coefficients.
const double * getReducedCost() const
Return the vector of reduced costs for the solution.
OsiDylpSolverInterface()
Default constructor.
static int idx(int i)
Convert 0-based index to 1-based index.
consys_struct * savedConsys_
Saved copy of original problem.
void setRowType(int index, char rowsen, double rowrhs, double rowrng)
Set the type of a row (constraint)
bool getStrParam(OsiStrParam key, std::string &value) const
Get an OSI string parameter.
void solveFromHotStart()
Call dylp to reoptimize (hot start).
void dylp_logfile(const char *name, bool echo=false)
Establish a log file.
void dylp_outfile(const char *name)
Establish an output (solution and/or statistics) file.
int passLimit_
Limit for iterations of the major presolve loop.
static T * idx_vec(T *vec)
Convert 0-based vector pointer to 1-based vector pointer.
void construct_consys(int cols, int rows)
CoinPresolveMatrix * initialisePresolve(bool keepIntegers)
Create and load a presolve object.
virtual void getBInvACol(int col, double *abarj) const
Get a column of the tableau.
static void assert_same(const lpprob_struct &l1, const lpprob_struct &l2, bool exact)
ioid local_outchn
Output stream for this ODSI instance.
void add_row(const CoinPackedVectorBase &coin_rowi, char clazzi, contyp_enum ctypi, double rhsi, double rhslowi, const std::string *nme)
CoinPackedMatrix * saved_matrix_by_col
CoinPresolveMatrix * preObj_
The presolve object.
static void assert_same(const OsiDylpSolverInterface &o1, const OsiDylpSolverInterface &o2, bool exact)
void initialSolve()
Solve an lp from scratch.
void doPresolve()
Perform presolve transformations.
void deleteRows(const int num, const int *rowIndices)
Delete row(s) (constraint(s)) from the problem.
void gen_rowparms(int rowcnt, double *rhs, double *rhslow, contyp_enum *ctyp, const char *sense, const double *rhsin, const double *range)
void installPostsolve()
Reload the original constraint system with the postsolved basis.
virtual void getBInvCol(int col, double *betak) const
Get a column of the basis inverse.
int getNumRows() const
Get the number of rows (constraints)
void applyRowCut(const OsiRowCut &cut)
Apply a row (constraint) cut (add one constraint)
struct OsiDylpSolverInterface::@38 simplex_state
State related to the OsiSimplex interface.
virtual void getBInvARow(int row, double *abari, double *betai=0) const
Get a row of the tableau.
void destruct_cache(bool rowStructure, bool colStructure)
bool setIntParam(OsiIntParam key, int value)
Set an OSI integer parameter.
static void copy(const T *src, T *dst, int n)
void * info_[OsiLastHintParam]
Array for info blocks associated with hints.
void newLanguage(CoinMessages::Language language)
Change the language for OsiDylp messages.
bool getDblParam(OsiDblParam key, double &value) const
Get an OSI double parameter.
bool isPrimalObjectiveLimitReached() const
Is the primal objective limit reached?
bool getHintParam(OsiHintParam key, bool &sense, OsiHintStrength &strength, void *&info) const
Get an OSI hint.
bool isAbandoned() const
True if dylp abandoned the problem.
static void packed_vector(const CoinShallowPackedVector vector, int dimension, pkvec_struct *dst)
struct OsiDylpSolverInterface::@37 activeBasis
Active basis.
void gen_rowiparms(contyp_enum *ctypi, double *rhsi, double *rhslowi, char sensei, double rhsini, double rangei)
int getIterationCount() const
Get the number of iterations for the last lp.
lpret_enum do_lp(ODSI_start_enum start, bool echo)
Common core method to invoke dylp.
const double * getObjCoefficients() const
Get the objective function coefficient vector.
int readMps(const char *filename, const char *extension, int &numberSets, CoinSet **&sets)
Read a problem description in MPS format from a file, including SOS information.
~OsiDylpSolverInterface()
Destructor.
The dylp warm start class.