Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Choice.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <functional>
5#include <set>
6
7#include <boost/any.hpp>
8#include <boost/optional.hpp>
9
12
13namespace storm {
14namespace generator {
15
16// A structure holding information about a particular choice.
17template<typename ValueType, typename StateType = uint32_t>
18struct Choice {
19 public:
20 Choice(uint_fast64_t actionIndex = 0, bool markovian = false);
21
22 Choice(Choice const& other) = default;
23 Choice& operator=(Choice const& other) = default;
24 Choice(Choice&& other) = default;
25 Choice& operator=(Choice&& other) = default;
26
30 void add(Choice const& other);
31
36 void reset(uint_fast64_t actionIndex = 0, bool markovian = false);
37
47 StateType sampleFromDistribution(ValueType const& quantile) const;
48
55
62
69
76
82 template<typename ValueTypePrime, typename StateTypePrime>
83 friend std::ostream& operator<<(std::ostream& out, Choice<ValueTypePrime, StateTypePrime> const& choice);
84
90 void addLabel(std::string const& label);
91
97 void addLabels(std::set<std::string> const& labels);
98
102 bool hasLabels() const;
103
109 std::set<std::string> const& getLabels() const;
110
116 void setPlayerIndex(storm::storage::PlayerIndex const& playerIndex);
117
121 bool hasPlayerIndex() const;
122
129
133 void addOriginData(boost::any const& data);
134
138 bool hasOriginData() const;
139
143 boost::any const& getOriginData() const;
144
150 uint_fast64_t getActionIndex() const;
151
157 ValueType getTotalMass() const;
158
162 void addProbability(StateType const& state, ValueType const& value);
163
167 void addReward(ValueType const& value);
168
172 void addRewards(std::vector<ValueType>&& values);
173
177 std::vector<ValueType> const& getRewards() const;
178
182 std::vector<ValueType>& getRewards();
183
187 bool isMarkovian() const;
188
192 std::size_t size() const;
193
197 void reserve(std::size_t const& size);
198
199 private:
200 // A flag indicating whether this choice is Markovian or not.
201 bool markovian;
202
203 // The action index associated with this choice.
204 uint_fast64_t actionIndex;
205
206 // The distribution that is associated with the choice.
208
209 // The total probability mass (or rates) of this choice.
210 ValueType totalMass;
211
212 // The reward values associated with this choice.
213 std::vector<ValueType> rewards;
214
215 // The data that stores what part of the model specification induced this choice
216 boost::optional<boost::any> originData;
217
218 // The labels of this choice
219 boost::optional<std::set<std::string>> labels;
220
221 // The playerIndex of this choice
222 boost::optional<storm::storage::PlayerIndex> playerIndex;
223};
224
225template<typename ValueType, typename StateType>
226std::ostream& operator<<(std::ostream& out, Choice<ValueType, StateType> const& choice);
227
228} // namespace generator
229} // namespace storm
container_type::const_iterator const_iterator
container_type::iterator iterator
std::ostream & operator<<(std::ostream &out, Choice< ValueType, StateType > const &choice)
Definition Choice.cpp:212
uint64_t PlayerIndex
Definition PlayerIndex.h:7
bool hasLabels() const
Returns whether there are labels defined for this choice.
Definition Choice.cpp:104
Choice(Choice const &other)=default
bool isMarkovian() const
Retrieves whether the choice is Markovian.
Definition Choice.cpp:197
boost::any const & getOriginData() const
Returns the origin data associated with this choice.
Definition Choice.cpp:156
void addLabel(std::string const &label)
Adds the given label to the labels associated with this choice.
Definition Choice.cpp:87
uint_fast64_t getActionIndex() const
Retrieves the index of the action of this choice.
Definition Choice.cpp:161
storm::storage::Distribution< ValueType, StateType >::iterator end()
Returns an iterator past the end of the distribution associated with this choice.
Definition Choice.cpp:77
std::vector< ValueType > const & getRewards() const
Retrieves the rewards for this choice under selected reward models.
Definition Choice.cpp:187
std::set< std::string > const & getLabels() const
Retrieves the set of labels associated with this choice.
Definition Choice.cpp:109
void add(Choice const &other)
Adds the given choice to the current one.
Definition Choice.cpp:34
ValueType getTotalMass() const
Retrieves the total mass of this choice.
Definition Choice.cpp:166
void addOriginData(boost::any const &data)
Adds the given data that specifies the origin of this choice w.r.t.
Definition Choice.cpp:129
void setPlayerIndex(storm::storage::PlayerIndex const &playerIndex)
Sets the players index.
Definition Choice.cpp:114
friend std::ostream & operator<<(std::ostream &out, Choice< ValueTypePrime, StateTypePrime > const &choice)
Inserts the contents of this object to the given output stream.
storm::storage::PlayerIndex const & getPlayerIndex() const
Retrieves the players index associated with this choice.
Definition Choice.cpp:124
Choice(uint_fast64_t actionIndex=0, bool markovian=false)
Definition Choice.cpp:16
void addLabels(std::set< std::string > const &labels)
Adds the given label set to the labels associated with this choice.
Definition Choice.cpp:95
bool hasOriginData() const
Returns whether there is origin data defined for this choice.
Definition Choice.cpp:151
void addRewards(std::vector< ValueType > &&values)
Adds the given choices rewards to this choice.
Definition Choice.cpp:182
Choice(Choice &&other)=default
StateType sampleFromDistribution(ValueType const &quantile) const
Given a value q, find the event in the ordered distribution that corresponds to this prob.
Definition Choice.cpp:62
storm::storage::Distribution< ValueType, StateType >::iterator begin()
Returns an iterator to the distribution associated with this choice.
Definition Choice.cpp:67
void reset(uint_fast64_t actionIndex=0, bool markovian=false)
Resets this choice to an empty choice with the given action index (i.e., as if it was newly construct...
Definition Choice.cpp:22
Choice & operator=(Choice const &other)=default
void reserve(std::size_t const &size)
If the size is already known, reserves space in the underlying distribution.
Definition Choice.cpp:207
bool hasPlayerIndex() const
Returns whether there is an index for the player defined for this choice.
Definition Choice.cpp:119
std::size_t size() const
Retrieves the size of the distribution associated with this choice.
Definition Choice.cpp:202
void addProbability(StateType const &state, ValueType const &value)
Adds the given probability value to the given state in the underlying distribution.
Definition Choice.cpp:171
void addReward(ValueType const &value)
Adds the given value to the reward associated with this choice.
Definition Choice.cpp:177
Choice & operator=(Choice &&other)=default