|
OpenGM
2.3.x
Discrete Graphical Model Library
|
Wrapper class for the IBM ILOG CPLEX optimizer. More...
#include <lp_solver_cplex.hxx>
Inheritance diagram for opengm::LPSolverCplex:
Collaboration diagram for opengm::LPSolverCplex:Public Types | |
| typedef IloNum | CplexValueType |
| Defines the value type used by CPLEX. More... | |
| typedef IloInt | CplexIndexType |
| Defines the index type used by CPLEX. More... | |
| typedef IloNumArrayIterator | CplexSolutionIteratorType |
| Defines the iterator type which can be used to iterate over the solution of CPLEX. More... | |
| typedef IloNum | CplexTimingType |
| Defines the timing type used by CPLEX. More... | |
| typedef LPSolverInterface< LPSolverCplex, CplexValueType, CplexIndexType, CplexSolutionIteratorType, CplexTimingType > | LPSolverBaseClass |
| Defines the type of the base class. More... | |
Public Types inherited from opengm::LPSolverInterface< LPSolverCplex, IloNum, IloInt, IloNumArrayIterator, IloNum > | |
| enum | Objective |
| This enum defines the type of the objective. It is used to select either to minimize or to maxime the objective function. More... | |
| typedef LPSolverCplex | SolverType |
| Defines the type of the child class which inherits from LPSolverInterface. More... | |
| typedef IloNum | SolverValueType |
| Defines the value type used by the LP Solver. More... | |
| typedef IloInt | SolverIndexType |
| Defines the index type used by the LP Solver. More... | |
| typedef IloNumArrayIterator | SolverSolutionIteratorType |
| Defines the iterator type which can be used to iterate over the solution of the LP Solver. More... | |
| typedef IloNum | SolverTimingType |
| Defines the timing type used by the LP Solver. More... | |
Public Member Functions | |
| LPSolverCplex (const Parameter ¶meter=Parameter()) | |
| Default constructor for LPSolverCplex. More... | |
| ~LPSolverCplex () | |
| Destructor for LPSolverCplex. More... | |
Public Member Functions inherited from opengm::LPSolverInterface< LPSolverCplex, IloNum, IloInt, IloNumArrayIterator, IloNum > | |
| LPSolverInterface (const Parameter ¶meter=Parameter()) | |
| Default constructor of class LPSolverInterface. More... | |
| ~LPSolverInterface () | |
| Default destructor of class LPSolverInterface. More... | |
| void | addContinuousVariables (const SolverIndexType numVariables, const SolverValueType lowerBound, const SolverValueType upperBound) |
| Add new continuous variables to the model. More... | |
| void | addIntegerVariables (const SolverIndexType numVariables, const SolverValueType lowerBound, const SolverValueType upperBound) |
| Add new integer variables to the model. More... | |
| void | addBinaryVariables (const SolverIndexType numVariables) |
| Add new binary variables to the model. More... | |
| void | setObjective (const Objective objective) |
| Set objective to minimize or maximize. More... | |
| void | setObjectiveValue (const SolverIndexType variable, const SolverValueType value) |
| Set the coefficient of a variable in the objective function. More... | |
| void | setObjectiveValue (ITERATOR_TYPE begin, const ITERATOR_TYPE end) |
| Set the coefficients of all variables in the objective function. More... | |
| void | setObjectiveValue (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin) |
| Set the coefficients of selected variables in the objective function. More... | |
| void | addEqualityConstraint (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin, const SolverValueType bound, const std::string &constraintName="") |
| Add a new equality constraint to the model. More... | |
| void | addLessEqualConstraint (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin, const SolverValueType bound, const std::string &constraintName="") |
| Add a new less equal constraint to the model. More... | |
| void | addGreaterEqualConstraint (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin, const SolverValueType bound, const std::string &constraintName="") |
| Add a new greater equal constraint to the model. More... | |
| void | addConstraintsFinished () |
| Join all constraints added via LPSolverInterface::addEqualityConstraint, LPSolverInterface::addLessEqualConstraint and LPSolverInterface::addGreaterEqualConstraint to the model. More... | |
| void | addConstraintsFinished (SolverTimingType &timing) |
| Join all constraints added via LPSolverInterface::addEqualityConstraint, LPSolverInterface::addLessEqualConstraint and LPSolverInterface::addGreaterEqualConstraint to the model. More... | |
| void | setParameter (const PARAMETER_TYPE parameter, const PARAMETER_VALUE_TYPE value) |
| Set Solver parameter. More... | |
| bool | solve () |
| Solve the current model. More... | |
| bool | solve (SolverTimingType &timing) |
| Solve the current model and measure solving time. More... | |
| SolverSolutionIteratorType | solutionBegin () const |
| Get an iterator which is pointing to the begin of the solution computed by the Solver. More... | |
| SolverSolutionIteratorType | solutionEnd () const |
| Get an iterator which is pointing to the end of the solution computed by the Solver. More... | |
| SolverValueType | solution (const SolverIndexType variable) const |
| Get the solution value of a variable computed by the Solver. More... | |
| SolverValueType | objectiveFunctionValue () const |
| Get the objective function value from the Solver. More... | |
| SolverValueType | objectiveFunctionValueBound () const |
| Get the best known bound for the optimal solution of the current model. More... | |
| void | exportModel (const std::string &filename) const |
| Export model to file. More... | |
Protected Member Functions | |
| void | addContinuousVariables_impl (const CplexIndexType numVariables, const CplexValueType lowerBound, const CplexValueType upperBound) |
| Add new continuous variables to the model. More... | |
| void | addIntegerVariables_impl (const CplexIndexType numVariables, const CplexValueType lowerBound, const CplexValueType upperBound) |
| Add new integer variables to the model. More... | |
| void | addBinaryVariables_impl (const CplexIndexType numVariables) |
| Add new binary variables to the model. More... | |
| void | setObjective_impl (const Objective objective) |
| Set objective to minimize or maximize. More... | |
| void | setObjectiveValue_impl (const CplexIndexType variable, const CplexValueType value) |
| Set the coefficient of a variable in the objective function. More... | |
| template<class ITERATOR_TYPE > | |
| void | setObjectiveValue_impl (ITERATOR_TYPE begin, const ITERATOR_TYPE end) |
| Set values of the coefficients of all variables in the objective function. More... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| void | setObjectiveValue_impl (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin) |
| Set values as the coefficients of selected variables in the objective function. More... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| void | addEqualityConstraint_impl (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin, const CplexValueType bound, const std::string &constraintName="") |
| Add a new equality constraint to the model. More... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| void | addLessEqualConstraint_impl (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin, const CplexValueType bound, const std::string &constraintName="") |
| Add a new less equal constraint to the model. More... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| void | addGreaterEqualConstraint_impl (VARIABLES_ITERATOR_TYPE variableIDsBegin, const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin, const CplexValueType bound, const std::string &constraintName="") |
| Add a new greater equal constraint to the model. More... | |
| void | addConstraintsFinished_impl () |
| Join all constraints added via LPSolverCplex::addEqualityConstraint, LPSolverCplex::addLessEqualConstraint and LPSolverCplex::addGreaterEqualConstraint to the model. More... | |
| void | addConstraintsFinished_impl (CplexTimingType &timing) |
| Join all constraints added via LPSolverCplex::addEqualityConstraint, LPSolverCplex::addLessEqualConstraint and LPSolverCplex::addGreaterEqualConstraint to the model. More... | |
| template<class PARAMETER_TYPE , class PARAMETER_VALUE_TYPE > | |
| void | setParameter_impl (const PARAMETER_TYPE parameter, const PARAMETER_VALUE_TYPE value) |
| Set CPLEX parameter. More... | |
| bool | solve_impl () |
| Solve the current model. More... | |
| bool | solve_impl (CplexTimingType &timing) |
| Solve the current model and measure solving time. More... | |
| CplexSolutionIteratorType | solutionBegin_impl () const |
| Get an iterator which is pointing to the begin of the solution computed by CPLEX. More... | |
| CplexSolutionIteratorType | solutionEnd_impl () const |
| Get an iterator which is pointing to the end of the solution computed by CPLEX. More... | |
| CplexValueType | solution_impl (const CplexIndexType variable) const |
| Get the solution value of a variable computed by CPLEX. More... | |
| CplexValueType | objectiveFunctionValue_impl () const |
| Get the objective function value from CPLEX. More... | |
| CplexValueType | objectiveFunctionValueBound_impl () const |
| Get the best known bound for the optimal solution of the current model. More... | |
| void | exportModel_impl (const std::string &filename) const |
| Export model to file. More... | |
| void | updateSolution () const |
| Update solution if required. More... | |
Static Protected Member Functions | |
| static CplexValueType | infinity_impl () |
| Get the value which is used by CPLEX to represent infinity. More... | |
| static int | getCutLevelValue (const LPDef::MIP_CUT cutLevel) |
| Translate LPDef::MIP_CUT into corresponding CPLEX int value. More... | |
Protected Attributes | |
| IloEnv | cplexEnvironment_ |
| The CPLEX environment. More... | |
| IloModel | cplexModel_ |
| The CPLEX model of the LP/MIP problem. More... | |
| IloNumVarArray | cplexVariables_ |
| The variables which are present in the model. More... | |
| IloObjective | cplexObjective_ |
| The objective function. More... | |
| IloRangeArray | cplexConstraints_ |
| Puffer for the constraints which are added by CPlexSolver::addEqualityConstraint, CPlexSolver::addLessEqualConstraint and CPlexSolver::addGreaterEqualConstraint. Will be flushed into the CPLEX model when CPlexSolver::addConstraintsFinished is called. More... | |
| IloNumArray | cplexSolution_ |
| Storage for the solution computed by CPLEX. More... | |
| bool | cplexSolutionValid_ |
| Tell if the currently stored solution is valid. More... | |
| IloCplex | cplexSolver_ |
| The CPLEX solver. More... | |
Protected Attributes inherited from opengm::LPSolverInterface< LPSolverCplex, IloNum, IloInt, IloNumArrayIterator, IloNum > | |
| const Parameter | parameter_ |
| Storage for parameter. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from opengm::LPSolverInterface< LPSolverCplex, IloNum, IloInt, IloNumArrayIterator, IloNum > | |
| static SolverValueType | infinity () |
| Get the value which is used by the LP Solver to represent infinity. More... | |
Wrapper class for the IBM ILOG CPLEX optimizer.
Definition at line 41 of file lp_solver_cplex.hxx.
Defines the index type used by CPLEX.
Definition at line 45 of file lp_solver_cplex.hxx.
Defines the iterator type which can be used to iterate over the solution of CPLEX.
Definition at line 46 of file lp_solver_cplex.hxx.
Defines the timing type used by CPLEX.
Definition at line 47 of file lp_solver_cplex.hxx.
Defines the value type used by CPLEX.
Definition at line 44 of file lp_solver_cplex.hxx.
Defines the type of the base class.
Definition at line 49 of file lp_solver_cplex.hxx.
|
inline |
Default constructor for LPSolverCplex.
| [in] | parameter | Settings for the CPLEX solver. |
Definition at line 633 of file lp_solver_cplex.hxx.
Here is the call graph for this function:
|
inline |
Destructor for LPSolverCplex.
Definition at line 865 of file lp_solver_cplex.hxx.
|
inlineprotected |
Add new binary variables to the model.
| [in] | numVariables | The number of new Variables. |
Definition at line 893 of file lp_solver_cplex.hxx.
|
inlineprotected |
Join all constraints added via LPSolverCplex::addEqualityConstraint, LPSolverCplex::addLessEqualConstraint and LPSolverCplex::addGreaterEqualConstraint to the model.
Definition at line 1030 of file lp_solver_cplex.hxx.
|
inlineprotected |
Join all constraints added via LPSolverCplex::addEqualityConstraint, LPSolverCplex::addLessEqualConstraint and LPSolverCplex::addGreaterEqualConstraint to the model.
| [out] | timing | Returns the time needed to join all constraints into the model. |
Definition at line 1043 of file lp_solver_cplex.hxx.
|
inlineprotected |
Add new continuous variables to the model.
| [in] | numVariables | The number of new Variables. |
| [in] | lowerBound | The lower bound for the new Variables. |
| [in] | upperBound | The upper bound for the new Variables. |
Definition at line 873 of file lp_solver_cplex.hxx.
|
inlineprotected |
Add a new equality constraint to the model.
| VARIABLES_ITERATOR_TYPE | Iterator type to iterate over the variable ids of the constraints. |
| COEFFICIENTS_ITERATOR_TYPE | Iterator type to iterate over the coefficients of the constraints. |
| [in] | variableIDsBegin | Iterator pointing to the begin of a sequence of values defining the variables of the constraint. |
| [in] | variableIDsEnd | Iterator pointing to the end of a sequence of values defining the variables of the constraint. |
| [in] | coefficientsBegin | Iterator pointing to the begin of a sequence of values defining the coefficients for the variables. |
| [in] | bound | The right hand side of the equality constraint. |
| [in] | constraintName | The name for the equality constraint. |
Definition at line 980 of file lp_solver_cplex.hxx.
|
inlineprotected |
Add a new greater equal constraint to the model.
| VARIABLES_ITERATOR_TYPE | Iterator type to iterate over the variable ids of the constraints. |
| COEFFICIENTS_ITERATOR_TYPE | Iterator type to iterate over the coefficients of the constraints. |
| [in] | variableIDsBegin | Iterator pointing to the begin of a sequence of values defining the variables of the constraint. |
| [in] | variableIDsEnd | Iterator pointing to the end of a sequence of values defining the variables of the constraint. |
| [in] | coefficientsBegin | Iterator pointing to the begin of a sequence of values defining the coefficients for the variables. |
| [in] | bound | The right hand side of the greater equal constraint. |
| [in] | constraintName | The name for the greater equal constraint. |
Definition at line 1014 of file lp_solver_cplex.hxx.
|
inlineprotected |
Add new integer variables to the model.
| [in] | numVariables | The number of new Variables. |
| [in] | lowerBound | The lower bound for the new Variables. |
| [in] | upperBound | The upper bound for the new Variables. |
Definition at line 883 of file lp_solver_cplex.hxx.
|
inlineprotected |
Add a new less equal constraint to the model.
| VARIABLES_ITERATOR_TYPE | Iterator type to iterate over the variable ids of the constraints. |
| COEFFICIENTS_ITERATOR_TYPE | Iterator type to iterate over the coefficients of the constraints. |
| [in] | variableIDsBegin | Iterator pointing to the begin of a sequence of values defining the variables of the constraint. |
| [in] | variableIDsEnd | Iterator pointing to the end of a sequence of values defining the variables of the constraint. |
| [in] | coefficientsBegin | Iterator pointing to the begin of a sequence of values defining the coefficients for the variables. |
| [in] | bound | The right hand side of the less equal constraint. |
| [in] | constraintName | The name for the less equal constraint. |
Definition at line 997 of file lp_solver_cplex.hxx.
|
inlineprotected |
Export model to file.
| [in] | filename | The name of the file where the model will be stored. |
Definition at line 1150 of file lp_solver_cplex.hxx.
|
inlinestaticprotected |
Translate LPDef::MIP_CUT into corresponding CPLEX int value.
Definition at line 1171 of file lp_solver_cplex.hxx.
Here is the caller graph for this function:
|
inlinestaticprotected |
Get the value which is used by CPLEX to represent infinity.
Definition at line 869 of file lp_solver_cplex.hxx.
|
inlineprotected |
Get the objective function value from CPLEX.
Definition at line 1128 of file lp_solver_cplex.hxx.
|
inlineprotected |
Get the best known bound for the optimal solution of the current model.
Definition at line 1137 of file lp_solver_cplex.hxx.
|
inlineprotected |
Set objective to minimize or maximize.
| [in] | objective | The new objective. |
Definition at line 903 of file lp_solver_cplex.hxx.
|
inlineprotected |
Set the coefficient of a variable in the objective function.
| [in] | variable | The index of the variable. |
| [in] | value | The value which will be set as the coefficient of the variable in the objective function. |
Definition at line 929 of file lp_solver_cplex.hxx.
|
inlineprotected |
Set values of the coefficients of all variables in the objective function.
| ITERATOR_TYPE | Iterator type used to iterate over the values which will be set as the coefficients of the objective function. |
| [in] | begin | Iterator pointing to the begin of the sequence of values which will be set as the coefficients of the objective function. |
| [in] | end | Iterator pointing to the end of the sequence of values which will be set as the coefficients of the objective function. |
Definition at line 939 of file lp_solver_cplex.hxx.
|
inlineprotected |
Set values as the coefficients of selected variables in the objective function.
| VARIABLES_ITERATOR_TYPE | Iterator type used to iterate over the indices of the variables. |
| COEFFICIENTS_ITERATOR_TYPE | Iterator type used to iterate over the coefficients of the variables which will be set in the objective function. |
| [in] | variableIDsBegin | Iterator pointing to the begin of the sequence of indices of the variables. |
| [in] | variableIDsEnd | Iterator pointing to the end of the sequence of indices of the variables. |
| [in] | coefficientsBegin | Iterator pointing to the begin of the sequence of values which will be set as the coefficients of the objective function. |
Definition at line 958 of file lp_solver_cplex.hxx.
|
inlineprotected |
Set CPLEX parameter.
| PARAMETER_VALUE_TYPE | The type of the parameter. |
| VALUE_TYPE | The type of the value. |
| [in] | parameter | The CPLEX parameter. |
| [in] | value | The new value to which the parameter will be set. |
Definition at line 1060 of file lp_solver_cplex.hxx.
|
inlineprotected |
Get the solution value of a variable computed by CPLEX.
| [in] | variable | Index of the variable for which the solution value is requested. |
Definition at line 1118 of file lp_solver_cplex.hxx.
Here is the call graph for this function:
|
inlineprotected |
Get an iterator which is pointing to the begin of the solution computed by CPLEX.
Definition at line 1108 of file lp_solver_cplex.hxx.
Here is the call graph for this function:
|
inlineprotected |
Get an iterator which is pointing to the end of the solution computed by CPLEX.
Definition at line 1113 of file lp_solver_cplex.hxx.
Here is the call graph for this function:
|
inlineprotected |
Solve the current model.
Definition at line 1069 of file lp_solver_cplex.hxx.
|
inlineprotected |
Solve the current model and measure solving time.
| [out] | timing | The time CPLEX needed to solve the problem. |
Definition at line 1086 of file lp_solver_cplex.hxx.
|
inlineprotected |
Update solution if required.
Definition at line 1159 of file lp_solver_cplex.hxx.
Here is the caller graph for this function:
|
protected |
Puffer for the constraints which are added by CPlexSolver::addEqualityConstraint, CPlexSolver::addLessEqualConstraint and CPlexSolver::addGreaterEqualConstraint. Will be flushed into the CPLEX model when CPlexSolver::addConstraintsFinished is called.
Definition at line 63 of file lp_solver_cplex.hxx.
|
protected |
The CPLEX environment.
Definition at line 59 of file lp_solver_cplex.hxx.
|
protected |
The CPLEX model of the LP/MIP problem.
Definition at line 60 of file lp_solver_cplex.hxx.
|
protected |
The objective function.
Definition at line 62 of file lp_solver_cplex.hxx.
|
protected |
Storage for the solution computed by CPLEX.
Definition at line 64 of file lp_solver_cplex.hxx.
|
mutableprotected |
Tell if the currently stored solution is valid.
Definition at line 65 of file lp_solver_cplex.hxx.
|
protected |
The CPLEX solver.
Definition at line 66 of file lp_solver_cplex.hxx.
|
protected |
The variables which are present in the model.
Definition at line 61 of file lp_solver_cplex.hxx.
1.8.9.1