Storm 1.14.0.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 <cstdint>
4#include <functional>
5#include <map>
6#include <memory>
7#include <unordered_set>
8#include <vector>
9
10namespace storm {
11namespace storage {
12class BitVector;
13}
14
15namespace dd {
16class Odd {
17 public:
26 Odd(std::shared_ptr<Odd> elseNode, uint_fast64_t elseOffset, std::shared_ptr<Odd> thenNode, uint_fast64_t thenOffset);
27
28 // Instantiate all copy/move constructors/assignments with the default implementation.
29 Odd() = default;
30 Odd(Odd const& other) = default;
31 Odd& operator=(Odd const& other) = default;
32 Odd(Odd&& other) = default;
33 Odd& operator=(Odd&& other) = default;
34
40 Odd const& getThenSuccessor() const;
41
47 Odd const& getElseSuccessor() const;
48
54 uint_fast64_t getElseOffset() const;
55
61 void setElseOffset(uint_fast64_t newOffset);
62
68 uint_fast64_t getThenOffset() const;
69
75 void setThenOffset(uint_fast64_t newOffset);
76
82 uint_fast64_t getTotalOffset() const;
83
90 uint_fast64_t getNodeCount() const;
91
97 uint_fast64_t getHeight() const;
98
104 bool isTerminalNode() const;
105
114 template<typename ValueType>
115 void expandExplicitVector(storm::dd::Odd const& newOdd, std::vector<ValueType> const& oldValues, std::vector<ValueType>& newValues) const;
116
125 void oldToNewIndex(storm::dd::Odd const& newOdd, std::function<void(uint64_t oldOffset, uint64_t newOffset)> const& callback) const;
126
132 void exportToDot(std::string const& filename) const;
133
139 void exportToText(std::string const& filename) const;
140
148 storm::storage::BitVector getEncoding(uint64_t offset, uint64_t variableCount = 0) const;
149
150 private:
157 void addToLevelToOddNodesMap(std::map<uint_fast64_t, std::unordered_set<storm::dd::Odd const*>>& levelToOddNodesMap, uint_fast64_t level = 0) const;
158
170 template<typename ValueType>
171 static void expandValuesToVectorRec(uint_fast64_t oldOffset, storm::dd::Odd const& oldOdd, std::vector<ValueType> const& oldValues, uint_fast64_t newOffset,
172 storm::dd::Odd const& newOdd, std::vector<ValueType>& newValues);
173
174 static void oldToNewIndexRec(uint_fast64_t oldOffset, storm::dd::Odd const& oldOdd, uint_fast64_t newOffset, storm::dd::Odd const& newOdd,
175 std::function<void(uint64_t oldOffset, uint64_t newOffset)> const& callback);
176
177 // The then- and else-nodes.
178 std::shared_ptr<Odd> elseNode;
179 std::shared_ptr<Odd> thenNode;
180
181 // The offsets that need to be added if the then- or else-successor is taken, respectively.
182 uint_fast64_t elseOffset;
183 uint_fast64_t thenOffset;
184};
185} // namespace dd
186} // namespace storm
Odd const & getThenSuccessor() const
Retrieves the then-successor of this ODD node.
Definition Odd.cpp:20
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:76
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:168
uint_fast64_t getNodeCount() const
Retrieves the size of the ODD.
Definition Odd.cpp:48
uint_fast64_t getTotalOffset() const
Retrieves the total offset, i.e., the sum of the then- and else-offset.
Definition Odd.cpp:44
uint_fast64_t getElseOffset() const
Retrieves the else-offset of this ODD node.
Definition Odd.cpp:28
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:95
Odd(std::shared_ptr< Odd > elseNode, uint_fast64_t elseOffset, std::shared_ptr< Odd > thenNode, uint_fast64_t thenOffset)
Constructs an offset-labeled DD with the given topmost DD node, else- and then-successor.
Definition Odd.cpp:15
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:32
uint_fast64_t getHeight() const
Retrieves the height of the ODD.
Definition Odd.cpp:62
bool isTerminalNode() const
Checks whether the given ODD node is a terminal node, i.e.
Definition Odd.cpp:71
Odd(Odd &&other)=default
void setThenOffset(uint_fast64_t newOffset)
Sets the then-offset of this ODD node.
Definition Odd.cpp:40
storm::storage::BitVector getEncoding(uint64_t offset, uint64_t variableCount=0) const
Retrieves the encoding for the given offset.
Definition Odd.cpp:186
Odd const & getElseSuccessor() const
Retrieves the else-successor of this ODD node.
Definition Odd.cpp:24
void exportToDot(std::string const &filename) const
Exports the ODD in the dot format to the given file.
Definition Odd.cpp:124
Odd()=default
uint_fast64_t getThenOffset() const
Retrieves the then-offset of this ODD node.
Definition Odd.cpp:36
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16