16template<
typename ValueType>
17AddIterator<DdType::CUDD, ValueType>::AddIterator()
24 enumerateDontCareMetaVariables(),
26 relevantDontCareDdVariables(),
31template<
typename ValueType>
32AddIterator<DdType::CUDD, ValueType>::AddIterator(DdManager<DdType::CUDD>
const& ddManager, DdGen* generator,
int* cube, ValueType
const& value,
bool isAtEnd,
33 std::set<storm::expressions::Variable>
const* metaVariables,
bool enumerateDontCareMetaVariables)
34 : ddManager(&ddManager),
39 metaVariables(metaVariables),
40 enumerateDontCareMetaVariables(enumerateDontCareMetaVariables),
42 relevantDontCareDdVariables(),
43 currentValuation(ddManager.getExpressionManager().getSharedPointer()) {
52template<
typename ValueType>
53AddIterator<DdType::CUDD, ValueType>::AddIterator(AddIterator<DdType::CUDD, ValueType>&& other)
54 : ddManager(other.ddManager),
55 generator(other.generator),
57 valueAsDouble(other.valueAsDouble),
58 isAtEnd(other.isAtEnd),
59 metaVariables(other.metaVariables),
60 cubeCounter(other.cubeCounter),
61 relevantDontCareDdVariables(other.relevantDontCareDdVariables),
62 currentValuation(other.currentValuation) {
65 other.generator =
nullptr;
68template<
typename ValueType>
69AddIterator<DdType::CUDD, ValueType>& AddIterator<DdType::CUDD, ValueType>::operator=(AddIterator<DdType::CUDD, ValueType>&& other) {
71 this->ddManager = other.ddManager;
72 this->generator = other.generator;
73 this->cube = other.cube;
74 this->valueAsDouble = other.valueAsDouble;
75 this->isAtEnd = other.isAtEnd;
76 this->metaVariables = other.metaVariables;
77 this->cubeCounter = other.cubeCounter;
78 this->relevantDontCareDdVariables = other.relevantDontCareDdVariables;
79 this->currentValuation = other.currentValuation;
83 other.generator =
nullptr;
88template<
typename ValueType>
89AddIterator<DdType::CUDD, ValueType>::~AddIterator() {
92 free(this->generator);
95template<
typename ValueType>
96AddIterator<DdType::CUDD, ValueType>& AddIterator<DdType::CUDD, ValueType>::operator++() {
97 STORM_LOG_ASSERT(!this->isAtEnd,
"Illegally incrementing iterator that is already at its end.");
101 if (this->relevantDontCareDdVariables.empty() || this->cubeCounter >= std::pow(2, this->relevantDontCareDdVariables.size()) - 1) {
103 cudd::ABDD::NextCube(generator, &cube, &valueAsDouble);
104 this->isAtEnd = (Cudd_IsGenEmpty(generator) != 0);
107 if (!this->isAtEnd) {
108 this->treatNewCube();
112 this->treatNextInCube();
118template<
typename ValueType>
119void AddIterator<DdType::CUDD, ValueType>::treatNextInCube() {
123 for (uint_fast64_t index = 0; index < this->relevantDontCareDdVariables.size(); ++index) {
124 auto const& ddMetaVariable = this->ddManager->getMetaVariable(std::get<0>(this->relevantDontCareDdVariables[index]));
125 if (ddMetaVariable.getType() == MetaVariableType::Bool) {
126 if ((this->cubeCounter & (1ull << index)) != 0) {
127 currentValuation.setBooleanValue(std::get<0>(this->relevantDontCareDdVariables[index]),
true);
129 currentValuation.setBooleanValue(std::get<0>(this->relevantDontCareDdVariables[index]),
false);
133 if ((this->cubeCounter & (1ull << index)) != 0) {
134 currentValuation.setBitVectorValue(metaVariable, ((currentValuation.getBitVectorValue(metaVariable) - ddMetaVariable.getLow()) |
135 (1ull << std::get<1>(this->relevantDontCareDdVariables[index]))) +
136 ddMetaVariable.getLow());
138 currentValuation.setBitVectorValue(metaVariable, ((currentValuation.getBitVectorValue(metaVariable) - ddMetaVariable.getLow()) &
139 ~(1ull << std::get<1>(this->relevantDontCareDdVariables[index]))) +
140 ddMetaVariable.getLow());
146template<
typename ValueType>
147void AddIterator<DdType::CUDD, ValueType>::treatNewCube() {
148 this->relevantDontCareDdVariables.clear();
153 for (
auto const& metaVariable : *this->metaVariables) {
154 bool metaVariableAppearsInCube =
false;
155 std::vector<std::tuple<storm::expressions::Variable, uint_fast64_t>> localRelevantDontCareDdVariables;
156 auto const& ddMetaVariable = this->ddManager->getMetaVariable(metaVariable);
157 if (ddMetaVariable.getType() == MetaVariableType::Bool) {
158 if (this->cube[ddMetaVariable.getDdVariables().front().getIndex()] == 0) {
159 metaVariableAppearsInCube =
true;
160 currentValuation.setBooleanValue(metaVariable,
false);
161 }
else if (this->cube[ddMetaVariable.getDdVariables().front().getIndex()] == 1) {
162 metaVariableAppearsInCube =
true;
163 currentValuation.setBooleanValue(metaVariable,
true);
165 currentValuation.setBooleanValue(metaVariable,
false);
166 localRelevantDontCareDdVariables.push_back(std::make_tuple(metaVariable, 0));
169 int_fast64_t intValue = 0;
170 for (uint_fast64_t bitIndex = 0; bitIndex < ddMetaVariable.getNumberOfDdVariables(); ++bitIndex) {
171 if (cube[ddMetaVariable.getDdVariables()[bitIndex].getIndex()] == 0) {
173 metaVariableAppearsInCube =
true;
174 }
else if (cube[ddMetaVariable.getDdVariables()[bitIndex].getIndex()] == 1) {
175 intValue |= 1ull << (ddMetaVariable.getNumberOfDdVariables() - bitIndex - 1);
176 metaVariableAppearsInCube =
true;
180 localRelevantDontCareDdVariables.push_back(std::make_tuple(metaVariable, ddMetaVariable.getNumberOfDdVariables() - bitIndex - 1));
183 if (this->enumerateDontCareMetaVariables || metaVariableAppearsInCube) {
184 currentValuation.setBitVectorValue(metaVariable, intValue + ddMetaVariable.getLow());
190 if (this->enumerateDontCareMetaVariables || metaVariableAppearsInCube) {
191 relevantDontCareDdVariables.insert(relevantDontCareDdVariables.end(), localRelevantDontCareDdVariables.begin(),
192 localRelevantDontCareDdVariables.end());
197 this->cubeCounter = 0;
200template<
typename ValueType>
201bool AddIterator<DdType::CUDD, ValueType>::operator==(AddIterator<DdType::CUDD, ValueType>
const& other)
const {
202 if (this->isAtEnd && other.isAtEnd) {
205 return this->ddManager == other.ddManager && this->generator == other.generator && this->cube == other.cube &&
206 this->valueAsDouble == other.valueAsDouble && this->isAtEnd == other.isAtEnd && this->metaVariables == other.metaVariables &&
207 this->cubeCounter == other.cubeCounter && this->relevantDontCareDdVariables == other.relevantDontCareDdVariables &&
208 this->currentValuation == other.currentValuation;
212template<
typename ValueType>
213bool AddIterator<DdType::CUDD, ValueType>::operator!=(AddIterator<DdType::CUDD, ValueType>
const& other)
const {
214 return !(*
this == other);
217template<
typename ValueType>
218std::pair<storm::expressions::SimpleValuation, ValueType> AddIterator<DdType::CUDD, ValueType>::operator*()
const {
219 return std::make_pair(currentValuation, storm::utility::convertNumber<ValueType>(valueAsDouble));
223template<
typename ValueType>
226 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
227 "of Storm with CUDD support.");
230template<
typename ValueType>
233 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
234 "of Storm with CUDD support.");
237template<
typename ValueType>
240 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
241 "of Storm with CUDD support.");
244template<
typename ValueType>
247template<
typename ValueType>
250 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
251 "of Storm with CUDD support.");
254template<
typename ValueType>
257 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
258 "of Storm with CUDD support.");
261template<
typename ValueType>
264 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
265 "of Storm with CUDD support.");
268template<
typename ValueType>
271 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
272 "of Storm with CUDD support.");
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
TargetType convertNumber(SourceType const &number)