Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
JaniNextStateGenerator.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
7
12
13namespace storm {
14namespace jani {
15class Edge;
16class EdgeDestination;
17} // namespace jani
18
19namespace generator {
20
21template<typename StateType, typename ValueType>
22class Distribution;
23
28template<typename ValueType, typename StateType = uint32_t>
30
31template<typename ValueType, typename StateType = uint32_t>
32class JaniNextStateGenerator : public NextStateGenerator<ValueType, StateType> {
33 public:
34 static_assert(!storm::IsIntervalType<ValueType>, "JaniNextStateGenerator does not support interval types.");
38
40
45
50
56 static bool canHandle(storm::jani::Model const& model);
57
58 virtual ModelType getModelType() const override;
59 virtual bool isDeterministicModel() const override;
60 virtual bool isDiscreteTimeModel() const override;
61 virtual bool isPartiallyObservable() const override;
62 virtual std::vector<StateType> getInitialStates(StateToIdCallback const& stateToIdCallback) override;
63
66
67 virtual StateBehavior<ValueType, StateType> const& expand(StateToIdCallback const& stateToIdCallback) override;
68
70 virtual void addStateValuation(storm::storage::sparse::state_type const& currentStateIndex, storm::storage::sparse::Valuations& valuations) const override;
71
72 virtual std::size_t getNumberOfRewardModels() const override;
73 virtual storm::builder::RewardModelInformation getRewardModelInformation(uint64_t const& index) const override;
74
76 std::vector<StateType> const& initialStateIndices = {},
77 std::vector<StateType> const& deadlockStateIndices = {},
78 std::vector<StateType> const& unexploredStateIndices = {}) override;
79
80 virtual std::shared_ptr<storm::storage::sparse::ChoiceOrigins> generateChoiceOrigins(std::vector<boost::any>& dataForChoiceOrigins) const override;
81
92
93 private:
97 uint64_t getLocation(CompressedState const& state, LocationVariableInformation const& locationVariable) const;
98
102 void setLocation(CompressedState& state, LocationVariableInformation const& locationVariable, uint64_t locationIndex) const;
103
107 std::vector<uint64_t> getLocations(CompressedState const& state) const;
108
112 void getLocations(CompressedState const& state, std::vector<uint64_t>& result) const;
113
120
130 void applyUpdate(CompressedState& state, storm::jani::EdgeDestination const& destination,
131 storm::generator::LocationVariableInformation const& locationVariable, int64_t assignmentlevel,
132 storm::expressions::ExpressionEvaluator<ValueType> const& expressionEvaluator);
133
143 void applyTransientUpdate(TransientVariableValuation<ValueType>& transientValuation, storm::jani::detail::ConstAssignments const& transientAssignments,
144 storm::expressions::ExpressionEvaluator<ValueType> const& expressionEvaluator) const;
145
153 virtual storm::storage::BitVector evaluateObservationLabels(CompressedState const& state) const override;
154
161 TransientVariableValuation<ValueType> getTransientVariableValuationAtLocations(std::vector<uint64_t> const& locations,
163
167 void getTransientVariableValuationAtLocations(std::vector<uint64_t> const& locations, storm::expressions::ExpressionEvaluator<ValueType> const& evaluator,
169
177 void setEvaluatorState(CompressedState const& state);
178
183 bool evaluatorHoldsState(CompressedState const& state) const;
184
193 void getActionChoices(std::vector<uint64_t> const& locations, CompressedState const& state, StateToIdCallback const& stateToIdCallback,
194 EdgeFilter const& edgeFilter, StateBehavior<ValueType, StateType>& behavior);
195
200 Choice<ValueType>& expandNonSynchronizingEdge(storm::jani::Edge const& edge, uint64_t outputActionIndex, uint64_t automatonIndex,
201 CompressedState const& state, StateToIdCallback const& stateToIdCallback,
203
204 typedef std::vector<std::pair<uint64_t, storm::jani::Edge const*>> EdgeSetWithIndices;
205 typedef std::unordered_map<uint64_t, EdgeSetWithIndices> LocationsAndEdges;
206 typedef std::vector<std::pair<uint64_t, LocationsAndEdges>> AutomataAndEdges;
207 typedef std::pair<boost::optional<uint64_t>, AutomataAndEdges> OutputAndEdges;
208
209 typedef std::pair<uint64_t, EdgeSetWithIndices> AutomatonAndEdgeSet;
210 typedef std::vector<AutomatonAndEdgeSet> AutomataEdgeSets;
211
212 void expandSynchronizingEdgeCombination(AutomataEdgeSets const& edgeCombination, uint64_t outputActionIndex, CompressedState const& state,
213 StateToIdCallback const& stateToIdCallback, StateBehavior<ValueType, StateType>& behavior);
214 void generateSynchronizedDistribution(storm::storage::BitVector const& state, AutomataEdgeSets const& edgeCombination,
215 std::vector<EdgeSetWithIndices::const_iterator> const& iteratorList,
216 storm::generator::Distribution<StateType, ValueType>& distribution, std::vector<ValueType>& stateActionRewards,
217 EdgeIndexSet& edgeIndices, StateToIdCallback const& stateToIdCallback);
218
222 void checkGlobalVariableWritesValid(AutomataEdgeSets const& enabledEdges) const;
223
227 std::vector<ValueType> evaluateRewardExpressions() const;
228
232 void evaluateRewardExpressions(std::vector<ValueType>& result) const;
233
237 void addEvaluatedRewardExpressions(std::vector<ValueType>& rewards, ValueType const& factor) const;
238
242 void buildRewardModelInformation();
243
247 void createSynchronizationInformation();
248
252 void checkValid() const;
253
255 storm::jani::Model model;
256
258 std::vector<std::reference_wrapper<storm::jani::Automaton const>> parallelAutomata;
259
261 std::vector<OutputAndEdges> edges;
262
264 std::vector<std::pair<std::string, storm::expressions::Expression>> rewardExpressions;
265
267 std::vector<storm::builder::RewardModelInformation> rewardModelInformation;
268
270 bool hasStateActionRewards;
271
273 bool evaluateRewardExpressionsAtEdges;
274
276 bool evaluateRewardExpressionsAtDestinations;
277
279 storm::jani::ArrayEliminatorData arrayEliminatorData;
280
282 TransientVariableInformation<ValueType> transientVariableInformation;
283
288 friend struct JaniNextStateGeneratorScratchMemory<ValueType, StateType>;
289
295 std::unique_ptr<JaniNextStateGeneratorScratchMemory<ValueType, StateType>> scratch;
296};
297
298} // namespace generator
299} // namespace storm
virtual ModelType getModelType() const override
static storm::jani::ModelFeatures getSupportedJaniFeatures()
Returns the jani features with which this builder can deal natively.
virtual std::shared_ptr< storm::storage::sparse::ChoiceOrigins > generateChoiceOrigins(std::vector< boost::any > &dataForChoiceOrigins) const override
virtual std::vector< StateType > getInitialStates(StateToIdCallback const &stateToIdCallback) override
JaniNextStateGenerator(storm::jani::Model const &model, NextStateGeneratorOptions const &options=NextStateGeneratorOptions())
virtual storm::builder::RewardModelInformation getRewardModelInformation(uint64_t const &index) const override
virtual StateBehavior< ValueType, StateType > const & expand(StateToIdCallback const &stateToIdCallback) override
virtual bool isPartiallyObservable() const override
virtual std::size_t getNumberOfRewardModels() const override
static bool canHandle(storm::jani::Model const &model)
A quick check to detect whether the given model is not supported.
NextStateGenerator< ValueType, StateType >::StateToIdCallback StateToIdCallback
virtual storm::models::sparse::StateLabeling label(storm::storage::sparse::StateStorage< StateType > const &stateStorage, std::vector< StateType > const &initialStateIndices={}, std::vector< StateType > const &deadlockStateIndices={}, std::vector< StateType > const &unexploredStateIndices={}) override
virtual void addStateValuation(storm::storage::sparse::state_type const &currentStateIndex, storm::storage::sparse::Valuations &valuations) const override
Adds the valuation for the currently loaded state to the given builder.
virtual void unpackTransientVariableValuesIntoEvaluator(CompressedState const &state, storm::expressions::ExpressionEvaluator< ValueType > &evaluator) const override
Sets the values of all transient variables in the current state to the given evaluator.
virtual storm::storage::sparse::Valuations initializeStateValuations() const override
Initializes state valuations by adding the appropriate variables.
~JaniNextStateGenerator()
Declared (instead of implicitly defaulted) and defined in the .cpp file, because JaniNextStateGenerat...
NextStateGenerator(storm::expressions::ExpressionManager const &expressionManager, VariableInformation const &variableInformation, NextStateGeneratorOptions const &options, std::shared_ptr< ActionMask< ValueType, uint32_t > > const &=nullptr)
std::unique_ptr< storm::expressions::ExpressionEvaluator< BaseValueType > > evaluator
An evaluator used to evaluate expressions.
std::function< StateType(CompressedState const &)> StateToIdCallback
CompressedState const * state
The currently loaded state.
NextStateGeneratorOptions options
The options to be used for next-state generation.
This class manages the labeling of the state space with a number of (atomic) labels.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
Provides access to valuations of variables for a set of entities (e.g.
Definition Valuations.h:28
storm::storage::BitVector CompressedState
storm::builder::BuilderOptions NextStateGeneratorOptions
storm::adapters::DereferenceIteratorAdapter< std::vector< std::shared_ptr< Assignment > > const > ConstAssignments
boost::container::flat_set< Key, std::less< Key >, boost::container::new_allocator< Key > > FlatSet
Redefinition of flat_set was needed, because from Boost 1.70 on the default allocator is set to void.
Definition BoostTypes.h:13
constexpr bool IsIntervalType
Helper to check if a type is an interval.
The actual (private) implementation of JaniNextStateGeneratorScratchMemory, see the corresponding mem...