Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
PrismProgramSimulator.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace storm {
9namespace simulator {
10
24template<typename ValueType>
26 public:
37 void setSeed(uint64_t);
43 std::vector<generator::Choice<ValueType, uint32_t>> const& getChoices() const;
44
45 bool isSinkState() const;
46
54 bool step(uint64_t actionNumber);
59 std::vector<ValueType> const& getLastRewards() const;
62 std::vector<std::string> getCurrentStateLabelling() const;
63
65
67
68 std::string getCurrentStateString() const;
74 bool resetToInitial();
75
76 bool resetToState(generator::CompressedState const& compressedState);
77
78 bool resetToState(expressions::SimpleValuation const& valuationState);
79
83 std::vector<std::string> getRewardNames() const;
84
85 protected:
86 bool explore();
87 void clearStateCaches();
92
98 std::shared_ptr<storm::generator::PrismNextStateGenerator<ValueType, uint32_t>> stateGenerator;
102 std::vector<ValueType> zeroRewards;
104 std::vector<ValueType> lastActionRewards;
109
110 std::unordered_map<uint32_t, generator::CompressedState> idToState;
111
112 private:
113 // Create a callback for the next-state generator to enable it to request the index of states.
114 std::function<uint32_t(generator::CompressedState const&)> stateToIdCallback =
115 std::bind(&DiscreteTimePrismProgramSimulator<ValueType>::getOrAddStateIndex, this, std::placeholders::_1);
116};
117} // namespace simulator
118} // namespace storm
A simple implementation of the valuation interface.
This class provides a simulator interface on the prism program, and uses the next state generator.
std::unordered_map< uint32_t, generator::CompressedState > idToState
std::vector< ValueType > const & getLastRewards() const
Accessor for the last state action reward and the current state reward, added together.
storm::utility::RandomProbabilityGenerator< ValueType > generator
Random number generator.
std::shared_ptr< storm::generator::PrismNextStateGenerator< ValueType, uint32_t > > stateGenerator
Generator for the next states.
std::vector< generator::Choice< ValueType, uint32_t > > const & getChoices() const
std::vector< ValueType > lastActionRewards
Stores the action rewards from the last action.
generator::StateBehavior< ValueType > behavior
Obtained behavior of a state.
uint32_t getOrAddStateIndex(generator::CompressedState const &)
Helper function for (temp) storing states.
bool step(uint64_t actionNumber)
Make a step and randomly select the successor.
generator::CompressedState currentState
The current state in the program, in its compressed form.
std::vector< std::string > getRewardNames() const
The names of the rewards that are returned.
storm::storage::BitVectorHashMap< uint32_t > stateToId
Data structure to temp store states.
std::vector< std::string > getCurrentStateLabelling() const
bool resetToState(generator::CompressedState const &compressedState)
storm::prism::Program const & program
The program that we are simulating.
expressions::SimpleValuation getCurrentStateAsValuation() const
std::vector< ValueType > zeroRewards
Helper for last action reward construction.
generator::CompressedState const & getCurrentState() const
bool resetToInitial()
Reset to the (unique) initial state.
This class represents a hash-map whose keys are bit vectors.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
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