12 : cuddManager(), reorderingTechnique(CUDD_REORDER_NONE), numberOfDdVariables(0) {
13 this->cuddManager.SetMaxMemory(
static_cast<unsigned long>(environment.
getMaximalMemory() * 1024ul * 1024ul));
18 switch (reorderingTechniqueAsSetting) {
20 this->reorderingTechnique = CUDD_REORDER_NONE;
23 this->reorderingTechnique = CUDD_REORDER_RANDOM;
26 this->reorderingTechnique = CUDD_REORDER_RANDOM_PIVOT;
29 this->reorderingTechnique = CUDD_REORDER_SIFT;
32 this->reorderingTechnique = CUDD_REORDER_SIFT_CONVERGE;
35 this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT;
38 this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT_CONV;
41 this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT;
44 this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT_CONV;
47 this->reorderingTechnique = CUDD_REORDER_WINDOW2;
50 this->reorderingTechnique = CUDD_REORDER_WINDOW2_CONV;
53 this->reorderingTechnique = CUDD_REORDER_WINDOW3;
56 this->reorderingTechnique = CUDD_REORDER_WINDOW3_CONV;
59 this->reorderingTechnique = CUDD_REORDER_WINDOW4;
62 this->reorderingTechnique = CUDD_REORDER_WINDOW4_CONV;
65 this->reorderingTechnique = CUDD_REORDER_ANNEALING;
68 this->reorderingTechnique = CUDD_REORDER_GENETIC;
71 this->reorderingTechnique = CUDD_REORDER_EXACT;
78InternalDdManager<DdType::CUDD>::~InternalDdManager() {
82InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddOne()
const {
83 return InternalBdd<DdType::CUDD>(
this, cuddManager.bddOne());
86template<
typename ValueType>
87InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddOne()
const {
88 return InternalAdd<DdType::CUDD, ValueType>(
this, cuddManager.addOne());
91InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddZero()
const {
92 return InternalBdd<DdType::CUDD>(
this, cuddManager.bddZero());
95InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddEncodingLessOrEqualThan(uint64_t bound, InternalBdd<DdType::CUDD>
const& cube,
96 uint64_t numberOfDdVariables)
const {
97 return InternalBdd<DdType::CUDD>(
this, cudd::BDD(cuddManager, this->getBddEncodingLessOrEqualThanRec(0, (1ull << numberOfDdVariables) - 1, bound,
98 cube.getCuddDdNode(), numberOfDdVariables)));
101DdNodePtr InternalDdManager<DdType::CUDD>::getBddEncodingLessOrEqualThanRec(uint64_t minimalValue, uint64_t maximalValue, uint64_t bound, DdNodePtr cube,
102 uint64_t remainingDdVariables)
const {
103 if (maximalValue <= bound) {
104 return Cudd_ReadOne(cuddManager.getManager());
105 }
else if (minimalValue > bound) {
106 return Cudd_ReadLogicZero(cuddManager.getManager());
109 STORM_LOG_ASSERT(remainingDdVariables > 0,
"Expected more remaining DD variables.");
111 uint64_t newRemainingDdVariables = remainingDdVariables - 1;
112 DdNodePtr elseResult =
113 getBddEncodingLessOrEqualThanRec(minimalValue, maximalValue & ~(1ull << newRemainingDdVariables), bound, Cudd_T(cube), newRemainingDdVariables);
114 Cudd_Ref(elseResult);
115 DdNodePtr thenResult =
116 getBddEncodingLessOrEqualThanRec(minimalValue | (1ull << newRemainingDdVariables), maximalValue, bound, Cudd_T(cube), newRemainingDdVariables);
117 Cudd_Ref(thenResult);
120 bool complemented = Cudd_IsComplement(thenResult);
122 cuddUniqueInter(cuddManager.getManager(), Cudd_NodeReadIndex(cube), Cudd_Regular(thenResult), complemented ? Cudd_Not(elseResult) : elseResult);
124 result = Cudd_Not(result);
126 Cudd_Deref(thenResult);
127 Cudd_Deref(elseResult);
131template<
typename ValueType>
132InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddZero()
const {
133 return InternalAdd<DdType::CUDD, ValueType>(
this, cuddManager.addZero());
136template<
typename ValueType>
137InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddUndefined()
const {
138 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Undefined values are not supported by CUDD.");
141template<
typename ValueType>
142InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getConstant(ValueType
const& value)
const {
143 return InternalAdd<DdType::CUDD, ValueType>(
this, cuddManager.constant(value));
147InternalAdd<DdType::CUDD, storm::RationalNumber> InternalDdManager<DdType::CUDD>::getConstant(storm::RationalNumber
const& value)
const {
148 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Operation not supported.");
151std::vector<InternalBdd<DdType::CUDD>> InternalDdManager<DdType::CUDD>::createDdVariables(uint64_t numberOfLayers,
152 boost::optional<uint_fast64_t>
const& position) {
153 std::vector<InternalBdd<DdType::CUDD>> result;
156 for (uint64_t layer = 0; layer < numberOfLayers; ++layer) {
157 result.emplace_back(InternalBdd<DdType::CUDD>(
this, cuddManager.bddNewVarAtLevel(position.get() + layer)));
160 for (uint64_t layer = 0; layer < numberOfLayers; ++layer) {
161 result.emplace_back(InternalBdd<DdType::CUDD>(
this, cuddManager.bddVar()));
168 cuddManager.MakeTreeNode(result.front().getIndex(), numberOfLayers, MTR_FIXED);
171 numberOfDdVariables += numberOfLayers;
176bool InternalDdManager<DdType::CUDD>::supportsOrderedInsertion()
const {
180void InternalDdManager<DdType::CUDD>::allowDynamicReordering(
bool value) {
182 this->getCuddManager().AutodynEnable(this->reorderingTechnique);
184 this->getCuddManager().AutodynDisable();
188bool InternalDdManager<DdType::CUDD>::isDynamicReorderingAllowed()
const {
189 Cudd_ReorderingType type;
190 return this->getCuddManager().ReorderingStatus(&type);
193void InternalDdManager<DdType::CUDD>::triggerReordering() {
194 this->getCuddManager().ReduceHeap(this->reorderingTechnique, 0);
197void InternalDdManager<DdType::CUDD>::debugCheck()
const {
198 this->getCuddManager().CheckKeys();
199 this->getCuddManager().DebugCheck();
202void InternalDdManager<DdType::CUDD>::execute(std::function<
void()>
const& f)
const {
206cudd::Cudd& InternalDdManager<DdType::CUDD>::getCuddManager() {
210cudd::Cudd
const& InternalDdManager<DdType::CUDD>::getCuddManager()
const {
214uint_fast64_t InternalDdManager<DdType::CUDD>::getNumberOfDdVariables()
const {
215 return numberOfDdVariables;
222 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
223 "of Storm with CUDD support.");
232 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
233 "of Storm with CUDD support.");
236template<
typename ValueType>
239 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
240 "of Storm with CUDD support.");
245 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
246 "of Storm with CUDD support.");
250 uint64_t numberOfDdVariables)
const {
252 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
253 "of Storm with CUDD support.");
256template<
typename ValueType>
259 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
260 "of Storm with CUDD support.");
263template<
typename ValueType>
266 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
267 "of Storm with CUDD support.");
270template<
typename ValueType>
273 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
274 "of Storm with CUDD support.");
280 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
281 "of Storm with CUDD support.");
285 boost::optional<uint_fast64_t>
const& position) {
287 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
288 "of Storm with CUDD support.");
293 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
294 "of Storm with CUDD support.");
299 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
300 "of Storm with CUDD support.");
305 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
306 "of Storm with CUDD support.");
311 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
312 "of Storm with CUDD support.");
317 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
318 "of Storm with CUDD support.");
323 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
324 "of Storm with CUDD support.");
329 "This version of Storm was compiled without support for CUDD. Yet, a method was called that requires this support. Please choose a version "
330 "of Storm with CUDD support.");
uint64_t getMaximalMemory() const
Retrieves the maximal amount of memory (in megabytes) that CUDD can occupy.
bool isReorderingEnabled() const
double getConstantPrecision() const
Retrieves the precision up to which constants are considered to be different.
storm::dd::CuddReorderingTechnique getReorderingTechnique() const
InternalDdManager(storm::CuddDdManagerEnvironment const &environment)
Creates a new internal manager for CUDD DDs.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)