1#ifndef STORM_SOLVER_LPSOLVER
2#define STORM_SOLVER_LPSOLVER
12namespace expressions {
13class ExpressionManager;
21template<
typename ValueType>
50template<
typename ValueType,
bool RawMode = false>
54 using Constant = std::conditional_t<RawMode, ValueType, storm::expressions::Expression>;
139 std::optional<ValueType>
const& upperBound = std::nullopt, ValueType objectiveFunctionCoefficient = 0);
204 std::optional<ValueType>
const& upperBound = std::nullopt, ValueType objectiveFunctionCoefficient = 0);
230 std::optional<ValueType>
const& upperBound = std::nullopt, ValueType objectiveFunctionCoefficient = 0) = 0;
391 std::shared_ptr<storm::expressions::ExpressionManager>
manager;
This class is responsible for managing a set of typed variables and all expressions using these varia...
An interface that captures the functionality of an LP solver.
Variable addUnboundedIntegerVariable(std::string const &name, ValueType objectiveFunctionCoefficient=0)
Registers an unbounded integer variable, i.e.
bool currentModelHasBeenOptimized
virtual void setMaximalMILPGap(ValueType const &gap, bool relative)=0
Specifies the maximum difference between lower- and upper objective bounds that triggers termination.
OptimizationDirection getOptimizationDirection() const
Retrieves whether the objective function of this model is to be minimized or maximized.
virtual bool getBinaryValue(Variable const &variable) const =0
Retrieves the value of the binary variable with the given name.
Variable addIntegerVariable(std::string const &name, std::optional< ValueType > const &lowerBound=std::nullopt, std::optional< ValueType > const &upperBound=std::nullopt, ValueType objectiveFunctionCoefficient=0)
Registers an integer variable, i.e.
Variable addContinuousVariable(std::string const &name, std::optional< ValueType > const &lowerBound=std::nullopt, std::optional< ValueType > const &upperBound=std::nullopt, ValueType objectiveFunctionCoefficient=0)
Registers a continuous variable, i.e.
virtual void update() const =0
Updates the model to make the variables that have been declared since the last call to update usable.
virtual void addConstraint(std::string const &name, Constraint const &constraint)=0
Adds a the given constraint to the LP problem.
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)=0
Registers a variable of the given type.
virtual void writeModelToFile(std::string const &filename) const =0
Writes the current LP problem to the given file.
virtual void pop()=0
Pops a backtracking point from the solver's stack.
Variable addUpperBoundedIntegerVariable(std::string const &name, ValueType upperBound, ValueType objectiveFunctionCoefficient=0)
Registers an upper-bounded integer variable, i.e.
virtual ValueType getMILPGap(bool relative) const =0
Returns the obtained gap after a call to optimize()
storm::expressions::Variable declareOrGetExpressionVariable(std::string const &name, VariableType const &type)
Variable addBoundedIntegerVariable(std::string const &name, ValueType lowerBound, ValueType upperBound, ValueType objectiveFunctionCoefficient=0)
Registers an upper- and lower-bounded integer variable, i.e.
storm::expressions::ExpressionManager const & getManager() const
Retrieves the manager for the variables created for this solver.
virtual void push()=0
Pushes a backtracking point on the solver's stack.
void setOptimizationDirection(OptimizationDirection const &optimizationDirection)
Sets whether the objective function of this model is to be minimized or maximized.
LpSolver()
Creates an empty LP solver.
std::conditional_t< RawMode, RawLpConstraint< ValueType >, storm::expressions::Expression > Constraint
std::conditional_t< RawMode, ValueType, storm::expressions::Expression > Constant
Variable addLowerBoundedContinuousVariable(std::string const &name, ValueType lowerBound, ValueType objectiveFunctionCoefficient=0)
Registers a lower-bounded continuous variable, i.e.
virtual int_fast64_t getIntegerValue(Variable const &variable) const =0
Retrieves the value of the integer variable with the given name.
std::conditional_t< RawMode, typename RawLpConstraint< ValueType >::VariableIndexType, storm::expressions::Variable > Variable
Constant getConstant(ValueType value) const
Retrieves an expression that characterizes the given constant value.
std::shared_ptr< storm::expressions::ExpressionManager > manager
virtual bool isInfeasible() const =0
Retrieves whether the model was found to be infeasible.
virtual void addIndicatorConstraint(std::string const &name, Variable indicatorVariable, bool indicatorValue, Constraint const &constraint)=0
Adds the given indicator constraint to the LP problem: "If indicatorVariable == indicatorValue,...
Variable addLowerBoundedIntegerVariable(std::string const &name, ValueType lowerBound, ValueType objectiveFunctionCoefficient=0)
Registers a lower-bounded integer variable, i.e.
virtual bool isUnbounded() const =0
Retrieves whether the model was found to be infeasible.
Variable addBoundedContinuousVariable(std::string const &name, ValueType lowerBound, ValueType upperBound, ValueType objectiveFunctionCoefficient=0)
Registers an upper- and lower-bounded continuous variable, i.e.
virtual ValueType getContinuousValue(Variable const &variable) const =0
Retrieves the value of the continuous variable with the given name.
virtual ~LpSolver()=default
VariableType
Enumerates the different types of variables.
virtual void optimize() const =0
Optimizes the LP problem previously constructed.
Variable addUnboundedContinuousVariable(std::string const &name, ValueType objectiveFunctionCoefficient=0)
Registers a unbounded continuous variable, i.e.
virtual ValueType getObjectiveValue() const =0
Retrieves the value of the objective function.
Variable addUpperBoundedContinuousVariable(std::string const &name, ValueType upperBound, ValueType objectiveFunctionCoefficient=0)
Registers an upper-bounded continuous variable, i.e.
Variable addBinaryVariable(std::string const &name, ValueType objectiveFunctionCoefficient=0)
Registers a boolean variable, i.e.
virtual bool isOptimal() const =0
Retrieves whether the model was found to be optimal, i.e.
RelationType
An enum type specifying the different relations applicable.
std::vector< VariableIndexType > lhsVariableIndices
uint64_t VariableIndexType
void addToLhs(VariableIndexType const &variable, ValueType const &coefficient)
Adds the summand 'coefficient * variable' to the left hand side.
storm::expressions::RelationType relationType
std::vector< ValueType > lhsCoefficients