Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Odd.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DD_ODD_H_
2#define STORM_STORAGE_DD_ODD_H_
3
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:
27 Odd(std::shared_ptr<Odd> elseNode, uint_fast64_t elseOffset, std::shared_ptr<Odd> thenNode, uint_fast64_t thenOffset);
28
29 // Instantiate all copy/move constructors/assignments with the default implementation.
30 Odd() = default;
31 Odd(Odd const& other) = default;
32 Odd& operator=(Odd const& other) = default;
33#ifndef WINDOWS
34 Odd(Odd&& other) = default;
35 Odd& operator=(Odd&& other) = default;
36#endif
37
43 Odd const& getThenSuccessor() const;
44
50 Odd const& getElseSuccessor() const;
51
57 uint_fast64_t getElseOffset() const;
58
64 void setElseOffset(uint_fast64_t newOffset);
65
71 uint_fast64_t getThenOffset() const;
72
78 void setThenOffset(uint_fast64_t newOffset);
79
85 uint_fast64_t getTotalOffset() const;
86
93 uint_fast64_t getNodeCount() const;
94
100 uint_fast64_t getHeight() const;
101
107 bool isTerminalNode() const;
108
117 template<typename ValueType>
118 void expandExplicitVector(storm::dd::Odd const& newOdd, std::vector<ValueType> const& oldValues, std::vector<ValueType>& newValues) const;
119
128 void oldToNewIndex(storm::dd::Odd const& newOdd, std::function<void(uint64_t oldOffset, uint64_t newOffset)> const& callback) const;
129
135 void exportToDot(std::string const& filename) const;
136
142 void exportToText(std::string const& filename) const;
143
151 storm::storage::BitVector getEncoding(uint64_t offset, uint64_t variableCount = 0) const;
152
153 private:
160 void addToLevelToOddNodesMap(std::map<uint_fast64_t, std::unordered_set<storm::dd::Odd const*>>& levelToOddNodesMap, uint_fast64_t level = 0) const;
161
173 template<typename ValueType>
174 static void expandValuesToVectorRec(uint_fast64_t oldOffset, storm::dd::Odd const& oldOdd, std::vector<ValueType> const& oldValues, uint_fast64_t newOffset,
175 storm::dd::Odd const& newOdd, std::vector<ValueType>& newValues);
176
177 static void oldToNewIndexRec(uint_fast64_t oldOffset, storm::dd::Odd const& oldOdd, uint_fast64_t newOffset, storm::dd::Odd const& newOdd,
178 std::function<void(uint64_t oldOffset, uint64_t newOffset)> const& callback);
179
180 // The then- and else-nodes.
181 std::shared_ptr<Odd> elseNode;
182 std::shared_ptr<Odd> thenNode;
183
184 // The offsets that need to be added if the then- or else-successor is taken, respectively.
185 uint_fast64_t elseOffset;
186 uint_fast64_t thenOffset;
187};
188} // namespace dd
189} // namespace storm
190
191#endif /* STORM_STORAGE_DD_ODD_H_ */
Odd const & getThenSuccessor() const
Retrieves the then-successor of this ODD node.
Definition Odd.cpp:23
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:79
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:172
uint_fast64_t getNodeCount() const
Retrieves the size of the ODD.
Definition Odd.cpp:51
uint_fast64_t getTotalOffset() const
Retrieves the total offset, i.e., the sum of the then- and else-offset.
Definition Odd.cpp:47
uint_fast64_t getElseOffset() const
Retrieves the else-offset of this ODD node.
Definition Odd.cpp:31
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:98
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:35
uint_fast64_t getHeight() const
Retrieves the height of the ODD.
Definition Odd.cpp:65
bool isTerminalNode() const
Checks whether the given ODD node is a terminal node, i.e.
Definition Odd.cpp:74
Odd(Odd &&other)=default
void setThenOffset(uint_fast64_t newOffset)
Sets the then-offset of this ODD node.
Definition Odd.cpp:43
storm::storage::BitVector getEncoding(uint64_t offset, uint64_t variableCount=0) const
Retrieves the encoding for the given offset.
Definition Odd.cpp:190
Odd const & getElseSuccessor() const
Retrieves the else-successor of this ODD node.
Definition Odd.cpp:27
void exportToDot(std::string const &filename) const
Exports the ODD in the dot format to the given file.
Definition Odd.cpp:127
Odd()=default
uint_fast64_t getThenOffset() const
Retrieves the then-offset of this ODD node.
Definition Odd.cpp:39
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