Storm 2.0.0.3
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
InternalCuddAdd.cpp
Go to the documentation of this file.
2
3#include "storm/dd/Odd.h"
13
14namespace storm {
15namespace dd {
16
17#ifdef STORM_HAVE_CUDD
18template<typename ValueType>
20 : ddManager(ddManager), cuddAdd(cuddAdd) {
21 // Intentionally left empty.
22}
23
24template<typename ValueType>
25bool InternalAdd<DdType::CUDD, ValueType>::operator==(InternalAdd<DdType::CUDD, ValueType> const& other) const {
26 return this->getCuddAdd() == other.getCuddAdd();
27}
28
29template<typename ValueType>
30bool InternalAdd<DdType::CUDD, ValueType>::operator!=(InternalAdd<DdType::CUDD, ValueType> const& other) const {
31 return !(*this == other);
32}
33
34template<typename ValueType>
35InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::operator+(InternalAdd<DdType::CUDD, ValueType> const& other) const {
36 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd() + other.getCuddAdd());
37}
38
39template<typename ValueType>
40InternalAdd<DdType::CUDD, ValueType>& InternalAdd<DdType::CUDD, ValueType>::operator+=(InternalAdd<DdType::CUDD, ValueType> const& other) {
41 this->cuddAdd = this->getCuddAdd() + other.getCuddAdd();
42 return *this;
43}
44
45template<typename ValueType>
46InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::operator*(InternalAdd<DdType::CUDD, ValueType> const& other) const {
47 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd() * other.getCuddAdd());
48}
49
50template<typename ValueType>
51InternalAdd<DdType::CUDD, ValueType>& InternalAdd<DdType::CUDD, ValueType>::operator*=(InternalAdd<DdType::CUDD, ValueType> const& other) {
52 this->cuddAdd = this->getCuddAdd() * other.getCuddAdd();
53 return *this;
54}
55
56template<typename ValueType>
57InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::operator-(InternalAdd<DdType::CUDD, ValueType> const& other) const {
58 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd() - other.getCuddAdd());
59}
60
61template<typename ValueType>
62InternalAdd<DdType::CUDD, ValueType>& InternalAdd<DdType::CUDD, ValueType>::operator-=(InternalAdd<DdType::CUDD, ValueType> const& other) {
63 this->cuddAdd = this->getCuddAdd() - other.getCuddAdd();
64 return *this;
65}
66
67template<typename ValueType>
68InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::operator/(InternalAdd<DdType::CUDD, ValueType> const& other) const {
69 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Divide(other.getCuddAdd()));
70}
71
72template<typename ValueType>
73InternalAdd<DdType::CUDD, ValueType>& InternalAdd<DdType::CUDD, ValueType>::operator/=(InternalAdd<DdType::CUDD, ValueType> const& other) {
74 this->cuddAdd = this->getCuddAdd().Divide(other.getCuddAdd());
75 return *this;
76}
77
78template<typename ValueType>
79InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::equals(InternalAdd<DdType::CUDD, ValueType> const& other) const {
80 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().EqualsBdd(other.getCuddAdd()));
81}
82
83template<typename ValueType>
84InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::notEquals(InternalAdd<DdType::CUDD, ValueType> const& other) const {
85 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().NotEqualsBdd(other.getCuddAdd()));
86}
87
88template<typename ValueType>
89InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::less(InternalAdd<DdType::CUDD, ValueType> const& other) const {
90 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().LessThanBdd(other.getCuddAdd()));
91}
92
93template<typename ValueType>
94InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::lessOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const {
95 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().LessThanOrEqualBdd(other.getCuddAdd()));
96}
97
98template<typename ValueType>
99InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::greater(InternalAdd<DdType::CUDD, ValueType> const& other) const {
100 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().GreaterThanBdd(other.getCuddAdd()));
101}
102
103template<typename ValueType>
104InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::greaterOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const {
105 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().GreaterThanOrEqualBdd(other.getCuddAdd()));
106}
107
108template<typename ValueType>
109InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::pow(InternalAdd<DdType::CUDD, ValueType> const& other) const {
110 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Pow(other.getCuddAdd()));
111}
112
113template<typename ValueType>
114InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::mod(InternalAdd<DdType::CUDD, ValueType> const& other) const {
115 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Mod(other.getCuddAdd()));
116}
117
118template<typename ValueType>
119InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::logxy(InternalAdd<DdType::CUDD, ValueType> const& other) const {
120 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().LogXY(other.getCuddAdd()));
121}
122
123template<typename ValueType>
124InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::floor() const {
125 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Floor());
126}
127
128template<typename ValueType>
129InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::ceil() const {
130 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Ceil());
131}
132
133template<typename ValueType>
134InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::minimum(InternalAdd<DdType::CUDD, ValueType> const& other) const {
135 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Minimum(other.getCuddAdd()));
136}
137
138template<typename ValueType>
139InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::maximum(InternalAdd<DdType::CUDD, ValueType> const& other) const {
140 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Maximum(other.getCuddAdd()));
141}
142
143template<typename ValueType>
144template<typename TargetValueType>
145typename std::enable_if<std::is_same<ValueType, TargetValueType>::value, InternalAdd<DdType::CUDD, TargetValueType>>
146
147 ::type InternalAdd<DdType::CUDD, ValueType>::toValueType() const {
148 return *this;
149}
150
151template<typename ValueType>
152template<typename TargetValueType>
153typename std::enable_if<!std::is_same<ValueType, TargetValueType>::value, InternalAdd<DdType::CUDD, TargetValueType>>
154
155 ::type InternalAdd<DdType::CUDD, ValueType>::toValueType() const {
156 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Operation not supported.");
157}
158
159template<typename ValueType>
160InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::sumAbstract(InternalBdd<DdType::CUDD> const& cube) const {
161 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().ExistAbstract(cube.toAdd<ValueType>().getCuddAdd()));
162}
163
164template<typename ValueType>
165InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::minAbstract(InternalBdd<DdType::CUDD> const& cube) const {
166 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().MinAbstract(cube.toAdd<ValueType>().getCuddAdd()));
167}
168
169template<typename ValueType>
170InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::minAbstractRepresentative(InternalBdd<DdType::CUDD> const& cube) const {
171 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().MinAbstractRepresentative(cube.toAdd<ValueType>().getCuddAdd()));
172}
173
174template<typename ValueType>
175InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::maxAbstract(InternalBdd<DdType::CUDD> const& cube) const {
176 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().MaxAbstract(cube.toAdd<ValueType>().getCuddAdd()));
177}
178
179template<typename ValueType>
180InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::maxAbstractRepresentative(InternalBdd<DdType::CUDD> const& cube) const {
181 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().MaxAbstractRepresentative(cube.toAdd<ValueType>().getCuddAdd()));
182}
183
184template<typename ValueType>
185bool InternalAdd<DdType::CUDD, ValueType>::equalModuloPrecision(InternalAdd<DdType::CUDD, ValueType> const& other, ValueType const& precision,
186 bool relative) const {
187 if (relative) {
188 return this->getCuddAdd().EqualSupNormRel(other.getCuddAdd(), precision);
189 } else {
190 return this->getCuddAdd().EqualSupNorm(other.getCuddAdd(), precision);
191 }
192}
193
194template<typename ValueType>
195InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::swapVariables(std::vector<InternalBdd<DdType::CUDD>> const& from,
196 std::vector<InternalBdd<DdType::CUDD>> const& to) const {
197 std::vector<cudd::ADD> fromAdd;
198 std::vector<cudd::ADD> toAdd;
199 STORM_LOG_ASSERT(fromAdd.size() == toAdd.size(), "Sizes of vectors do not match.");
200 for (auto it1 = from.begin(), ite1 = from.end(), it2 = to.begin(); it1 != ite1; ++it1, ++it2) {
201 fromAdd.push_back(it1->getCuddBdd().Add());
202 toAdd.push_back(it2->getCuddBdd().Add());
203 }
204 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().SwapVariables(fromAdd, toAdd));
205}
206
207template<typename ValueType>
208InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::permuteVariables(std::vector<InternalBdd<DdType::CUDD>> const& from,
209 std::vector<InternalBdd<DdType::CUDD>> const& to) const {
210 // Build the full permutation.
211 uint64_t numberOfVariables = ddManager->getCuddManager().ReadSize();
212 int* permutation = new int[numberOfVariables];
213 for (uint64_t variable = 0; variable < numberOfVariables; ++variable) {
214 permutation[variable] = variable;
215 }
216
217 for (auto it1 = from.begin(), ite1 = from.end(), it2 = to.begin(); it1 != ite1; ++it1, ++it2) {
218 permutation[it1->getIndex()] = it2->getIndex();
219 }
220 InternalAdd<DdType::CUDD, ValueType> result(ddManager, this->getCuddAdd().Permute(permutation));
221
222 delete[] permutation;
223 return result;
224}
225
226template<typename ValueType>
227InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::multiplyMatrix(
228 InternalAdd<DdType::CUDD, ValueType> const& otherMatrix, std::vector<InternalBdd<DdType::CUDD>> const& summationDdVariables) const {
229 // Create the CUDD summation variables.
230 std::vector<cudd::ADD> summationAdds;
231 for (auto const& ddVariable : summationDdVariables) {
232 summationAdds.push_back(ddVariable.toAdd<ValueType>().getCuddAdd());
233 }
234
235 // return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().TimesPlus(otherMatrix.getCuddAdd(), summationAdds));
236 // return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Triangle(otherMatrix.getCuddAdd(), summationAdds));
237 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().MatrixMultiply(otherMatrix.getCuddAdd(), summationAdds));
238}
239
240template<typename ValueType>
241InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::multiplyMatrix(
242 InternalBdd<DdType::CUDD> const& otherMatrix, std::vector<InternalBdd<DdType::CUDD>> const& summationDdVariables) const {
243 return this->multiplyMatrix(otherMatrix.template toAdd<ValueType>(), summationDdVariables);
244}
245
246template<typename ValueType>
247InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::greater(ValueType const& value) const {
248 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().BddStrictThreshold(value));
249}
250
251template<typename ValueType>
252InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::greaterOrEqual(ValueType const& value) const {
253 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().BddThreshold(value));
254}
255
256template<typename ValueType>
257InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::less(ValueType const& value) const {
258 return InternalBdd<DdType::CUDD>(ddManager, ~this->getCuddAdd().BddThreshold(value));
259}
260
261template<typename ValueType>
262InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::lessOrEqual(ValueType const& value) const {
263 return InternalBdd<DdType::CUDD>(ddManager, ~this->getCuddAdd().BddStrictThreshold(value));
264}
265
266template<typename ValueType>
267InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::notZero() const {
268 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().BddPattern());
269}
270
271template<typename ValueType>
272InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::constrain(InternalAdd<DdType::CUDD, ValueType> const& constraint) const {
273 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Constrain(constraint.getCuddAdd()));
274}
275
276template<typename ValueType>
277InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::restrict(InternalAdd<DdType::CUDD, ValueType> const& constraint) const {
278 return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Restrict(constraint.getCuddAdd()));
279}
280
281template<typename ValueType>
282InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::getSupport() const {
283 return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().Support());
284}
285
286template<typename ValueType>
287uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getNonZeroCount(uint_fast64_t numberOfDdVariables) const {
288 // If the number of DD variables is zero, CUDD returns a number greater 0 for constant nodes different from
289 // zero, which is not the behaviour we expect.
290 if (numberOfDdVariables == 0) {
291 return 0;
292 }
293 return static_cast<uint_fast64_t>(this->getCuddAdd().CountMinterm(static_cast<int>(numberOfDdVariables)));
294}
295
296template<typename ValueType>
297uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getLeafCount() const {
298 return static_cast<uint_fast64_t>(this->getCuddAdd().CountLeaves());
299}
300
301template<typename ValueType>
302uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getNodeCount() const {
303 return static_cast<uint_fast64_t>(this->getCuddAdd().nodeCount());
304}
305
306template<typename ValueType>
307ValueType InternalAdd<DdType::CUDD, ValueType>::getMin() const {
308 cudd::ADD constantMinAdd = this->getCuddAdd().FindMin();
309 return storm::utility::convertNumber<ValueType>(Cudd_V(constantMinAdd.getNode()));
310}
311
312template<typename ValueType>
313ValueType InternalAdd<DdType::CUDD, ValueType>::getMax() const {
314 cudd::ADD constantMaxAdd = this->getCuddAdd().FindMax();
315 return storm::utility::convertNumber<ValueType>(Cudd_V(constantMaxAdd.getNode()));
316}
317
318template<typename ValueType>
319ValueType InternalAdd<DdType::CUDD, ValueType>::getValue() const {
320 return storm::utility::convertNumber<ValueType>(Cudd_V(this->getCuddAdd().getNode()));
321}
322
323template<typename ValueType>
324bool InternalAdd<DdType::CUDD, ValueType>::isOne() const {
325 return this->getCuddAdd().IsOne();
326}
327
328template<typename ValueType>
329bool InternalAdd<DdType::CUDD, ValueType>::isZero() const {
330 return this->getCuddAdd().IsZero();
331}
332
333template<typename ValueType>
334bool InternalAdd<DdType::CUDD, ValueType>::isConstant() const {
335 return Cudd_IsConstant(this->getCuddAdd().getNode());
336}
337
338template<typename ValueType>
339uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getIndex() const {
340 return static_cast<uint_fast64_t>(this->getCuddAdd().NodeReadIndex());
341}
342
343template<typename ValueType>
344uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getLevel() const {
345 return static_cast<uint_fast64_t>(ddManager->getCuddManager().ReadPerm(this->getIndex()));
346}
347
348template<typename ValueType>
349void InternalAdd<DdType::CUDD, ValueType>::exportToDot(std::string const& filename, std::vector<std::string> const& ddVariableNamesAsStrings,
350 bool showVariablesIfPossible) const {
351 // Build the name input of the DD.
352 std::vector<char*> ddNames;
353 std::string ddName("f");
354 ddNames.push_back(new char[ddName.size() + 1]);
355 std::copy(ddName.c_str(), ddName.c_str() + 2, ddNames.back());
356
357 // Now build the variables names.
358 std::vector<char*> ddVariableNames;
359 for (auto const& element : ddVariableNamesAsStrings) {
360 ddVariableNames.push_back(new char[element.size() + 1]);
361 std::copy(element.c_str(), element.c_str() + element.size() + 1, ddVariableNames.back());
362 }
363
364 // Open the file, dump the DD and close it again.
365 FILE* filePointer = fopen(filename.c_str(), "w");
366 std::vector<cudd::ADD> cuddAddVector = {this->getCuddAdd()};
367 if (showVariablesIfPossible) {
368 ddManager->getCuddManager().DumpDot(cuddAddVector, ddVariableNames.data(), &ddNames[0], filePointer);
369 } else {
370 ddManager->getCuddManager().DumpDot(cuddAddVector, nullptr, &ddNames[0], filePointer);
371 }
372 fclose(filePointer);
373
374 // Finally, delete the names.
375 for (char* element : ddNames) {
376 delete[] element;
377 }
378 for (char* element : ddVariableNames) {
379 delete[] element;
380 }
381}
382
383template<typename ValueType>
384void InternalAdd<DdType::CUDD, ValueType>::exportToText(std::string const&) const {
385 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Operation not supported.");
386}
387
388template<typename ValueType>
389AddIterator<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::begin(DdManager<DdType::CUDD> const& fullDdManager, InternalBdd<DdType::CUDD> const&,
390 uint_fast64_t, std::set<storm::expressions::Variable> const& metaVariables,
391 bool enumerateDontCareMetaVariables) const {
392 int* cube;
393 double value;
394 DdGen* generator = this->getCuddAdd().FirstCube(&cube, &value);
395 return AddIterator<DdType::CUDD, ValueType>(fullDdManager, generator, cube, storm::utility::convertNumber<ValueType>(value),
396 (Cudd_IsGenEmpty(generator) != 0), &metaVariables, enumerateDontCareMetaVariables);
397}
398
399template<typename ValueType>
400AddIterator<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::end(DdManager<DdType::CUDD> const& fullDdManager) const {
401 return AddIterator<DdType::CUDD, ValueType>(fullDdManager, nullptr, nullptr, 0, true, nullptr, false);
402}
403
404template<typename ValueType>
405cudd::ADD InternalAdd<DdType::CUDD, ValueType>::getCuddAdd() const {
406 return this->cuddAdd;
407}
408
409template<typename ValueType>
410DdNode* InternalAdd<DdType::CUDD, ValueType>::getCuddDdNode() const {
411 return this->getCuddAdd().getNode();
412}
413
414template<typename ValueType>
415std::string InternalAdd<DdType::CUDD, ValueType>::getStringId() const {
416 std::stringstream ss;
417 ss << this->getCuddDdNode();
418 return ss.str();
419}
420
421template<typename ValueType>
422Odd InternalAdd<DdType::CUDD, ValueType>::createOdd(std::vector<uint_fast64_t> const& ddVariableIndices) const {
423 // Prepare a unique table for each level that keeps the constructed ODD nodes unique.
424 std::vector<std::unordered_map<DdNode*, std::shared_ptr<Odd>>> uniqueTableForLevels(ddVariableIndices.size() + 1);
425
426 // Now construct the ODD structure from the ADD.
427 std::shared_ptr<Odd> rootOdd =
428 createOddRec(this->getCuddDdNode(), ddManager->getCuddManager(), 0, ddVariableIndices.size(), ddVariableIndices, uniqueTableForLevels);
429
430 // Return a copy of the root node to remove the shared_ptr encapsulation.
431 return Odd(*rootOdd);
432}
433
434template<typename ValueType>
435std::shared_ptr<Odd> InternalAdd<DdType::CUDD, ValueType>::createOddRec(DdNode* dd, cudd::Cudd const& manager, uint_fast64_t currentLevel,
436 uint_fast64_t maxLevel, std::vector<uint_fast64_t> const& ddVariableIndices,
437 std::vector<std::unordered_map<DdNode*, std::shared_ptr<Odd>>>& uniqueTableForLevels) {
438 // Check whether the ODD for this node has already been computed (for this level) and if so, return this instead.
439 auto const& iterator = uniqueTableForLevels[currentLevel].find(dd);
440 if (iterator != uniqueTableForLevels[currentLevel].end()) {
441 return iterator->second;
442 } else {
443 // Otherwise, we need to recursively compute the ODD.
444
445 // If we are already past the maximal level that is to be considered, we can simply create an Odd without
446 // successors
447 if (currentLevel == maxLevel) {
448 uint_fast64_t elseOffset = 0;
449 uint_fast64_t thenOffset = 0;
450
451 // If the DD is not the zero leaf, then the then-offset is 1.
452 if (dd != Cudd_ReadZero(manager.getManager())) {
453 thenOffset = 1;
454 }
455
456 auto oddNode = std::make_shared<Odd>(nullptr, elseOffset, nullptr, thenOffset);
457 uniqueTableForLevels[currentLevel].emplace(dd, oddNode);
458 return oddNode;
459 } else if (ddVariableIndices[currentLevel] < Cudd_NodeReadIndex(dd)) {
460 // If we skipped the level in the DD, we compute the ODD just for the else-successor and use the same
461 // node for the then-successor as well.
462 std::shared_ptr<Odd> elseNode = createOddRec(dd, manager, currentLevel + 1, maxLevel, ddVariableIndices, uniqueTableForLevels);
463 std::shared_ptr<Odd> thenNode = elseNode;
464 auto oddNode = std::make_shared<Odd>(elseNode, elseNode->getElseOffset() + elseNode->getThenOffset(), thenNode,
465 thenNode->getElseOffset() + thenNode->getThenOffset());
466 uniqueTableForLevels[currentLevel].emplace(dd, oddNode);
467 return oddNode;
468 } else {
469 // Otherwise, we compute the ODDs for both the then- and else successors.
470 std::shared_ptr<Odd> elseNode = createOddRec(Cudd_E(dd), manager, currentLevel + 1, maxLevel, ddVariableIndices, uniqueTableForLevels);
471 std::shared_ptr<Odd> thenNode = createOddRec(Cudd_T(dd), manager, currentLevel + 1, maxLevel, ddVariableIndices, uniqueTableForLevels);
472
473 uint_fast64_t totalElseOffset = elseNode->getElseOffset() + elseNode->getThenOffset();
474 uint_fast64_t totalThenOffset = thenNode->getElseOffset() + thenNode->getThenOffset();
475
476 auto oddNode = std::make_shared<Odd>(elseNode, totalElseOffset, thenNode, totalThenOffset);
477 uniqueTableForLevels[currentLevel].emplace(dd, oddNode);
478 return oddNode;
479 }
480 }
481}
482
483template<typename ValueType>
484InternalDdManager<DdType::CUDD> const& InternalAdd<DdType::CUDD, ValueType>::getInternalDdManager() const {
485 return *ddManager;
486}
487
488template<typename ValueType>
489void InternalAdd<DdType::CUDD, ValueType>::composeWithExplicitVector(storm::dd::Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
490 std::vector<ValueType>& targetVector,
491 std::function<ValueType(ValueType const&, ValueType const&)> const& function) const {
492 forEachRec(this->getCuddDdNode(), 0, ddVariableIndices.size(), 0, odd, ddVariableIndices,
493 [&function, &targetVector](uint64_t const& offset, ValueType const& value) { targetVector[offset] = function(targetVector[offset], value); });
494}
495
496template<typename ValueType>
497void InternalAdd<DdType::CUDD, ValueType>::forEach(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
498 std::function<void(uint64_t const&, ValueType const&)> const& function) const {
499 forEachRec(this->getCuddDdNode(), 0, ddVariableIndices.size(), 0, odd, ddVariableIndices, function);
500}
501
502template<typename ValueType>
503void InternalAdd<DdType::CUDD, ValueType>::composeWithExplicitVector(storm::dd::Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
504 std::vector<uint_fast64_t> const& offsets, std::vector<ValueType>& targetVector,
505 std::function<ValueType(ValueType const&, ValueType const&)> const& function) const {
506 forEachRec(this->getCuddDdNode(), 0, ddVariableIndices.size(), 0, odd, ddVariableIndices,
507 [&function, &targetVector, &offsets](uint64_t const& offset, ValueType const& value) {
508 ValueType& targetValue = targetVector[offsets[offset]];
509 targetValue = function(targetValue, value);
510 });
511}
512
513template<typename ValueType>
514void InternalAdd<DdType::CUDD, ValueType>::forEachRec(DdNode const* dd, uint_fast64_t currentLevel, uint_fast64_t maxLevel, uint_fast64_t currentOffset,
515 Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
516 std::function<void(uint64_t const&, ValueType const&)> const& function) const {
517 // For the empty DD, we do not need to add any entries.
518 if (dd == Cudd_ReadZero(ddManager->getCuddManager().getManager())) {
519 return;
520 }
521
522 // If we are at the maximal level, the value to be set is stored as a constant in the DD.
523 if (currentLevel == maxLevel) {
524 function(currentOffset, storm::utility::convertNumber<ValueType>(Cudd_V(dd)));
525 } else if (ddVariableIndices[currentLevel] < Cudd_NodeReadIndex(dd)) {
526 // If we skipped a level, we need to enumerate the explicit entries for the case in which the bit is set
527 // and for the one in which it is not set.
528 forEachRec(dd, currentLevel + 1, maxLevel, currentOffset, odd.getElseSuccessor(), ddVariableIndices, function);
529 forEachRec(dd, currentLevel + 1, maxLevel, currentOffset + odd.getElseOffset(), odd.getThenSuccessor(), ddVariableIndices, function);
530 } else {
531 // Otherwise, we simply recursively call the function for both (different) cases.
532 forEachRec(Cudd_E_const(dd), currentLevel + 1, maxLevel, currentOffset, odd.getElseSuccessor(), ddVariableIndices, function);
533 forEachRec(Cudd_T_const(dd), currentLevel + 1, maxLevel, currentOffset + odd.getElseOffset(), odd.getThenSuccessor(), ddVariableIndices, function);
534 }
535}
536
537template<typename ValueType>
538std::vector<uint64_t> InternalAdd<DdType::CUDD, ValueType>::decodeGroupLabels(std::vector<uint_fast64_t> const& ddGroupVariableIndices,
539 storm::storage::BitVector const& ddLabelVariableIndices) const {
540 std::vector<uint64_t> result;
541 decodeGroupLabelsRec(this->getCuddDdNode(), result, ddGroupVariableIndices, ddLabelVariableIndices, 0, ddGroupVariableIndices.size(), 0);
542 return result;
543}
544
545template<typename ValueType>
546void InternalAdd<DdType::CUDD, ValueType>::decodeGroupLabelsRec(DdNode* dd, std::vector<uint64_t>& labels,
547 std::vector<uint_fast64_t> const& ddGroupVariableIndices,
548 storm::storage::BitVector const& ddLabelVariableIndices, uint_fast64_t currentLevel,
549 uint_fast64_t maxLevel, uint64_t label) const {
550 // For the empty DD, we do not need to create a group.
551 if (dd == Cudd_ReadZero(ddManager->getCuddManager().getManager())) {
552 return;
553 }
554
555 if (currentLevel == maxLevel) {
556 labels.push_back(label);
557 } else {
558 uint64_t elseLabel = label;
559 uint64_t thenLabel = label;
560
561 if (ddLabelVariableIndices.get(currentLevel)) {
562 elseLabel <<= 1;
563 thenLabel = (thenLabel << 1) | 1;
564 }
565
566 if (ddGroupVariableIndices[currentLevel] < Cudd_NodeReadIndex(dd)) {
567 decodeGroupLabelsRec(dd, labels, ddGroupVariableIndices, ddLabelVariableIndices, currentLevel + 1, maxLevel, elseLabel);
568 decodeGroupLabelsRec(dd, labels, ddGroupVariableIndices, ddLabelVariableIndices, currentLevel + 1, maxLevel, thenLabel);
569 } else {
570 decodeGroupLabelsRec(Cudd_E(dd), labels, ddGroupVariableIndices, ddLabelVariableIndices, currentLevel + 1, maxLevel, elseLabel);
571 decodeGroupLabelsRec(Cudd_T(dd), labels, ddGroupVariableIndices, ddLabelVariableIndices, currentLevel + 1, maxLevel, thenLabel);
572 }
573 }
574}
575
576template<typename ValueType>
577std::vector<InternalAdd<DdType::CUDD, ValueType>> InternalAdd<DdType::CUDD, ValueType>::splitIntoGroups(
578 std::vector<uint_fast64_t> const& ddGroupVariableIndices) const {
579 std::vector<InternalAdd<DdType::CUDD, ValueType>> result;
580 splitIntoGroupsRec(this->getCuddDdNode(), result, ddGroupVariableIndices, 0, ddGroupVariableIndices.size());
581 return result;
582}
583
584template<typename ValueType>
585void InternalAdd<DdType::CUDD, ValueType>::splitIntoGroupsRec(DdNode* dd, std::vector<InternalAdd<DdType::CUDD, ValueType>>& groups,
586 std::vector<uint_fast64_t> const& ddGroupVariableIndices, uint_fast64_t currentLevel,
587 uint_fast64_t maxLevel) const {
588 // For the empty DD, we do not need to create a group.
589 if (dd == Cudd_ReadZero(ddManager->getCuddManager().getManager())) {
590 return;
591 }
592
593 if (currentLevel == maxLevel) {
594 groups.push_back(InternalAdd<DdType::CUDD, ValueType>(ddManager, cudd::ADD(ddManager->getCuddManager(), dd)));
595 } else if (ddGroupVariableIndices[currentLevel] < Cudd_NodeReadIndex(dd)) {
596 splitIntoGroupsRec(dd, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
597 splitIntoGroupsRec(dd, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
598 } else {
599 // FIXME: We first traverse the else successor (unlike other variants of this method).
600 // Otherwise, the GameBasedMdpModelCheckerTest would not terminate. See github issue #64
601 splitIntoGroupsRec(Cudd_E(dd), groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
602 splitIntoGroupsRec(Cudd_T(dd), groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
603 }
604}
605
606template<typename ValueType>
607std::vector<std::pair<InternalAdd<DdType::CUDD, ValueType>, InternalAdd<DdType::CUDD, ValueType>>> InternalAdd<DdType::CUDD, ValueType>::splitIntoGroups(
608 InternalAdd<DdType::CUDD, ValueType> vector, std::vector<uint_fast64_t> const& ddGroupVariableIndices) const {
609 std::vector<std::pair<InternalAdd<DdType::CUDD, ValueType>, InternalAdd<DdType::CUDD, ValueType>>> result;
610 splitIntoGroupsRec(this->getCuddDdNode(), vector.getCuddDdNode(), result, ddGroupVariableIndices, 0, ddGroupVariableIndices.size());
611 return result;
612}
613
614template<typename ValueType>
615void InternalAdd<DdType::CUDD, ValueType>::splitIntoGroupsRec(
616 DdNode* dd1, DdNode* dd2, std::vector<std::pair<InternalAdd<DdType::CUDD, ValueType>, InternalAdd<DdType::CUDD, ValueType>>>& groups,
617 std::vector<uint_fast64_t> const& ddGroupVariableIndices, uint_fast64_t currentLevel, uint_fast64_t maxLevel) const {
618 // For the empty DD, we do not need to create a group.
619 if (dd1 == Cudd_ReadZero(ddManager->getCuddManager().getManager()) && dd2 == Cudd_ReadZero(ddManager->getCuddManager().getManager())) {
620 return;
621 }
622
623 if (currentLevel == maxLevel) {
624 groups.push_back(std::make_pair(InternalAdd<DdType::CUDD, ValueType>(ddManager, cudd::ADD(ddManager->getCuddManager(), dd1)),
625 InternalAdd<DdType::CUDD, ValueType>(ddManager, cudd::ADD(ddManager->getCuddManager(), dd2))));
626 } else if (ddGroupVariableIndices[currentLevel] < Cudd_NodeReadIndex(dd1)) {
627 if (ddGroupVariableIndices[currentLevel] < Cudd_NodeReadIndex(dd2)) {
628 splitIntoGroupsRec(dd1, dd2, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
629 splitIntoGroupsRec(dd1, dd2, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
630 } else {
631 splitIntoGroupsRec(dd1, Cudd_T(dd2), groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
632 splitIntoGroupsRec(dd1, Cudd_E(dd2), groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
633 }
634 } else if (ddGroupVariableIndices[currentLevel] < Cudd_NodeReadIndex(dd2)) {
635 splitIntoGroupsRec(Cudd_T(dd1), dd2, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
636 splitIntoGroupsRec(Cudd_E(dd1), dd2, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
637 } else {
638 splitIntoGroupsRec(Cudd_T(dd1), Cudd_T(dd2), groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
639 splitIntoGroupsRec(Cudd_E(dd1), Cudd_E(dd2), groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
640 }
641}
642
643template<typename ValueType>
644std::vector<std::vector<InternalAdd<DdType::CUDD, ValueType>>> InternalAdd<DdType::CUDD, ValueType>::splitIntoGroups(
645 std::vector<InternalAdd<DdType::CUDD, ValueType>> const& vectors, std::vector<uint_fast64_t> const& ddGroupVariableIndices) const {
646 std::vector<std::vector<InternalAdd<DdType::CUDD, ValueType>>> result;
647 std::vector<DdNode*> dds;
648 for (auto const& vector : vectors) {
649 dds.push_back(vector.getCuddDdNode());
650 }
651 dds.push_back(this->getCuddDdNode());
652
653 splitIntoGroupsRec(dds, result, ddGroupVariableIndices, 0, ddGroupVariableIndices.size());
654 return result;
655}
656
657template<typename ValueType>
658void InternalAdd<DdType::CUDD, ValueType>::splitIntoGroupsRec(std::vector<DdNode*> const& dds,
659 std::vector<std::vector<InternalAdd<DdType::CUDD, ValueType>>>& groups,
660 std::vector<uint_fast64_t> const& ddGroupVariableIndices, uint_fast64_t currentLevel,
661 uint_fast64_t maxLevel) const {
662 // For the empty DD, we do not need to create a group.
663 {
664 bool emptyDd = true;
665 for (auto const& dd : dds) {
666 if (dd != Cudd_ReadZero(ddManager->getCuddManager().getManager())) {
667 emptyDd = false;
668 break;
669 }
670 }
671 if (emptyDd) {
672 return;
673 }
674 }
675
676 if (currentLevel == maxLevel) {
677 std::vector<InternalAdd<DdType::CUDD, ValueType>> newGroup;
678 for (auto dd : dds) {
679 newGroup.emplace_back(ddManager, cudd::ADD(ddManager->getCuddManager(), dd));
680 }
681 groups.push_back(std::move(newGroup));
682 } else {
683 std::vector<DdNode*> thenSubDds(dds), elseSubDds(dds);
684 for (uint64_t ddIndex = 0; ddIndex < dds.size(); ++ddIndex) {
685 auto const& dd = dds[ddIndex];
686 if (ddGroupVariableIndices[currentLevel] == Cudd_NodeReadIndex(dd)) {
687 thenSubDds[ddIndex] = Cudd_T(dd);
688 elseSubDds[ddIndex] = Cudd_E(dd);
689 }
690 }
691 splitIntoGroupsRec(thenSubDds, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
692 splitIntoGroupsRec(elseSubDds, groups, ddGroupVariableIndices, currentLevel + 1, maxLevel);
693 }
694}
695
696template<typename ValueType>
697void InternalAdd<DdType::CUDD, ValueType>::toMatrixComponents(std::vector<uint_fast64_t> const& rowGroupIndices, std::vector<uint_fast64_t>& rowIndications,
698 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>>& columnsAndValues,
699 Odd const& rowOdd, Odd const& columnOdd, std::vector<uint_fast64_t> const& ddRowVariableIndices,
700 std::vector<uint_fast64_t> const& ddColumnVariableIndices, bool writeValues) const {
701 return toMatrixComponentsRec(this->getCuddDdNode(), rowGroupIndices, rowIndications, columnsAndValues, rowOdd, columnOdd, 0, 0,
702 ddRowVariableIndices.size() + ddColumnVariableIndices.size(), 0, 0, ddRowVariableIndices, ddColumnVariableIndices,
703 writeValues);
704}
705
706template<typename ValueType>
707void InternalAdd<DdType::CUDD, ValueType>::toMatrixComponentsRec(DdNode const* dd, std::vector<uint_fast64_t> const& rowGroupOffsets,
708 std::vector<uint_fast64_t>& rowIndications,
709 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>>& columnsAndValues,
710 Odd const& rowOdd, Odd const& columnOdd, uint_fast64_t currentRowLevel,
711 uint_fast64_t currentColumnLevel, uint_fast64_t maxLevel, uint_fast64_t currentRowOffset,
712 uint_fast64_t currentColumnOffset, std::vector<uint_fast64_t> const& ddRowVariableIndices,
713 std::vector<uint_fast64_t> const& ddColumnVariableIndices, bool generateValues) const {
714 // For the empty DD, we do not need to add any entries.
715 if (dd == Cudd_ReadZero(ddManager->getCuddManager().getManager())) {
716 return;
717 }
718
719 // If we are at the maximal level, the value to be set is stored as a constant in the DD.
720 if (currentRowLevel + currentColumnLevel == maxLevel) {
721 if (generateValues) {
722 columnsAndValues[rowIndications[rowGroupOffsets[currentRowOffset]]] =
724 }
725 ++rowIndications[rowGroupOffsets[currentRowOffset]];
726 } else {
727 DdNode const* elseElse;
728 DdNode const* elseThen;
729 DdNode const* thenElse;
730 DdNode const* thenThen;
731
732 if (ddColumnVariableIndices[currentColumnLevel] < Cudd_NodeReadIndex(dd)) {
733 elseElse = elseThen = thenElse = thenThen = dd;
734 } else if (ddRowVariableIndices[currentColumnLevel] < Cudd_NodeReadIndex(dd)) {
735 elseElse = thenElse = Cudd_E_const(dd);
736 elseThen = thenThen = Cudd_T_const(dd);
737 } else {
738 DdNode const* elseNode = Cudd_E_const(dd);
739 if (ddColumnVariableIndices[currentColumnLevel] < Cudd_NodeReadIndex(elseNode)) {
740 elseElse = elseThen = elseNode;
741 } else {
742 elseElse = Cudd_E_const(elseNode);
743 elseThen = Cudd_T_const(elseNode);
744 }
745
746 DdNode const* thenNode = Cudd_T_const(dd);
747 if (ddColumnVariableIndices[currentColumnLevel] < Cudd_NodeReadIndex(thenNode)) {
748 thenElse = thenThen = thenNode;
749 } else {
750 thenElse = Cudd_E_const(thenNode);
751 thenThen = Cudd_T_const(thenNode);
752 }
753 }
754
755 // Visit else-else.
756 toMatrixComponentsRec(elseElse, rowGroupOffsets, rowIndications, columnsAndValues, rowOdd.getElseSuccessor(), columnOdd.getElseSuccessor(),
757 currentRowLevel + 1, currentColumnLevel + 1, maxLevel, currentRowOffset, currentColumnOffset, ddRowVariableIndices,
758 ddColumnVariableIndices, generateValues);
759 // Visit else-then.
760 toMatrixComponentsRec(elseThen, rowGroupOffsets, rowIndications, columnsAndValues, rowOdd.getElseSuccessor(), columnOdd.getThenSuccessor(),
761 currentRowLevel + 1, currentColumnLevel + 1, maxLevel, currentRowOffset, currentColumnOffset + columnOdd.getElseOffset(),
762 ddRowVariableIndices, ddColumnVariableIndices, generateValues);
763 // Visit then-else.
764 toMatrixComponentsRec(thenElse, rowGroupOffsets, rowIndications, columnsAndValues, rowOdd.getThenSuccessor(), columnOdd.getElseSuccessor(),
765 currentRowLevel + 1, currentColumnLevel + 1, maxLevel, currentRowOffset + rowOdd.getElseOffset(), currentColumnOffset,
766 ddRowVariableIndices, ddColumnVariableIndices, generateValues);
767 // Visit then-then.
768 toMatrixComponentsRec(thenThen, rowGroupOffsets, rowIndications, columnsAndValues, rowOdd.getThenSuccessor(), columnOdd.getThenSuccessor(),
769 currentRowLevel + 1, currentColumnLevel + 1, maxLevel, currentRowOffset + rowOdd.getElseOffset(),
770 currentColumnOffset + columnOdd.getElseOffset(), ddRowVariableIndices, ddColumnVariableIndices, generateValues);
771 }
772}
773
774template<typename ValueType>
775InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::fromVector(InternalDdManager<DdType::CUDD> const* ddManager,
776 std::vector<ValueType> const& values, storm::dd::Odd const& odd,
777 std::vector<uint_fast64_t> const& ddVariableIndices) {
778 uint_fast64_t offset = 0;
779 return InternalAdd<DdType::CUDD, ValueType>(
780 ddManager, cudd::ADD(ddManager->getCuddManager(),
781 fromVectorRec(ddManager->getCuddManager().getManager(), offset, 0, ddVariableIndices.size(), values, odd, ddVariableIndices)));
782}
783
784template<typename ValueType>
785DdNode* InternalAdd<DdType::CUDD, ValueType>::fromVectorRec(::DdManager* manager, uint_fast64_t& currentOffset, uint_fast64_t currentLevel,
786 uint_fast64_t maxLevel, std::vector<ValueType> const& values, Odd const& odd,
787 std::vector<uint_fast64_t> const& ddVariableIndices) {
788 if (currentLevel == maxLevel) {
789 // If we are in a terminal node of the ODD, we need to check whether the then-offset of the ODD is one
790 // (meaning the encoding is a valid one) or zero (meaning the encoding is not valid). Consequently, we
791 // need to copy the next value of the vector iff the then-offset is greater than zero.
792 if (odd.getThenOffset() > 0) {
793 return Cudd_addConst(manager, values[currentOffset++]);
794 } else {
795 return Cudd_ReadZero(manager);
796 }
797 } else {
798 // If the total offset is zero, we can just return the constant zero DD.
799 if (odd.getThenOffset() + odd.getElseOffset() == 0) {
800 return Cudd_ReadZero(manager);
801 }
802
803 // Determine the new else-successor.
804 DdNode* elseSuccessor = nullptr;
805 if (odd.getElseOffset() > 0) {
806 elseSuccessor = fromVectorRec(manager, currentOffset, currentLevel + 1, maxLevel, values, odd.getElseSuccessor(), ddVariableIndices);
807 } else {
808 elseSuccessor = Cudd_ReadZero(manager);
809 }
810 Cudd_Ref(elseSuccessor);
811
812 // Determine the new then-successor.
813 DdNode* thenSuccessor = nullptr;
814 if (odd.getThenOffset() > 0) {
815 thenSuccessor = fromVectorRec(manager, currentOffset, currentLevel + 1, maxLevel, values, odd.getThenSuccessor(), ddVariableIndices);
816 } else {
817 thenSuccessor = Cudd_ReadZero(manager);
818 }
819 Cudd_Ref(thenSuccessor);
820
821 // Create a node representing ITE(currentVar, thenSuccessor, elseSuccessor);
822 DdNode* result = Cudd_addIthVar(manager, static_cast<int>(ddVariableIndices[currentLevel]));
823 Cudd_Ref(result);
824 DdNode* newResult = Cudd_addIte(manager, result, thenSuccessor, elseSuccessor);
825 Cudd_Ref(newResult);
826
827 // Dispose of the intermediate results
828 Cudd_RecursiveDeref(manager, result);
829 Cudd_RecursiveDeref(manager, thenSuccessor);
830 Cudd_RecursiveDeref(manager, elseSuccessor);
831
832 // Before returning, we remove the protection imposed by the previous call to Cudd_Ref.
833 Cudd_Deref(newResult);
834
835 return newResult;
836 }
837}
838
839#else
840template<typename ValueType>
842 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
843 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
844 "of Storm with CUDD support.");
845}
846
847template<typename ValueType>
849 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
850 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
851 "of Storm with CUDD support.");
852}
853
854template<typename ValueType>
856 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
857 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
858 "of Storm with CUDD support.");
859}
860
861template<typename ValueType>
863 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
864 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
865 "of Storm with CUDD support.");
866}
867
868template<typename ValueType>
870 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
871 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
872 "of Storm with CUDD support.");
873}
874
875template<typename ValueType>
877 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
878 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
879 "of Storm with CUDD support.");
880}
881
882template<typename ValueType>
884 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
885 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
886 "of Storm with CUDD support.");
887}
888
889template<typename ValueType>
891 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
892 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
893 "of Storm with CUDD support.");
894}
895
896template<typename ValueType>
898 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
899 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
900 "of Storm with CUDD support.");
901}
902
903template<typename ValueType>
905 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
906 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
907 "of Storm with CUDD support.");
908}
909
910template<typename ValueType>
912 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
913 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
914 "of Storm with CUDD support.");
915}
916
917template<typename ValueType>
919 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
920 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
921 "of Storm with CUDD support.");
922}
923
924template<typename ValueType>
926 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
927 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
928 "of Storm with CUDD support.");
929}
930
931template<typename ValueType>
933 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
934 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
935 "of Storm with CUDD support.");
936}
937
938template<typename ValueType>
940 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
941 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
942 "of Storm with CUDD support.");
943}
944
945template<typename ValueType>
947 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
948 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
949 "of Storm with CUDD support.");
950}
951
952template<typename ValueType>
954 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
955 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
956 "of Storm with CUDD support.");
957}
958
959template<typename ValueType>
961 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
962 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
963 "of Storm with CUDD support.");
964}
965
966template<typename ValueType>
968 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
969 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
970 "of Storm with CUDD support.");
971}
972
973template<typename ValueType>
975 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
976 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
977 "of Storm with CUDD support.");
978}
979
980template<typename ValueType>
982 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
983 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
984 "of Storm with CUDD support.");
985}
986
987template<typename ValueType>
989 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
990 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
991 "of Storm with CUDD support.");
992}
993
994template<typename ValueType>
996 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
997 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
998 "of Storm with CUDD support.");
999}
1000
1001template<typename ValueType>
1002template<typename TargetValueType>
1003typename std::enable_if<std::is_same<ValueType, TargetValueType>::value, InternalAdd<DdType::CUDD, TargetValueType>>::type
1005 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1006 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1007 "of Storm with CUDD support.");
1008}
1009
1010template<typename ValueType>
1011template<typename TargetValueType>
1012typename std::enable_if<!std::is_same<ValueType, TargetValueType>::value, InternalAdd<DdType::CUDD, TargetValueType>>::type
1014 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1015 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1016 "of Storm with CUDD support.");
1017}
1018
1019template<typename ValueType>
1021 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1022 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1023 "of Storm with CUDD support.");
1024}
1025
1026template<typename ValueType>
1028 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1029 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1030 "of Storm with CUDD support.");
1031}
1032
1033template<typename ValueType>
1035 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1036 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1037 "of Storm with CUDD support.");
1038}
1039
1040template<typename ValueType>
1042 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1043 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1044 "of Storm with CUDD support.");
1045}
1046
1047template<typename ValueType>
1049 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1050 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1051 "of Storm with CUDD support.");
1052}
1053
1054template<typename ValueType>
1056 bool relative) const {
1057 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1058 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1059 "of Storm with CUDD support.");
1060}
1061
1062template<typename ValueType>
1064 std::vector<InternalBdd<DdType::CUDD>> const& to) const {
1065 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1066 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1067 "of Storm with CUDD support.");
1068}
1069
1070template<typename ValueType>
1072 std::vector<InternalBdd<DdType::CUDD>> const& to) const {
1073 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1074 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1075 "of Storm with CUDD support.");
1076}
1077
1078template<typename ValueType>
1080 InternalAdd<DdType::CUDD, ValueType> const& otherMatrix, std::vector<InternalBdd<DdType::CUDD>> const& summationDdVariables) const {
1081 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1082 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1083 "of Storm with CUDD support.");
1084}
1085
1086template<typename ValueType>
1088 InternalBdd<DdType::CUDD> const& otherMatrix, std::vector<InternalBdd<DdType::CUDD>> const& summationDdVariables) const {
1089 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1090 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1091 "of Storm with CUDD support.");
1092}
1093
1094template<typename ValueType>
1096 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1097 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1098 "of Storm with CUDD support.");
1099}
1100
1101template<typename ValueType>
1103 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1104 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1105 "of Storm with CUDD support.");
1106}
1107
1108template<typename ValueType>
1110 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1111 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1112 "of Storm with CUDD support.");
1113}
1114
1115template<typename ValueType>
1117 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1118 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1119 "of Storm with CUDD support.");
1120}
1121
1122template<typename ValueType>
1124 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1125 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1126 "of Storm with CUDD support.");
1127}
1128
1129template<typename ValueType>
1131 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1132 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1133 "of Storm with CUDD support.");
1134}
1135
1136template<typename ValueType>
1138 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1139 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1140 "of Storm with CUDD support.");
1141}
1142
1143template<typename ValueType>
1145 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1146 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1147 "of Storm with CUDD support.");
1148}
1149
1150template<typename ValueType>
1151uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getNonZeroCount(uint_fast64_t numberOfDdVariables) const {
1152 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1153 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1154 "of Storm with CUDD support.");
1155}
1156
1157template<typename ValueType>
1159 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1160 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1161 "of Storm with CUDD support.");
1162}
1163
1164template<typename ValueType>
1166 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1167 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1168 "of Storm with CUDD support.");
1169}
1170
1171template<typename ValueType>
1173 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1174 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1175 "of Storm with CUDD support.");
1176}
1177
1178template<typename ValueType>
1180 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1181 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1182 "of Storm with CUDD support.");
1183}
1184
1185template<typename ValueType>
1187 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1188 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1189 "of Storm with CUDD support.");
1190}
1191
1192template<typename ValueType>
1194 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1195 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1196 "of Storm with CUDD support.");
1197}
1198
1199template<typename ValueType>
1201 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1202 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1203 "of Storm with CUDD support.");
1204}
1205
1206template<typename ValueType>
1208 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1209 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1210 "of Storm with CUDD support.");
1211}
1212
1213template<typename ValueType>
1215 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1216 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1217 "of Storm with CUDD support.");
1218}
1219
1220template<typename ValueType>
1222 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1223 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1224 "of Storm with CUDD support.");
1225}
1226
1227template<typename ValueType>
1228void InternalAdd<DdType::CUDD, ValueType>::exportToDot(std::string const& filename, std::vector<std::string> const& ddVariableNamesAsStrings,
1229 bool showVariablesIfPossible) const {
1230 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1231 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1232 "of Storm with CUDD support.");
1233}
1234
1235template<typename ValueType>
1237 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1238 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1239 "of Storm with CUDD support.");
1240}
1241
1242template<typename ValueType>
1244 uint_fast64_t, std::set<storm::expressions::Variable> const& metaVariables,
1245 bool enumerateDontCareMetaVariables) const {
1246 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1247 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1248 "of Storm with CUDD support.");
1249}
1250
1251template<typename ValueType>
1253 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1254 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1255 "of Storm with CUDD support.");
1256}
1257
1258template<typename ValueType>
1260 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1261 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1262 "of Storm with CUDD support.");
1263}
1264
1265template<typename ValueType>
1266Odd InternalAdd<DdType::CUDD, ValueType>::createOdd(std::vector<uint_fast64_t> const& ddVariableIndices) const {
1267 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1268 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1269 "of Storm with CUDD support.");
1270}
1271
1272template<typename ValueType>
1274 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1275 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1276 "of Storm with CUDD support.");
1277}
1278
1279template<typename ValueType>
1280void InternalAdd<DdType::CUDD, ValueType>::composeWithExplicitVector(storm::dd::Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
1281 std::vector<ValueType>& targetVector,
1282 std::function<ValueType(ValueType const&, ValueType const&)> const& function) const {
1283 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1284 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1285 "of Storm with CUDD support.");
1286}
1287
1288template<typename ValueType>
1289void InternalAdd<DdType::CUDD, ValueType>::forEach(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
1290 std::function<void(uint64_t const&, ValueType const&)> const& function) const {
1291 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1292 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1293 "of Storm with CUDD support.");
1294}
1295
1296template<typename ValueType>
1297void InternalAdd<DdType::CUDD, ValueType>::composeWithExplicitVector(storm::dd::Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
1298 std::vector<uint_fast64_t> const& offsets, std::vector<ValueType>& targetVector,
1299 std::function<ValueType(ValueType const&, ValueType const&)> const& function) const {
1300 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1301 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1302 "of Storm with CUDD support.");
1303}
1304
1305template<typename ValueType>
1306std::vector<uint64_t> InternalAdd<DdType::CUDD, ValueType>::decodeGroupLabels(std::vector<uint_fast64_t> const& ddGroupVariableIndices,
1307 storm::storage::BitVector const& ddLabelVariableIndices) const {
1308 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1309 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1310 "of Storm with CUDD support.");
1311}
1312
1313template<typename ValueType>
1314std::vector<InternalAdd<DdType::CUDD, ValueType>> InternalAdd<DdType::CUDD, ValueType>::splitIntoGroups(
1315 std::vector<uint_fast64_t> const& ddGroupVariableIndices) const {
1316 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1317 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1318 "of Storm with CUDD support.");
1319}
1320
1321template<typename ValueType>
1322std::vector<std::pair<InternalAdd<DdType::CUDD, ValueType>, InternalAdd<DdType::CUDD, ValueType>>> InternalAdd<DdType::CUDD, ValueType>::splitIntoGroups(
1323 InternalAdd<DdType::CUDD, ValueType> vector, std::vector<uint_fast64_t> const& ddGroupVariableIndices) const {
1324 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1325 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1326 "of Storm with CUDD support.");
1327}
1328
1329template<typename ValueType>
1330std::vector<std::vector<InternalAdd<DdType::CUDD, ValueType>>> InternalAdd<DdType::CUDD, ValueType>::splitIntoGroups(
1331 std::vector<InternalAdd<DdType::CUDD, ValueType>> const& vectors, std::vector<uint_fast64_t> const& ddGroupVariableIndices) const {
1332 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1333 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1334 "of Storm with CUDD support.");
1335}
1336
1337template<typename ValueType>
1338void InternalAdd<DdType::CUDD, ValueType>::toMatrixComponents(std::vector<uint_fast64_t> const& rowGroupIndices, std::vector<uint_fast64_t>& rowIndications,
1339 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>>& columnsAndValues,
1340 Odd const& rowOdd, Odd const& columnOdd, std::vector<uint_fast64_t> const& ddRowVariableIndices,
1341 std::vector<uint_fast64_t> const& ddColumnVariableIndices, bool writeValues) const {
1342 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1343 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1344 "of Storm with CUDD support.");
1345}
1346
1347template<typename ValueType>
1349 std::vector<ValueType> const& values, storm::dd::Odd const& odd,
1350 std::vector<uint_fast64_t> const& ddVariableIndices) {
1351 STORM_LOG_THROW(false, storm::exceptions::MissingLibraryException,
1352 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
1353 "of Storm with CUDD support.");
1354}
1355
1356#endif
1357
1362} // namespace dd
1363} // namespace storm
InternalAdd< DdType::Sylvan, double > toValueType() const
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.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
SFTBDDChecker::ValueType ValueType
SettingsManager const & manager()
Retrieves the settings manager.
Extremum< storm::OptimizationDirection::Maximize, ValueType > Maximum
Definition Extremum.h:166
Extremum< storm::OptimizationDirection::Minimize, ValueType > Minimum
Definition Extremum.h:168
TargetType convertNumber(SourceType const &number)
The contract of a DD backend.