|
OpenGM
2.3.x
Discrete Graphical Model Library
|
Wrapper class for the Gurobi optimizer. More...
#include <lp_solver_gurobi.hxx>
Inheritance diagram for opengm::LPSolverGurobi:
Collaboration diagram for opengm::LPSolverGurobi:Public Types | |
| typedef double | GurobiValueType |
| Defines the value type used by Gurobi. More... | |
| typedef int | GurobiIndexType |
| Defines the index type used by Gurobi. More... | |
| typedef std::vector< GurobiValueType >::const_iterator | GurobiSolutionIteratorType |
| Defines the iterator type which can be used to iterate over the solution of Gurobi. More... | |
| typedef double | GurobiTimingType |
| Defines the timing type used by Gurobi. More... | |
| typedef LPSolverInterface< LPSolverGurobi, GurobiValueType, GurobiIndexType, GurobiSolutionIteratorType, GurobiTimingType > | LPSolverBaseClass |
| Defines the type of the base class. More... | |
Public Types inherited from opengm::LPSolverInterface< LPSolverGurobi, double, int, std::vector< double >::const_iterator, double > | |
| 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 LPSolverGurobi | SolverType |
| Defines the type of the child class which inherits from LPSolverInterface. More... | |
| typedef double | SolverValueType |
| Defines the value type used by the LP Solver. More... | |
| typedef int | SolverIndexType |
| Defines the index type used by the LP Solver. More... | |
| typedef std::vector< double >::const_iterator | SolverSolutionIteratorType |
| Defines the iterator type which can be used to iterate over the solution of the LP Solver. More... | |
| typedef double | SolverTimingType |
| Defines the timing type used by the LP Solver. More... | |
Public Member Functions | |
| LPSolverGurobi (const Parameter ¶meter=Parameter()) | |
| Default constructor for LPSolverGurobi. More... | |
| ~LPSolverGurobi () | |
| Destructor for LPSolverGurobi. More... | |
Public Member Functions inherited from opengm::LPSolverInterface< LPSolverGurobi, double, int, std::vector< double >::const_iterator, double > | |
| 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 GurobiIndexType numVariables, const GurobiValueType lowerBound, const GurobiValueType upperBound) |
| Add new continuous variables to the model. More... | |
| void | addIntegerVariables_impl (const GurobiIndexType numVariables, const GurobiValueType lowerBound, const GurobiValueType upperBound) |
| Add new integer variables to the model. More... | |
| void | addBinaryVariables_impl (const GurobiIndexType 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 GurobiIndexType variable, const GurobiValueType 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 GurobiValueType 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 GurobiValueType 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 GurobiValueType bound, const std::string &constraintName="") |
| Add a new greater equal constraint to the model. More... | |
| void | addConstraintsFinished_impl () |
| Join all constraints added via LPSolverGurobi::addEqualityConstraint, LPSolverGurobi::addLessEqualConstraint and LPSolverGurobi::addGreaterEqualConstraint to the model. More... | |
| void | addConstraintsFinished_impl (GurobiTimingType &timing) |
| Join all constraints added via LPSolverGurobi::addEqualityConstraint, LPSolverGurobi::addLessEqualConstraint and LPSolverGurobi::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 Gurobi parameter. More... | |
| bool | solve_impl () |
| Solve the current model. More... | |
| bool | solve_impl (GurobiTimingType &timing) |
| Solve the current model and measure solving time. More... | |
| GurobiSolutionIteratorType | solutionBegin_impl () const |
| Get an iterator which is pointing to the begin of the solution computed by Gurobi. More... | |
| GurobiSolutionIteratorType | solutionEnd_impl () const |
| Get an iterator which is pointing to the end of the solution computed by Gurobi. More... | |
| GurobiValueType | solution_impl (const GurobiIndexType variable) const |
| Get the solution value of a variable computed by Gurobi. More... | |
| GurobiValueType | objectiveFunctionValue_impl () const |
| Get the objective function value from Gurobi. More... | |
| GurobiValueType | 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 GurobiValueType | infinity_impl () |
| Get the value which is used by Gurobi to represent infinity. More... | |
| static int | getCutLevelValue (const LPDef::MIP_CUT cutLevel) |
| Translate LPDef::MIP_CUT into corresponding Gurobi int value. More... | |
Protected Attributes | |
| GRBEnv | gurobiEnvironment_ |
| The Gurobi environment. More... | |
| GRBModel | gurobiModel_ |
| The Gurobi model of the LP/MIP problem. More... | |
| std::vector< GRBVar > | gurobiVariables_ |
| The variables which are present in the model. More... | |
| std::vector< GurobiValueType > | gurobiSolution_ |
| Storage for the solution computed by Gurobi. More... | |
| bool | gurobiSolutionValid_ |
| Tell if the currently stored solution is valid. More... | |
Protected Attributes inherited from opengm::LPSolverInterface< LPSolverGurobi, double, int, std::vector< double >::const_iterator, double > | |
| const Parameter | parameter_ |
| Storage for parameter. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from opengm::LPSolverInterface< LPSolverGurobi, double, int, std::vector< double >::const_iterator, double > | |
| static SolverValueType | infinity () |
| Get the value which is used by the LP Solver to represent infinity. More... | |
Wrapper class for the Gurobi optimizer.
Definition at line 15 of file lp_solver_gurobi.hxx.
Defines the index type used by Gurobi.
Definition at line 19 of file lp_solver_gurobi.hxx.
Defines the iterator type which can be used to iterate over the solution of Gurobi.
Definition at line 20 of file lp_solver_gurobi.hxx.
Defines the timing type used by Gurobi.
Definition at line 21 of file lp_solver_gurobi.hxx.
Defines the value type used by Gurobi.
Definition at line 18 of file lp_solver_gurobi.hxx.
Defines the type of the base class.
Definition at line 23 of file lp_solver_gurobi.hxx.
|
inline |
Default constructor for LPSolverGurobi.
| [in] | parameter | Settings for the Gurobi solver. |
Definition at line 471 of file lp_solver_gurobi.hxx.
Here is the call graph for this function:
|
inline |
Destructor for LPSolverGurobi.
Definition at line 664 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Add new binary variables to the model.
| [in] | numVariables | The number of new Variables. |
Definition at line 712 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Join all constraints added via LPSolverGurobi::addEqualityConstraint, LPSolverGurobi::addLessEqualConstraint and LPSolverGurobi::addGreaterEqualConstraint to the model.
Definition at line 885 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Join all constraints added via LPSolverGurobi::addEqualityConstraint, LPSolverGurobi::addLessEqualConstraint and LPSolverGurobi::addGreaterEqualConstraint to the model.
| [out] | timing | Returns the time needed to join all constraints into the model. |
Definition at line 898 of file lp_solver_gurobi.hxx.
Here is the call graph for this function:
|
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 672 of file lp_solver_gurobi.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 814 of file lp_solver_gurobi.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 862 of file lp_solver_gurobi.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 692 of file lp_solver_gurobi.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 838 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Export model to file.
| [in] | filename | The name of the file where the model will be stored. |
Definition at line 1021 of file lp_solver_gurobi.hxx.
|
inlinestaticprotected |
Translate LPDef::MIP_CUT into corresponding Gurobi int value.
Definition at line 1052 of file lp_solver_gurobi.hxx.
Here is the caller graph for this function:
|
inlinestaticprotected |
Get the value which is used by Gurobi to represent infinity.
Definition at line 668 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Get the objective function value from Gurobi.
Definition at line 991 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Get the best known bound for the optimal solution of the current model.
Definition at line 1004 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Set objective to minimize or maximize.
| [in] | objective | The new objective. |
Definition at line 732 of file lp_solver_gurobi.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 766 of file lp_solver_gurobi.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 780 of file lp_solver_gurobi.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 796 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Set Gurobi parameter.
| PARAMETER_VALUE_TYPE | The type of the parameter. |
| VALUE_TYPE | The type of the value. |
| [in] | parameter | The Gurobi parameter. |
| [in] | value | The new value to which the parameter will be set. |
Definition at line 916 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Get the solution value of a variable computed by Gurobi.
| [in] | variable | Index of the variable for which the solution value is requested. |
Definition at line 978 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Get an iterator which is pointing to the begin of the solution computed by Gurobi.
Definition at line 968 of file lp_solver_gurobi.hxx.
Here is the call graph for this function:
|
inlineprotected |
Get an iterator which is pointing to the end of the solution computed by Gurobi.
Definition at line 973 of file lp_solver_gurobi.hxx.
Here is the call graph for this function:
|
inlineprotected |
Solve the current model.
Definition at line 929 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Solve the current model and measure solving time.
| [out] | timing | The time Gurobi needed to solve the problem. |
Definition at line 948 of file lp_solver_gurobi.hxx.
|
inlineprotected |
Update solution if required.
Definition at line 1034 of file lp_solver_gurobi.hxx.
Here is the caller graph for this function:
|
protected |
The Gurobi environment.
Definition at line 33 of file lp_solver_gurobi.hxx.
|
mutableprotected |
The Gurobi model of the LP/MIP problem.
Definition at line 34 of file lp_solver_gurobi.hxx.
|
mutableprotected |
Storage for the solution computed by Gurobi.
Definition at line 36 of file lp_solver_gurobi.hxx.
|
mutableprotected |
Tell if the currently stored solution is valid.
Definition at line 37 of file lp_solver_gurobi.hxx.
|
protected |
The variables which are present in the model.
Definition at line 35 of file lp_solver_gurobi.hxx.
1.8.9.1