Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MaximalEndComponent.cpp
Go to the documentation of this file.
4
5namespace storm {
6namespace storage {
7
8std::ostream& operator<<(std::ostream& out, storm::storage::FlatSet<uint_fast64_t> const& block);
9
10MaximalEndComponent::MaximalEndComponent() : stateToChoicesMapping() {
11 // Intentionally left empty.
12}
13
14MaximalEndComponent::MaximalEndComponent(MaximalEndComponent const& other) : stateToChoicesMapping(other.stateToChoicesMapping) {
15 // Intentionally left empty.
16}
17
19 stateToChoicesMapping = other.stateToChoicesMapping;
20 return *this;
21}
22
23MaximalEndComponent::MaximalEndComponent(MaximalEndComponent&& other) : stateToChoicesMapping(std::move(other.stateToChoicesMapping)) {
24 // Intentionally left empty.
25}
26
28 stateToChoicesMapping = std::move(other.stateToChoicesMapping);
29 return *this;
30}
31
33 return stateToChoicesMapping == other.stateToChoicesMapping;
34}
35
37 return stateToChoicesMapping != other.stateToChoicesMapping;
38}
39
40void MaximalEndComponent::addState(uint_fast64_t state, set_type const& choices) {
41 stateToChoicesMapping[state] = choices;
42}
43
44void MaximalEndComponent::addState(uint_fast64_t state, set_type&& choices) {
45 stateToChoicesMapping.emplace(state, std::move(choices));
46}
47
48std::size_t MaximalEndComponent::size() const {
49 return stateToChoicesMapping.size();
50}
51
53 auto stateChoicePair = stateToChoicesMapping.find(state);
54
55 if (stateChoicePair == stateToChoicesMapping.end()) {
56 throw storm::exceptions::InvalidStateException()
57 << "Invalid call to MaximalEndComponent::getChoicesForState: cannot retrieve choices for state not contained in MEC.";
58 }
59
60 return stateChoicePair->second;
61}
62
64 auto stateChoicePair = stateToChoicesMapping.find(state);
65
66 if (stateChoicePair == stateToChoicesMapping.end()) {
67 throw storm::exceptions::InvalidStateException()
68 << "Invalid call to MaximalEndComponent::getChoicesForState: cannot retrieve choices for state not contained in MEC.";
69 }
70
71 return stateChoicePair->second;
72}
73
74bool MaximalEndComponent::containsState(uint_fast64_t state) const {
75 auto stateChoicePair = stateToChoicesMapping.find(state);
76
77 if (stateChoicePair == stateToChoicesMapping.end()) {
78 return false;
79 }
80 return true;
81}
82
84 // TODO: iteration over unordered_map is potentially inefficient?
85 for (auto const& stateChoicesPair : stateToChoicesMapping) {
86 if (stateSet.get(stateChoicesPair.first)) {
87 return true;
88 }
89 }
90 return false;
91}
92
93void MaximalEndComponent::removeState(uint_fast64_t state) {
94 auto stateChoicePair = stateToChoicesMapping.find(state);
95
96 if (stateChoicePair == stateToChoicesMapping.end()) {
97 throw storm::exceptions::InvalidStateException() << "Invalid call to MaximalEndComponent::removeState: cannot remove state not contained in MEC.";
98 }
99
100 stateToChoicesMapping.erase(stateChoicePair);
101}
102
103bool MaximalEndComponent::containsChoice(uint_fast64_t state, uint_fast64_t choice) const {
104 auto stateChoicePair = stateToChoicesMapping.find(state);
105
106 if (stateChoicePair == stateToChoicesMapping.end()) {
107 throw storm::exceptions::InvalidStateException()
108 << "Invalid call to MaximalEndComponent::containsChoice: cannot obtain choices for state not contained in MEC.";
109 }
110
111 return stateChoicePair->second.find(choice) != stateChoicePair->second.end();
112}
113
115 set_type states;
116 states.reserve(stateToChoicesMapping.size());
117
118 for (auto const& stateChoicesPair : stateToChoicesMapping) {
119 states.insert(stateChoicesPair.first);
120 }
121
122 return states;
123}
124
125std::ostream& operator<<(std::ostream& out, MaximalEndComponent const& component) {
126 out << "{";
127 for (auto const& stateChoicesPair : component.stateToChoicesMapping) {
128 out << "{" << stateChoicesPair.first << ", " << stateChoicesPair.second << "}";
129 }
130 out << "}";
131
132 return out;
133}
134
136 return stateToChoicesMapping.begin();
137}
138
140 return stateToChoicesMapping.end();
141}
142
144 return stateToChoicesMapping.begin();
145}
146
148 return stateToChoicesMapping.end();
149}
150} // namespace storage
151} // namespace storm
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
bool get(uint_fast64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
This class represents a maximal end-component of a nondeterministic model.
iterator end()
Retrieves an iterator that points past the last state and its choices in the MEC.
bool operator!=(MaximalEndComponent const &other)
set_type const & getChoicesForState(uint_fast64_t state) const
Retrieves the choices for the given state that are contained in this MEC under the assumption that th...
set_type getStateSet() const
Retrieves the set of states contained in the MEC.
map_type::const_iterator const_iterator
storm::storage::FlatSet< sparse::state_type > set_type
void addState(uint_fast64_t state, set_type const &choices)
Adds the given state and the given choices to the MEC.
bool operator==(MaximalEndComponent const &other)
bool containsAnyState(storm::storage::BitVector stateSet) const
Retrieves whether at least one of the given states is contained in this MEC.
bool containsState(uint_fast64_t state) const
Retrieves whether the given state is contained in this MEC.
void removeState(uint_fast64_t state)
Removes the given state and all of its choices from the MEC.
iterator begin()
Retrieves an iterator that points to the first state and its choices in the MEC.
MaximalEndComponent & operator=(MaximalEndComponent const &other)
Assigns the contents of the given MEC to the current one via copying.
bool containsChoice(uint_fast64_t state, uint_fast64_t choice) const
Retrieves whether the given choice for the given state is contained in the MEC.
boost::container::flat_set< Key, std::less< Key >, boost::container::new_allocator< Key > > FlatSet
Redefinition of flat_set was needed, because from Boost 1.70 on the default allocator is set to void.
Definition BoostTypes.h:13
std::ostream & operator<<(std::ostream &out, ParameterRegion< ParametricType > const &region)
LabParser.cpp.
Definition cli.cpp:18