Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
StateAndChoiceInformationBuilder.cpp
Go to the documentation of this file.
2
4
5namespace storm {
6namespace builder {
7
9 : _buildChoiceLabels(false), _buildChoiceOrigins(false), _buildStatePlayerIndications(false), _buildMarkovianStates(false), _buildStateValuations(false) {
10 // Intentionally left empty
11}
12
14 _buildChoiceLabels = value;
15}
16
18 return _buildChoiceLabels;
19}
20
21void StateAndChoiceInformationBuilder::addChoiceLabel(std::string const& label, uint_fast64_t choiceIndex) {
22 STORM_LOG_ASSERT(_buildChoiceLabels, "Building ChoiceLabels was not enabled.");
23 storm::storage::BitVector& labeledChoices = _choiceLabels[label];
24 labeledChoices.grow(choiceIndex + 1, false);
25 labeledChoices.set(choiceIndex, true);
26}
27
29 storm::models::sparse::ChoiceLabeling result(totalNumberOfChoices);
30 for (auto& label : _choiceLabels) {
31 label.second.resize(totalNumberOfChoices, false);
32 result.addLabel(label.first, std::move(label.second));
33 }
34 return result;
35}
36
38 _buildChoiceOrigins = value;
39}
40
42 return _buildChoiceOrigins;
43}
44
45void StateAndChoiceInformationBuilder::addChoiceOriginData(boost::any const& originData, uint_fast64_t choiceIndex) {
46 STORM_LOG_ASSERT(_buildChoiceOrigins, "Building ChoiceOrigins was not enabled.");
47 STORM_LOG_ASSERT(_dataOfChoiceOrigins.size() <= choiceIndex, "Unexpected choice index. Apparently, the choice indices are provided in an incorrect order.");
48 if (_dataOfChoiceOrigins.size() != choiceIndex) {
49 _dataOfChoiceOrigins.resize(choiceIndex);
50 }
51 _dataOfChoiceOrigins.push_back(originData);
52}
53
54std::vector<boost::any> StateAndChoiceInformationBuilder::buildDataOfChoiceOrigins(uint_fast64_t totalNumberOfChoices) {
55 STORM_LOG_ASSERT(_buildChoiceOrigins, "Building ChoiceOrigins was not enabled.");
56 _dataOfChoiceOrigins.resize(totalNumberOfChoices);
57 _dataOfChoiceOrigins.shrink_to_fit();
58 return std::move(_dataOfChoiceOrigins);
59}
60
62 _buildStatePlayerIndications = value;
63}
64
66 return _buildStatePlayerIndications;
67}
68
70 STORM_LOG_ASSERT(_buildStatePlayerIndications, "Building StatePlayerIndications was not enabled.");
71 STORM_LOG_ASSERT(_statePlayerIndications.size() <= stateIndex,
72 "Unexpected choice index. Apparently, the choice indices are provided in an incorrect order.");
73 if (_statePlayerIndications.size() != stateIndex) {
74 _statePlayerIndications.resize(stateIndex, storm::storage::INVALID_PLAYER_INDEX);
75 }
76 _statePlayerIndications.push_back(player);
77}
78
80 STORM_LOG_ASSERT(_buildStatePlayerIndications, "Building StatePlayerIndications was not enabled.");
81 return (stateIndex < _statePlayerIndications.size()) && (_statePlayerIndications[stateIndex] == expectedPlayer);
82}
83
84std::vector<storm::storage::PlayerIndex> StateAndChoiceInformationBuilder::buildStatePlayerIndications(uint_fast64_t totalNumberOfStates) {
85 STORM_LOG_ASSERT(_buildStatePlayerIndications, "Building StatePlayerIndications was not enabled.");
86 _statePlayerIndications.resize(totalNumberOfStates, storm::storage::INVALID_PLAYER_INDEX);
87 _statePlayerIndications.shrink_to_fit();
88 return std::move(_statePlayerIndications);
89}
90
92 _buildMarkovianStates = value;
93}
94
96 return _buildMarkovianStates;
97}
98
99void StateAndChoiceInformationBuilder::addMarkovianState(uint_fast64_t markovianStateIndex) {
100 STORM_LOG_ASSERT(_buildMarkovianStates, "Building MarkovianStates was not enabled.");
101 _markovianStates.grow(markovianStateIndex + 1, false);
102 _markovianStates.set(markovianStateIndex, true);
103}
104
106 STORM_LOG_ASSERT(_buildMarkovianStates, "Building MarkovianStates was not enabled.");
107 _markovianStates.resize(totalNumberOfStates, false);
108 return _markovianStates;
109}
110
112 _buildStateValuations = value;
113}
114
116 return _buildStateValuations;
117}
118
120 STORM_LOG_ASSERT(_buildStateValuations, "Building StateValuations was not enabled.");
121 return _stateValuationsBuilder;
122}
123
124} // namespace builder
125} // namespace storm
std::vector< boost::any > buildDataOfChoiceOrigins(uint_fast64_t totalNumberOfChoices)
storm::storage::sparse::StateValuationsBuilder & stateValuationsBuilder()
storm::storage::BitVector buildMarkovianStates(uint_fast64_t totalNumberOfStates)
bool hasStatePlayerIndicationBeenSet(storm::storage::PlayerIndex expectedPlayer, uint_fast64_t stateIndex) const
void addStatePlayerIndication(storm::storage::PlayerIndex player, uint_fast64_t stateIndex)
storm::models::sparse::ChoiceLabeling buildChoiceLabeling(uint_fast64_t totalNumberOfChoices)
void addChoiceLabel(std::string const &label, uint_fast64_t choiceIndex)
std::vector< storm::storage::PlayerIndex > buildStatePlayerIndications(uint_fast64_t totalNumberOfStates)
void addChoiceOriginData(boost::any const &originData, uint_fast64_t choiceIndex)
This class manages the labeling of the choice space with a number of (atomic) labels.
void addLabel(std::string const &label)
Adds a new label to the labelings.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
void resize(uint_fast64_t newLength, bool init=false)
Resizes the bit vector to hold the given new number of bits.
void set(uint_fast64_t index, bool value=true)
Sets the given truth value at the given index.
void grow(uint_fast64_t minimumLength, bool init=false)
Enlarges the bit vector such that it holds at least the given number of bits (but possibly more).
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
PlayerIndex const INVALID_PLAYER_INDEX
Definition PlayerIndex.h:8
uint64_t PlayerIndex
Definition PlayerIndex.h:7
LabParser.cpp.
Definition cli.cpp:18