Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
InternalSylvanAdd.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANADD_H_
2#define STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANADD_H_
3
4#include <set>
5#include <unordered_map>
6
10
13
15
16#include "storm-config.h"
18
19namespace storm {
20namespace storage {
21template<typename T>
22class SparseMatrix;
23
24class BitVector;
25
26template<typename E, typename V>
27class MatrixEntry;
28} // namespace storage
29
30namespace dd {
31template<DdType LibraryType>
32class DdManager;
33
34template<DdType LibraryType>
36
37template<DdType LibraryType>
38class InternalBdd;
39
40template<DdType LibraryType, typename ValueType>
41class AddIterator;
42
43template<typename ValueType>
44class InternalAdd<DdType::Sylvan, ValueType> {
45 public:
46 friend class AddIterator<DdType::Sylvan, ValueType>;
47 friend class InternalBdd<DdType::Sylvan>;
48
55 InternalAdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Mtbdd const& sylvanMtbdd);
56
57 // Instantiate all copy/move constructors/assignments with the default implementation.
59 InternalAdd(InternalAdd<DdType::Sylvan, ValueType> const& other) = default;
60 InternalAdd& operator=(InternalAdd<DdType::Sylvan, ValueType> const& other) = default;
61 InternalAdd(InternalAdd<DdType::Sylvan, ValueType>&& other) = default;
62 InternalAdd& operator=(InternalAdd<DdType::Sylvan, ValueType>&& other) = default;
63 virtual ~InternalAdd() = default;
64
71 bool operator==(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
72
79 bool operator!=(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
80
87 InternalAdd<DdType::Sylvan, ValueType> operator+(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
88
95 InternalAdd<DdType::Sylvan, ValueType>& operator+=(InternalAdd<DdType::Sylvan, ValueType> const& other);
96
103 InternalAdd<DdType::Sylvan, ValueType> operator*(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
104
111 InternalAdd<DdType::Sylvan, ValueType>& operator*=(InternalAdd<DdType::Sylvan, ValueType> const& other);
112
119 InternalAdd<DdType::Sylvan, ValueType> operator-(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
120
127 InternalAdd<DdType::Sylvan, ValueType>& operator-=(InternalAdd<DdType::Sylvan, ValueType> const& other);
128
135 InternalAdd<DdType::Sylvan, ValueType> operator/(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
136
143 InternalAdd<DdType::Sylvan, ValueType>& operator/=(InternalAdd<DdType::Sylvan, ValueType> const& other);
144
151 InternalBdd<DdType::Sylvan> equals(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
152
159 InternalBdd<DdType::Sylvan> notEquals(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
160
168 InternalBdd<DdType::Sylvan> less(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
169
177 InternalBdd<DdType::Sylvan> lessOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
178
186 InternalBdd<DdType::Sylvan> greater(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
187
195 InternalBdd<DdType::Sylvan> greaterOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
196
203 InternalAdd<DdType::Sylvan, ValueType> pow(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
204
211 InternalAdd<DdType::Sylvan, ValueType> mod(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
212
220 InternalAdd<DdType::Sylvan, ValueType> logxy(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
221
227 InternalAdd<DdType::Sylvan, ValueType> floor() const;
228
234 InternalAdd<DdType::Sylvan, ValueType> ceil() const;
235
241 InternalAdd<DdType::Sylvan, storm::RationalNumber> sharpenKwekMehlhorn(size_t precision) const;
242
249 InternalAdd<DdType::Sylvan, ValueType> minimum(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
250
257 InternalAdd<DdType::Sylvan, ValueType> maximum(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
258
264 template<typename TargetValueType>
265 InternalAdd<DdType::Sylvan, TargetValueType> toValueType() const;
266
272 InternalAdd<DdType::Sylvan, ValueType> sumAbstract(InternalBdd<DdType::Sylvan> const& cube) const;
273
279 InternalAdd<DdType::Sylvan, ValueType> minAbstract(InternalBdd<DdType::Sylvan> const& cube) const;
280
286 InternalBdd<DdType::Sylvan> minAbstractRepresentative(InternalBdd<DdType::Sylvan> const& cube) const;
287
293 InternalAdd<DdType::Sylvan, ValueType> maxAbstract(InternalBdd<DdType::Sylvan> const& cube) const;
294
300 InternalBdd<DdType::Sylvan> maxAbstractRepresentative(InternalBdd<DdType::Sylvan> const& cube) const;
301
311 bool equalModuloPrecision(InternalAdd<DdType::Sylvan, ValueType> const& other, ValueType const& precision, bool relative = true) const;
312
321 InternalAdd<DdType::Sylvan, ValueType> swapVariables(std::vector<InternalBdd<DdType::Sylvan>> const& from,
322 std::vector<InternalBdd<DdType::Sylvan>> const& to) const;
323
332 InternalAdd<DdType::Sylvan, ValueType> permuteVariables(std::vector<InternalBdd<DdType::Sylvan>> const& from,
333 std::vector<InternalBdd<DdType::Sylvan>> const& to) const;
334
343 InternalAdd<DdType::Sylvan, ValueType> multiplyMatrix(InternalAdd<DdType::Sylvan, ValueType> const& otherMatrix,
344 std::vector<InternalBdd<DdType::Sylvan>> const& summationDdVariables) const;
345
354 InternalAdd<DdType::Sylvan, ValueType> multiplyMatrix(InternalBdd<DdType::Sylvan> const& otherMatrix,
355 std::vector<InternalBdd<DdType::Sylvan>> const& summationDdVariables) const;
356
364 InternalBdd<DdType::Sylvan> greater(ValueType const& value) const;
365
373 InternalBdd<DdType::Sylvan> greaterOrEqual(ValueType const& value) const;
374
382 InternalBdd<DdType::Sylvan> less(ValueType const& value) const;
383
391 InternalBdd<DdType::Sylvan> lessOrEqual(ValueType const& value) const;
392
399 InternalBdd<DdType::Sylvan> notZero() const;
400
409 InternalAdd<DdType::Sylvan, ValueType> constrain(InternalAdd<DdType::Sylvan, ValueType> const& constraint) const;
410
419 InternalAdd<DdType::Sylvan, ValueType> restrict(InternalAdd<DdType::Sylvan, ValueType> const& constraint) const;
420
426 InternalBdd<DdType::Sylvan> getSupport() const;
427
434 virtual uint_fast64_t getNonZeroCount(uint_fast64_t numberOfDdVariables) const;
435
441 virtual uint_fast64_t getLeafCount() const;
442
448 virtual uint_fast64_t getNodeCount() const;
449
455 ValueType getMin() const;
456
462 ValueType getMax() const;
463
469 ValueType getValue() const;
470
476 bool isOne() const;
477
483 bool isZero() const;
484
490 bool isConstant() const;
491
497 uint_fast64_t getIndex() const;
498
504 uint_fast64_t getLevel() const;
505
512 void exportToDot(std::string const& filename, std::vector<std::string> const& ddVariableNamesAsStrings, bool showVariablesIfPossible = true) const;
513
519 void exportToText(std::string const& filename) const;
520
532 AddIterator<DdType::Sylvan, ValueType> begin(DdManager<DdType::Sylvan> const& fullDdManager, InternalBdd<DdType::Sylvan> const& variableCube,
533 uint_fast64_t numberOfDdVariables, std::set<storm::expressions::Variable> const& metaVariables,
534 bool enumerateDontCareMetaVariables = true) const;
535
542 AddIterator<DdType::Sylvan, ValueType> end(DdManager<DdType::Sylvan> const& fullDdManager) const;
543
554 void composeWithExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, std::vector<ValueType>& targetVector,
555 std::function<ValueType(ValueType const&, ValueType const&)> const& function) const;
556
568 void composeWithExplicitVector(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices, std::vector<uint_fast64_t> const& offsets,
569 std::vector<ValueType>& targetVector, std::function<ValueType(ValueType const&, ValueType const&)> const& function) const;
570
581 void forEach(Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices,
582 std::function<void(uint64_t const&, ValueType const&)> const& function) const;
583
590 std::vector<InternalAdd<DdType::Sylvan, ValueType>> splitIntoGroups(std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
591
600 std::vector<uint64_t> decodeGroupLabels(std::vector<uint_fast64_t> const& ddGroupVariableIndices,
601 storm::storage::BitVector const& ddLabelVariableIndices) const;
602
612 std::vector<std::pair<InternalAdd<DdType::Sylvan, ValueType>, InternalAdd<DdType::Sylvan, ValueType>>> splitIntoGroups(
613 InternalAdd<DdType::Sylvan, ValueType> vector, std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
614
624 std::vector<std::vector<InternalAdd<DdType::Sylvan, ValueType>>> splitIntoGroups(std::vector<InternalAdd<DdType::Sylvan, ValueType>> const& vectors,
625 std::vector<uint_fast64_t> const& ddGroupVariableIndices) const;
626
640 void toMatrixComponents(std::vector<uint_fast64_t> const& rowGroupIndices, std::vector<uint_fast64_t>& rowIndications,
641 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>>& columnsAndValues, Odd const& rowOdd, Odd const& columnOdd,
642 std::vector<uint_fast64_t> const& ddRowVariableIndices, std::vector<uint_fast64_t> const& ddColumnVariableIndices,
643 bool writeValues) const;
644
653 static InternalAdd<DdType::Sylvan, ValueType> fromVector(InternalDdManager<DdType::Sylvan> const* ddManager, std::vector<ValueType> const& values,
654 storm::dd::Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices);
655
661 Odd createOdd(std::vector<uint_fast64_t> const& ddVariableIndices) const;
662
663 InternalDdManager<DdType::Sylvan> const& getInternalDdManager() const;
664
670 sylvan::Mtbdd getSylvanMtbdd() const;
671
677 static ValueType getValue(MTBDD const& node);
678
679 std::string getStringId() const;
680
681 private:
693 static std::shared_ptr<Odd> createOddRec(BDD dd, uint_fast64_t currentLevel, uint_fast64_t maxLevel, std::vector<uint_fast64_t> const& ddVariableIndices,
694 std::vector<std::unordered_map<BDD, std::shared_ptr<Odd>>>& uniqueTableForLevels);
695
708 void forEachRec(MTBDD dd, uint_fast64_t currentLevel, uint_fast64_t maxLevel, uint_fast64_t currentOffset, Odd const& odd,
709 std::vector<uint_fast64_t> const& ddVariableIndices, std::function<void(uint64_t const&, ValueType const&)> const& function) const;
710
723 void decodeGroupLabelsRec(MTBDD dd, std::vector<uint64_t>& labels, std::vector<uint_fast64_t> const& ddGroupVariableIndices,
724 storm::storage::BitVector const& ddLabelVariableIndices, uint_fast64_t currentLevel, uint_fast64_t maxLevel,
725 uint64_t label) const;
726
737 void splitIntoGroupsRec(MTBDD dd, bool negated, std::vector<InternalAdd<DdType::Sylvan, ValueType>>& groups,
738 std::vector<uint_fast64_t> const& ddGroupVariableIndices, uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
739
752 void splitIntoGroupsRec(MTBDD dd1, bool negated1, MTBDD dd2, bool negated2,
753 std::vector<std::pair<InternalAdd<DdType::Sylvan, ValueType>, InternalAdd<DdType::Sylvan, ValueType>>>& groups,
754 std::vector<uint_fast64_t> const& ddGroupVariableIndices, uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
755
766 void splitIntoGroupsRec(std::vector<MTBDD> const& dds, storm::storage::BitVector const& negatedDds,
767 std::vector<std::vector<InternalAdd<DdType::Sylvan, ValueType>>>& groups, std::vector<uint_fast64_t> const& ddGroupVariableIndices,
768 uint_fast64_t currentLevel, uint_fast64_t maxLevel) const;
769
781 static MTBDD fromVectorRec(uint_fast64_t& currentOffset, uint_fast64_t currentLevel, uint_fast64_t maxLevel, std::vector<ValueType> const& values,
782 Odd const& odd, std::vector<uint_fast64_t> const& ddVariableIndices);
783
810 void toMatrixComponentsRec(MTBDD dd, bool negated, std::vector<uint_fast64_t> const& rowGroupOffsets, std::vector<uint_fast64_t>& rowIndications,
811 std::vector<storm::storage::MatrixEntry<uint_fast64_t, ValueType>>& columnsAndValues, Odd const& rowOdd, Odd const& columnOdd,
812 uint_fast64_t currentRowLevel, uint_fast64_t currentColumnLevel, uint_fast64_t maxLevel, uint_fast64_t currentRowOffset,
813 uint_fast64_t currentColumnOffset, std::vector<uint_fast64_t> const& ddRowVariableIndices,
814 std::vector<uint_fast64_t> const& ddColumnVariableIndices, bool writeValues) const;
815
821 static MTBDD getLeaf(double value);
822
828 static MTBDD getLeaf(uint_fast64_t value);
829
835 static MTBDD getLeaf(storm::RationalNumber const& value);
836
837#ifdef STORM_HAVE_CARL
843 static MTBDD getLeaf(storm::RationalFunction const& value);
844#endif
845
846 // The manager responsible for this MTBDD.
847 InternalDdManager<DdType::Sylvan> const* ddManager;
848
849 // The underlying sylvan MTBDD.
850 sylvan::Mtbdd sylvanMtbdd;
851};
852} // namespace dd
853} // namespace storm
854
855#endif /* STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANADD_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