Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
PrismProgramSimulator.h
Go to the documentation of this file.
1#pragma once
2
3#include <span>
4
9
10namespace storm {
11namespace simulator {
12
26template<typename ValueType>
28 public:
39 void setSeed(uint64_t);
45 std::span<generator::Choice<ValueType, uint32_t> const> getChoices() const;
46
47 bool isSinkState() const;
48
56 bool step(uint64_t actionNumber);
61 std::vector<ValueType> const& getLastRewards() const;
64 std::vector<std::string> getCurrentStateLabelling() const;
65
67
69
70 std::string getCurrentStateString() const;
76 bool resetToInitial();
77
78 bool resetToState(generator::CompressedState const& compressedState);
79
80 bool resetToState(expressions::SimpleValuation const& valuationState);
81
85 std::vector<std::string> getRewardNames() const;
86
87 protected:
88 bool explore();
89 void clearStateCaches();
94
100 std::shared_ptr<storm::generator::PrismNextStateGenerator<ValueType, uint32_t>> stateGenerator;
104 std::vector<ValueType> zeroRewards;
106 std::vector<ValueType> lastActionRewards;
111
112 std::unordered_map<uint32_t, generator::CompressedState> idToState;
113
114 private:
115 // Create a callback for the next-state generator to enable it to request the index of states.
116 std::function<uint32_t(generator::CompressedState const&)> stateToIdCallback =
117 std::bind(&DiscreteTimePrismProgramSimulator<ValueType>::getOrAddStateIndex, this, std::placeholders::_1);
118};
119} // namespace simulator
120} // namespace storm
A simple implementation of the valuation interface.
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.
DiscreteTimePrismProgramSimulator(storm::prism::Program const &program, storm::generator::NextStateGeneratorOptions const &options)
Initialize the simulator for a given prism program.
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.
std::span< generator::Choice< ValueType, uint32_t > const > getChoices() const
generator::CompressedState const & getCurrentState() const
bool resetToInitial()
Reset to the (unique) initial state.
This class represents a hash-map whose keys are bit vectors.
storm::storage::BitVector CompressedState
storm::builder::BuilderOptions NextStateGeneratorOptions
nlohmann::basic_json< std::map, std::vector, std::string, bool, int64_t, uint64_t, ValueType > json
Definition JsonForward.h:11