Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
InternalCuddAdd.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DD_CUDD_INTERNALCUDDADD_H_
2#define STORM_STORAGE_DD_CUDD_INTERNALCUDDADD_H_
3
4#include <functional>
5#include <memory>
6#include <set>
7#include <unordered_map>
8
10
14
16
17// Include the C++-interface of CUDD.
18#include "cuddObj.hh"
19
20namespace storm {
21namespace storage {
22template<typename T>
23class SparseMatrix;
24
25class BitVector;
26
27template<typename E, typename V>
28class MatrixEntry;
29} // namespace storage
30
31namespace dd {
32template<DdType LibraryType>
33class DdManager;
34
35template<DdType LibraryType>
37
38template<DdType LibraryType>
40
41template<DdType LibraryType, typename ValueType>
42class AddIterator;
43
44namespace bisimulation {
45template<DdType LibraryType, typename ValueType>
47}
48
49template<typename ValueType>
50class InternalAdd<DdType::CUDD, ValueType> {
51 public:
52 friend class InternalBdd<DdType::CUDD>;
53
54 friend class bisimulation::InternalSignatureRefiner<DdType::CUDD, ValueType>;
55
62 InternalAdd(InternalDdManager<DdType::CUDD> const* ddManager, cudd::ADD cuddAdd);
63
64 // Instantiate all copy/move constructors/assignments with the default implementation.
65 InternalAdd() = default;
66 InternalAdd(InternalAdd<DdType::CUDD, ValueType> const& other) = default;
67 InternalAdd& operator=(InternalAdd<DdType::CUDD, ValueType> const& other) = default;
68 InternalAdd(InternalAdd<DdType::CUDD, ValueType>&& other) = default;
69 InternalAdd& operator=(InternalAdd<DdType::CUDD, ValueType>&& other) = default;
70 virtual ~InternalAdd() = default;
71
78 bool operator==(InternalAdd<DdType::CUDD, ValueType> const& other) const;
79
86 bool operator!=(InternalAdd<DdType::CUDD, ValueType> const& other) const;
87
94 InternalAdd<DdType::CUDD, ValueType> operator+(InternalAdd<DdType::CUDD, ValueType> const& other) const;
95
102 InternalAdd<DdType::CUDD, ValueType>& operator+=(InternalAdd<DdType::CUDD, ValueType> const& other);
103
110 InternalAdd<DdType::CUDD, ValueType> operator*(InternalAdd<DdType::CUDD, ValueType> const& other) const;
111
118 InternalAdd<DdType::CUDD, ValueType>& operator*=(InternalAdd<DdType::CUDD, ValueType> const& other);
119
126 InternalAdd<DdType::CUDD, ValueType> operator-(InternalAdd<DdType::CUDD, ValueType> const& other) const;
127
134 InternalAdd<DdType::CUDD, ValueType>& operator-=(InternalAdd<DdType::CUDD, ValueType> const& other);
135
142 InternalAdd<DdType::CUDD, ValueType> operator/(InternalAdd<DdType::CUDD, ValueType> const& other) const;
143
150 InternalAdd<DdType::CUDD, ValueType>& operator/=(InternalAdd<DdType::CUDD, ValueType> const& other);
151
158 InternalBdd<DdType::CUDD> equals(InternalAdd<DdType::CUDD, ValueType> const& other) const;
159
166 InternalBdd<DdType::CUDD> notEquals(InternalAdd<DdType::CUDD, ValueType> const& other) const;
167
175 InternalBdd<DdType::CUDD> less(InternalAdd<DdType::CUDD, ValueType> const& other) const;
176
184 InternalBdd<DdType::CUDD> lessOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const;
185
193 InternalBdd<DdType::CUDD> greater(InternalAdd<DdType::CUDD, ValueType> const& other) const;
194
202 InternalBdd<DdType::CUDD> greaterOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const;
203
210 InternalAdd<DdType::CUDD, ValueType> pow(InternalAdd<DdType::CUDD, ValueType> const& other) const;
211
218 InternalAdd<DdType::CUDD, ValueType> mod(InternalAdd<DdType::CUDD, ValueType> const& other) const;
219
227 InternalAdd<DdType::CUDD, ValueType> logxy(InternalAdd<DdType::CUDD, ValueType> const& other) const;
228
234 InternalAdd<DdType::CUDD, ValueType> floor() const;
235
241 InternalAdd<DdType::CUDD, ValueType> ceil() const;
242
248 InternalAdd<DdType::CUDD, storm::RationalNumber> sharpenKwekMehlhorn(size_t precision) const;
249
256 InternalAdd<DdType::CUDD, ValueType> minimum(InternalAdd<DdType::CUDD, ValueType> const& other) const;
257
264 InternalAdd<DdType::CUDD, ValueType> maximum(InternalAdd<DdType::CUDD, ValueType> const& other) const;
265
271 template<typename TargetValueType>
272 typename std::enable_if<std::is_same<ValueType, TargetValueType>::value, InternalAdd<DdType::CUDD, TargetValueType>>::type toValueType() const;
273 template<typename TargetValueType>
274 typename std::enable_if<!std::is_same<ValueType, TargetValueType>::value, InternalAdd<DdType::CUDD, TargetValueType>>::type toValueType() const;
275
281 InternalAdd<DdType::CUDD, ValueType> sumAbstract(InternalBdd<DdType::CUDD> const& cube) const;
282
288 InternalAdd<DdType::CUDD, ValueType> minAbstract(InternalBdd<DdType::CUDD> const& cube) const;
289
295 InternalBdd<DdType::CUDD> minAbstractRepresentative(InternalBdd<DdType::CUDD> const& cube) const;
296
302 InternalAdd<DdType::CUDD, ValueType> maxAbstract(InternalBdd<DdType::CUDD> const& cube) const;
303
309 InternalBdd<DdType::CUDD> maxAbstractRepresentative(InternalBdd<DdType::CUDD> const& cube) const;
310
320 bool equalModuloPrecision(InternalAdd<DdType::CUDD, ValueType> const& other, ValueType const& precision, bool relative = true) const;
321
330 InternalAdd<DdType::CUDD, ValueType> swapVariables(std::vector<InternalBdd<DdType::CUDD>> const& from,
331 std::vector<InternalBdd<DdType::CUDD>> const& to) const;
332
341 InternalAdd<DdType::CUDD, ValueType> permuteVariables(std::vector<InternalBdd<DdType::CUDD>> const& from,
342 std::vector<InternalBdd<DdType::CUDD>> const& to) const;
343
352 InternalAdd<DdType::CUDD, ValueType> multiplyMatrix(InternalAdd<DdType::CUDD, ValueType> const& otherMatrix,
353 std::vector<InternalBdd<DdType::CUDD>> const& summationDdVariables) const;
354
363 InternalAdd<DdType::CUDD, ValueType> multiplyMatrix(InternalBdd<DdType::CUDD> const& otherMatrix,
364 std::vector<InternalBdd<DdType::CUDD>> const& summationDdVariables) const;
365
373 InternalBdd<DdType::CUDD> greater(ValueType const& value) const;
374
382 InternalBdd<DdType::CUDD> greaterOrEqual(ValueType const& value) const;
383
391 InternalBdd<DdType::CUDD> less(ValueType const& value) const;
392
400 InternalBdd<DdType::CUDD> lessOrEqual(ValueType const& value) const;
401
408 InternalBdd<DdType::CUDD> notZero() const;
409
418 InternalAdd<DdType::CUDD, ValueType> constrain(InternalAdd<DdType::CUDD, ValueType> const& constraint) const;
419
428 InternalAdd<DdType::CUDD, ValueType> restrict(InternalAdd<DdType::CUDD, ValueType> const& constraint) const;
429
435 InternalBdd<DdType::CUDD> getSupport() const;
436
443 uint_fast64_t getNonZeroCount(uint_fast64_t numberOfDdVariables) const;
444
450 virtual uint_fast64_t getLeafCount() const;
451
457 virtual uint_fast64_t getNodeCount() const;
458
464 ValueType getMin() const;
465
471 ValueType getMax() const;
472
478 ValueType getValue() const;
479
485 bool isOne() const;
486
492 bool isZero() const;
493
499 bool isConstant() const;
500
506 uint_fast64_t getIndex() const;
507
513 uint_fast64_t getLevel() const;
514
521 void exportToDot(std::string const& filename, std::vector<std::string> const& ddVariableNamesAsStrings, bool showVariablesIfPossible = true) const;
522
528 void exportToText(std::string const& filename) const;
540 AddIterator<DdType::CUDD, ValueType> begin(DdManager<DdType::CUDD> const& fullDdManager, InternalBdd<DdType::CUDD> const& variableCube,
541 uint_fast64_t numberOfDdVariables, std::set<storm::expressions::Variable> const& metaVariables,
542 bool enumerateDontCareMetaVariables = true) const;
543
550 AddIterator<DdType::CUDD, ValueType> end(DdManager<DdType::CUDD> const& fullDdManager) const;
551
562 void composeWithExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, std::vector<ValueType>& targetVector,
563 std::function<ValueType(ValueType const&, ValueType const&)> const& function) const;
564
575 void forEach(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
576 std::function<void(uint64_t const&, ValueType const&)> const& function) const;
577
589 void composeWithExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, std::vector<uint_fast64_t> const& offsets,
590 std::vector<ValueType>& targetVector, std::function<ValueType(ValueType const&, ValueType const&)> const& function) const;
591
598 std::vector<InternalAdd<DdType::CUDD, ValueType>> splitIntoGroups(std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
599
608 std::vector<uint64_t> decodeGroupLabels(std::vector<uint_fast64_t> const& ddGroupVariableIndices,
609 storm::storage::BitVector const& ddLabelVariableIndices) const;
610
620 std::vector<std::pair<InternalAdd<DdType::CUDD, ValueType>, InternalAdd<DdType::CUDD, ValueType>>> splitIntoGroups(
621 InternalAdd<DdType::CUDD, ValueType> vector, std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
622
632 std::vector<std::vector<InternalAdd<DdType::CUDD, ValueType>>> splitIntoGroups(std::vector<InternalAdd<DdType::CUDD, ValueType>> const& vectors,
633 std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
634
648 void toMatrixComponents(std::vector<uint_fast64_t> const& rowGroupIndices, std::vector<uint_fast64_t>& rowIndications,
649 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>>& columnsAndValues, Odd const& rowOdd, Odd const& columnOdd,
650 std::vector<uint_fast64_t> const& ddRowVariableIndices, std::vector<uint_fast64_t> const& ddColumnVariableIndices,
651 bool writeValues) const;
652
661 static InternalAdd<DdType::CUDD, ValueType> fromVector(InternalDdManager<DdType::CUDD> const* ddManager, std::vector<ValueType> const& values,
662 storm::dd::Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices);
663
669 Odd createOdd(std::vector<uint_fast64_t> const& ddVariableIndices) const;
670
671 InternalDdManager<DdType::CUDD> const& getInternalDdManager() const;
672
678 cudd::ADD getCuddAdd() const;
679
685 DdNode* getCuddDdNode() const;
686
690 std::string getStringId() const;
691
692 private:
705 void forEachRec(DdNode const* dd, uint_fast64_t currentLevel, uint_fast64_t maxLevel, uint_fast64_t currentOffset, Odd const& odd,
706 std::vector<uint_fast64_t> const& ddVariableIndices, std::function<void(uint64_t const&, ValueType const&)> const& function) const;
707
718 void splitIntoGroupsRec(DdNode* dd, std::vector<InternalAdd<DdType::CUDD, ValueType>>& groups, std::vector<uint_fast64_t> const& ddGroupVariableIndices,
719 uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
720
733 void decodeGroupLabelsRec(DdNode* dd, std::vector<uint64_t>& labels, std::vector<uint_fast64_t> const& ddGroupVariableIndices,
734 storm::storage::BitVector const& ddLabelVariableIndices, uint_fast64_t currentLevel, uint_fast64_t maxLevel,
735 uint64_t label) const;
736
748 void splitIntoGroupsRec(DdNode* dd1, DdNode* dd2,
749 std::vector<std::pair<InternalAdd<DdType::CUDD, ValueType>, InternalAdd<DdType::CUDD, ValueType>>>& groups,
750 std::vector<uint_fast64_t> const& ddGroupVariableIndices, uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
751
762 void splitIntoGroupsRec(std::vector<DdNode*> const& dds, std::vector<std::vector<InternalAdd<DdType::CUDD, ValueType>>>& groups,
763 std::vector<uint_fast64_t> const& ddGroupVariableIndices, uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
764
790 void toMatrixComponentsRec(DdNode const* dd, std::vector<uint_fast64_t> const& rowGroupOffsets, std::vector<uint_fast64_t>& rowIndications,
791 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>>& columnsAndValues, Odd const& rowOdd, Odd const& columnOdd,
792 uint_fast64_t currentRowLevel, uint_fast64_t currentColumnLevel, uint_fast64_t maxLevel, uint_fast64_t currentRowOffset,
793 uint_fast64_t currentColumnOffset, std::vector<uint_fast64_t> const& ddRowVariableIndices,
794 std::vector<uint_fast64_t> const& ddColumnVariableIndices, bool writeValues) const;
795
808 static DdNode* fromVectorRec(::DdManager* manager, uint_fast64_t& currentOffset, uint_fast64_t currentLevel, uint_fast64_t maxLevel,
809 std::vector<ValueType> const& values, Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices);
810
823 static std::shared_ptr<Odd> createOddRec(DdNode* dd, cudd::Cudd const& manager, uint_fast64_t currentLevel, uint_fast64_t maxLevel,
824 std::vector<uint_fast64_t> const& ddVariableIndices,
825 std::vector<std::unordered_map<DdNode*, std::shared_ptr<Odd>>>& uniqueTableForLevels);
826
827 InternalDdManager<DdType::CUDD> const* ddManager;
828
829 cudd::ADD cuddAdd;
830};
831} // namespace dd
832} // namespace storm
833
834#endif /* STORM_STORAGE_DD_CUDD_INTERNALCUDDADD_H_ */
InternalAdd< DdType::Sylvan, double > toValueType() const
InternalAdd< DdType::Sylvan, storm::RationalNumber > multiplyMatrix(InternalAdd< DdType::Sylvan, storm::RationalNumber > const &otherMatrix, std::vector< InternalBdd< DdType::Sylvan > > const &summationDdVariables) const
storm::RationalNumber getValue(MTBDD const &node)
InternalBdd< DdType::CUDD > lessOrEqual(storm::RationalNumber const &value) const
InternalAdd< DdType::Sylvan, storm::RationalNumber > maximum(InternalAdd< DdType::Sylvan, storm::RationalNumber > const &other) const
storm::RationalNumber getMin() const
InternalBdd< DdType::CUDD > greaterOrEqual(storm::RationalNumber const &value) const
InternalBdd< DdType::Sylvan > maxAbstractRepresentative(InternalBdd< DdType::Sylvan > const &cube) const
InternalBdd< DdType::Sylvan > equals(InternalAdd< DdType::Sylvan, storm::RationalNumber > const &other) const
storm::RationalNumber getMax() const
InternalBdd< DdType::Sylvan > minAbstractRepresentative(InternalBdd< DdType::Sylvan > const &cube) const
InternalAdd< DdType::Sylvan, storm::RationalNumber > ceil() const
InternalAdd< DdType::Sylvan, storm::RationalNumber > sumAbstract(InternalBdd< DdType::Sylvan > const &cube) const
InternalAdd< DdType::Sylvan, storm::RationalNumber > floor() const
InternalAdd< DdType::Sylvan, storm::RationalNumber > pow(InternalAdd< DdType::Sylvan, storm::RationalNumber > const &other) const
bool equalModuloPrecision(InternalAdd< DdType::CUDD, storm::RationalNumber > const &, storm::RationalNumber const &, bool) const
InternalAdd< DdType::Sylvan, storm::RationalNumber > maxAbstract(InternalBdd< DdType::Sylvan > const &cube) const
InternalAdd< DdType::Sylvan, storm::RationalNumber > minAbstract(InternalBdd< DdType::Sylvan > const &cube) const
InternalBdd< DdType::CUDD > less(storm::RationalNumber const &value) const
InternalAdd< DdType::Sylvan, storm::RationalNumber > logxy(InternalAdd< DdType::Sylvan, storm::RationalNumber > const &) const
DdNode * fromVectorRec(::DdManager *manager, uint_fast64_t &currentOffset, uint_fast64_t currentLevel, uint_fast64_t maxLevel, std::vector< storm::RationalNumber > const &values, Odd const &odd, std::vector< uint_fast64_t > const &ddVariableIndices)
InternalAdd< DdType::Sylvan, storm::RationalNumber > minimum(InternalAdd< DdType::Sylvan, storm::RationalNumber > const &other) const
InternalAdd< DdType::Sylvan, storm::RationalNumber > mod(InternalAdd< DdType::Sylvan, storm::RationalNumber > const &other) const
InternalBdd< DdType::CUDD > greater(storm::RationalNumber const &value) const
LabParser.cpp.
Definition cli.cpp:18