From 6a2d75d68dbbd97991d64a4acf7b516b36d337a4 Mon Sep 17 00:00:00 2001 From: dehnert Date: Thu, 15 May 2014 21:34:23 +0200 Subject: [PATCH] Some changes in anticipation of integrating MEDDLY. Former-commit-id: 0f7a71ec9bdfaa979ab071dbf0ba60dbab8d9b83 --- src/storage/dd/CuddDdManager.h | 2 +- src/storage/dd/CuddDdMetaVariable.cpp | 52 ++++++++++ src/storage/dd/CuddDdMetaVariable.h | 138 ++++++++++++++++++++++++++ src/storage/dd/DdMetaVariable.cpp | 65 ------------ src/storage/dd/DdMetaVariable.h | 136 ++----------------------- 5 files changed, 197 insertions(+), 196 deletions(-) create mode 100644 src/storage/dd/CuddDdMetaVariable.cpp create mode 100644 src/storage/dd/CuddDdMetaVariable.h delete mode 100644 src/storage/dd/DdMetaVariable.cpp diff --git a/src/storage/dd/CuddDdManager.h b/src/storage/dd/CuddDdManager.h index a4607a57c..14ea4d8a3 100644 --- a/src/storage/dd/CuddDdManager.h +++ b/src/storage/dd/CuddDdManager.h @@ -4,7 +4,7 @@ #include #include "src/storage/dd/DdManager.h" -#include "src/storage/dd/DdMetaVariable.h" +#include "src/storage/dd/CuddDdMetaVariable.h" #include "src/utility/OsDetection.h" // Include the C++-interface of CUDD. diff --git a/src/storage/dd/CuddDdMetaVariable.cpp b/src/storage/dd/CuddDdMetaVariable.cpp new file mode 100644 index 000000000..b7f45dbe3 --- /dev/null +++ b/src/storage/dd/CuddDdMetaVariable.cpp @@ -0,0 +1,52 @@ +#include "src/storage/dd/CuddDdMetaVariable.h" +#include "src/storage/dd/CuddDdManager.h" + +namespace storm { + namespace dd { + DdMetaVariable::DdMetaVariable(std::string const& name, int_fast64_t low, int_fast64_t high, std::vector> const& ddVariables, std::shared_ptr> manager) : name(name), type(MetaVariableType::Int), low(low), high(high), ddVariables(ddVariables), cube(manager->getOne()), manager(manager) { + // Create the cube of all variables of this meta variable. + for (auto const& ddVariable : this->ddVariables) { + this->cube *= ddVariable; + } + } + + DdMetaVariable::DdMetaVariable(std::string const& name, std::vector> const& ddVariables, std::shared_ptr> manager) : name(name), type(MetaVariableType::Bool), ddVariables(ddVariables), cube(manager->getOne()), manager(manager) { + // Create the cube of all variables of this meta variable. + for (auto const& ddVariable : this->ddVariables) { + this->cube *= ddVariable; + } + } + + std::string const& DdMetaVariable::getName() const { + return this->name; + } + + typename DdMetaVariable::MetaVariableType DdMetaVariable::getType() const { + return this->type; + } + + int_fast64_t DdMetaVariable::getLow() const { + return this->low; + } + + int_fast64_t DdMetaVariable::getHigh() const { + return this->high; + } + + std::size_t DdMetaVariable::getNumberOfDdVariables() const { + return this->ddVariables.size(); + } + + std::shared_ptr> DdMetaVariable::getDdManager() const { + return this->manager; + } + + std::vector> const& DdMetaVariable::getDdVariables() const { + return this->ddVariables; + } + + Dd const& DdMetaVariable::getCube() const { + return this->cube; + } + } +} \ No newline at end of file diff --git a/src/storage/dd/CuddDdMetaVariable.h b/src/storage/dd/CuddDdMetaVariable.h new file mode 100644 index 000000000..b54ca1939 --- /dev/null +++ b/src/storage/dd/CuddDdMetaVariable.h @@ -0,0 +1,138 @@ +#ifndef STORM_STORAGE_DD_DDMETAVARIABLE_H_ +#define STORM_STORAGE_DD_DDMETAVARIABLE_H_ + +#include +#include +#include +#include + +#include "utility/OsDetection.h" +#include "src/storage/dd/CuddDd.h" +#include "src/storage/dd/DdMetaVariable.h" +#include "src/storage/expressions/Expression.h" + +namespace storm { + namespace dd { + // Forward-declare the DdManager class. + template class DdManager; + + template<> + class DdMetaVariable { + public: + // Declare the DdManager class as friend so it can access the internals of a meta variable. + friend class DdManager; + friend class Dd; + friend class DdForwardIterator; + + // An enumeration for all legal types of meta variables. + enum class MetaVariableType { Bool, Int }; + + /*! + * Creates an integer meta variable with the given name and range bounds. + * + * @param name The name of the meta variable. + * @param low The lowest value of the range of the variable. + * @param high The highest value of the range of the variable. + * @param ddVariables The vector of variables used to encode this variable. + * @param manager A pointer to the manager that is responsible for this meta variable. + */ + DdMetaVariable(std::string const& name, int_fast64_t low, int_fast64_t high, std::vector> const& ddVariables, std::shared_ptr> manager); + + /*! + * Creates a boolean meta variable with the given name. + * @param name The name of the meta variable. + * @param ddVariables The vector of variables used to encode this variable. + * @param manager A pointer to the manager that is responsible for this meta variable. + */ + DdMetaVariable(std::string const& name, std::vector> const& ddVariables, std::shared_ptr> manager); + + // Explictly generate all default versions of copy/move constructors/assignments. + DdMetaVariable(DdMetaVariable const& other) = default; + DdMetaVariable& operator=(DdMetaVariable const& other) = default; +#ifndef WINDOWS + DdMetaVariable(DdMetaVariable&& other) = default; + DdMetaVariable& operator=(DdMetaVariable&& other) = default; +#endif + + /*! + * Retrieves the name of the meta variable. + * + * @return The name of the variable. + */ + std::string const& getName() const; + + /*! + * Retrieves the type of the meta variable. + * + * @return The type of the meta variable. + */ + MetaVariableType getType() const; + + /*! + * Retrieves the lowest value of the range of the variable. + * + * @return The lowest value of the range of the variable. + */ + int_fast64_t getLow() const; + + /*! + * Retrieves the highest value of the range of the variable. + * + * @return The highest value of the range of the variable. + */ + int_fast64_t getHigh() const; + + /*! + * Retrieves the manager that is responsible for this meta variable. + * + * A pointer to the manager that is responsible for this meta variable. + */ + std::shared_ptr> getDdManager() const; + + /*! + * Retrieves the number of DD variables for this meta variable. + * + * @return The number of DD variables for this meta variable. + */ + std::size_t getNumberOfDdVariables() const; + + private: + /*! + * Retrieves the variables used to encode the meta variable. + * + * @return A vector of variables used to encode the meta variable. + */ + std::vector> const& getDdVariables() const; + + /*! + * Retrieves the cube of all variables that encode this meta variable. + * + * @return The cube of all variables that encode this meta variable. + */ + Dd const& getCube() const; + + // The name of the meta variable. + std::string name; + + // The type of the variable. + MetaVariableType type; + + // The lowest value of the range of the variable. + int_fast64_t low; + + // The highest value of the range of the variable. + int_fast64_t high; + + // The vector of variables that are used to encode the meta variable. + std::vector> ddVariables; + + // The cube consisting of all variables that encode the meta variable. + Dd cube; + + // A pointer to the manager responsible for this meta variable. + std::shared_ptr> manager; + }; + } +} + +#endif /* STORM_STORAGE_DD_DDMETAVARIABLE_H_ */ \ No newline at end of file diff --git a/src/storage/dd/DdMetaVariable.cpp b/src/storage/dd/DdMetaVariable.cpp deleted file mode 100644 index 453b83cc8..000000000 --- a/src/storage/dd/DdMetaVariable.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "src/storage/dd/DdMetaVariable.h" -#include "src/storage/dd/CuddDdManager.h" - -namespace storm { - namespace dd { - template - DdMetaVariable::DdMetaVariable(std::string const& name, int_fast64_t low, int_fast64_t high, std::vector> const& ddVariables, std::shared_ptr> manager) : name(name), type(MetaVariableType::Int), low(low), high(high), ddVariables(ddVariables), cube(manager->getOne()), manager(manager) { - // Create the cube of all variables of this meta variable. - for (auto const& ddVariable : this->ddVariables) { - this->cube *= ddVariable; - } - } - - template - DdMetaVariable::DdMetaVariable(std::string const& name, std::vector> const& ddVariables, std::shared_ptr> manager) : name(name), type(MetaVariableType::Bool), ddVariables(ddVariables), cube(manager->getOne()), manager(manager) { - // Create the cube of all variables of this meta variable. - for (auto const& ddVariable : this->ddVariables) { - this->cube *= ddVariable; - } - } - - template - std::string const& DdMetaVariable::getName() const { - return this->name; - } - - template - typename DdMetaVariable::MetaVariableType DdMetaVariable::getType() const { - return this->type; - } - - template - int_fast64_t DdMetaVariable::getLow() const { - return this->low; - } - - template - int_fast64_t DdMetaVariable::getHigh() const { - return this->high; - } - - template - std::size_t DdMetaVariable::getNumberOfDdVariables() const { - return this->ddVariables.size(); - } - - template - std::shared_ptr> DdMetaVariable::getDdManager() const { - return this->manager; - } - - template - std::vector> const& DdMetaVariable::getDdVariables() const { - return this->ddVariables; - } - - template - Dd const& DdMetaVariable::getCube() const { - return this->cube; - } - - // Explicitly instantiate DdMetaVariable. - template class DdMetaVariable; - } -} \ No newline at end of file diff --git a/src/storage/dd/DdMetaVariable.h b/src/storage/dd/DdMetaVariable.h index 47936d805..b85b23c1c 100644 --- a/src/storage/dd/DdMetaVariable.h +++ b/src/storage/dd/DdMetaVariable.h @@ -1,137 +1,13 @@ -#ifndef STORM_STORAGE_DD_DDMETAVARIABLE_H_ -#define STORM_STORAGE_DD_DDMETAVARIABLE_H_ +#ifndef STORM_STORAGE_DD_DDMETAVARIBLE_H_ +#define STORM_STORAGE_DD_DDMETAVARIBLE_H_ -#include -#include -#include -#include - -#include "utility/OsDetection.h" -#include "src/storage/dd/CuddDd.h" -#include "src/storage/expressions/Expression.h" +#include "src/storage/dd/DdType.h" namespace storm { namespace dd { - // Forward-declare the DdManager class. - template class DdManager; - - template - class DdMetaVariable { - public: - // Declare the DdManager class as friend so it can access the internals of a meta variable. - friend class DdManager; - friend class Dd; - friend class DdForwardIterator; - - // An enumeration for all legal types of meta variables. - enum class MetaVariableType { Bool, Int }; - - /*! - * Creates an integer meta variable with the given name and range bounds. - * - * @param name The name of the meta variable. - * @param low The lowest value of the range of the variable. - * @param high The highest value of the range of the variable. - * @param ddVariables The vector of variables used to encode this variable. - * @param manager A pointer to the manager that is responsible for this meta variable. - */ - DdMetaVariable(std::string const& name, int_fast64_t low, int_fast64_t high, std::vector> const& ddVariables, std::shared_ptr> manager); - - /*! - * Creates a boolean meta variable with the given name. - * @param name The name of the meta variable. - * @param ddVariables The vector of variables used to encode this variable. - * @param manager A pointer to the manager that is responsible for this meta variable. - */ - DdMetaVariable(std::string const& name, std::vector> const& ddVariables, std::shared_ptr> manager); - - // Explictly generate all default versions of copy/move constructors/assignments. - DdMetaVariable(DdMetaVariable const& other) = default; - DdMetaVariable& operator=(DdMetaVariable const& other) = default; -#ifndef WINDOWS - DdMetaVariable(DdMetaVariable&& other) = default; - DdMetaVariable& operator=(DdMetaVariable&& other) = default; -#endif - - /*! - * Retrieves the name of the meta variable. - * - * @return The name of the variable. - */ - std::string const& getName() const; - - /*! - * Retrieves the type of the meta variable. - * - * @return The type of the meta variable. - */ - MetaVariableType getType() const; - - /*! - * Retrieves the lowest value of the range of the variable. - * - * @return The lowest value of the range of the variable. - */ - int_fast64_t getLow() const; - - /*! - * Retrieves the highest value of the range of the variable. - * - * @return The highest value of the range of the variable. - */ - int_fast64_t getHigh() const; - - /*! - * Retrieves the manager that is responsible for this meta variable. - * - * A pointer to the manager that is responsible for this meta variable. - */ - std::shared_ptr> getDdManager() const; - - /*! - * Retrieves the number of DD variables for this meta variable. - * - * @return The number of DD variables for this meta variable. - */ - std::size_t getNumberOfDdVariables() const; - - private: - /*! - * Retrieves the variables used to encode the meta variable. - * - * @return A vector of variables used to encode the meta variable. - */ - std::vector> const& getDdVariables() const; - - /*! - * Retrieves the cube of all variables that encode this meta variable. - * - * @return The cube of all variables that encode this meta variable. - */ - Dd const& getCube() const; - - // The name of the meta variable. - std::string name; - - // The type of the variable. - MetaVariableType type; - - // The lowest value of the range of the variable. - int_fast64_t low; - - // The highest value of the range of the variable. - int_fast64_t high; - - // The vector of variables that are used to encode the meta variable. - std::vector> ddVariables; - - // The cube consisting of all variables that encode the meta variable. - Dd cube; - - // A pointer to the manager responsible for this meta variable. - std::shared_ptr> manager; - }; + // Declare DdMetaVariable class so we can then specialize it for the different DD types. + template class DdMetaVariable; } } -#endif /* STORM_STORAGE_DD_DDMETAVARIABLE_H_ */ \ No newline at end of file +#endif /* STORM_STORAGE_DD_DDMETAVARIBLE_H_ */ \ No newline at end of file