14template<
typename ValueType,
typename StateType>
19template<
typename ValueType,
typename StateType>
21 : choices(other.choices.
begin(), other.choices.
begin() + other.numberOfChoices),
22 numberOfChoices(other.numberOfChoices),
23 stateRewards(other.stateRewards),
24 expanded(other.expanded) {
28template<
typename ValueType,
typename StateType>
30 : choices(std::move(other.choices)),
31 numberOfChoices(std::exchange(other.numberOfChoices, 0)),
32 stateRewards(std::move(other.stateRewards)),
33 expanded(std::exchange(other.expanded,
false)) {
35 other.choices.clear();
36 other.stateRewards.clear();
39template<
typename ValueType,
typename StateType>
42 choices = std::move(other.choices);
43 numberOfChoices = std::exchange(other.numberOfChoices, 0);
44 stateRewards = std::move(other.stateRewards);
45 expanded = std::exchange(other.expanded,
false);
46 other.choices.clear();
47 other.stateRewards.clear();
52template<
typename ValueType,
typename StateType>
56 if (choices.size() < other.numberOfChoices) {
57 choices.resize(other.numberOfChoices);
59 std::copy(other.choices.begin(), other.choices.begin() + other.numberOfChoices, choices.begin());
60 numberOfChoices = other.numberOfChoices;
61 stateRewards = other.stateRewards;
62 expanded = other.expanded;
67template<
typename ValueType,
typename StateType>
74template<
typename ValueType,
typename StateType>
79template<
typename ValueType,
typename StateType>
81 if (numberOfChoices < choices.size()) {
82 choices[numberOfChoices] = std::move(choice);
84 choices.push_back(std::move(choice));
89template<
typename ValueType,
typename StateType>
91 if (numberOfChoices < choices.size()) {
92 choices[numberOfChoices].reset(actionIndex, markovian);
94 choices.emplace_back(actionIndex, markovian);
96 return choices[numberOfChoices++];
99template<
typename ValueType,
typename StateType>
101 STORM_LOG_ASSERT(numberOfChoicesToRemove <= numberOfChoices,
"Cannot remove more choices than available.");
102 numberOfChoices -= numberOfChoicesToRemove;
105template<
typename ValueType,
typename StateType>
107 stateRewards.push_back(stateReward);
110template<
typename ValueType,
typename StateType>
112 this->stateRewards = std::move(stateRewards);
115template<
typename ValueType,
typename StateType>
117 this->expanded = newValue;
120template<
typename ValueType,
typename StateType>
125template<
typename ValueType,
typename StateType>
127 return numberOfChoices == 0;
130template<
typename ValueType,
typename StateType>
132 return choices.begin();
135template<
typename ValueType,
typename StateType>
137 return choices.begin() + numberOfChoices;
140template<
typename ValueType,
typename StateType>
142 return std::span<Choice<ValueType, StateType>
const>(choices.data(), numberOfChoices);
145template<
typename ValueType,
typename StateType>
147 return std::span<Choice<ValueType, StateType>>(choices.data(), numberOfChoices);
150template<
typename ValueType,
typename StateType>
155template<
typename ValueType,
typename StateType>
160template<
typename ValueType,
typename StateType>
162 return numberOfChoices;
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.
#define STORM_LOG_ASSERT(cond, message)