Storm 1.11.1.1
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
24
25namespace storm {
26namespace expressions {
27template<typename V>
28class ExpressionEvaluator;
29class SimpleValuation;
30} // namespace expressions
31namespace generator {
33
34enum class ModelType { DTMC, CTMC, MDP, MA, POMDP, SMG };
35
36template<typename ValueType, typename StateType = uint32_t>
37class NextStateGenerator;
38
43template<typename ValueType, typename StateType = uint32_t>
45 public:
46 virtual ~ActionMask() = default;
55 virtual bool query(storm::generator::NextStateGenerator<ValueType, StateType> const& generator, uint64_t actionIndex) = 0;
56};
57
62template<typename ValueType, typename StateType = uint32_t>
63class StateValuationFunctionMask : public ActionMask<ValueType, StateType> {
64 public:
65 StateValuationFunctionMask(std::function<bool(storm::expressions::SimpleValuation const&, uint64_t)> const& f);
66 virtual ~StateValuationFunctionMask() = default;
67 bool query(storm::generator::NextStateGenerator<ValueType, StateType> const& generator, uint64_t actionIndex) override;
68
69 private:
70 std::function<bool(storm::expressions::SimpleValuation, uint64_t)> func;
71};
72
73template<typename ValueType, typename StateType>
75 public:
76 typedef std::function<StateType(CompressedState const&)> StateToIdCallback;
77
79 NextStateGeneratorOptions const& options, std::shared_ptr<ActionMask<ValueType, StateType>> const& = nullptr);
80
86 std::shared_ptr<ActionMask<ValueType, StateType>> const& = nullptr);
87
89
90 uint64_t getStateSize() const;
91 virtual ModelType getModelType() const = 0;
92 virtual bool isDeterministicModel() const = 0;
93 virtual bool isDiscreteTimeModel() const = 0;
94 virtual bool isPartiallyObservable() const = 0;
95 virtual std::vector<StateType> getInitialStates(StateToIdCallback const& stateToIdCallback) = 0;
96
99
102
103 void load(CompressedState const& state);
104 virtual StateBehavior<ValueType, StateType> expand(StateToIdCallback const& stateToIdCallback) = 0;
105 bool satisfies(storm::expressions::Expression const& expression) const;
106
108 virtual void addStateValuation(storm::storage::sparse::state_type const& currentStateIndex,
109 storm::storage::sparse::StateValuationsBuilder& valuationsBuilder) const;
112
113 virtual std::size_t getNumberOfRewardModels() const = 0;
115
116 std::string stateToString(CompressedState const& state) const;
117
118 storm::json<ValueType> currentStateToJson(bool onlyObservable = false) const;
120
121 uint32_t observabilityClass(CompressedState const& state) const;
122
123 virtual std::map<std::string, storm::storage::PlayerIndex> getPlayerNameToIndexMap() const;
124
126 std::vector<StateType> const& initialStateIndices = {},
127 std::vector<StateType> const& deadlockStateIndices = {},
128 std::vector<StateType> const& unexploredStateIndices = {}) = 0;
129
131
132 VariableInformation const& getVariableInformation() const;
133
134 virtual std::shared_ptr<storm::storage::sparse::ChoiceOrigins> generateChoiceOrigins(std::vector<boost::any>& dataForChoiceOrigins) const;
135
141 void remapStateIds(std::function<StateType(StateType const&)> const& remapping);
142
143 protected:
145
149 bool isSpecialLabel(std::string const& label) const;
150
155 std::vector<StateType> const& initialStateIndices, std::vector<StateType> const& deadlockStateIndices,
156 std::vector<StateType> const& unexploredStateIndices,
157 std::vector<std::pair<std::string, storm::expressions::Expression>> labelsAndExpressions);
158
169
171
172 virtual void extendStateInformation(storm::json<BaseValueType>& stateInfo) const;
173
175
177
180
182 std::shared_ptr<storm::expressions::ExpressionManager const> expressionManager;
183
185 std::vector<std::pair<storm::expressions::Expression, bool>> terminalStates;
186
189
191 std::unique_ptr<storm::expressions::ExpressionEvaluator<BaseValueType>> evaluator;
192
195
198
201
203 // TODO consider using a BitVectorHashMap for this?
204 mutable std::unordered_map<storm::storage::BitVector, uint32_t> observabilityMap;
207
209 boost::optional<std::vector<uint64_t>> overlappingGuardStates;
210
211 std::shared_ptr<ActionMask<ValueType, StateType>> actionMask;
212};
213} // namespace generator
214} // namespace storm
215
216#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.
bool isSpecialLabel(std::string const &label) const
Checks if the input label has a special purpose (e.g.
std::unique_ptr< storm::expressions::ExpressionEvaluator< BaseValueType > > evaluator
An evaluator used to evaluate expressions.
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 approximately compare constants, e.g., whether they sum to one....
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 void extendStateInformation(storm::json< BaseValueType > &stateInfo) 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.
void remapStateIds(std::function< StateType(StateType const &)> const &remapping)
Performs a remapping of all values stored by applying the given remapping.
storm::IntervalBaseType< ValueType > BaseValueType
VariableInformation const & getVariableInformation() const
virtual bool isPartiallyObservable() const =0
virtual bool isDeterministicModel() const =0
virtual std::size_t getNumberOfRewardModels() const =0
virtual void unpackTransientVariableValuesIntoEvaluator(CompressedState const &state, storm::expressions::ExpressionEvaluator< BaseValueType > &evaluator) const
Sets the values of all transient variables in the current state to the given evaluator.
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:16
storm::builder::BuilderOptions NextStateGeneratorOptions
typename detail::IntervalMetaProgrammingHelper< ValueType >::BaseType IntervalBaseType
Helper to access the type in which interval boundaries are stored.
nlohmann::basic_json< std::map, std::vector, std::string, bool, int64_t, uint64_t, ValueType > json
Definition JsonForward.h:10