1#ifndef STORM_SOLVER_GUROBILPSOLVER
2#define STORM_SOLVER_GUROBILPSOLVER
8#include "storm-config.h"
10#ifdef STORM_HAVE_GUROBI
14int __stdcall GRBislp(GRBenv**,
const char*,
const char*,
const char*,
const char*);
32#ifdef STORM_HAVE_GUROBI
36 bool initialized =
false;
37#ifdef STORM_HAVE_GUROBI
38 GRBenv* env =
nullptr;
45template<
typename ValueType,
bool RawMode = false>
68 GurobiLpSolver(std::shared_ptr<GurobiEnvironment>
const& environment, std::string
const& name);
82 GurobiLpSolver(std::shared_ptr<GurobiEnvironment>
const& environment);
97 std::optional<ValueType>
const& upperBound = std::nullopt, ValueType objectiveFunctionCoefficient = 0)
override;
100 virtual void update()
const override;
107 virtual void optimize()
const override;
120 virtual void push()
override;
121 virtual void pop()
override;
124 virtual ValueType
getMILPGap(
bool relative)
const override;
135#ifdef STORM_HAVE_GUROBI
140 std::shared_ptr<GurobiEnvironment> environment;
143 int nextVariableIndex;
146 std::map<storm::expressions::Variable, int> variableToIndexMap;
148 struct IncrementalLevel {
149 std::vector<storm::expressions::Variable> variables;
152 int firstConstraintIndex;
153 int firstGenConstraintIndex;
155 std::vector<IncrementalLevel> incrementalData;
GurobiEnvironment()=default
GurobiEnvironment(GurobiEnvironment const &)=delete
void setOutput(bool set=false)
GurobiEnvironment & operator=(GurobiEnvironment const &)=delete
void initialize()
Sets some properties of the Gurobi environment according to parameters given by the options.
virtual ~GurobiEnvironment()
A class that implements the LpSolver interface using Gurobi.
virtual ~GurobiLpSolver()
Destructs a solver by freeing the pointers to Gurobi's structures.
GurobiLpSolver(GurobiLpSolver< ValueType > const &other)
Creates a (deep) copy of this solver.
virtual bool isInfeasible() const override
Retrieves whether the model was found to be infeasible.
virtual int_fast64_t getIntegerValue(Variable const &name) const override
Retrieves the value of the integer variable with the given name.
virtual bool isUnbounded() const override
Retrieves whether the model was found to be infeasible.
virtual void setMaximalMILPGap(ValueType const &gap, bool relative) override
Specifies the maximum difference between lower- and upper objective bounds that triggers termination.
virtual void push() override
Pushes a backtracking point on the solver's stack.
void setMaximalSolutionCount(uint64_t value)
typename LpSolver< ValueType, RawMode >::VariableType VariableType
virtual void addIndicatorConstraint(std::string const &name, Variable indicatorVariable, bool indicatorValue, Constraint const &constraint) override
Adds the given indicator constraint to the LP problem: "If indicatorVariable == indicatorValue,...
virtual void addConstraint(std::string const &name, Constraint const &constraint) override
Adds a the given constraint to the LP problem.
virtual ValueType getContinuousValue(Variable const &name) const override
Retrieves the value of the continuous variable with the given name.
virtual bool getBinaryValue(Variable const &name) const override
Retrieves the value of the binary variable with the given name.
virtual ValueType getObjectiveValue() const override
Retrieves the value of the objective function.
typename LpSolver< ValueType, RawMode >::Constant Constant
virtual void pop() override
Pops a backtracking point from the solver's stack.
virtual void writeModelToFile(std::string const &filename) const override
Writes the current LP problem to the given file.
typename LpSolver< ValueType, RawMode >::Variable Variable
virtual void optimize() const override
Optimizes the LP problem previously constructed.
virtual Variable addVariable(std::string const &name, VariableType const &type, std::optional< ValueType > const &lowerBound=std::nullopt, std::optional< ValueType > const &upperBound=std::nullopt, ValueType objectiveFunctionCoefficient=0) override
Registers a variable of the given type.
uint64_t getSolutionCount() const
typename LpSolver< ValueType, RawMode >::Constraint Constraint
virtual ValueType getMILPGap(bool relative) const override
Returns the obtained gap after a call to optimize()
virtual bool isOptimal() const override
Retrieves whether the model was found to be optimal, i.e.
virtual void update() const override
Updates the model to make the variables that have been declared since the last call to update usable.
An interface that captures the functionality of an LP solver.
std::conditional_t< RawMode, RawLpConstraint< ValueType >, storm::expressions::Expression > Constraint
std::conditional_t< RawMode, ValueType, storm::expressions::Expression > Constant
std::conditional_t< RawMode, typename RawLpConstraint< ValueType >::VariableIndexType, storm::expressions::Variable > Variable
VariableType
Enumerates the different types of variables.
std::string toString(GurobiSolverMethod const &method)
Yields a string representation of the GurobiSolverMethod.
std::optional< GurobiSolverMethod > gurobiSolverMethodFromString(std::string const &method)
std::vector< GurobiSolverMethod > getGurobiSolverMethods()