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
41 StateType sampleFromDistribution(ValueType const& quantile) const;
42
49
56
63
70
76 template<typename ValueTypePrime, typename StateTypePrime>
77 friend std::ostream& operator<<(std::ostream& out, Choice<ValueTypePrime, StateTypePrime> const& choice);
78
84 void addLabel(std::string const& label);
85
91 void addLabels(std::set<std::string> const& labels);
92
96 bool hasLabels() const;
97
103 std::set<std::string> const& getLabels() const;
104
110 void setPlayerIndex(storm::storage::PlayerIndex const& playerIndex);
111
115 bool hasPlayerIndex() const;
116
123
127 void addOriginData(boost::any const& data);
128
132 bool hasOriginData() const;
133
137 boost::any const& getOriginData() const;
138
144 uint_fast64_t getActionIndex() const;
145
151 ValueType getTotalMass() const;
152
156 void addProbability(StateType const& state, ValueType const& value);
157
161 void addReward(ValueType const& value);
162
166 void addRewards(std::vector<ValueType>&& values);
167
171 std::vector<ValueType> const& getRewards() const;
172
176 bool isMarkovian() const;
177
181 std::size_t size() const;
182
186 void reserve(std::size_t const& size);
187
188 private:
189 // A flag indicating whether this choice is Markovian or not.
190 bool markovian;
191
192 // The action index associated with this choice.
193 uint_fast64_t actionIndex;
194
195 // The distribution that is associated with the choice.
197
198 // The total probability mass (or rates) of this choice.
199 ValueType totalMass;
200
201 // The reward values associated with this choice.
202 std::vector<ValueType> rewards;
203
204 // The data that stores what part of the model specification induced this choice
205 boost::optional<boost::any> originData;
206
207 // The labels of this choice
208 boost::optional<std::set<std::string>> labels;
209
210 // The playerIndex of this choice
211 boost::optional<storm::storage::PlayerIndex> playerIndex;
212};
213
214template<typename ValueType, typename StateType>
215std::ostream& operator<<(std::ostream& out, Choice<ValueType, StateType> const& choice);
216
217} // namespace generator
218} // 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:194
uint64_t PlayerIndex
Definition PlayerIndex.h:7
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
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: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