Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SylvanAddIterator.h
Go to the documentation of this file.
1#pragma once
2
3#include <unordered_map>
4
5#include "storm-config.h"
9
10namespace storm {
11namespace dd {
12// Forward-declare the DdManager class.
13template<DdType Type>
14class DdManager;
15
16template<DdType Type, typename ValueType>
17class InternalAdd;
18
19template<typename ValueType>
20class AddIterator<DdType::Sylvan, ValueType> {
21 public:
22 friend class InternalAdd<DdType::Sylvan, ValueType>;
23
24 // Default-instantiate the constructor.
26
27 // Forbid copy-construction and copy assignment, because ownership of the internal pointer is unclear then.
28 AddIterator(AddIterator<DdType::Sylvan, ValueType> const& other) = delete;
29 AddIterator& operator=(AddIterator<DdType::Sylvan, ValueType> const& other) = delete;
30
31 // Provide move-construction and move-assignment, though.
32 AddIterator(AddIterator<DdType::Sylvan, ValueType>&& other) = default;
33 AddIterator& operator=(AddIterator<DdType::Sylvan, ValueType>&& other) = default;
34
38 AddIterator<DdType::Sylvan, ValueType>& operator++();
39
46 std::pair<storm::expressions::SimpleValuation, ValueType> operator*() const;
47
55 bool operator==(AddIterator<DdType::Sylvan, ValueType> const& other) const;
56
64 bool operator!=(AddIterator<DdType::Sylvan, ValueType> const& other) const;
65
66 private:
67#ifdef STORM_HAVE_SYLVAN
81 AddIterator(DdManager<DdType::Sylvan> const& ddManager, sylvan::Mtbdd mtbdd, sylvan::Bdd variables, uint_fast64_t numberOfDdVariables, bool isAtEnd,
82 std::set<storm::expressions::Variable> const* metaVariables, bool enumerateDontCareMetaVariables);
83
95 static AddIterator createBeginIterator(DdManager<DdType::Sylvan> const& ddManager, sylvan::Mtbdd mtbdd, sylvan::Bdd variables,
96 uint_fast64_t numberOfDdVariables, std::set<storm::expressions::Variable> const* metaVariables,
97 bool enumerateDontCareMetaVariables = true);
98
104 static AddIterator createEndIterator(DdManager<DdType::Sylvan> const& ddManager);
105
109 void treatNewCube();
110
114 void treatNextInCube();
115
119 void createGlobalToLocalIndexMapping();
120
121 // The manager responsible for the meta variables (and therefore the underlying DD).
122 DdManager<DdType::Sylvan> const* ddManager;
123
124 // The MTBDD over which to iterate.
125 sylvan::Mtbdd mtbdd;
126
127 // The cube of variables in the MTBDD.
128 sylvan::Bdd variables;
129
130 // The currently considered cube of the DD.
131 std::vector<uint8_t> cube;
132
133 // The function value of the current cube, represented by the corresponding leaf.
134 MTBDD leaf;
135
136 // A flag that indicates whether the iterator is at its end and may not be moved further. This is also used
137 // for the check against the end iterator.
138 bool isAtEnd;
139
140 // The set of meta variables appearing in the DD.
141 std::set<storm::expressions::Variable> const* metaVariables;
142
143 // A mapping from global variable indices to local (i.e. appearing the MTBDD) ones.
144 std::unordered_map<uint_fast64_t, uint_fast64_t> globalToLocalIndexMap;
145
146 // A flag that indicates whether the iterator is supposed to enumerate meta variable valuations even if
147 // they don't influence the function value.
148 bool enumerateDontCareMetaVariables;
149
150 // A number that represents how many assignments of the current cube have already been returned previously.
151 // This is needed, because cubes may represent many assignments (if they have don't care variables).
152 uint_fast64_t cubeCounter;
153
154 // A vector of tuples of the form <metaVariable, bitIndex>.
155 std::vector<std::tuple<storm::expressions::Variable, uint_fast64_t>> relevantDontCareDdVariables;
156
157 // The current valuation of meta variables.
159#endif
160};
161} // namespace dd
162} // namespace storm
A simple implementation of the valuation interface.