Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
NextStateGenerator.h
Go to the documentation of this file.
1#ifndef STORM_GENERATOR_NEXTSTATEGENERATOR_H_
2#define STORM_GENERATOR_NEXTSTATEGENERATOR_H_
3
4#include <cstdint>
5#include <vector>
6
7#include <boost/variant.hpp>
8
14
17
21
23
24namespace storm {
25namespace expressions {
26template<typename V>
27class ExpressionEvaluator;
28class SimpleValuation;
29} // namespace expressions
30namespace generator {
32
33enum class ModelType { DTMC, CTMC, MDP, MA, POMDP, SMG };
34
35template<typename ValueType, typename StateType = uint32_t>
36class NextStateGenerator;
37
42template<typename ValueType, typename StateType = uint32_t>
44 public:
45 virtual ~ActionMask() = default;
54 virtual bool query(storm::generator::NextStateGenerator<ValueType, StateType> const& generator, uint64_t actionIndex) = 0;
55};
56
61template<typename ValueType, typename StateType = uint32_t>
62class StateValuationFunctionMask : public ActionMask<ValueType, StateType> {
63 public:
64 StateValuationFunctionMask(std::function<bool(storm::expressions::SimpleValuation const&, uint64_t)> const& f);
65 virtual ~StateValuationFunctionMask() = default;
66 bool query(storm::generator::NextStateGenerator<ValueType, StateType> const& generator, uint64_t actionIndex) override;
67
68 private:
69 std::function<bool(storm::expressions::SimpleValuation, uint64_t)> func;
70};
71
72template<typename ValueType, typename StateType>
74 public:
75 typedef std::function<StateType(CompressedState const&)> StateToIdCallback;
76
78 NextStateGeneratorOptions const& options, std::shared_ptr<ActionMask<ValueType, StateType>> const& = nullptr);
79
85 std::shared_ptr<ActionMask<ValueType, StateType>> const& = nullptr);
86
88
89 uint64_t getStateSize() const;
90 virtual ModelType getModelType() const = 0;
91 virtual bool isDeterministicModel() const = 0;
92 virtual bool isDiscreteTimeModel() const = 0;
93 virtual bool isPartiallyObservable() const = 0;
94 virtual std::vector<StateType> getInitialStates(StateToIdCallback const& stateToIdCallback) = 0;
95
98
101
102 void load(CompressedState const& state);
103 virtual StateBehavior<ValueType, StateType> expand(StateToIdCallback const& stateToIdCallback) = 0;
104 bool satisfies(storm::expressions::Expression const& expression) const;
105
107 virtual void addStateValuation(storm::storage::sparse::state_type const& currentStateIndex,
108 storm::storage::sparse::StateValuationsBuilder& valuationsBuilder) const;
111
112 virtual std::size_t getNumberOfRewardModels() const = 0;
114
115 std::string stateToString(CompressedState const& state) const;
116
117 storm::json<ValueType> currentStateToJson(bool onlyObservable = false) const;
119
120 uint32_t observabilityClass(CompressedState const& state) const;
121
122 virtual std::map<std::string, storm::storage::PlayerIndex> getPlayerNameToIndexMap() const;
123
125 std::vector<StateType> const& initialStateIndices = {},
126 std::vector<StateType> const& deadlockStateIndices = {},
127 std::vector<StateType> const& unexploredStateIndices = {}) = 0;
128
130
131 VariableInformation const& getVariableInformation() const;
132
133 virtual std::shared_ptr<storm::storage::sparse::ChoiceOrigins> generateChoiceOrigins(std::vector<boost::any>& dataForChoiceOrigins) const;
134
140 void remapStateIds(std::function<StateType(StateType const&)> const& remapping);
141
142 protected:
146 bool isSpecialLabel(std::string const& label) const;
147
152 std::vector<StateType> const& initialStateIndices, std::vector<StateType> const& deadlockStateIndices,
153 std::vector<StateType> const& unexploredStateIndices,
154 std::vector<std::pair<std::string, storm::expressions::Expression>> labelsAndExpressions);
155
165
167
168 virtual void extendStateInformation(storm::json<ValueType>& stateInfo) const;
169
171
173
176
178 std::shared_ptr<storm::expressions::ExpressionManager const> expressionManager;
179
181 std::vector<std::pair<storm::expressions::Expression, bool>> terminalStates;
182
185
187 std::unique_ptr<storm::expressions::ExpressionEvaluator<ValueType>> evaluator;
188
191
194
197
199 // TODO consider using a BitVectorHashMap for this?
200 mutable std::unordered_map<storm::storage::BitVector, uint32_t> observabilityMap;
203
205 boost::optional<std::vector<uint64_t>> overlappingGuardStates;
206
207 std::shared_ptr<ActionMask<ValueType, StateType>> actionMask;
208};
209} // namespace generator
210} // namespace storm
211
212#endif /* STORM_GENERATOR_NEXTSTATEGENERATOR_H_ */
This class is responsible for managing a set of typed variables and all expressions using these varia...
A simple implementation of the valuation interface.
Action masks are arguments you can give to the state generator that limit which states are generated.
virtual ~ActionMask()=default
virtual bool query(storm::generator::NextStateGenerator< ValueType, StateType > const &generator, uint64_t actionIndex)=0
This method is called to check whether an action should be expanded.
virtual std::shared_ptr< storm::storage::sparse::ChoiceOrigins > generateChoiceOrigins(std::vector< boost::any > &dataForChoiceOrigins) const
virtual std::map< std::string, storm::storage::PlayerIndex > getPlayerNameToIndexMap() const
std::shared_ptr< storm::expressions::ExpressionManager const > expressionManager
The expression manager used for evaluating expressions.
virtual storm::storage::sparse::StateValuations makeObservationValuation() const
Adds the valuation for the currently loaded state.
std::unique_ptr< storm::expressions::ExpressionEvaluator< ValueType > > evaluator
An evaluator used to evaluate expressions.
bool isSpecialLabel(std::string const &label) const
Checks if the input label has a special purpose (e.g.
std::shared_ptr< ActionMask< ValueType, StateType > > actionMask
virtual storm::storage::BitVector evaluateObservationLabels(CompressedState const &state) const =0
void initializeSpecialStates()
Initializes the out-of-bounds state and states with overlapping guards.
std::string stateToString(CompressedState const &state) const
virtual storm::storage::sparse::StateValuationsBuilder initializeStateValuationsBuilder() const
Initializes a builder for state valuations by adding the appropriate variables.
storm::utility::ConstantsComparator< ValueType > comparator
A comparator used to compare constants.
std::function< StateType(CompressedState const &)> StateToIdCallback
void postprocess(StateBehavior< ValueType, StateType > &result)
boost::optional< std::vector< uint64_t > > overlappingGuardStates
A map that stores the indices of states with overlapping guards.
CompressedState const * state
The currently loaded state.
uint32_t observabilityClass(CompressedState const &state) const
virtual ModelType getModelType() const =0
NextStateGeneratorOptions const & getOptions() const
std::vector< std::pair< storm::expressions::Expression, bool > > terminalStates
The expressions that define terminal states.
storm::expressions::SimpleValuation currentStateToSimpleValuation() const
CompressedState outOfBoundsState
A state that encodes the outOfBoundsState.
virtual bool isDiscreteTimeModel() const =0
storm::storage::BitVector mask
The mask to compute the observability class (Constructed upon first use)
storm::json< ValueType > currentStateToJson(bool onlyObservable=false) const
void load(CompressedState const &state)
virtual storm::storage::sparse::StateValuationsBuilder initializeObservationValuationsBuilder() const
bool satisfies(storm::expressions::Expression const &expression) const
std::unordered_map< storm::storage::BitVector, uint32_t > observabilityMap
The observability classes handed out so far.
virtual std::vector< StateType > getInitialStates(StateToIdCallback const &stateToIdCallback)=0
virtual storm::builder::RewardModelInformation getRewardModelInformation(uint64_t const &index) const =0
virtual void addStateValuation(storm::storage::sparse::state_type const &currentStateIndex, storm::storage::sparse::StateValuationsBuilder &valuationsBuilder) const
Adds the valuation for the currently loaded state to the given builder.
NextStateGeneratorOptions options
The options to be used for next-state generation.
virtual void extendStateInformation(storm::json< ValueType > &stateInfo) const
void remapStateIds(std::function< StateType(StateType const &)> const &remapping)
Performs a remapping of all values stored by applying the given remapping.
virtual void unpackTransientVariableValuesIntoEvaluator(CompressedState const &state, storm::expressions::ExpressionEvaluator< ValueType > &evaluator) const
Sets the values of all transient variables in the current state to the given evaluator.
VariableInformation const & getVariableInformation() const
virtual bool isPartiallyObservable() const =0
virtual bool isDeterministicModel() const =0
virtual std::size_t getNumberOfRewardModels() const =0
virtual StateBehavior< ValueType, StateType > expand(StateToIdCallback const &stateToIdCallback)=0
VariableInformation variableInformation
Information about how the variables are packed.
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={})=0
A particular instance of the action mask that uses a callback function to evaluate whether an action ...
bool query(storm::generator::NextStateGenerator< ValueType, StateType > const &generator, uint64_t actionIndex) override
This method is called to check whether an action should be expanded.
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:18
storm::storage::BitVector CompressedState
storm::builder::BuilderOptions NextStateGeneratorOptions
LabParser.cpp.
Definition cli.cpp:18
nlohmann::basic_json< std::map, std::vector, std::string, bool, int64_t, uint64_t, ValueType > json
Definition JsonForward.h:10