Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
InternalCuddDdManager.cpp
Go to the documentation of this file.
2
5
7
8namespace storm {
9namespace dd {
10
11InternalDdManager<DdType::CUDD>::InternalDdManager() : cuddManager(), reorderingTechnique(CUDD_REORDER_NONE), numberOfDdVariables(0) {
12 this->cuddManager.SetMaxMemory(
13 static_cast<unsigned long>(storm::settings::getModule<storm::settings::modules::CuddSettings>().getMaximalMemory() * 1024ul * 1024ul));
14
16 this->cuddManager.SetEpsilon(settings.getConstantPrecision());
17
18 // Now set the selected reordering technique.
19 storm::settings::modules::CuddSettings::ReorderingTechnique reorderingTechniqueAsSetting = settings.getReorderingTechnique();
20 switch (reorderingTechniqueAsSetting) {
22 this->reorderingTechnique = CUDD_REORDER_NONE;
23 break;
25 this->reorderingTechnique = CUDD_REORDER_RANDOM;
26 break;
28 this->reorderingTechnique = CUDD_REORDER_RANDOM_PIVOT;
29 break;
31 this->reorderingTechnique = CUDD_REORDER_SIFT;
32 break;
34 this->reorderingTechnique = CUDD_REORDER_SIFT_CONVERGE;
35 break;
37 this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT;
38 break;
40 this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT_CONV;
41 break;
43 this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT;
44 break;
46 this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT_CONV;
47 break;
49 this->reorderingTechnique = CUDD_REORDER_WINDOW2;
50 break;
52 this->reorderingTechnique = CUDD_REORDER_WINDOW2_CONV;
53 break;
55 this->reorderingTechnique = CUDD_REORDER_WINDOW3;
56 break;
58 this->reorderingTechnique = CUDD_REORDER_WINDOW3_CONV;
59 break;
61 this->reorderingTechnique = CUDD_REORDER_WINDOW4;
62 break;
64 this->reorderingTechnique = CUDD_REORDER_WINDOW4_CONV;
65 break;
67 this->reorderingTechnique = CUDD_REORDER_ANNEALING;
68 break;
70 this->reorderingTechnique = CUDD_REORDER_GENETIC;
71 break;
73 this->reorderingTechnique = CUDD_REORDER_EXACT;
74 break;
75 }
76
77 this->allowDynamicReordering(settings.isReorderingEnabled());
78}
79
81 // Intentionally left empty.
82}
83
87
88template<typename ValueType>
92
96
98 uint64_t numberOfDdVariables) const {
99 return InternalBdd<DdType::CUDD>(this, cudd::BDD(cuddManager, this->getBddEncodingLessOrEqualThanRec(0, (1ull << numberOfDdVariables) - 1, bound,
100 cube.getCuddDdNode(), numberOfDdVariables)));
101}
102
103DdNodePtr InternalDdManager<DdType::CUDD>::getBddEncodingLessOrEqualThanRec(uint64_t minimalValue, uint64_t maximalValue, uint64_t bound, DdNodePtr cube,
104 uint64_t remainingDdVariables) const {
105 if (maximalValue <= bound) {
106 return Cudd_ReadOne(cuddManager.getManager());
107 } else if (minimalValue > bound) {
108 return Cudd_ReadLogicZero(cuddManager.getManager());
109 }
110
111 STORM_LOG_ASSERT(remainingDdVariables > 0, "Expected more remaining DD variables.");
112 STORM_LOG_ASSERT(!Cudd_IsConstant(cube), "Expected non-constant cube.");
113 uint64_t newRemainingDdVariables = remainingDdVariables - 1;
114 DdNodePtr elseResult =
115 getBddEncodingLessOrEqualThanRec(minimalValue, maximalValue & ~(1ull << newRemainingDdVariables), bound, Cudd_T(cube), newRemainingDdVariables);
116 Cudd_Ref(elseResult);
117 DdNodePtr thenResult =
118 getBddEncodingLessOrEqualThanRec(minimalValue | (1ull << newRemainingDdVariables), maximalValue, bound, Cudd_T(cube), newRemainingDdVariables);
119 Cudd_Ref(thenResult);
120 STORM_LOG_ASSERT(thenResult != elseResult, "Expected different results.");
121
122 bool complemented = Cudd_IsComplement(thenResult);
123 DdNodePtr result =
124 cuddUniqueInter(cuddManager.getManager(), Cudd_NodeReadIndex(cube), Cudd_Regular(thenResult), complemented ? Cudd_Not(elseResult) : elseResult);
125 if (complemented) {
126 result = Cudd_Not(result);
127 }
128 Cudd_Deref(thenResult);
129 Cudd_Deref(elseResult);
130 return result;
131}
132
133template<typename ValueType>
137
138template<typename ValueType>
140 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Undefined values are not supported by CUDD.");
141}
142
143template<typename ValueType>
145 return InternalAdd<DdType::CUDD, ValueType>(this, cuddManager.constant(value));
146}
147
148template<>
150 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Operation not supported.");
151}
152
153std::vector<InternalBdd<DdType::CUDD>> InternalDdManager<DdType::CUDD>::createDdVariables(uint64_t numberOfLayers,
154 boost::optional<uint_fast64_t> const& position) {
155 std::vector<InternalBdd<DdType::CUDD>> result;
156
157 if (position) {
158 for (uint64_t layer = 0; layer < numberOfLayers; ++layer) {
159 result.emplace_back(InternalBdd<DdType::CUDD>(this, cuddManager.bddNewVarAtLevel(position.get() + layer)));
160 }
161 } else {
162 for (uint64_t layer = 0; layer < numberOfLayers; ++layer) {
163 result.emplace_back(InternalBdd<DdType::CUDD>(this, cuddManager.bddVar()));
164 }
165 }
166
167 // Connect the variables so they are not 'torn apart' by dynamic reordering.
168 // Note that MTR_FIXED preserves the order of the layers. While this is not always necessary to preserve,
169 // (for example) the hybrid engine relies on this connection, so we choose MTR_FIXED instead of MTR_DEFAULT.
170 cuddManager.MakeTreeNode(result.front().getIndex(), numberOfLayers, MTR_FIXED);
171
172 // Keep track of the number of variables.
173 numberOfDdVariables += numberOfLayers;
174
175 return result;
176}
177
181
183 if (value) {
184 this->getCuddManager().AutodynEnable(this->reorderingTechnique);
185 } else {
186 this->getCuddManager().AutodynDisable();
187 }
188}
189
191 Cudd_ReorderingType type;
192 return this->getCuddManager().ReorderingStatus(&type);
193}
194
196 this->getCuddManager().ReduceHeap(this->reorderingTechnique, 0);
197}
198
200 this->getCuddManager().CheckKeys();
201 this->getCuddManager().DebugCheck();
202}
203
204void InternalDdManager<DdType::CUDD>::execute(std::function<void()> const& f) const {
205 f();
206}
207
209 return cuddManager;
210}
211
213 return cuddManager;
214}
215
217 return numberOfDdVariables;
218}
219
223
227
230} // namespace dd
231} // namespace storm
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18