Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
CuddAddIterator.h
Go to the documentation of this file.
1#pragma once
2
3#include "storm-config.h"
4
5#include <cstdint>
6#include <memory>
7#include <set>
8#include <tuple>
9#include <utility>
10
13
14#ifdef STORM_HAVE_CUDD
15// Include the C++-interface of CUDD.
16#include "cuddObj.hh"
17#endif
18
19namespace storm {
20namespace dd {
21// Forward-declare the DdManager class.
22template<DdType Type>
23class DdManager;
24
25template<DdType Type, typename ValueType>
27
28template<typename ValueType>
29class AddIterator<DdType::CUDD, ValueType> {
30 public:
31 friend class InternalAdd<DdType::CUDD, ValueType>;
32
33 // Default-instantiate the constructor.
35
36 // Forbid copy-construction and copy assignment, because ownership of the internal pointer is unclear then.
37 AddIterator(AddIterator<DdType::CUDD, ValueType> const& other) = delete;
38 AddIterator& operator=(AddIterator<DdType::CUDD, ValueType> const& other) = delete;
39
40 // Provide move-construction and move-assignment, though.
41 AddIterator(AddIterator<DdType::CUDD, ValueType>&& other);
42 AddIterator& operator=(AddIterator<DdType::CUDD, ValueType>&& other);
43
47 ~AddIterator();
48
52 AddIterator<DdType::CUDD, ValueType>& operator++();
53
60 std::pair<storm::expressions::SimpleValuation, ValueType> operator*() const;
61
69 bool operator==(AddIterator<DdType::CUDD, ValueType> const& other) const;
70
78 bool operator!=(AddIterator<DdType::CUDD, ValueType> const& other) const;
79
80 private:
81#ifdef STORM_HAVE_CUDD
95 AddIterator(DdManager<DdType::CUDD> const& ddManager, DdGen* generator, int* cube, ValueType const& value, bool isAtEnd,
96 std::set<storm::expressions::Variable> const* metaVariables = nullptr, bool enumerateDontCareMetaVariables = true);
97
101 void treatNewCube();
102
106 void treatNextInCube();
107
108 // The manager responsible for the meta variables (and therefore the underlying DD).
109 DdManager<DdType::CUDD> const* ddManager;
110
111 // The CUDD generator used to enumerate the cubes of the DD.
112 DdGen* generator;
113
114 // The currently considered cube of the DD.
115 int* cube;
116
117 // The function value of the current cube.
118 double valueAsDouble;
119
120 // A flag that indicates whether the iterator is at its end and may not be moved further. This is also used
121 // for the check against the end iterator.
122 bool isAtEnd;
123
124 // The set of meta variables appearing in the DD.
125 std::set<storm::expressions::Variable> const* metaVariables;
126
127 // A flag that indicates whether the iterator is supposed to enumerate meta variable valuations even if
128 // they don't influence the function value.
129 bool enumerateDontCareMetaVariables;
130
131 // A number that represents how many assignments of the current cube have already been returned previously.
132 // This is needed, because cubes may represent many assignments (if they have don't care variables).
133 uint_fast64_t cubeCounter;
134
135 // A vector of tuples of the form <metaVariable, bitIndex>.
136 std::vector<std::tuple<storm::expressions::Variable, uint_fast64_t>> relevantDontCareDdVariables;
137
138 // The current valuation of meta variables.
140#endif
141};
142} // namespace dd
143} // namespace storm
A simple implementation of the valuation interface.