diff --git a/src/abstraction/MenuGameAbstractor.cpp b/src/abstraction/MenuGameAbstractor.cpp deleted file mode 100644 index dc9f1ceac..000000000 --- a/src/abstraction/MenuGameAbstractor.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "src/abstraction/MenuGameAbstractor.h" \ No newline at end of file diff --git a/src/abstraction/prism/PrismMenuGameAbstractor.cpp b/src/abstraction/prism/PrismMenuGameAbstractor.cpp new file mode 100644 index 000000000..996d66db7 --- /dev/null +++ b/src/abstraction/prism/PrismMenuGameAbstractor.cpp @@ -0,0 +1,27 @@ +#include "src/abstraction/prism/PrismMenuGameAbstractor.h" + +#include "src/settings/SettingsManager.h" +#include "src/settings/modules/AbstractionSettings.h" + +namespace storm { + namespace abstraction { + namespace prism { + + template + PrismMenuGameAbstractor::PrismMenuGameAbstractor(storm::expressions::ExpressionManager& expressionManager, storm::prism::Program const& program, std::vector const& initialPredicates, std::unique_ptr&& smtSolverFactory) : abstractProgram(expressionManager, program, initialPredicates, std::move(smtSolverFactory), storm::settings::getModule().isAddAllGuardsSet()) { + // Intentionally left empty. + } + + template + storm::abstraction::MenuGame PrismMenuGameAbstractor::abstract() { + return abstractProgram.getAbstractGame(); + } + + template + void PrismMenuGameAbstractor::refine(std::vector const& predicates) { + abstractProgram.refine(predicates); + } + + } + } +} \ No newline at end of file diff --git a/src/abstraction/prism/PrismMenuGameAbstractor.h b/src/abstraction/prism/PrismMenuGameAbstractor.h new file mode 100644 index 000000000..b3f30bea7 --- /dev/null +++ b/src/abstraction/prism/PrismMenuGameAbstractor.h @@ -0,0 +1,26 @@ +#pragma once + +#include "src/abstraction/MenuGameAbstractor.h" + +#include "src/abstraction/prism/AbstractProgram.h" + +namespace storm { + namespace abstraction { + namespace prism { + + template + class PrismMenuGameAbstractor : public MenuGameAbstractor { + public: + PrismMenuGameAbstractor(storm::expressions::ExpressionManager& expressionManager, storm::prism::Program const& program, std::vector const& initialPredicates, std::unique_ptr&& smtSolverFactory = std::make_unique()); + + virtual storm::abstraction::MenuGame abstract() override; + virtual void refine(std::vector const& predicates) override; + + private: + /// The abstract program that performs the actual abstraction. + AbstractProgram abstractProgram; + }; + + } + } +} \ No newline at end of file diff --git a/src/modelchecker/abstraction/GameBasedMdpModelChecker.cpp b/src/modelchecker/abstraction/GameBasedMdpModelChecker.cpp index d5a4928c0..bf946d58a 100644 --- a/src/modelchecker/abstraction/GameBasedMdpModelChecker.cpp +++ b/src/modelchecker/abstraction/GameBasedMdpModelChecker.cpp @@ -15,7 +15,7 @@ namespace storm { namespace modelchecker { template GameBasedMdpModelChecker::GameBasedMdpModelChecker(storm::prism::Program const& program, std::unique_ptr&& smtSolverFactory) : originalProgram(program), smtSolverFactory(std::move(smtSolverFactory)) { - STORM_LOG_THROW(program.getModelType() == storm::prism::Program::ModelType::MDP, storm::exceptions::NotSupportedException, "Currently only MDPs are supported by the game-based model checker."); + STORM_LOG_THROW(program.getModelType() == storm::prism::Program::ModelType::DTMC || program.getModelType() == storm::prism::Program::ModelType::MDP, storm::exceptions::NotSupportedException, "Currently only DTMCs/MDPs are supported by the game-based model checker."); // Start by preparing the program. That is, we flatten the modules if there is more than one. if (originalProgram.getNumberOfModules() > 1) { @@ -46,12 +46,11 @@ namespace storm { template std::unique_ptr GameBasedMdpModelChecker::computeReachabilityProbabilities(CheckTask const& checkTask) { storm::logic::EventuallyFormula const& pathFormula = checkTask.getFormula(); - return performGameBasedAbstractionRefinement(CheckTask(pathFormula), originalProgram.getManager().boolean(true), getExpression(pathFormula.getSubformula())); + return performGameBasedAbstractionRefinement(checkTask.substituteFormula(pathFormula), originalProgram.getManager().boolean(true), getExpression(pathFormula.getSubformula())); } template std::unique_ptr GameBasedMdpModelChecker::performGameBasedAbstractionRefinement(CheckTask const& checkTask, storm::expressions::Expression const& constraintExpression, storm::expressions::Expression const& targetStateExpression) { - STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidPropertyException, "The game-based abstraction refinement model checker can only compute the result for the initial states."); // 1. build initial abstraction based on the the constraint expression (if not 'true') and the target state expression. diff --git a/src/settings/SettingsManager.cpp b/src/settings/SettingsManager.cpp index 2c049ae62..bbd80ec42 100644 --- a/src/settings/SettingsManager.cpp +++ b/src/settings/SettingsManager.cpp @@ -32,6 +32,7 @@ #include "src/settings/modules/TopologicalValueIterationEquationSolverSettings.h" #include "src/settings/modules/ExplorationSettings.h" #include "src/settings/modules/ResourceSettings.h" +#include "src/settings/modules/AbstractionSettings.h" #include "src/utility/macros.h" #include "src/settings/Option.h" @@ -522,6 +523,7 @@ namespace storm { storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); + storm::settings::addModule(); } } diff --git a/src/settings/modules/AbstractionSettings.cpp b/src/settings/modules/AbstractionSettings.cpp new file mode 100644 index 000000000..06aec79ee --- /dev/null +++ b/src/settings/modules/AbstractionSettings.cpp @@ -0,0 +1,23 @@ +#include "src/settings/modules/AbstractionSettings.h" + +#include "src/settings/Option.h" +#include "src/settings/OptionBuilder.h" + +namespace storm { + namespace settings { + namespace modules { + + const std::string AbstractionSettings::moduleName = "abstraction"; + const std::string AbstractionSettings::addAllGuardsOptionName = "allguards"; + + AbstractionSettings::AbstractionSettings() : ModuleSettings(moduleName) { + this->addOption(storm::settings::OptionBuilder(moduleName, addAllGuardsOptionName, true, "Sets whether all guards are added as initial predicates.").build()); + } + + bool AbstractionSettings::isAddAllGuardsSet() const { + return this->getOption(addAllGuardsOptionName).getHasOptionBeenSet(); + } + + } + } +} \ No newline at end of file diff --git a/src/settings/modules/AbstractionSettings.h b/src/settings/modules/AbstractionSettings.h new file mode 100644 index 000000000..44a504171 --- /dev/null +++ b/src/settings/modules/AbstractionSettings.h @@ -0,0 +1,34 @@ +#pragma once + +#include "src/settings/modules/ModuleSettings.h" + +namespace storm { + namespace settings { + namespace modules { + + /*! + * This class represents the settings for the abstraction procedures. + */ + class AbstractionSettings : public ModuleSettings { + public: + /*! + * Creates a new set of abstraction settings. + */ + AbstractionSettings(); + + /*! + * Retrieves whether the option to add all guards was set. + * + * @return True iff the option was set. + */ + bool isAddAllGuardsSet() const; + + const static std::string moduleName; + + private: + const static std::string addAllGuardsOptionName; + }; + + } + } +} \ No newline at end of file diff --git a/src/utility/storm.h b/src/utility/storm.h index cb6a085c7..aa1c6ed87 100644 --- a/src/utility/storm.h +++ b/src/utility/storm.h @@ -441,7 +441,7 @@ namespace storm { template std::unique_ptr verifyProgramWithAbstractionRefinementEngine(storm::prism::Program const& program, std::shared_ptr const& formula, bool onlyInitialStatesRelevant = false) { - STORM_LOG_THROW(program.getModelType() == storm::prism::Program::ModelType::MDP, storm::exceptions::InvalidSettingsException, "Cannot treat non-MDP model using the abstraction refinement engine."); + STORM_LOG_THROW(program.getModelType() == storm::prism::Program::ModelType::DTMC || program.getModelType() == storm::prism::Program::ModelType::MDP, storm::exceptions::InvalidSettingsException, "Can only treat DTMCs/MDPs using the abstraction refinement engine."); // FIXME: Cudd -> ValueType, double -> ValueType storm::modelchecker::GameBasedMdpModelChecker modelchecker(program);