13InternalDdManager<DdType::CUDD>::InternalDdManager() : cuddManager(), reorderingTechnique(CUDD_REORDER_NONE), numberOfDdVariables(0) {
14 this->cuddManager.SetMaxMemory(
15 static_cast<unsigned long>(storm::settings::getModule<storm::settings::modules::CuddSettings>().getMaximalMemory() * 1024ul * 1024ul));
17 auto const& settings = storm::settings::getModule<storm::settings::modules::CuddSettings>();
18 this->cuddManager.SetEpsilon(settings.getConstantPrecision());
22 switch (reorderingTechniqueAsSetting) {
24 this->reorderingTechnique = CUDD_REORDER_NONE;
27 this->reorderingTechnique = CUDD_REORDER_RANDOM;
30 this->reorderingTechnique = CUDD_REORDER_RANDOM_PIVOT;
33 this->reorderingTechnique = CUDD_REORDER_SIFT;
36 this->reorderingTechnique = CUDD_REORDER_SIFT_CONVERGE;
39 this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT;
42 this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT_CONV;
45 this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT;
48 this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT_CONV;
51 this->reorderingTechnique = CUDD_REORDER_WINDOW2;
54 this->reorderingTechnique = CUDD_REORDER_WINDOW2_CONV;
57 this->reorderingTechnique = CUDD_REORDER_WINDOW3;
60 this->reorderingTechnique = CUDD_REORDER_WINDOW3_CONV;
63 this->reorderingTechnique = CUDD_REORDER_WINDOW4;
66 this->reorderingTechnique = CUDD_REORDER_WINDOW4_CONV;
69 this->reorderingTechnique = CUDD_REORDER_ANNEALING;
72 this->reorderingTechnique = CUDD_REORDER_GENETIC;
75 this->reorderingTechnique = CUDD_REORDER_EXACT;
79 this->allowDynamicReordering(settings.isReorderingEnabled());
82InternalDdManager<DdType::CUDD>::~InternalDdManager() {
86InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddOne()
const {
87 return InternalBdd<DdType::CUDD>(
this, cuddManager.bddOne());
90template<
typename ValueType>
91InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddOne()
const {
92 return InternalAdd<DdType::CUDD, ValueType>(
this, cuddManager.addOne());
95InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddZero()
const {
96 return InternalBdd<DdType::CUDD>(
this, cuddManager.bddZero());
99InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddEncodingLessOrEqualThan(uint64_t bound, InternalBdd<DdType::CUDD>
const& cube,
100 uint64_t numberOfDdVariables)
const {
101 return InternalBdd<DdType::CUDD>(
this, cudd::BDD(cuddManager, this->getBddEncodingLessOrEqualThanRec(0, (1ull << numberOfDdVariables) - 1, bound,
102 cube.getCuddDdNode(), numberOfDdVariables)));
105DdNodePtr InternalDdManager<DdType::CUDD>::getBddEncodingLessOrEqualThanRec(uint64_t minimalValue, uint64_t maximalValue, uint64_t bound, DdNodePtr cube,
106 uint64_t remainingDdVariables)
const {
107 if (maximalValue <= bound) {
108 return Cudd_ReadOne(cuddManager.getManager());
109 }
else if (minimalValue > bound) {
110 return Cudd_ReadLogicZero(cuddManager.getManager());
113 STORM_LOG_ASSERT(remainingDdVariables > 0,
"Expected more remaining DD variables.");
115 uint64_t newRemainingDdVariables = remainingDdVariables - 1;
116 DdNodePtr elseResult =
117 getBddEncodingLessOrEqualThanRec(minimalValue, maximalValue & ~(1ull << newRemainingDdVariables), bound, Cudd_T(cube), newRemainingDdVariables);
118 Cudd_Ref(elseResult);
119 DdNodePtr thenResult =
120 getBddEncodingLessOrEqualThanRec(minimalValue | (1ull << newRemainingDdVariables), maximalValue, bound, Cudd_T(cube), newRemainingDdVariables);
121 Cudd_Ref(thenResult);
124 bool complemented = Cudd_IsComplement(thenResult);
126 cuddUniqueInter(cuddManager.getManager(), Cudd_NodeReadIndex(cube), Cudd_Regular(thenResult), complemented ? Cudd_Not(elseResult) : elseResult);
128 result = Cudd_Not(result);
130 Cudd_Deref(thenResult);
131 Cudd_Deref(elseResult);
135template<
typename ValueType>
136InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddZero()
const {
137 return InternalAdd<DdType::CUDD, ValueType>(
this, cuddManager.addZero());
140template<
typename ValueType>
141InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddUndefined()
const {
142 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Undefined values are not supported by CUDD.");
145template<
typename ValueType>
146InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getConstant(ValueType
const& value)
const {
147 return InternalAdd<DdType::CUDD, ValueType>(
this, cuddManager.constant(value));
151InternalAdd<DdType::CUDD, storm::RationalNumber> InternalDdManager<DdType::CUDD>::getConstant(storm::RationalNumber
const& value)
const {
152 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Operation not supported.");
155std::vector<InternalBdd<DdType::CUDD>> InternalDdManager<DdType::CUDD>::createDdVariables(uint64_t numberOfLayers,
156 boost::optional<uint_fast64_t>
const& position) {
157 std::vector<InternalBdd<DdType::CUDD>> result;
160 for (uint64_t layer = 0; layer < numberOfLayers; ++layer) {
161 result.emplace_back(InternalBdd<DdType::CUDD>(
this, cuddManager.bddNewVarAtLevel(position.get() + layer)));
164 for (uint64_t layer = 0; layer < numberOfLayers; ++layer) {
165 result.emplace_back(InternalBdd<DdType::CUDD>(
this, cuddManager.bddVar()));
172 cuddManager.MakeTreeNode(result.front().getIndex(), numberOfLayers, MTR_FIXED);
175 numberOfDdVariables += numberOfLayers;
180bool InternalDdManager<DdType::CUDD>::supportsOrderedInsertion()
const {
184void InternalDdManager<DdType::CUDD>::allowDynamicReordering(
bool value) {
186 this->getCuddManager().AutodynEnable(this->reorderingTechnique);
188 this->getCuddManager().AutodynDisable();
192bool InternalDdManager<DdType::CUDD>::isDynamicReorderingAllowed()
const {
193 Cudd_ReorderingType type;
194 return this->getCuddManager().ReorderingStatus(&type);
197void InternalDdManager<DdType::CUDD>::triggerReordering() {
198 this->getCuddManager().ReduceHeap(this->reorderingTechnique, 0);
201void InternalDdManager<DdType::CUDD>::debugCheck()
const {
202 this->getCuddManager().CheckKeys();
203 this->getCuddManager().DebugCheck();
206void InternalDdManager<DdType::CUDD>::execute(std::function<
void()>
const& f)
const {
210cudd::Cudd& InternalDdManager<DdType::CUDD>::getCuddManager() {
214cudd::Cudd
const& InternalDdManager<DdType::CUDD>::getCuddManager()
const {
218uint_fast64_t InternalDdManager<DdType::CUDD>::getNumberOfDdVariables()
const {
219 return numberOfDdVariables;
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.");
236 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
237 "of Storm with CUDD support.");
240template<
typename ValueType>
243 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
244 "of Storm with CUDD support.");
249 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
250 "of Storm with CUDD support.");
254 uint64_t numberOfDdVariables)
const {
256 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
257 "of Storm with CUDD support.");
260template<
typename ValueType>
263 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
264 "of Storm with CUDD support.");
267template<
typename ValueType>
270 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
271 "of Storm with CUDD support.");
274template<
typename ValueType>
277 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
278 "of Storm with CUDD support.");
284 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
285 "of Storm with CUDD support.");
289 boost::optional<uint_fast64_t>
const& position) {
291 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
292 "of Storm with CUDD support.");
297 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
298 "of Storm with CUDD support.");
303 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
304 "of Storm with CUDD support.");
309 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
310 "of Storm with CUDD support.");
315 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
316 "of Storm with CUDD support.");
321 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
322 "of Storm with CUDD support.");
327 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
328 "of Storm with CUDD support.");
333 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
334 "of Storm with CUDD support.");
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)