Storm 1.11.1.1
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
15
18
19namespace storm {
20
21class Environment;
22
23namespace storage {
24template<typename T>
25class SparseMatrix;
26template<typename ValueType>
27class Scheduler;
28} // namespace storage
29
30namespace solver {
31
35template<typename ValueType, typename SolutionType = ValueType>
37 protected:
39
40 public:
42
43 virtual void setMatrix(storm::storage::SparseMatrix<ValueType> const& matrix) = 0;
45
56 bool solveEquations(Environment const& env, OptimizationDirection d, std::vector<SolutionType>& x, std::vector<ValueType> const& b) const;
57
63 void solveEquations(Environment const& env, std::vector<SolutionType>& x, std::vector<ValueType> const& b) const;
64
69
74
78 void setUncertaintyResolutionMode(UncertaintyResolutionMode uncertaintyResolutionMode);
79
84
89 virtual void setSchedulerFixedForRowGroup(storm::storage::BitVector&& schedulerFixedForRowGroup);
90
94 void setHasUniqueSolution(bool value = true);
95
103 bool hasUniqueSolution() const;
104
108 void setHasNoEndComponents(bool value = true);
109
113 bool hasNoEndComponents() const;
114
119 void setTrackScheduler(bool trackScheduler = true);
120
124 bool isTrackSchedulerSet() const;
125
129 bool hasScheduler() const;
130
135
139 std::vector<uint_fast64_t> const& getSchedulerChoices() const;
140
144 std::vector<uint_fast64_t> const& getRobustSchedulerIndex() const;
145
150 void setCachingEnabled(bool value);
151
155 bool isCachingEnabled() const;
156
160 virtual void clearCache() const;
161
165 void setInitialScheduler(std::vector<uint_fast64_t>&& choices);
166
170 bool hasInitialScheduler() const;
171
175 std::vector<uint_fast64_t> const& getInitialScheduler() const;
176
182 boost::optional<storm::solver::OptimizationDirection> const& direction = boost::none,
183 bool const& hasInitialScheduler = false) const;
184
189 void setRequirementsChecked(bool value = true);
190
194 bool isRequirementsCheckedSet() const;
195
196 protected:
197 virtual bool internalSolveEquations(Environment const& env, OptimizationDirection d, std::vector<SolutionType>& x,
198 std::vector<ValueType> const& b) const = 0;
199
202
205
207 mutable boost::optional<std::vector<uint_fast64_t>> schedulerChoices;
208
218 mutable boost::optional<std::vector<uint_fast64_t>> robustSchedulerIndex;
219
221 boost::optional<std::vector<uint_fast64_t>> initialScheduler;
222
224 boost::optional<storm::storage::BitVector> choiceFixedForRowGroup;
225
226 private:
228 bool uniqueSolution;
229
231 bool noEndComponents;
232
234 bool cachingEnabled;
235
237 bool requirementsChecked;
238
240 UncertaintyResolutionMode uncertaintyResolutionMode;
241};
242
243template<typename ValueType, typename SolutionType = ValueType>
245 public:
248
249 std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env,
250 storm::storage::SparseMatrix<ValueType> const& matrix) const;
251 std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env, storm::storage::SparseMatrix<ValueType>&& matrix) const;
252 virtual std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env) const = 0;
253
258 MinMaxLinearEquationSolverRequirements getRequirements(Environment const& env, bool hasUniqueSolution = false, bool hasNoEndComponents = false,
259 boost::optional<storm::solver::OptimizationDirection> const& direction = boost::none,
260 bool hasInitialScheduler = false, bool trackScheduler = false) const;
261 void setRequirementsChecked(bool value = true);
262 bool isRequirementsCheckedSet() const;
263
264 private:
265 bool requirementsChecked;
266};
267
268template<typename ValueType, typename SolutionType = ValueType>
270 public:
272
273 // Make the other create methods visible.
274 using MinMaxLinearEquationSolverFactory<ValueType, SolutionType>::create;
275
276 virtual std::unique_ptr<MinMaxLinearEquationSolver<ValueType, SolutionType>> create(Environment const& env) const override;
277
278 protected:
279 MinMaxMethod getMethod(Environment env) const;
280};
281
282} // namespace solver
283} // 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.
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.
boost::optional< std::vector< uint_fast64_t > > robustSchedulerIndex
For interval models, this index points into the schedulerChoices and is a state -> index map.
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.
std::vector< uint_fast64_t > const & getRobustSchedulerIndex() const
Retrieves the generated robust index into the scheduler.
void setUncertaintyResolutionMode(UncertaintyResolutionMode uncertaintyResolutionMode)
Sets how the uncertainty should be resolved.
UncertaintyResolutionMode getUncertaintyResolutionMode() const
Retrieves the mode indicating how the uncertainty should be resolved.
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:16
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.