|
OpenGM
2.3.x
Discrete Graphical Model Library
|
Interface definition for wrapper of LP Solvers like CPLEX and Gurobi. More...
#include <lp_solver_interface.hxx>
Inheritance diagram for opengm::LPSolverInterface< LP_SOLVER_TYPE, VALUE_TYPE, INDEX_TYPE, SOLUTION_ITERATOR_TYPE, SOLVER_TIMING_TYPE >:
Collaboration diagram for opengm::LPSolverInterface< LP_SOLVER_TYPE, VALUE_TYPE, INDEX_TYPE, SOLUTION_ITERATOR_TYPE, SOLVER_TIMING_TYPE >:Classes | |
| class | Parameter |
| Parameter class provides options to modify LP Solver behavior. More... | |
Public Types | |
| enum | Objective { Minimize, Maximize } |
| This enum defines the type of the objective. It is used to select either to minimize or to maxime the objective function. More... | |
| typedef LP_SOLVER_TYPE | SolverType |
| Defines the type of the child class which inherits from LPSolverInterface. More... | |
| typedef VALUE_TYPE | SolverValueType |
| Defines the value type used by the LP Solver. More... | |
| typedef INDEX_TYPE | SolverIndexType |
| Defines the index type used by the LP Solver. More... | |
| typedef SOLUTION_ITERATOR_TYPE | SolverSolutionIteratorType |
| Defines the iterator type which can be used to iterate over the solution of the LP Solver. More... | |
| typedef SOLVER_TIMING_TYPE | SolverTimingType |
| Defines the timing type used by the LP Solver. More... | |
Public Member Functions | |
| 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... | |
| template<class ITERATOR_TYPE > | |
| void | setObjectiveValue (ITERATOR_TYPE begin, const ITERATOR_TYPE end) |
| Set the coefficients of all variables in the objective function. More... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| 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... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| 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... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| 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... | |
| template<class VARIABLES_ITERATOR_TYPE , class COEFFICIENTS_ITERATOR_TYPE > | |
| 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... | |
| template<class PARAMETER_TYPE , class PARAMETER_VALUE_TYPE > | |
| 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... | |
Static Public Member Functions | |
| static SolverValueType | infinity () |
| Get the value which is used by the LP Solver to represent infinity. More... | |
Protected Attributes | |
| const Parameter | parameter_ |
| Storage for parameter. More... | |
Interface definition for wrapper of LP Solvers like CPLEX and Gurobi.
| LP_SOLVER_TYPE | The type of the child class which inherits from LPSolverInterface. |
| VALUE_TYPE | The value type used by the LP Solver. |
| INDEX_TYPE | The index type used by the LP Solver. |
| SOLUTION_ITERATOR_TYPE | The iterator type which can be used to iterate over the solution of the LP Solver. |
| SOLVER_TIMING_TYPE | The timing type used by the LP Solver. |
Definition at line 12 of file lp_solver_interface.hxx.
| LPSolverInterface::SolverIndexType |
Defines the index type used by the LP Solver.
Definition at line 17 of file lp_solver_interface.hxx.
| LPSolverInterface::SolverSolutionIteratorType |
Defines the iterator type which can be used to iterate over the solution of the LP Solver.
Definition at line 18 of file lp_solver_interface.hxx.
| LPSolverInterface::SolverTimingType |
Defines the timing type used by the LP Solver.
Definition at line 19 of file lp_solver_interface.hxx.
| LPSolverInterface::SolverType |
Defines the type of the child class which inherits from LPSolverInterface.
Definition at line 15 of file lp_solver_interface.hxx.
| LPSolverInterface::SolverValueType |
Defines the value type used by the LP Solver.
Definition at line 16 of file lp_solver_interface.hxx.
| enum opengm::LPSolverInterface::Objective |
This enum defines the type of the objective. It is used to select either to minimize or to maxime the objective function.
| Enumerator | |
|---|---|
| Minimize |
Objective function will be minimized. |
| Maximize |
Objective function will be maximized. |
Definition at line 22 of file lp_solver_interface.hxx.
|
inline |
Default constructor of class LPSolverInterface.
Definition at line 663 of file lp_solver_interface.hxx.
|
inline |
Default destructor of class LPSolverInterface.
Definition at line 669 of file lp_solver_interface.hxx.
|
inline |
Add new binary variables to the model.
| [in] | numVariables | The number of new Variables. |
Definition at line 684 of file lp_solver_interface.hxx.
|
inline |
Join all constraints added via LPSolverInterface::addEqualityConstraint, LPSolverInterface::addLessEqualConstraint and LPSolverInterface::addGreaterEqualConstraint to the model.
Definition at line 729 of file lp_solver_interface.hxx.
|
inline |
Join all constraints added via LPSolverInterface::addEqualityConstraint, LPSolverInterface::addLessEqualConstraint and LPSolverInterface::addGreaterEqualConstraint to the model.
| [out] | timing | Returns the time needed to join all constraints to the model. |
Definition at line 734 of file lp_solver_interface.hxx.
|
inline |
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 674 of file lp_solver_interface.hxx.
|
inline |
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 712 of file lp_solver_interface.hxx.
|
inline |
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 724 of file lp_solver_interface.hxx.
|
inline |
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 679 of file lp_solver_interface.hxx.
|
inline |
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 718 of file lp_solver_interface.hxx.
|
inline |
Export model to file.
| [in] | filename | The name of the file where the model will be stored. |
Definition at line 780 of file lp_solver_interface.hxx.
|
inlinestatic |
Get the value which is used by the LP Solver to represent infinity.
Definition at line 658 of file lp_solver_interface.hxx.
|
inline |
Get the objective function value from the Solver.
Definition at line 770 of file lp_solver_interface.hxx.
|
inline |
Get the best known bound for the optimal solution of the current model.
Definition at line 775 of file lp_solver_interface.hxx.
|
inline |
Set objective to minimize or maximize.
| [in] | objective | The new objective. |
Definition at line 689 of file lp_solver_interface.hxx.
|
inline |
Set the coefficient of a variable in the objective function.
| [in] | variable | The index of the variable. |
| [in] | value | The value which will be added to the coefficient of the variable in the objective function. |
Definition at line 694 of file lp_solver_interface.hxx.
|
inline |
Set 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 700 of file lp_solver_interface.hxx.
|
inline |
Set 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 for 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 706 of file lp_solver_interface.hxx.
|
inline |
Set Solver parameter.
| PARAMETER_VALUE_TYPE | The type of the parameter. |
| VALUE_TYPE | The type of the value. |
| [in] | parameter | The Solver parameter. |
| [in] | value | The new value to which the parameter will be set. |
Definition at line 740 of file lp_solver_interface.hxx.
|
inline |
Get the solution value of a variable computed by the Solver.
| [in] | variable | Index of the variable for which the solution value is requested. |
Definition at line 765 of file lp_solver_interface.hxx.
|
inline |
Get an iterator which is pointing to the begin of the solution computed by the Solver.
Definition at line 755 of file lp_solver_interface.hxx.
|
inline |
Get an iterator which is pointing to the end of the solution computed by the Solver.
Definition at line 760 of file lp_solver_interface.hxx.
|
inline |
Solve the current model.
Definition at line 745 of file lp_solver_interface.hxx.
|
inline |
Solve the current model and measure solving time.
| [out] | timing | The time the solver needed to solve the problem. |
Definition at line 750 of file lp_solver_interface.hxx.
|
protected |
Storage for parameter.
Definition at line 112 of file lp_solver_interface.hxx.
1.8.9.1