7#include "storm-config.h"
9#ifdef STORM_HAVE_GUROBI
13int __stdcall GRBislp(GRBenv**,
const char*,
const char*,
const char*,
const char*);
35#ifdef STORM_HAVE_GUROBI
39 bool initialized =
false;
40 double integerTolerance = 0.0;
41#ifdef STORM_HAVE_GUROBI
42 GRBenv* env =
nullptr;
49template<
typename ValueType,
bool RawMode = false>
72 GurobiLpSolver(std::shared_ptr<GurobiEnvironment>
const& environment, std::string
const& name);
86 GurobiLpSolver(std::shared_ptr<GurobiEnvironment>
const& environment);
95 std::optional<ValueType>
const& upperBound = std::nullopt, ValueType objectiveFunctionCoefficient = 0)
override;
98 virtual void update()
const override;
105 virtual void optimize()
const override;
118 virtual void push()
override;
119 virtual void pop()
override;
122 virtual ValueType
getMILPGap(
bool relative)
const override;
142#ifdef STORM_HAVE_GUROBI
147 std::shared_ptr<GurobiEnvironment> environment;
150 int nextVariableIndex;
153 std::map<storm::expressions::Variable, int> variableToIndexMap;
155 struct IncrementalLevel {
156 std::vector<storm::expressions::Variable> variables;
159 int firstConstraintIndex;
160 int firstGenConstraintIndex;
162 std::vector<IncrementalLevel> incrementalData;
164 std::optional<uint64_t> timeLimit;
GurobiEnvironment()=default
double getIntegerTolerance() const
GurobiEnvironment(GurobiEnvironment const &)=delete
void setOutput(bool set=false)
GurobiEnvironment & operator=(GurobiEnvironment const &)=delete
void initialize(storm::GurobiSolverEnvironment const &gurobiSettings, bool debug)
Sets some properties of the Gurobi environment according to parameters given by the options.
virtual ~GurobiEnvironment()
virtual ~GurobiLpSolver()
Destructs a solver by freeing the pointers to Gurobi's structures.
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
GurobiLpSolver(std::shared_ptr< GurobiEnvironment > const &environment, std::string const &name, OptimizationDirection const &optDir)
Constructs a solver with the given name and model sense.
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.
void setTimeLimit(uint64_t seconds)
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
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.
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()