Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
InternalSylvanBdd.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANBDD_H_
2#define STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANBDD_H_
3
4#include <functional>
5#include <memory>
6#include <unordered_map>
7#include <vector>
8
11
15
17
18namespace storm {
19namespace storage {
20class BitVector;
21}
22
23namespace dd {
24template<DdType LibraryType>
25class InternalDdManager;
26
27class Odd;
28
29template<>
31 public:
32 template<DdType LibraryType, typename ValueType>
33 friend class InternalAdd;
34
35 InternalBdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Bdd const& sylvanBdd);
36
37 // Instantiate all copy/move constructors/assignments with the default implementation.
43
53 static InternalBdd<storm::dd::DdType::Sylvan> fromVector(InternalDdManager<DdType::Sylvan> const* ddManager, Odd const& odd,
54 std::vector<uint_fast64_t> const& sortedDdVariableIndices,
55 std::function<bool(uint64_t)> const& filter);
56
63 bool operator==(InternalBdd<DdType::Sylvan> const& other) const;
64
71 bool operator!=(InternalBdd<DdType::Sylvan> const& other) const;
72
81 InternalBdd<DdType::Sylvan> relationalProduct(InternalBdd<DdType::Sylvan> const& relation, std::vector<InternalBdd<DdType::Sylvan>> const& rowVariables,
82 std::vector<InternalBdd<DdType::Sylvan>> const& columnVariables) const;
83
92 InternalBdd<DdType::Sylvan> inverseRelationalProduct(InternalBdd<DdType::Sylvan> const& relation,
93 std::vector<InternalBdd<DdType::Sylvan>> const& rowVariables,
94 std::vector<InternalBdd<DdType::Sylvan>> const& columnVariables) const;
95
105 InternalBdd<DdType::Sylvan> inverseRelationalProductWithExtendedRelation(InternalBdd<DdType::Sylvan> const& relation,
106 std::vector<InternalBdd<DdType::Sylvan>> const& rowVariables,
107 std::vector<InternalBdd<DdType::Sylvan>> const& columnVariables) const;
108
119
128 template<typename ValueType>
130 InternalAdd<DdType::Sylvan, ValueType> const& elseAdd) const;
131
138 InternalBdd<DdType::Sylvan> operator||(InternalBdd<DdType::Sylvan> const& other) const;
139
147
154 InternalBdd<DdType::Sylvan> operator&&(InternalBdd<DdType::Sylvan> const& other) const;
155
163
171
178 InternalBdd<DdType::Sylvan> exclusiveOr(InternalBdd<DdType::Sylvan> const& other) const;
179
187
193 InternalBdd<DdType::Sylvan> operator!() const;
194
200 InternalBdd<DdType::Sylvan>& complement();
201
207 InternalBdd<DdType::Sylvan> existsAbstract(InternalBdd<DdType::Sylvan> const& cube) const;
208
216 InternalBdd<DdType::Sylvan> existsAbstractRepresentative(InternalBdd<DdType::Sylvan> const& cube) const;
217
223 InternalBdd<DdType::Sylvan> universalAbstract(InternalBdd<DdType::Sylvan> const& cube) const;
224
233 InternalBdd<DdType::Sylvan> swapVariables(std::vector<InternalBdd<DdType::Sylvan>> const& from, std::vector<InternalBdd<DdType::Sylvan>> const& to) const;
234
243
252 InternalBdd<DdType::Sylvan> constrain(InternalBdd<DdType::Sylvan> const& constraint) const;
253
262 InternalBdd<DdType::Sylvan> restrict(InternalBdd<DdType::Sylvan> const& constraint) const;
263
269 InternalBdd<DdType::Sylvan> getSupport() const;
270
277 uint_fast64_t getNonZeroCount(uint_fast64_t numberOfDdVariables) const;
278
284 uint_fast64_t getLeafCount() const;
285
291 uint_fast64_t getNodeCount() const;
292
298 bool isOne() const;
299
305 bool isZero() const;
306
312 uint_fast64_t getIndex() const;
313
319 uint_fast64_t getLevel() const;
320
327 void exportToDot(std::string const& filename, std::vector<std::string> const& ddVariableNamesAsStrings, bool showVariablesIfPossible = true) const;
328
334 void exportToText(std::string const& filename) const;
335
341 template<typename ValueType>
343
352 storm::storage::BitVector toVector(storm::dd::Odd const& rowOdd, std::vector<uint_fast64_t> const& ddVariableIndices) const;
353
361 std::pair<std::vector<storm::expressions::Expression>, std::unordered_map<uint_fast64_t, storm::expressions::Variable>> toExpression(
363
370 Odd createOdd(std::vector<uint_fast64_t> const& ddVariableIndices) const;
371
380 template<typename ValueType>
381 void filterExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, std::vector<ValueType> const& sourceValues,
382 std::vector<ValueType>& targetValues) const;
383
392 void filterExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, storm::storage::BitVector const& sourceValues,
393 storm::storage::BitVector& targetValues) const;
394
401 std::vector<InternalBdd<DdType::Sylvan>> splitIntoGroups(std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
402
403 friend struct std::hash<storm::dd::InternalBdd<storm::dd::DdType::Sylvan>>;
404
410 sylvan::Bdd& getSylvanBdd();
411
417 sylvan::Bdd const& getSylvanBdd() const;
418
419 private:
431 static BDD fromVectorRec(uint_fast64_t& currentOffset, uint_fast64_t currentLevel, uint_fast64_t maxLevel, Odd const& odd,
432 std::vector<uint_fast64_t> const& ddVariableIndices, std::function<bool(uint64_t)> const& filter);
433
434 // Declare a hash functor that is used for the unique tables in the construction process of ODDs.
435 class HashFunctor {
436 public:
437 std::size_t operator()(std::pair<BDD, bool> const& key) const;
438 };
439
452 static std::shared_ptr<Odd> createOddRec(BDD dd, bool complement, uint_fast64_t currentLevel, uint_fast64_t maxLevel,
453 std::vector<uint_fast64_t> const& ddVariableIndices,
454 std::vector<std::unordered_map<std::pair<BDD, bool>, std::shared_ptr<Odd>, HashFunctor>>& uniqueTableForLevels);
455
468 void toVectorRec(BDD dd, storm::storage::BitVector& result, Odd const& rowOdd, bool complement, uint_fast64_t currentRowLevel, uint_fast64_t maxLevel,
469 uint_fast64_t currentRowOffset, std::vector<uint_fast64_t> const& ddRowVariableIndices) const;
470
484 template<typename ValueType>
485 static void filterExplicitVectorRec(BDD dd, uint_fast64_t currentLevel, bool complement, uint_fast64_t maxLevel,
486 std::vector<uint_fast64_t> const& ddVariableIndices, uint_fast64_t currentOffset, storm::dd::Odd const& odd,
487 std::vector<ValueType>& result, uint_fast64_t& currentIndex, std::vector<ValueType> const& values);
488
502 static void filterExplicitVectorRec(BDD dd, uint_fast64_t currentLevel, bool complement, uint_fast64_t maxLevel,
503 std::vector<uint_fast64_t> const& ddVariableIndices, uint_fast64_t currentOffset, storm::dd::Odd const& odd,
504 storm::storage::BitVector& result, uint_fast64_t& currentIndex, storm::storage::BitVector const& values);
505
523 static storm::expressions::Variable toExpressionRec(
524 BDD dd, storm::expressions::ExpressionManager& manager, std::vector<storm::expressions::Expression>& expressions,
525 std::unordered_map<uint_fast64_t, storm::expressions::Variable>& indexToVariableMap,
526 std::unordered_map<std::pair<uint_fast64_t, uint_fast64_t>, storm::expressions::Variable>& countIndexToVariablePair,
527 std::unordered_map<BDD, uint_fast64_t>& nodeToCounterMap, std::vector<uint_fast64_t>& nextCounterForIndex);
528
529 void splitIntoGroupsRec(BDD dd, std::vector<InternalBdd<DdType::Sylvan>>& groups, std::vector<uint_fast64_t> const& ddGroupVariableIndices,
530 uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
531
532 // The internal manager responsible for this BDD.
533 InternalDdManager<DdType::Sylvan> const* ddManager;
534
535 // The sylvan BDD.
536 sylvan::Bdd sylvanBdd;
537};
538} // namespace dd
539} // namespace storm
540
541namespace std {
542template<>
543struct hash<storm::dd::InternalBdd<storm::dd::DdType::Sylvan>> {
545 return static_cast<std::size_t>(key.sylvanBdd.GetBDD());
546 }
547};
548} // namespace std
549
550#endif /* STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANBDD_H_ */
InternalBdd(InternalBdd< DdType::Sylvan > const &other)=default
InternalBdd & operator=(InternalBdd< DdType::Sylvan > const &other)=default
InternalBdd(InternalBdd< DdType::Sylvan > &&other)=default
InternalBdd & operator=(InternalBdd< DdType::Sylvan > &&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::Sylvan > const &key) const