1 #ifndef OPENGM_LP_SOLVER_INTERFACE_HXX_ 2 #define OPENGM_LP_SOLVER_INTERFACE_HXX_ 11 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
69 void addContinuousVariables(
const SolverIndexType numVariables,
const SolverValueType lowerBound,
const SolverValueType upperBound);
70 void addIntegerVariables(
const SolverIndexType numVariables,
const SolverValueType lowerBound,
const SolverValueType upperBound);
75 void setObjectiveValue(
const SolverIndexType variable,
const SolverValueType value);
76 template<
class ITERATOR_TYPE>
78 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
79 void setObjectiveValue(VARIABLES_ITERATOR_TYPE variableIDsBegin,
const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin);
82 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
83 void addEqualityConstraint(VARIABLES_ITERATOR_TYPE variableIDsBegin,
const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin,
const SolverValueType bound,
const std::string& constraintName =
"");
84 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
85 void addLessEqualConstraint(VARIABLES_ITERATOR_TYPE variableIDsBegin,
const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin,
const SolverValueType bound,
const std::string& constraintName =
"");
86 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
87 void addGreaterEqualConstraint(VARIABLES_ITERATOR_TYPE variableIDsBegin,
const VARIABLES_ITERATOR_TYPE variableIDsEnd, COEFFICIENTS_ITERATOR_TYPE coefficientsBegin,
const SolverValueType bound,
const std::string& constraintName =
"");
93 template <
class PARAMETER_TYPE,
class PARAMETER_VALUE_TYPE>
94 void setParameter(
const PARAMETER_TYPE parameter,
const PARAMETER_VALUE_TYPE value);
98 bool solve(SolverTimingType& timing);
103 SolverValueType
solution(
const SolverIndexType variable)
const;
109 void exportModel(
const std::string& filename)
const;
631 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
661 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
663 return SolverType::infinity_impl();
666 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
672 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
677 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
679 static_cast<SolverType*
>(
this)->addContinuousVariables_impl(numVariables, lowerBound, upperBound);
682 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
684 static_cast<SolverType*
>(
this)->addIntegerVariables_impl(numVariables, lowerBound, upperBound);
687 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
689 static_cast<SolverType*
>(
this)->addBinaryVariables_impl(numVariables);
692 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
694 static_cast<SolverType*
>(
this)->setObjective_impl(objective);
697 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
699 static_cast<SolverType*
>(
this)->setObjectiveValue_impl(variable, value);
702 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
703 template<
class ITERATOR_TYPE>
705 static_cast<SolverType*
>(
this)->setObjectiveValue_impl(begin, end);
708 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
709 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
711 static_cast<SolverType*
>(
this)->setObjectiveValue_impl(variableIDsBegin, variableIDsEnd, coefficientsBegin);
714 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
715 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
717 static_cast<SolverType*
>(
this)->addEqualityConstraint_impl(variableIDsBegin, variableIDsEnd, coefficientsBegin, bound, constraintName);
720 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
721 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
723 static_cast<SolverType*
>(
this)->addLessEqualConstraint_impl(variableIDsBegin, variableIDsEnd, coefficientsBegin, bound, constraintName);
726 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
727 template<
class VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
729 static_cast<SolverType*
>(
this)->addGreaterEqualConstraint_impl(variableIDsBegin, variableIDsEnd, coefficientsBegin, bound, constraintName);
732 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
734 static_cast<SolverType*
>(
this)->addConstraintsFinished_impl();
737 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
739 static_cast<SolverType*
>(
this)->addConstraintsFinished_impl(timing);
742 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
743 template <
class PARAMETER_TYPE,
class PARAMETER_VALUE_TYPE>
745 static_cast<SolverType*
>(
this)->setParameter_impl(parameter, value);
748 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
750 return static_cast<SolverType*
>(
this)->solve_impl();
753 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
755 return static_cast<SolverType*
>(
this)->solve_impl(timing);
758 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
760 return static_cast<const SolverType*
>(
this)->solutionBegin_impl();
763 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
765 return static_cast<const SolverType*
>(
this)->solutionEnd_impl();
768 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
770 return static_cast<const SolverType*
>(
this)->solution_impl(variable);
773 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
775 return static_cast<const SolverType*
>(
this)->objectiveFunctionValue_impl();
778 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
780 return static_cast<const SolverType*
>(
this)->objectiveFunctionValueBound_impl();
783 template <
class LP_SOLVER_TYPE,
class VALUE_TYPE,
class INDEX_TYPE,
class SOLUTION_ITERATOR_TYPE,
class SOLVER_TIMING_TYPE>
785 static_cast<const SolverType*
>(
this)->exportModel_impl(filename);
INDEX_TYPE SolverIndexType
Defines the index type used by the LP Solver.
void addBinaryVariables(const SolverIndexType numVariables)
Add new binary variables to the model.
LPDef::MIP_CUT flowcoverCutLevel_
Determines whether or not to generate flow cover cuts for the problem and how aggressively.
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.
LPDef::MIP_CUT gubCutLevel_
Determines whether or not to generate generalized upper bound (GUB) cuts for the problem and how aggr...
LPDef::LP_SOLVER rootAlg_
Select which algorithm is used to solve continuous models or to solve the root relaxation of a MIP...
Objective function will be maximized.
int numberOfThreads_
The number of threads used for Optimization (0 = autoselect).
double epRHS_
Feasibility tolerance.
double epMrk_
Markowitz tolerance.
Objective
This enum defines the type of the objective. It is used to select either to minimize or to maxime the...
SOLUTION_ITERATOR_TYPE SolverSolutionIteratorType
Defines the iterator type which can be used to iterate over the solution of the LP Solver...
LPDef::MIP_CUT flowpathCutLevel_
Determines whether or not to generate flow path cuts for the problem and how aggressively.
LP_SOLVER_TYPE SolverType
Defines the type of the child class which inherits from LPSolverInterface.
VALUE_TYPE SolverValueType
Defines the value type used by the LP Solver.
void addContinuousVariables(const SolverIndexType numVariables, const SolverValueType lowerBound, const SolverValueType upperBound)
Add new continuous variables to the model.
LPSolverInterface(const Parameter ¶meter=Parameter())
Default constructor of class LPSolverInterface.
void addIntegerVariables(const SolverIndexType numVariables, const SolverValueType lowerBound, const SolverValueType upperBound)
Add new integer variables to the model.
double epOpt_
Optimality tolerance.
SOLVER_TIMING_TYPE SolverTimingType
Defines the timing type used by the LP Solver.
double epGap_
Relative MIP gap tolerance.
LPDef::MIP_CUT disjunctCutLevel_
Determines whether or not to generate disjunctive cuts for the problem and how aggressively.
SolverSolutionIteratorType solutionEnd() const
Get an iterator which is pointing to the end of the solution computed by the Solver.
LPDef::MIP_CUT cliqueCutLevel_
Determines whether or not to generate clique cuts for the problem and how aggressively.
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.
void setParameter(const PARAMETER_TYPE parameter, const PARAMETER_VALUE_TYPE value)
Set Solver parameter.
void setObjective(const Objective objective)
Set objective to minimize or maximize.
void exportModel(const std::string &filename) const
Export model to file.
int probingLevel_
Amount of probing on variables to be performed before MIP branching.
static SolverValueType infinity()
Get the value which is used by the LP Solver to represent infinity.
LPDef::MIP_CUT mirCutLevel_
Determines whether or not mixed integer rounding (MIR) cuts should be generated for the problem and h...
LPDef::MIP_CUT coverCutLevel_
Determines whether or not to generate cover cuts for the problem and how aggressively.
double epAGap_
Absolute MIP gap tolerance.
Interface definition for wrapper of LP Solvers like CPLEX and Gurobi.
LPDef::MIP_EMPHASIS mipEmphasis_
Controls trade-offs between speed, feasibility, optimality, and moving bounds in a MIP...
double epInt_
Amount by which an integer variable can differ from an integer.
double treeMemoryLimit_
Maximal amount of memory in MB used for tree.
Wrapper class for the IBM ILOG CPLEX optimizer.
const Parameter parameter_
Storage for parameter.
double timeLimit_
Maximal time in seconds the solver has.
SolverValueType solution(const SolverIndexType variable) const
Get the solution value of a variable computed by the Solver.
Parameter()
Default constructor of class Parameter. Sets default values provided by class LPDef for all options...
LPDef::MIP_CUT cutLevel_
Determines whether or not to generate cuts for the problem and how aggressively (will be overruled by...
Parameter class provides options to modify LP Solver behavior.
LPDef::LP_SOLVER nodeAlg_
Select which algorithm is used to solve the subproblems in a MIP after the initial relaxation has bee...
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.
void setObjectiveValue(const SolverIndexType variable, const SolverValueType value)
Set the coefficient of a variable in the objective function.
~LPSolverInterface()
Default destructor of class LPSolverInterface.
bool verbose_
Enable verbose output if set to true.
bool solve()
Solve the current model.
Objective function will be minimized.
double cutUp_
Upper cutoff tolerance.
SolverValueType objectiveFunctionValueBound() const
Get the best known bound for the optimal solution of the current model.
SolverValueType objectiveFunctionValue() const
Get the objective function value from the Solver.
double workMem_
Maximal amount of memory in MB used for workspace.
LPDef::LP_PRESOLVE presolve_
Controls how aggressive presolve is performed during preprocessing.
LPDef::MIP_CUT iboundCutLevel_
Determines whether or not to generate implied bound cuts for the problem and how aggressively.
void addConstraintsFinished()
Join all constraints added via LPSolverInterface::addEqualityConstraint, LPSolverInterface::addLessEq...
SolverSolutionIteratorType solutionBegin() const
Get an iterator which is pointing to the begin of the solution computed by the Solver.
LPDef::MIP_CUT gomoryCutLevel_
Determines whether or not to generate gomory fractional cuts for the problem and how aggressively...