Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Choice.h
Go to the documentation of this file.
1#ifndef STORM_GENERATOR_CHOICE_H_
2#define STORM_GENERATOR_CHOICE_H_
3
4#include <cstdint>
5#include <functional>
6#include <set>
7
8#include <boost/any.hpp>
9#include <boost/optional.hpp>
10
13
14namespace storm {
15namespace generator {
16
17// A structure holding information about a particular choice.
18template<typename ValueType, typename StateType = uint32_t>
19struct Choice {
20 public:
21 Choice(uint_fast64_t actionIndex = 0, bool markovian = false);
22
23 Choice(Choice const& other) = default;
24 Choice& operator=(Choice const& other) = default;
25 Choice(Choice&& other) = default;
26 Choice& operator=(Choice&& other) = default;
27
31 void add(Choice const& other);
32
42 StateType sampleFromDistribution(ValueType const& quantile) const;
43
50
57
64
71
77 template<typename ValueTypePrime, typename StateTypePrime>
78 friend std::ostream& operator<<(std::ostream& out, Choice<ValueTypePrime, StateTypePrime> const& choice);
79
85 void addLabel(std::string const& label);
86
92 void addLabels(std::set<std::string> const& labels);
93
97 bool hasLabels() const;
98
104 std::set<std::string> const& getLabels() const;
105
111 void setPlayerIndex(storm::storage::PlayerIndex const& playerIndex);
112
116 bool hasPlayerIndex() const;
117
124
128 void addOriginData(boost::any const& data);
129
133 bool hasOriginData() const;
134
138 boost::any const& getOriginData() const;
139
145 uint_fast64_t getActionIndex() const;
146
152 ValueType getTotalMass() const;
153
157 void addProbability(StateType const& state, ValueType const& value);
158
162 void addReward(ValueType const& value);
163
167 void addRewards(std::vector<ValueType>&& values);
168
172 std::vector<ValueType> const& getRewards() const;
173
177 bool isMarkovian() const;
178
182 std::size_t size() const;
183
187 void reserve(std::size_t const& size);
188
189 private:
190 // A flag indicating whether this choice is Markovian or not.
191 bool markovian;
192
193 // The action index associated with this choice.
194 uint_fast64_t actionIndex;
195
196 // The distribution that is associated with the choice.
198
199 // The total probability mass (or rates) of this choice.
200 ValueType totalMass;
201
202 // The reward values associated with this choice.
203 std::vector<ValueType> rewards;
204
205 // The data that stores what part of the model specification induced this choice
206 boost::optional<boost::any> originData;
207
208 // The labels of this choice
209 boost::optional<std::set<std::string>> labels;
210
211 // The playerIndex of this choice
212 boost::optional<storm::storage::PlayerIndex> playerIndex;
213};
214
215template<typename ValueType, typename StateType>
216std::ostream& operator<<(std::ostream& out, Choice<ValueType, StateType> const& choice);
217
218} // namespace generator
219} // namespace storm
220
221#endif /* STORM_GENERATOR_CHOICE_H_ */
container_type::const_iterator const_iterator
container_type::iterator iterator
std::ostream & operator<<(std::ostream &out, Choice< ValueType, StateType > const &choice)
Definition Choice.cpp:194
uint64_t PlayerIndex
Definition PlayerIndex.h:7
LabParser.cpp.
Definition cli.cpp:18
bool hasLabels() const
Returns whether there are labels defined for this choice.
Definition Choice.cpp:91
Choice(Choice const &other)=default
bool isMarkovian() const
Retrieves whether the choice is Markovian.
Definition Choice.cpp:179
boost::any const & getOriginData() const
Returns the origin data associated with this choice.
Definition Choice.cpp:143
void addLabel(std::string const &label)
Adds the given label to the labels associated with this choice.
Definition Choice.cpp:74
uint_fast64_t getActionIndex() const
Retrieves the index of the action of this choice.
Definition Choice.cpp:148
storm::storage::Distribution< ValueType, StateType >::iterator end()
Returns an iterator past the end of the distribution associated with this choice.
Definition Choice.cpp:64
std::vector< ValueType > const & getRewards() const
Retrieves the rewards for this choice under selected reward models.
Definition Choice.cpp:174
std::set< std::string > const & getLabels() const
Retrieves the set of labels associated with this choice.
Definition Choice.cpp:96
void add(Choice const &other)
Adds the given choice to the current one.
Definition Choice.cpp:22
ValueType getTotalMass() const
Retrieves the total mass of this choice.
Definition Choice.cpp:153
void addOriginData(boost::any const &data)
Adds the given data that specifies the origin of this choice w.r.t.
Definition Choice.cpp:116
void setPlayerIndex(storm::storage::PlayerIndex const &playerIndex)
Sets the players index.
Definition Choice.cpp:101
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:111
void addLabels(std::set< std::string > const &labels)
Adds the given label set to the labels associated with this choice.
Definition Choice.cpp:82
bool hasOriginData() const
Returns whether there is origin data defined for this choice.
Definition Choice.cpp:138
void addRewards(std::vector< ValueType > &&values)
Adds the given choices rewards to this choice.
Definition Choice.cpp:169
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:49
storm::storage::Distribution< ValueType, StateType >::iterator begin()
Returns an iterator to the distribution associated with this choice.
Definition Choice.cpp:54
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:189
bool hasPlayerIndex() const
Returns whether there is an index for the player defined for this choice.
Definition Choice.cpp:106
std::size_t size() const
Retrieves the size of the distribution associated with this choice.
Definition Choice.cpp:184
void addProbability(StateType const &state, ValueType const &value)
Adds the given probability value to the given state in the underlying distribution.
Definition Choice.cpp:158
void addReward(ValueType const &value)
Adds the given value to the reward associated with this choice.
Definition Choice.cpp:164
Choice & operator=(Choice &&other)=default