Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
LraViHelper.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace storm {
9class Environment;
10
11namespace modelchecker {
12namespace helper {
13namespace internal {
14
28
41template<typename ValueType, typename ComponentType, LraViTransitionsType TransitionsType>
43 public:
45 typedef std::function<ValueType(uint64_t)> ValueGetter;
46
57 LraViHelper(ComponentType const& component, storm::storage::SparseMatrix<ValueType> const& transitionMatrix, ValueType const& aperiodicFactor,
58 storm::storage::BitVector const* timedStates = nullptr, std::vector<ValueType> const* exitRates = nullptr);
59
74 ValueType performValueIteration(Environment const& env, ValueGetter const& stateValueGetter, ValueGetter const& actionValueGetter,
75 std::vector<ValueType> const* exitRates = nullptr, storm::solver::OptimizationDirection const* dir = nullptr,
76 std::vector<uint64_t>* choices = nullptr);
77
78 private:
86 void initializeNewValues(ValueGetter const& stateValueGetter, ValueGetter const& actionValueGetter, std::vector<ValueType> const* exitRates = nullptr);
87
98 void performIterationStep(Environment const& env, storm::solver::OptimizationDirection const* dir = nullptr, std::vector<uint64_t>* choices = nullptr);
99
100 struct ConvergenceCheckResult {
101 bool isPrecisionAchieved;
102 ValueType currentValue;
103 };
104
108 ConvergenceCheckResult checkConvergence(bool relative, ValueType precision) const;
109
113 void prepareNextIteration(Environment const& env);
114
116 void prepareSolversAndMultipliers(Environment const& env, storm::solver::OptimizationDirection const* dir = nullptr);
117
118 void setInputModelChoices(std::vector<uint64_t>& choices, std::vector<uint64_t> const& localMecChoices, bool setChoiceZeroToMarkovianStates = false,
119 bool setChoiceZeroToProbabilisticStates = false) const;
120
122 bool isTimedState(uint64_t const& inputModelStateIndex) const;
123
125 std::vector<ValueType>& xNew();
126 std::vector<ValueType> const& xNew() const;
127
129 std::vector<ValueType>& xOld();
130 std::vector<ValueType> const& xOld() const;
131
133 bool nondetTs() const;
134
136 bool nondetIs() const;
137
138 void setComponent(ComponentType component);
139
140 // We need to make sure that states/choices will be processed in ascending order
141 typedef std::map<uint64_t, std::set<uint64_t>> InternalComponentType;
142
143 InternalComponentType _component;
144 storm::storage::SparseMatrix<ValueType> const& _transitionMatrix;
145 storm::storage::BitVector const* _timedStates; // e.g. Markovian states of a Markov automaton.
146 bool _hasInstantStates;
147 ValueType _uniformizationRate;
148 storm::storage::SparseMatrix<ValueType> _TsTransitions, _TsToIsTransitions, _IsTransitions, _IsToTsTransitions;
149 std::vector<ValueType> _Tsx1, _Tsx2, _TsChoiceValues;
150 bool _Tsx1IsCurrent;
151 std::vector<ValueType> _Isx, _Isb, _IsChoiceValues;
152 std::unique_ptr<storm::solver::Multiplier<ValueType>> _TsMultiplier, _TsToIsMultiplier, _IsToTsMultiplier;
153 std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType>> _NondetIsSolver;
154 std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> _DetIsSolver;
155 std::unique_ptr<storm::Environment> _IsSolverEnv;
156};
157} // namespace internal
158} // namespace helper
159} // namespace modelchecker
160} // namespace storm
Helper class that performs iterations of the value iteration method.
Definition LraViHelper.h:42
ValueType performValueIteration(Environment const &env, ValueGetter const &stateValueGetter, ValueGetter const &actionValueGetter, std::vector< ValueType > const *exitRates=nullptr, storm::solver::OptimizationDirection const *dir=nullptr, std::vector< uint64_t > *choices=nullptr)
Performs value iteration with the given state- and action values.
std::function< ValueType(uint64_t)> ValueGetter
Function mapping from indices to values.
Definition LraViHelper.h:45
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
A class that holds a possibly non-square matrix in the compressed row storage format.
LraViTransitionsType
Specifies differnt kinds of transition types with which this helper can be used Ts means timed states...
Definition LraViHelper.h:22
@ NondetTsNoIs
deterministic choice at timed states, deterministic choice at instant states (as in Markov Automata w...
@ DetTsNondetIs
deterministic choice at timed states, no instant states (as in DTMCs and CTMCs)
@ DetTsDetIs
deterministic choice at timed states, nondeterministic choice at instant states (as in Markov Automat...
LabParser.cpp.
Definition cli.cpp:18