Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
InternalCuddBdd.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DD_CUDD_INTERNALCUDDBDD_H_
2#define STORM_STORAGE_DD_CUDD_INTERNALCUDDBDD_H_
3
4#include <functional>
5#include <memory>
6#include <set>
7#include <unordered_map>
8
11
15
16// Include the C++-interface of CUDD.
17#include "cuddObj.hh"
18
19namespace storm {
20namespace storage {
21class BitVector;
22}
23
24namespace dd {
25template<DdType LibraryType>
26class InternalDdManager;
27
28template<DdType LibraryType, typename ValueType>
29class InternalAdd;
30
31class Odd;
32
33template<>
35 public:
36 template<DdType LibraryType, typename ValueType>
37 friend class InternalAdd;
38
46 InternalBdd(InternalDdManager<DdType::CUDD> const* ddManager, cudd::BDD cuddBdd);
47
48 // Instantiate all copy/move constructors/assignments with the default implementation.
49 InternalBdd() = default;
50 InternalBdd(InternalBdd<DdType::CUDD> const& other) = default;
54
64 static InternalBdd<storm::dd::DdType::CUDD> fromVector(InternalDdManager<DdType::CUDD> const* ddManager, Odd const& odd,
65 std::vector<uint_fast64_t> const& sortedDdVariableIndices,
66 std::function<bool(uint64_t)> const& filter);
67
74 bool operator==(InternalBdd<DdType::CUDD> const& other) const;
75
82 bool operator!=(InternalBdd<DdType::CUDD> const& other) const;
83
92 InternalBdd<DdType::CUDD> relationalProduct(InternalBdd<DdType::CUDD> const& relation, std::vector<InternalBdd<DdType::CUDD>> const& rowVariables,
93 std::vector<InternalBdd<DdType::CUDD>> const& columnVariables) const;
94
103 InternalBdd<DdType::CUDD> inverseRelationalProduct(InternalBdd<DdType::CUDD> const& relation, std::vector<InternalBdd<DdType::CUDD>> const& rowVariables,
104 std::vector<InternalBdd<DdType::CUDD>> const& columnVariables) const;
105
115 InternalBdd<DdType::CUDD> inverseRelationalProductWithExtendedRelation(InternalBdd<DdType::CUDD> const& relation,
116 std::vector<InternalBdd<DdType::CUDD>> const& rowVariables,
117 std::vector<InternalBdd<DdType::CUDD>> const& columnVariables) const;
118
128 InternalBdd<DdType::CUDD> ite(InternalBdd<DdType::CUDD> const& thenBdd, InternalBdd<DdType::CUDD> const& elseBdd) const;
129
138 template<typename ValueType>
140
147 InternalBdd<DdType::CUDD> operator||(InternalBdd<DdType::CUDD> const& other) const;
148
156
163 InternalBdd<DdType::CUDD> operator&&(InternalBdd<DdType::CUDD> const& other) const;
164
172
180
187 InternalBdd<DdType::CUDD> exclusiveOr(InternalBdd<DdType::CUDD> const& other) const;
188
195 InternalBdd<DdType::CUDD> implies(InternalBdd<DdType::CUDD> const& other) const;
196
202 InternalBdd<DdType::CUDD> operator!() const;
203
209 InternalBdd<DdType::CUDD>& complement();
210
216 InternalBdd<DdType::CUDD> existsAbstract(InternalBdd<DdType::CUDD> const& cube) const;
217
225 InternalBdd<DdType::CUDD> existsAbstractRepresentative(InternalBdd<DdType::CUDD> const& cube) const;
226
232 InternalBdd<DdType::CUDD> universalAbstract(InternalBdd<DdType::CUDD> const& cube) const;
233
242 InternalBdd<DdType::CUDD> swapVariables(std::vector<InternalBdd<DdType::CUDD>> const& from, std::vector<InternalBdd<DdType::CUDD>> const& to) const;
243
252
261 InternalBdd<DdType::CUDD> constrain(InternalBdd<DdType::CUDD> const& constraint) const;
262
271 InternalBdd<DdType::CUDD> restrict(InternalBdd<DdType::CUDD> const& constraint) const;
272
278 InternalBdd<DdType::CUDD> getSupport() const;
279
286 uint_fast64_t getNonZeroCount(uint_fast64_t numberOfDdVariables) const;
287
293 uint_fast64_t getLeafCount() const;
294
300 uint_fast64_t getNodeCount() const;
301
307 bool isOne() const;
308
314 bool isZero() const;
315
321 uint_fast64_t getIndex() const;
322
328 uint_fast64_t getLevel() const;
329
336 void exportToDot(std::string const& filename, std::vector<std::string> const& ddVariableNamesAsStrings, bool showVariablesIfPossible = true) const;
337
343 void exportToText(std::string const& filename) const;
344
350 template<typename ValueType>
352
361 storm::storage::BitVector toVector(storm::dd::Odd const& rowOdd, std::vector<uint_fast64_t> const& ddVariableIndices) const;
362
370 std::pair<std::vector<storm::expressions::Expression>, std::unordered_map<uint_fast64_t, storm::expressions::Variable>> toExpression(
372
379 Odd createOdd(std::vector<uint_fast64_t> const& ddVariableIndices) const;
380
389 template<typename ValueType>
390 void filterExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, std::vector<ValueType> const& sourceValues,
391 std::vector<ValueType>& targetValues) const;
392
401 void filterExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, storm::storage::BitVector const& sourceValues,
402 storm::storage::BitVector& targetValues) const;
403
410 std::vector<InternalBdd<DdType::CUDD>> splitIntoGroups(std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
411
412 friend struct std::hash<storm::dd::InternalBdd<storm::dd::DdType::CUDD>>;
413
419 cudd::BDD getCuddBdd() const;
420
426 DdNode* getCuddDdNode() const;
427
428 private:
441 static DdNode* fromVectorRec(::DdManager* manager, uint_fast64_t& currentOffset, uint_fast64_t currentLevel, uint_fast64_t maxLevel, Odd const& odd,
442 std::vector<uint_fast64_t> const& ddVariableIndices, std::function<bool(uint64_t)> const& filter);
443
457 void toVectorRec(DdNode const* dd, cudd::Cudd const& manager, storm::storage::BitVector& result, Odd const& rowOdd, bool complement,
458 uint_fast64_t currentRowLevel, uint_fast64_t maxLevel, uint_fast64_t currentRowOffset,
459 std::vector<uint_fast64_t> const& ddRowVariableIndices) const;
460
461 // Declare a hash functor that is used for the unique tables in the construction process of ODDs.
462 class HashFunctor {
463 public:
464 std::size_t operator()(std::pair<DdNode const*, bool> const& key) const;
465 };
466
479 static std::shared_ptr<Odd> createOddRec(DdNode const* dd, cudd::Cudd const& manager, uint_fast64_t currentLevel, uint_fast64_t maxLevel,
480 std::vector<uint_fast64_t> const& ddVariableIndices,
481 std::vector<std::unordered_map<DdNode const*, std::shared_ptr<Odd>>>& uniqueTableForLevels);
482
497 template<typename ValueType>
498 static void filterExplicitVectorRec(DdNode const* dd, cudd::Cudd const& manager, uint_fast64_t currentLevel, bool complement, uint_fast64_t maxLevel,
499 std::vector<uint_fast64_t> const& ddVariableIndices, uint_fast64_t currentOffset, storm::dd::Odd const& odd,
500 std::vector<ValueType>& result, uint_fast64_t& currentIndex, std::vector<ValueType> const& values);
501
516 static void filterExplicitVectorRec(DdNode const* dd, cudd::Cudd const& manager, uint_fast64_t currentLevel, bool complement, uint_fast64_t maxLevel,
517 std::vector<uint_fast64_t> const& ddVariableIndices, uint_fast64_t currentOffset, storm::dd::Odd const& odd,
518 storm::storage::BitVector& result, uint_fast64_t& currentIndex, storm::storage::BitVector const& values);
519
538 static storm::expressions::Variable toExpressionRec(
539 DdNode const* dd, cudd::Cudd const& ddManager, storm::expressions::ExpressionManager& manager, std::vector<storm::expressions::Expression>& expressions,
540 std::unordered_map<uint_fast64_t, storm::expressions::Variable>& indexToVariableMap,
541 std::unordered_map<std::pair<uint_fast64_t, uint_fast64_t>, storm::expressions::Variable>& countIndexToVariablePair,
542 std::unordered_map<DdNode const*, uint_fast64_t>& nodeToCounterMap, std::vector<uint_fast64_t>& nextCounterForIndex);
543
544 void splitIntoGroupsRec(DdNode* dd, bool negated, std::vector<InternalBdd<DdType::CUDD>>& groups, std::vector<uint_fast64_t> const& ddGroupVariableIndices,
545 uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
546
547 InternalDdManager<DdType::CUDD> const* ddManager;
548
549 cudd::BDD cuddBdd;
550};
551} // namespace dd
552} // namespace storm
553
554namespace std {
555template<>
556struct hash<storm::dd::InternalBdd<storm::dd::DdType::CUDD>> {
558 return reinterpret_cast<std::size_t>(key.cuddBdd.getNode());
559 }
560};
561} // namespace std
562
563#endif /* STORM_STORAGE_DD_CUDD_INTERNALCUDDBDD_H_ */
InternalBdd(InternalBdd< DdType::CUDD > &&other)=default
InternalBdd & operator=(InternalBdd< DdType::CUDD > &&other)=default
InternalBdd(InternalBdd< DdType::CUDD > const &other)=default
InternalBdd & operator=(InternalBdd< DdType::CUDD > const &other)=default
This class is responsible for managing a set of typed variables and all expressions using these varia...
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
storage::BitVector BitVector
LabParser.cpp.
Definition cli.cpp:18
std::size_t operator()(storm::dd::InternalBdd< storm::dd::DdType::CUDD > const &key) const