Class MILPSolver
Defined in File solver.h
Nested Relationships
Nested Types
Inheritance Relationships
Derived Types
public MILPSolverCLP
(Class MILPSolverCLP)public MILPSolverCPX
(Class MILPSolverCPX)
Class Documentation
-
class MILPSolver
Subclassed by MILPSolverCLP, MILPSolverCPX
Public Functions
-
inline virtual ~MILPSolver()
-
virtual MILPSolver *clone() = 0
-
virtual double getInfinity() = 0
-
virtual void addRow(const vector<pair<int, double>> &entries, const double &lb, const double &ub) = 0
Functions for the rows (constraints) of the model.
-
virtual void setRowName(const int &cons, const string &asString) = 0
-
virtual string getRowName(const int &cons) = 0
-
virtual double getRowUpper(const int &var) = 0
-
virtual void setRowUpper(const int &c, const double &b) = 0
-
virtual double getRowLower(const int &var) = 0
-
virtual void setRowLower(const int &c, const double &b) = 0
-
virtual int getNumRows() = 0
-
virtual void addCol(const vector<pair<int, double>> &entries, const double &lb, const double &ub, const ColumnType &type) = 0
Functions for the columns (variables) of the model.
-
virtual bool isColumnInteger(const int &c) = 0
Ascertain whether the given column is an integer.
- Parameters:
c – A column index
- Returns:
true
if columnc
is an integer.
-
inline virtual bool isColumnBinary(const int &c)
Ascertain whether the given column is binary (i.e. a [0,1] integer).
- Parameters:
c – A column index
- Returns:
true
if columnc
is binary.
-
virtual void setColName(const int &var, const string &asString) = 0
-
virtual string getColName(const int &var) = 0
-
virtual double getColUpper(const int &var) = 0
-
virtual void setColUpper(const int &var, const double &b) = 0
-
virtual double getColLower(const int &var) = 0
-
virtual void setColLower(const int &var, const double &b) = 0
-
virtual void setColBounds(const int &var, const double &lb, const double &ub) = 0
-
virtual int getNumCols() = 0
-
inline virtual void addEmptyRealCols(const int &n)
Add empty columns to the LP, for real-valued variables. Default bounds are
0
togetInfinity()
.- Parameters:
n – The number of columns to add
-
virtual void setMaximiseObjective(const bool &maxim) = 0
Objective function calls.
Specify that the calls to
solve()
should maximise the given objective, rather than minimising.- Parameters:
maxim – If
true
, the objective will be maximised.
-
virtual void setObjective(double *const entries) = 0
Set the objective function according to the vector of weights given.
- Parameters:
entries – An array, size equal to
getNumCols()
containing the linear coefficient for each column, to use in the objective.
-
inline virtual void setQuadraticObjective(const Objective &o)
Specify a (possibly quadratic) objective to use when solving the LP.
- Parameters:
o – The objective function to use
-
virtual void setObjCoeff(const int &var, const double &w) = 0
Set the linear coefficient in the objective function of the given column.
- Parameters:
var – The column whose coefficient is to be changed
w – The coefficient for column <codevar
-
virtual void clearObjective() = 0
Clear the objective coefficients (set each to 0).
-
virtual bool solve(const bool &skipPresolve) = 0
Solving, and accessing solutions.
-
virtual bool quadraticPreSolve()
Find the best combination of the settings to the binary variables in the quadratic objective passed to
setQuadraticObjective()
. The default implementation branches over the settings to the integer objective terms, fixing the bounds on the variables to the best solution found. Note that after calling this a call tosolve()
is still to be able to access the best solution.- Returns:
true
if the MIQCP could be solved.
-
virtual const double *getSolution() = 0
-
virtual const double *getPartialSolution(const int &from, const int &to) = 0
Obtain the solution values of a subset of the columns in the LP.
- Parameters:
from – The start column index of the range to return (inclusive)
to – The end column index of the range to return (exclusive)
- Returns:
A pointer to an array, where index 0 contains the value of the variable
from
etc.
-
inline virtual double getSingleSolutionVariableValue(const int &col)
Obtain the solution values of the specified variable.
- Parameters:
col – The index of the variable (column)
- Returns:
The value that variable takes in the most recent solution to the LP
-
virtual const double *getSolutionRows() = 0
Obtain the value of the row in the solution.
- Returns:
An array containing
getNumRows()
values, one for each row.
-
inline virtual double getSingleSolutionRowValue(const int &row)
Obtain the value of the specified row in the solution.
- Parameters:
row – A row index
- Returns:
The value it takes in the solution
-
virtual double getObjValue() = 0
Return the computed value of the objective function.
-
virtual void writeLp(const string &filename) = 0
Miscellaneous functions.
-
virtual void getRow(const int &i, vector<pair<int, double>> &entries) = 0
Get a row from the LP, returning the coefficients it contains.
- Parameters:
i – The index of the row to get
entries – A reference to a vector of
int
,double
pairs which, after calling the method, will contain the column indices and coefficients of rowi
of the LP.
-
virtual void hush() = 0
Suppress all output from the solver
Protected Functions
-
inline MILPSolver()
-
class Objective
Public Types
-
typedef map<int, Coefficient>::const_iterator const_iterator
Public Functions
-
inline Objective(const bool maxObj = false)
-
inline void setMaximise(const bool &m)
-
inline const bool &maximise() const
-
inline Coefficient &getTerm(const int &v)
-
inline const_iterator begin() const
-
inline const_iterator end() const
-
inline size_t size() const
-
typedef map<int, Coefficient>::const_iterator const_iterator
-
inline virtual ~MILPSolver()