Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MaximalEndComponent.cpp
Go to the documentation of this file.
5
6namespace storm {
7namespace storage {
8
9std::ostream& operator<<(std::ostream& out, storm::storage::FlatSet<uint_fast64_t> const& block);
10
11MaximalEndComponent::MaximalEndComponent() : stateToChoicesMapping() {
12 // Intentionally left empty.
13}
14
15MaximalEndComponent::MaximalEndComponent(MaximalEndComponent const& other) : stateToChoicesMapping(other.stateToChoicesMapping) {
16 // Intentionally left empty.
17}
18
20 stateToChoicesMapping = other.stateToChoicesMapping;
21 return *this;
22}
23
24MaximalEndComponent::MaximalEndComponent(MaximalEndComponent&& other) : stateToChoicesMapping(std::move(other.stateToChoicesMapping)) {
25 // Intentionally left empty.
26}
27
29 stateToChoicesMapping = std::move(other.stateToChoicesMapping);
30 return *this;
31}
32
34 return stateToChoicesMapping == other.stateToChoicesMapping;
35}
36
38 return stateToChoicesMapping != other.stateToChoicesMapping;
39}
40
41void MaximalEndComponent::addState(uint_fast64_t state, set_type const& choices) {
42 stateToChoicesMapping[state] = choices;
43}
44
45void MaximalEndComponent::addState(uint_fast64_t state, set_type&& choices) {
46 stateToChoicesMapping.emplace(state, std::move(choices));
47}
48
49std::size_t MaximalEndComponent::size() const {
50 return stateToChoicesMapping.size();
51}
52
54 auto stateChoicePair = stateToChoicesMapping.find(state);
55
56 STORM_LOG_THROW(stateChoicePair != stateToChoicesMapping.end(), storm::exceptions::InvalidStateException,
57 "Invalid call to MaximalEndComponent::getChoicesForState: cannot retrieve choices for state not contained in MEC.");
58
59 return stateChoicePair->second;
60}
61
63 auto stateChoicePair = stateToChoicesMapping.find(state);
64
65 STORM_LOG_THROW(stateChoicePair != stateToChoicesMapping.end(), storm::exceptions::InvalidStateException,
66 "Invalid call to MaximalEndComponent::getChoicesForState: cannot retrieve choices for state not contained in MEC.");
67
68 return stateChoicePair->second;
69}
70
71bool MaximalEndComponent::containsState(uint_fast64_t state) const {
72 auto stateChoicePair = stateToChoicesMapping.find(state);
73
74 if (stateChoicePair == stateToChoicesMapping.end()) {
75 return false;
76 }
77 return true;
78}
79
81 // TODO: iteration over unordered_map is potentially inefficient?
82 for (auto const& stateChoicesPair : stateToChoicesMapping) {
83 if (stateSet.get(stateChoicesPair.first)) {
84 return true;
85 }
86 }
87 return false;
88}
89
90void MaximalEndComponent::removeState(uint_fast64_t state) {
91 auto stateChoicePair = stateToChoicesMapping.find(state);
92
93 STORM_LOG_THROW(stateChoicePair != stateToChoicesMapping.end(), storm::exceptions::InvalidStateException,
94 "Invalid call to MaximalEndComponent::removeState: cannot remove state not contained in MEC.");
95
96 stateToChoicesMapping.erase(stateChoicePair);
97}
98
99bool MaximalEndComponent::containsChoice(uint_fast64_t state, uint_fast64_t choice) const {
100 auto stateChoicePair = stateToChoicesMapping.find(state);
101
102 STORM_LOG_THROW(stateChoicePair != stateToChoicesMapping.end(), storm::exceptions::InvalidStateException,
103 "Invalid call to MaximalEndComponent::containsChoice: cannot obtain choices for state not contained in MEC.");
104
105 return stateChoicePair->second.find(choice) != stateChoicePair->second.end();
106}
107
109 set_type states;
110 states.reserve(stateToChoicesMapping.size());
111
112 for (auto const& stateChoicesPair : stateToChoicesMapping) {
113 states.insert(stateChoicesPair.first);
114 }
115
116 return states;
117}
118
119std::ostream& operator<<(std::ostream& out, MaximalEndComponent const& component) {
120 out << "{";
121 for (auto const& stateChoicesPair : component.stateToChoicesMapping) {
122 out << "{" << stateChoicesPair.first << ", " << stateChoicesPair.second << "}";
123 }
124 out << "}";
125
126 return out;
127}
128
130 return stateToChoicesMapping.begin();
131}
132
134 return stateToChoicesMapping.end();
135}
136
138 return stateToChoicesMapping.begin();
139}
140
142 return stateToChoicesMapping.end();
143}
144} // namespace storage
145} // namespace storm
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
bool get(uint64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
iterator end()
Retrieves an iterator that points past the last state and its choices in the MEC.
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.
bool operator!=(MaximalEndComponent const &other) const
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 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.
bool operator==(MaximalEndComponent const &other) const
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
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)