Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Odd.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <map>
5#include <memory>
6#include <unordered_set>
7#include <vector>
8
9namespace storm {
10namespace storage {
11class BitVector;
12}
13
14namespace dd {
15class Odd {
16 public:
25 Odd(std::shared_ptr<Odd> elseNode, uint_fast64_t elseOffset, std::shared_ptr<Odd> thenNode, uint_fast64_t thenOffset);
26
27 // Instantiate all copy/move constructors/assignments with the default implementation.
28 Odd() = default;
29 Odd(Odd const& other) = default;
30 Odd& operator=(Odd const& other) = default;
31 Odd(Odd&& other) = default;
32 Odd& operator=(Odd&& other) = default;
33
39 Odd const& getThenSuccessor() const;
40
46 Odd const& getElseSuccessor() const;
47
53 uint_fast64_t getElseOffset() const;
54
60 void setElseOffset(uint_fast64_t newOffset);
61
67 uint_fast64_t getThenOffset() const;
68
74 void setThenOffset(uint_fast64_t newOffset);
75
81 uint_fast64_t getTotalOffset() const;
82
89 uint_fast64_t getNodeCount() const;
90
96 uint_fast64_t getHeight() const;
97
103 bool isTerminalNode() const;
104
113 template<typename ValueType>
114 void expandExplicitVector(storm::dd::Odd const& newOdd, std::vector<ValueType> const& oldValues, std::vector<ValueType>& newValues) const;
115
124 void oldToNewIndex(storm::dd::Odd const& newOdd, std::function<void(uint64_t oldOffset, uint64_t newOffset)> const& callback) const;
125
131 void exportToDot(std::string const& filename) const;
132
138 void exportToText(std::string const& filename) const;
139
147 storm::storage::BitVector getEncoding(uint64_t offset, uint64_t variableCount = 0) const;
148
149 private:
156 void addToLevelToOddNodesMap(std::map<uint_fast64_t, std::unordered_set<storm::dd::Odd const*>>& levelToOddNodesMap, uint_fast64_t level = 0) const;
157
169 template<typename ValueType>
170 static void expandValuesToVectorRec(uint_fast64_t oldOffset, storm::dd::Odd const& oldOdd, std::vector<ValueType> const& oldValues, uint_fast64_t newOffset,
171 storm::dd::Odd const& newOdd, std::vector<ValueType>& newValues);
172
173 static void oldToNewIndexRec(uint_fast64_t oldOffset, storm::dd::Odd const& oldOdd, uint_fast64_t newOffset, storm::dd::Odd const& newOdd,
174 std::function<void(uint64_t oldOffset, uint64_t newOffset)> const& callback);
175
176 // The then- and else-nodes.
177 std::shared_ptr<Odd> elseNode;
178 std::shared_ptr<Odd> thenNode;
179
180 // The offsets that need to be added if the then- or else-successor is taken, respectively.
181 uint_fast64_t elseOffset;
182 uint_fast64_t thenOffset;
183};
184} // namespace dd
185} // namespace storm
Odd const & getThenSuccessor() const
Retrieves the then-successor of this ODD node.
Definition Odd.cpp:21
void expandExplicitVector(storm::dd::Odd const &newOdd, std::vector< ValueType > const &oldValues, std::vector< ValueType > &newValues) const
Adds the old values to the new values.
Definition Odd.cpp:77
Odd & operator=(Odd const &other)=default
void exportToText(std::string const &filename) const
Exports the ODD in the text format to the given file.
Definition Odd.cpp:169
uint_fast64_t getNodeCount() const
Retrieves the size of the ODD.
Definition Odd.cpp:49
uint_fast64_t getTotalOffset() const
Retrieves the total offset, i.e., the sum of the then- and else-offset.
Definition Odd.cpp:45
uint_fast64_t getElseOffset() const
Retrieves the else-offset of this ODD node.
Definition Odd.cpp:29
void oldToNewIndex(storm::dd::Odd const &newOdd, std::function< void(uint64_t oldOffset, uint64_t newOffset)> const &callback) const
Translates the indices of the old ODD to that of the new ODD by calling the callback for each old-new...
Definition Odd.cpp:96
Odd & operator=(Odd &&other)=default
Odd(Odd const &other)=default
void setElseOffset(uint_fast64_t newOffset)
Sets the else-offset of this ODD node.
Definition Odd.cpp:33
uint_fast64_t getHeight() const
Retrieves the height of the ODD.
Definition Odd.cpp:63
bool isTerminalNode() const
Checks whether the given ODD node is a terminal node, i.e.
Definition Odd.cpp:72
Odd(Odd &&other)=default
void setThenOffset(uint_fast64_t newOffset)
Sets the then-offset of this ODD node.
Definition Odd.cpp:41
storm::storage::BitVector getEncoding(uint64_t offset, uint64_t variableCount=0) const
Retrieves the encoding for the given offset.
Definition Odd.cpp:187
Odd const & getElseSuccessor() const
Retrieves the else-successor of this ODD node.
Definition Odd.cpp:25
void exportToDot(std::string const &filename) const
Exports the ODD in the dot format to the given file.
Definition Odd.cpp:125
Odd()=default
uint_fast64_t getThenOffset() const
Retrieves the then-offset of this ODD node.
Definition Odd.cpp:37
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
storage::BitVector BitVector