diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 88e0a396f..05d262b65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,6 +33,7 @@ file(GLOB STORM_SETTINGS_FILES ${PROJECT_SOURCE_DIR}/src/settings/*.h ${PROJECT_ file(GLOB STORM_SETTINGS_MODULES_FILES ${PROJECT_SOURCE_DIR}/src/settings/modules/*.h ${PROJECT_SOURCE_DIR}/src/settings/modules/*.cpp) file(GLOB_RECURSE STORM_SOLVER_FILES ${PROJECT_SOURCE_DIR}/src/solver/*.h ${PROJECT_SOURCE_DIR}/src/solver/*.cpp) file(GLOB STORM_STORAGE_FILES ${PROJECT_SOURCE_DIR}/src/storage/*.h ${PROJECT_SOURCE_DIR}/src/storage/*.cpp) +file(GLOB STORM_STORAGE_BISIMULATION_FILES ${PROJECT_SOURCE_DIR}/src/storage/bisimulation/*.h ${PROJECT_SOURCE_DIR}/src/storage/bisimulation/*.cpp) file(GLOB_RECURSE STORM_STORAGE_DD_FILES ${PROJECT_SOURCE_DIR}/src/storage/dd/*.h ${PROJECT_SOURCE_DIR}/src/storage/dd/*.cpp) file(GLOB_RECURSE STORM_STORAGE_EXPRESSIONS_FILES ${PROJECT_SOURCE_DIR}/src/storage/expressions/*.h ${PROJECT_SOURCE_DIR}/src/storage/expressions/*.cpp) file(GLOB_RECURSE STORM_STORAGE_PRISM_FILES ${PROJECT_SOURCE_DIR}/src/storage/prism/*.h ${PROJECT_SOURCE_DIR}/src/storage/prism/*.cpp) @@ -77,6 +78,7 @@ source_group(settings FILES ${STORM_SETTINGS_FILES}) source_group(settings\\modules FILES ${STORM_SETTINGS_MODULES_FILES}) source_group(solver FILES ${STORM_SOLVER_FILES}) source_group(storage FILES ${STORM_STORAGE_FILES}) +source_group(storage\\bisimulation FILES ${STORM_STORAGE_BISIMULATION_FILES}) source_group(storage\\dd FILES ${STORM_STORAGE_DD_FILES}) source_group(storage\\expressions FILES ${STORM_STORAGE_EXPRESSIONS_FILES}) source_group(storage\\prism FILES ${STORM_STORAGE_PRISM_FILES}) diff --git a/src/adapters/CarlAdapter.h b/src/adapters/CarlAdapter.h index 99e01e575..2ed172cde 100644 --- a/src/adapters/CarlAdapter.h +++ b/src/adapters/CarlAdapter.h @@ -42,7 +42,7 @@ namespace carl { } namespace storm { - typedef mpq_class RationalNumber; + typedef cln::cl_RA RationalNumber; typedef carl::Variable Variable; typedef carl::MultivariatePolynomial RawPolynomial; typedef carl::FactorizedPolynomial Polynomial; diff --git a/src/builder/DdPrismModelBuilder.cpp b/src/builder/DdPrismModelBuilder.cpp index 4f6ab3871..0a20bf38b 100644 --- a/src/builder/DdPrismModelBuilder.cpp +++ b/src/builder/DdPrismModelBuilder.cpp @@ -1020,7 +1020,7 @@ namespace storm { preparedProgram = preparedProgram.substituteConstants(); - STORM_LOG_DEBUG("Building representation of program :" << std::endl << preparedProgram << std::endl); + STORM_LOG_DEBUG("Building representation of program:" << std::endl << preparedProgram << std::endl); // Start by initializing the structure used for storing all information needed during the model generation. // In particular, this creates the meta variables used to encode the model. diff --git a/src/builder/ExplicitPrismModelBuilder.cpp b/src/builder/ExplicitPrismModelBuilder.cpp index 5b62364b4..4f6117c9c 100644 --- a/src/builder/ExplicitPrismModelBuilder.cpp +++ b/src/builder/ExplicitPrismModelBuilder.cpp @@ -295,7 +295,7 @@ namespace storm { // Now that the program is fixed, we we need to substitute all constants with their concrete value. preparedProgram = preparedProgram.substituteConstants(); - STORM_LOG_DEBUG("Building representation of program :" << std::endl << preparedProgram << std::endl); + STORM_LOG_DEBUG("Building representation of program:" << std::endl << preparedProgram << std::endl); // Select the appropriate reward models (after the constants have been substituted). std::vector> selectedRewardModels; diff --git a/src/builder/ExplicitPrismModelBuilder.h b/src/builder/ExplicitPrismModelBuilder.h index 8680c0d7b..dfab62136 100644 --- a/src/builder/ExplicitPrismModelBuilder.h +++ b/src/builder/ExplicitPrismModelBuilder.h @@ -72,8 +72,6 @@ namespace storm { std::string stateInfo(uint_fast64_t state) const override { return valuations[state].toString(); } - - }; // A structure storing information about the used variables of the program. diff --git a/src/cli/entrypoints.h b/src/cli/entrypoints.h index c17b2fda9..bcbf8cdfa 100644 --- a/src/cli/entrypoints.h +++ b/src/cli/entrypoints.h @@ -3,11 +3,9 @@ #include "src/utility/storm.h" - namespace storm { namespace cli { - template void verifySparseModel(std::shared_ptr> model, std::vector> const& formulas) { for (auto const& formula : formulas) { @@ -85,15 +83,40 @@ namespace storm { } } } - - + +#define BRANCH_ON_MODELTYPE(result, model, value_type, dd_type, function, ...) \ + if (model->isSymbolicModel()) { \ + if (model->isOfType(storm::models::ModelType::Dtmc)) { \ + result = function>(model->as>(), __VA_ARGS__); \ + } else if (model->isOfType(storm::models::ModelType::Ctmc)) { \ + result = function>(model->as>(), __VA_ARGS__); \ + } else if (model->isOfType(storm::models::ModelType::Mdp)) { \ + result = function>(model->as>(), __VA_ARGS__); \ + } else { \ + STORM_LOG_ASSERT(false, "Unknown model type."); \ + } \ + } else { \ + STORM_LOG_ASSERT(model->isSparseModel(), "Unknown model type."); \ + if (model->isOfType(storm::models::ModelType::Dtmc)) { \ + result = function>(model->as>(), __VA_ARGS__); \ + } else if (model->isOfType(storm::models::ModelType::Ctmc)) { \ + result = function>(model->as>(), __VA_ARGS__); \ + } else if (model->isOfType(storm::models::ModelType::Mdp)) { \ + result = function>(model->as>(), __VA_ARGS__); \ + } else if (model->isOfType(storm::models::ModelType::MarkovAutomaton)) { \ + result = function>(model->as>(), __VA_ARGS__); \ + } else { \ + STORM_LOG_ASSERT(false, "Unknown model type."); \ + } \ + } + template void buildAndCheckSymbolicModel(storm::prism::Program const& program, std::vector> const& formulas) { std::shared_ptr model = buildSymbolicModel(program, formulas); STORM_LOG_THROW(model != nullptr, storm::exceptions::InvalidStateException, "Model could not be constructed for an unknown reason."); // Preprocess the model if needed. - model = preprocessModel(model, formulas); + BRANCH_ON_MODELTYPE(model, model, ValueType, storm::dd::DdType::CUDD, preprocessModel, formulas); // Print some information about the model. model->printModelInformationToStream(std::cout); @@ -127,8 +150,9 @@ namespace storm { STORM_LOG_THROW(settings.isExplicitSet(), storm::exceptions::InvalidStateException, "Unable to build explicit model without model files."); std::shared_ptr model = buildExplicitModel(settings.getTransitionFilename(), settings.getLabelingFilename(), settings.isStateRewardsSet() ? settings.getStateRewardsFilename() : boost::optional(), settings.isTransitionRewardsSet() ? settings.getTransitionRewardsFilename() : boost::optional(), settings.isChoiceLabelingSet() ? settings.getChoiceLabelingFilename() : boost::optional()); + // Preprocess the model if needed. - model = preprocessModel(model, formulas); + BRANCH_ON_MODELTYPE(model, model, ValueType, storm::dd::DdType::CUDD, preprocessModel, formulas); // Print some information about the model. model->printModelInformationToStream(std::cout); diff --git a/src/models/ModelBase.cpp b/src/models/ModelBase.cpp index 1eff87d18..b79d7a81f 100644 --- a/src/models/ModelBase.cpp +++ b/src/models/ModelBase.cpp @@ -13,5 +13,9 @@ namespace storm { bool ModelBase::isSymbolicModel() const { return false; } + + bool ModelBase::isOfType(storm::models::ModelType const& modelType) const { + return this->getType() == modelType; + } } } \ No newline at end of file diff --git a/src/models/ModelBase.h b/src/models/ModelBase.h index 4bbe31b64..d118e1516 100644 --- a/src/models/ModelBase.h +++ b/src/models/ModelBase.h @@ -89,6 +89,14 @@ namespace storm { */ virtual bool isSymbolicModel() const; + /*! + * Checks whether the model is of the given type. + * + * @param modelType The model type to check for. + * @return True iff the model is of the given type. + */ + bool isOfType(storm::models::ModelType const& modelType) const; + private: // The type of the model. ModelType modelType; diff --git a/src/models/sparse/Model.h b/src/models/sparse/Model.h index ce5a85b89..3d7776800 100644 --- a/src/models/sparse/Model.h +++ b/src/models/sparse/Model.h @@ -154,7 +154,6 @@ namespace storm { */ RewardModelType const& getRewardModel(std::string const& rewardModelName) const; - /*! * Retrieves the unique reward model, if there exists exactly one. Otherwise, an exception is thrown. * diff --git a/src/models/sparse/StandardRewardModel.cpp b/src/models/sparse/StandardRewardModel.cpp index 1f7db2b79..4cab9bbb4 100644 --- a/src/models/sparse/StandardRewardModel.cpp +++ b/src/models/sparse/StandardRewardModel.cpp @@ -147,6 +147,7 @@ namespace storm { if (this->hasTransitionRewards()) { if (this->hasStateActionRewards()) { storm::utility::vector::addVectors(this->getStateActionRewardVector(), transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()), this->getStateActionRewardVector()); + this->optionalStateActionRewardVector = boost::none; } else { this->optionalStateActionRewardVector = transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()); } @@ -157,8 +158,9 @@ namespace storm { STORM_LOG_THROW(this->getStateRewardVector().size() == this->getStateActionRewardVector().size(), storm::exceptions::InvalidOperationException, "The reduction to state rewards is only possible of both the state and the state-action rewards have the same dimension."); storm::utility::vector::addVectors(this->getStateActionRewardVector(), this->getStateRewardVector(), this->getStateRewardVector()); } else { - this->optionalStateRewardVector = std::move(this->optionalStateRewardVector); + this->optionalStateRewardVector = std::move(this->optionalStateActionRewardVector); } + this->optionalStateActionRewardVector = boost::none; } } diff --git a/src/models/symbolic/Model.h b/src/models/symbolic/Model.h index b70c39b97..4dc6ff31e 100644 --- a/src/models/symbolic/Model.h +++ b/src/models/symbolic/Model.h @@ -38,6 +38,7 @@ namespace storm { template class Model : public storm::models::ModelBase { public: + static const storm::dd::DdType DdType = Type; typedef StandardRewardModel RewardModelType; Model(Model const& other) = default; diff --git a/src/settings/OptionBuilder.h b/src/settings/OptionBuilder.h index 622a7cb1c..f70ac7c2a 100644 --- a/src/settings/OptionBuilder.h +++ b/src/settings/OptionBuilder.h @@ -85,7 +85,7 @@ namespace storm { * @return The resulting option. */ std::shared_ptr