15 changed files with 901 additions and 314 deletions
			
			
		- 
					2src/storage/dd/Bdd.cpp
- 
					1src/storage/dd/Bdd.h
- 
					281src/storage/dd/DdManager.cpp
- 
					212src/storage/dd/DdManager.h
- 
					62src/storage/dd/DdMetaVariable.cpp
- 
					102src/storage/dd/DdMetaVariable.h
- 
					14src/storage/dd/InternalDdManager.h
- 
					240src/storage/dd/cudd/CuddDdManager.cpp
- 
					20src/storage/dd/cudd/CuddDdManager.h
- 
					0src/storage/dd/cudd/InternalCuddAdd.cpp
- 
					0src/storage/dd/cudd/InternalCuddAdd.h
- 
					62src/storage/dd/cudd/InternalCuddBdd.cpp
- 
					10src/storage/dd/cudd/InternalCuddBdd.h
- 
					88src/storage/dd/cudd/InternalCuddDdManager.cpp
- 
					119src/storage/dd/cudd/InternalCuddDdManager.h
| @ -0,0 +1,62 @@ | |||
| #include "src/storage/dd/DdMetaVariable.h"
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace dd { | |||
|         template<DdType LibraryType> | |||
|         DdMetaVariable<LibraryType>::DdMetaVariable(std::string const& name, int_fast64_t low, int_fast64_t high, std::vector<Bdd<LibraryType>> const& ddVariables) : name(name), type(MetaVariableType::Int), low(low), high(high), ddVariables(ddVariables) { | |||
|             this->createCube(); | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         DdMetaVariable<LibraryType>::DdMetaVariable(std::string const& name, std::vector<Bdd<LibraryType>> const& ddVariables) : name(name), type(MetaVariableType::Bool), low(0), high(1), ddVariables(ddVariables) { | |||
|             this->createCube(); | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         std::string const& DdMetaVariable<LibraryType>::getName() const { | |||
|             return this->name; | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         MetaVariableType DdMetaVariable<LibraryType>::getType() const { | |||
|             return this->type; | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         int_fast64_t DdMetaVariable<LibraryType>::getLow() const { | |||
|             return this->low; | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         int_fast64_t DdMetaVariable<LibraryType>::getHigh() const { | |||
|             return this->high; | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         std::size_t DdMetaVariable<LibraryType>::getNumberOfDdVariables() const { | |||
|             return this->ddVariables.size(); | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         std::vector<Bdd<LibraryType>> const& DdMetaVariable<LibraryType>::getDdVariables() const { | |||
|             return this->ddVariables; | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         Bdd<LibraryType> const& DdMetaVariable<LibraryType>::getCube() const { | |||
|             return this->cube; | |||
|         } | |||
|          | |||
|         template<DdType LibraryType> | |||
|         void DdMetaVariable<LibraryType>::createCube() { | |||
|             auto it = this->ddVariables.begin(); | |||
|             this->cube = *it; | |||
|             ++it; | |||
|             for (auto ite = this->ddVariables.end(); it != ite; ++it) { | |||
|                 this->cube &= *it; | |||
|             } | |||
|         } | |||
|          | |||
|         template class DdMetaVariable<DdType::CUDD>; | |||
|     } | |||
| } | |||
| @ -0,0 +1,14 @@ | |||
| #ifndef STORM_STORAGE_DD_INTERNALDDMANAGER_H_ | |||
| #define STORM_STORAGE_DD_INTERNALDDMANAGER_H_ | |||
| 
 | |||
| #include "src/storage/dd/DdType.h" | |||
| 
 | |||
| namespace storm { | |||
|     namespace dd { | |||
|         template <storm::dd::DdType LibraryType> | |||
|         class InternalDdManager; | |||
|     } | |||
| } | |||
| 
 | |||
| 
 | |||
| #endif /* STORM_STORAGE_DD_INTERNALDDMANAGER_H_ */ | |||
| @ -0,0 +1,88 @@ | |||
| #include "src/storage/dd/cudd/InternalCuddDdManager.h"
 | |||
| 
 | |||
| #include "src/settings/SettingsManager.h"
 | |||
| #include "src/settings/modules/CuddSettings.h"
 | |||
| 
 | |||
| namespace storm { | |||
|     namespace dd { | |||
|          | |||
|         InternalDdManager<DdType::CUDD>::InternalDdManager() : cuddManager(), reorderingTechnique(CUDD_REORDER_NONE) { | |||
|             this->cuddManager.SetMaxMemory(static_cast<unsigned long>(storm::settings::cuddSettings().getMaximalMemory() * 1024ul * 1024ul)); | |||
|             this->cuddManager.SetEpsilon(storm::settings::cuddSettings().getConstantPrecision()); | |||
|              | |||
|             // Now set the selected reordering technique.
 | |||
|             storm::settings::modules::CuddSettings::ReorderingTechnique reorderingTechniqueAsSetting = storm::settings::cuddSettings().getReorderingTechnique(); | |||
|             switch (reorderingTechniqueAsSetting) { | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::None: this->reorderingTechnique = CUDD_REORDER_NONE; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Random: this->reorderingTechnique = CUDD_REORDER_RANDOM; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::RandomPivot: this->reorderingTechnique = CUDD_REORDER_RANDOM_PIVOT; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Sift: this->reorderingTechnique = CUDD_REORDER_SIFT; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::SiftConv: this->reorderingTechnique = CUDD_REORDER_SIFT_CONVERGE; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::SymmetricSift: this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::SymmetricSiftConv: this->reorderingTechnique = CUDD_REORDER_SYMM_SIFT_CONV; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::GroupSift: this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::GroupSiftConv: this->reorderingTechnique = CUDD_REORDER_GROUP_SIFT_CONV; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Win2: this->reorderingTechnique = CUDD_REORDER_WINDOW2; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Win2Conv: this->reorderingTechnique = CUDD_REORDER_WINDOW2_CONV; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Win3: this->reorderingTechnique = CUDD_REORDER_WINDOW3; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Win3Conv: this->reorderingTechnique = CUDD_REORDER_WINDOW3_CONV; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Win4: this->reorderingTechnique = CUDD_REORDER_WINDOW4; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Win4Conv: this->reorderingTechnique = CUDD_REORDER_WINDOW4_CONV; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Annealing: this->reorderingTechnique = CUDD_REORDER_ANNEALING; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Genetic: this->reorderingTechnique = CUDD_REORDER_GENETIC; break; | |||
|                 case storm::settings::modules::CuddSettings::ReorderingTechnique::Exact: this->reorderingTechnique = CUDD_REORDER_EXACT; break; | |||
|             } | |||
|         } | |||
|          | |||
|         InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddOne() const { | |||
|             return InternalBdd<DdType::CUDD>(this, cuddManager.bddOne()); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddOne() const { | |||
|             return InternalAdd<DdType::CUDD, ValueType>(this, cuddManager.addOne()); | |||
|         } | |||
|          | |||
|         InternalBdd<DdType::CUDD> InternalDdManager<DdType::CUDD>::getBddZero() const { | |||
|             return InternalBdd<DdType::CUDD>(this, cuddManager.bddZero()); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getAddZero() const { | |||
|             return InternalAdd<DdType::CUDD, ValueType>(this, cuddManager.addZero()); | |||
|         } | |||
|          | |||
|         template<typename ValueType> | |||
|         InternalAdd<DdType::CUDD, ValueType> InternalDdManager<DdType::CUDD>::getConstant(ValueType const& value) const { | |||
|             return InternalAdd<DdType::CUDD, ValueType>(this, cuddManager.constant(value)); | |||
|         } | |||
| 
 | |||
|         std::pair<InternalBdd<DdType::CUDD>, InternalBdd<DdType::CUDD>> InternalDdManager<DdType::CUDD>::createNewDdVariablePair() { | |||
|             std::pair<InternalBdd<DdType::CUDD>, InternalBdd<DdType::CUDD>> result; | |||
|             result.first = InternalBdd<DdType::CUDD>(this, cuddManager.bddVar()); | |||
|             result.second = InternalBdd<DdType::CUDD>(this, cuddManager.bddVar()); | |||
|              | |||
|             // Connect the two variables so they are not 'torn apart' during dynamic reordering.
 | |||
|             cuddManager.MakeTreeNode(result.first.getIndex(), 2, MTR_FIXED); | |||
|              | |||
|             return result; | |||
|         } | |||
|          | |||
|         void InternalDdManager<DdType::CUDD>::allowDynamicReordering(bool value) { | |||
|             if (value) { | |||
|                 this->getCuddManager().AutodynEnable(this->reorderingTechnique); | |||
|             } else { | |||
|                 this->getCuddManager().AutodynDisable(); | |||
|             } | |||
|         } | |||
|          | |||
|         bool InternalDdManager<DdType::CUDD>::isDynamicReorderingAllowed() const { | |||
|             Cudd_ReorderingType type; | |||
|             return this->getCuddManager().ReorderingStatus(&type); | |||
|         } | |||
|          | |||
|         void InternalDdManager<DdType::CUDD>::triggerReordering() { | |||
|             this->getCuddManager().ReduceHeap(this->reorderingTechnique, 0); | |||
|         } | |||
|     } | |||
| } | |||
| @ -0,0 +1,119 @@ | |||
| #ifndef STORM_STORAGE_DD_INTERNALCUDDDDMANAGER_H_ | |||
| #define STORM_STORAGE_DD_INTERNALCUDDDDMANAGER_H_ | |||
| 
 | |||
| #include "src/storage/dd/DdType.h" | |||
| #include "src/storage/dd/InternalDdManager.h" | |||
| 
 | |||
| #include "src/storage/dd/cudd/InternalCuddBdd.h" | |||
| #include "src/storage/dd/cudd/InternalCuddAdd.h" | |||
| 
 | |||
| #include "cuddObj.hh" | |||
| 
 | |||
| namespace storm { | |||
|     namespace dd { | |||
|         template<DdType LibraryType, typename ValueType> | |||
|         class InternalAdd; | |||
| 
 | |||
|         template<DdType LibraryType> | |||
|         class InternalBdd; | |||
|          | |||
|         template<> | |||
|         class InternalDdManager<DdType::CUDD> { | |||
|         public: | |||
|             friend class InternalAdd<DdType::CUDD, double>; | |||
|             friend class InternalBdd<DdType::CUDD>; | |||
|              | |||
|             /*! | |||
|              * Creates a new internal manager for CUDD DDs. | |||
|              */ | |||
|             InternalDdManager(); | |||
|              | |||
|             /*! | |||
|              * Retrieves a BDD representing the constant one function. | |||
|              * | |||
|              * @return A BDD representing the constant one function. | |||
|              */ | |||
|             InternalBdd<DdType::CUDD> getBddOne() const; | |||
|              | |||
|             /*! | |||
|              * Retrieves an ADD representing the constant one function. | |||
|              * | |||
|              * @return An ADD representing the constant one function. | |||
|              */ | |||
|             template<typename ValueType> | |||
|             InternalAdd<DdType::CUDD, ValueType> getAddOne() const; | |||
|              | |||
|             /*! | |||
|              * Retrieves a BDD representing the constant zero function. | |||
|              * | |||
|              * @return A BDD representing the constant zero function. | |||
|              */ | |||
|             InternalBdd<DdType::CUDD> getBddZero() const; | |||
|              | |||
|             /*! | |||
|              * Retrieves an ADD representing the constant zero function. | |||
|              * | |||
|              * @return An ADD representing the constant zero function. | |||
|              */ | |||
|             template<typename ValueType> | |||
|             InternalAdd<DdType::CUDD, ValueType> getAddZero() const; | |||
|              | |||
|             /*! | |||
|              * Retrieves an ADD representing the constant function with the given value. | |||
|              * | |||
|              * @return An ADD representing the constant function with the given value. | |||
|              */ | |||
|             template<typename ValueType> | |||
|             InternalAdd<DdType::CUDD, ValueType> getConstant(ValueType const& value) const; | |||
|              | |||
|             /*! | |||
|              * Creates a new pair of DD variables and returns the two cubes as a result. | |||
|              * | |||
|              * @return The two cubes belonging to the DD variables. | |||
|              */ | |||
|             std::pair<InternalBdd<DdType::CUDD>, InternalBdd<DdType::CUDD>> createNewDdVariablePair(); | |||
|              | |||
|             /*! | |||
|              * Sets whether or not dynamic reordering is allowed for the DDs managed by this manager. | |||
|              * | |||
|              * @param value If set to true, dynamic reordering is allowed and forbidden otherwise. | |||
|              */ | |||
|             void allowDynamicReordering(bool value); | |||
|              | |||
|             /*! | |||
|              * Retrieves whether dynamic reordering is currently allowed. | |||
|              * | |||
|              * @return True iff dynamic reordering is currently allowed. | |||
|              */ | |||
|             bool isDynamicReorderingAllowed() const; | |||
|              | |||
|             /*! | |||
|              * Triggers a reordering of the DDs managed by this manager. | |||
|              */ | |||
|             void triggerReordering(); | |||
|              | |||
|         private: | |||
|             /*! | |||
|              * Retrieves the underlying CUDD manager. | |||
|              * | |||
|              * @return The underlying CUDD manager. | |||
|              */ | |||
|             Cudd& getCuddManager(); | |||
|              | |||
|             /*! | |||
|              * Retrieves the underlying CUDD manager. | |||
|              * | |||
|              * @return The underlying CUDD manager. | |||
|              */ | |||
|             Cudd const& getCuddManager() const; | |||
|              | |||
|             // The manager responsible for the DDs created/modified with this DdManager. | |||
|             Cudd cuddManager; | |||
|              | |||
|             // The technique that is used for dynamic reordering. | |||
|             Cudd_ReorderingType reorderingTechnique; | |||
|         }; | |||
|     } | |||
| } | |||
| 
 | |||
| #endif /* STORM_STORAGE_DD_INTERNALCUDDDDMANAGER_H_ */ | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue