Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
StateBehavior.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <span>
5
7
8namespace storm {
9namespace generator {
10
11template<typename ValueType, typename StateType = uint32_t>
13 public:
18
19 StateBehavior(StateBehavior const& other);
23 StateBehavior(StateBehavior&& other) noexcept;
25 StateBehavior& operator=(StateBehavior&& other) noexcept;
26
31 void clear();
32
36 void clearChoices();
37
42
48 Choice<ValueType, StateType>& startNewChoice(uint_fast64_t actionIndex = 0, bool markovian = false);
49
53 void removeLastChoices(std::size_t numberOfChoices);
54
58 void addStateReward(ValueType const& stateReward);
59
63 void addStateRewards(std::vector<ValueType>&& stateRewards);
64
68 void setExpanded(bool newValue = true);
69
73 bool wasExpanded() const;
74
78 bool empty() const;
79
83 typename std::vector<Choice<ValueType, StateType>>::const_iterator begin() const;
84
88 typename std::vector<Choice<ValueType, StateType>>::const_iterator end() const;
89
93 std::span<Choice<ValueType, StateType> const> getChoices() const;
94
98 std::span<Choice<ValueType, StateType>> getChoices();
99
103 std::vector<ValueType> const& getStateRewards() const;
104
108 std::vector<ValueType>& getStateRewards();
109
113 std::size_t getNumberOfChoices() const;
114
115 private:
116 // The storage for the choices. Only the first numberOfChoices entries are considered to be part of this behavior; the remaining entries are kept for reuse.
117 std::vector<Choice<ValueType, StateType>> choices;
118
119 // The number of choices available in the state.
120 std::size_t numberOfChoices;
121
122 // The state rewards (under the different, selected reward models) of the state.
123 std::vector<ValueType> stateRewards;
124
125 // A flag indicating whether the state was actually expanded.
126 bool expanded;
127};
128
129} // namespace generator
130} // namespace storm
void addChoice(Choice< ValueType, StateType > &&choice)
Adds the given choice to the behavior of the state.
void addStateReward(ValueType const &stateReward)
Adds the given state reward to the behavior of the state.
void removeLastChoices(std::size_t numberOfChoices)
Removes the last given number of choices.
bool empty() const
Retrieves whether the behavior is empty in the sense that there are no available choices.
StateBehavior & operator=(StateBehavior const &other)
std::vector< Choice< ValueType, StateType > >::const_iterator end() const
Retrieves an iterator past the choices available in the behavior.
StateBehavior()
Creates an empty behavior, i.e.
std::span< Choice< ValueType, StateType > const > getChoices() const
Retrieves the choices.
std::vector< Choice< ValueType, StateType > >::const_iterator begin() const
Retrieves an iterator to the choices available in the behavior.
bool wasExpanded() const
Retrieves whether the state was expanded.
void clearChoices()
Removes all choices (but keeps the state rewards and the allocated memory of the choices for reuse).
void addStateRewards(std::vector< ValueType > &&stateRewards)
Adds the given state rewards to the behavior of the state.
std::vector< ValueType > const & getStateRewards() const
Retrieves the list of state rewards under selected reward models.
void clear()
Resets this to an empty behavior, i.e.
std::size_t getNumberOfChoices() const
Retrieves the number of choices in the behavior.
void setExpanded(bool newValue=true)
Sets whether the state was expanded.
Choice< ValueType, StateType > & startNewChoice(uint_fast64_t actionIndex=0, bool markovian=false)
Adds a new empty choice with the given action index and returns a reference to it.