Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MinMaxLinearEquationSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <vector>
6
7#include <boost/optional.hpp>
8
14
17
18namespace storm {
19
20class Environment;
21
22namespace storage {
23template<typename T>
24class SparseMatrix;
25template<typename ValueType>
26class Scheduler;
27} // namespace storage
28
29namespace solver {
30
34template<typename ValueType, typename SolutionType = ValueType>
36 protected:
38
39 public:
41
42 virtual void setMatrix(storm::storage::SparseMatrix<ValueType> const& matrix) = 0;
44
55 bool solveEquations(Environment const& env, OptimizationDirection d, std::vector<SolutionType>& x, std::vector<ValueType> const& b) const;
56
62 void solveEquations(Environment const& env, std::vector<SolutionType>& x, std::vector<ValueType> const& b) const;
63
68
73
77 void setUncertaintyIsRobust(bool robust);
78
82 bool isUncertaintyRobust() const;
83
88 virtual void setSchedulerFixedForRowGroup(storm::storage::BitVector&& schedulerFixedForRowGroup);
89
93 void setHasUniqueSolution(bool value = true);
94
102 bool hasUniqueSolution() const;
103
107 void setHasNoEndComponents(bool value = true);
108
112 bool hasNoEndComponents() const;
113
118 void setTrackScheduler(bool trackScheduler = true);
119
123 bool isTrackSchedulerSet() const;
124
128 bool hasScheduler() const;
129
134
138 std::vector<uint_fast64_t> const& getSchedulerChoices() const;
139
144 void setCachingEnabled(bool value);
145
149 bool isCachingEnabled() const;
150
154 virtual void clearCache() const;
155
159 void setInitialScheduler(std::vector<uint_fast64_t>&& choices);
160
164 bool hasInitialScheduler() const;
165
169 std::vector<uint_fast64_t> const& getInitialScheduler() const;
170
176 boost::optional<storm::solver::OptimizationDirection> const& direction = boost::none,
177 bool const& hasInitialScheduler = false) const;
178
183 void setRequirementsChecked(bool value = true);
184
188 bool isRequirementsCheckedSet() const;
189
190 protected:
191 virtual bool internalSolveEquations(Environment const& env, OptimizationDirection d, std::vector<SolutionType>& x,
192 std::vector<ValueType> const& b) const = 0;
193
196
199
201 mutable boost::optional<std::vector<uint_fast64_t>> schedulerChoices;
202
204 boost::optional<std::vector<uint_fast64_t>> initialScheduler;
205
207 boost::optional<storm::storage::BitVector> choiceFixedForRowGroup;
208
209 private:
211 bool uniqueSolution;
212
214 bool noEndComponents;
215
217 bool cachingEnabled;
218
220 bool requirementsChecked;
221
223 bool robustUncertainty;
224};
225
226template<typename ValueType, typename SolutionType = ValueType>
228 public:
231
232 std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env,
233 storm::storage::SparseMatrix<ValueType> const& matrix) const;
234 std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env, storm::storage::SparseMatrix<ValueType>&& matrix) const;
235 virtual std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env) const = 0;
236
241 MinMaxLinearEquationSolverRequirements getRequirements(Environment const& env, bool hasUniqueSolution = false, bool hasNoEndComponents = false,
242 boost::optional<storm::solver::OptimizationDirection> const& direction = boost::none,
243 bool hasInitialScheduler = false, bool trackScheduler = false) const;
244 void setRequirementsChecked(bool value = true);
245 bool isRequirementsCheckedSet() const;
246
247 private:
248 bool requirementsChecked;
249};
250
251template<typename ValueType, typename SolutionType = ValueType>
253 public:
255
256 // Make the other create methods visible.
257 using MinMaxLinearEquationSolverFactory<ValueType, SolutionType>::create;
258
259 virtual std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env) const override;
260};
261
262} // namespace solver
263} // namespace storm
virtual std::unique_ptr< MinMaxLinearEquationSolver< ValueType, SolutionType > > create(Environment const &env) const override
MinMaxLinearEquationSolverRequirements getRequirements(Environment const &env, bool hasUniqueSolution=false, bool hasNoEndComponents=false, boost::optional< storm::solver::OptimizationDirection > const &direction=boost::none, bool hasInitialScheduler=false, bool trackScheduler=false) const
Retrieves the requirements of the solver that would be created when calling create() right now.
std::unique_ptr< MinMaxLinearEquationSolver< ValueType, SolutionType > > create(Environment const &env, storm::storage::SparseMatrix< ValueType > const &matrix) const
virtual std::unique_ptr< MinMaxLinearEquationSolver< ValueType, SolutionType > > create(Environment const &env) const =0
A class representing the interface that all min-max linear equation solvers shall implement.
virtual void setSchedulerFixedForRowGroup(storm::storage::BitVector &&schedulerFixedForRowGroup)
Sets the states for which the choices are fixed.
void unsetOptimizationDirection()
Unsets the optimization direction to use for calls to methods that do not explicitly provide one.
storm::storage::Scheduler< ValueType > computeScheduler() const
Retrieves the generated scheduler.
void setHasUniqueSolution(bool value=true)
Sets whether the solution to the min max equation system is known to be unique.
void setUncertaintyIsRobust(bool robust)
Set whether uncertainty should be interpreted adverserially (robust) or not.
bool solveEquations(Environment const &env, OptimizationDirection d, std::vector< SolutionType > &x, std::vector< ValueType > const &b) const
Solves the equation system x = min/max(A*x + b) given by the parameters.
virtual void clearCache() const
Clears the currently cached data that has been stored during previous calls of the solver.
void setOptimizationDirection(OptimizationDirection direction)
Sets an optimization direction to use for calls to methods that do not explicitly provide one.
OptimizationDirectionSetting direction
The optimization direction to use for calls to functions that do not provide it explicitly....
boost::optional< std::vector< uint_fast64_t > > initialScheduler
A scheduler that can be used by solvers that require a valid initial scheduler.
void setInitialScheduler(std::vector< uint_fast64_t > &&choices)
Sets a valid initial scheduler that is required by some solvers (see requirements of solvers).
bool hasScheduler() const
Retrieves whether the solver generated a scheduler.
std::vector< uint_fast64_t > const & getSchedulerChoices() const
Retrieves the generated (deterministic) choices of the optimal scheduler.
std::vector< uint_fast64_t > const & getInitialScheduler() const
Retrieves the initial scheduler if one was set.
bool trackScheduler
Whether we generate a scheduler during solving.
void setRequirementsChecked(bool value=true)
Notifies the solver that the requirements for solving equations have been checked.
bool hasUniqueSolution() const
Retrieves whether the solution to the min max equation system is assumed to be unique.
virtual MinMaxLinearEquationSolverRequirements getRequirements(Environment const &env, boost::optional< storm::solver::OptimizationDirection > const &direction=boost::none, bool const &hasInitialScheduler=false) const
Retrieves the requirements of this solver for solving equations with the current settings.
boost::optional< storm::storage::BitVector > choiceFixedForRowGroup
void setHasNoEndComponents(bool value=true)
Sets whether the min max equation system is known to not have any end components.
bool isUncertaintyRobust() const
Is the uncertainty to be interpreted robustly (adverserially) or not?
bool isTrackSchedulerSet() const
Retrieves whether this solver is set to generate schedulers.
bool hasNoEndComponents() const
Retrieves whether the min max equation system is known to not have any end components.
virtual bool internalSolveEquations(Environment const &env, OptimizationDirection d, std::vector< SolutionType > &x, std::vector< ValueType > const &b) const =0
void setCachingEnabled(bool value)
Sets whether some of the generated data during solver calls should be cached.
bool isRequirementsCheckedSet() const
Retrieves whether the solver is aware that the requirements were checked.
bool isCachingEnabled() const
Retrieves whether some of the generated data during solver calls should be cached.
boost::optional< std::vector< uint_fast64_t > > schedulerChoices
The scheduler choices that induce the optimal values (if they could be successfully generated).
virtual void setMatrix(storm::storage::SparseMatrix< ValueType > const &matrix)=0
bool hasInitialScheduler() const
Returns true iff an initial scheduler is set.
void setTrackScheduler(bool trackScheduler=true)
Sets whether schedulers are generated when solving equation systems.
virtual void setMatrix(storm::storage::SparseMatrix< ValueType > &&matrix)=0
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
This class defines which action is chosen in a particular state of a non-deterministic model.
Definition Scheduler.h:18
A class that holds a possibly non-square matrix in the compressed row storage format.
LabParser.cpp.
Definition cli.cpp:18