diff --git a/src/storm/api/verification.h b/src/storm/api/verification.h index 27392b81e..c22668610 100644 --- a/src/storm/api/verification.h +++ b/src/storm/api/verification.h @@ -2,6 +2,8 @@ #include +#include "storm/environment/Environment.h" + #include "storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h" #include "storm/modelchecker/prctl/HybridDtmcPrctlModelChecker.h" #include "storm/modelchecker/prctl/SymbolicDtmcPrctlModelChecker.h" @@ -47,9 +49,9 @@ namespace storm { std::vector constraints; std::vector> injectedRefinementPredicates; }; - + template - typename std::enable_if::value || std::is_same::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task, AbstractionRefinementOptions const& options = AbstractionRefinementOptions()) { + typename std::enable_if::value || std::is_same::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::Environment const& env, storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task, AbstractionRefinementOptions const& options = AbstractionRefinementOptions()) { STORM_LOG_THROW(model.getModelType() == storm::storage::SymbolicModelDescription::ModelType::DTMC || model.getModelType() == storm::storage::SymbolicModelDescription::ModelType::MDP, storm::exceptions::NotSupportedException, "Can only treat DTMCs/MDPs using the abstraction refinement engine."); std::unique_ptr result; @@ -59,50 +61,75 @@ namespace storm { if (model.getModelType() == storm::storage::SymbolicModelDescription::ModelType::DTMC) { storm::modelchecker::GameBasedMdpModelChecker> modelchecker(model, modelCheckerOptions); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } } else if (model.getModelType() == storm::storage::SymbolicModelDescription::ModelType::MDP) { storm::modelchecker::GameBasedMdpModelChecker> modelchecker(model, modelCheckerOptions); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "The model type is currently not supported."); } return result; } - + + template + typename std::enable_if::value || std::is_same::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task, AbstractionRefinementOptions const& options = AbstractionRefinementOptions()) { + Environment env; + return verifyWithAbstractionRefinementEngine(env, model, task, options); + } + template - typename std::enable_if::value && !std::is_same::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::storage::SymbolicModelDescription const&, storm::modelchecker::CheckTask const&, AbstractionRefinementOptions const& = AbstractionRefinementOptions()) { + typename std::enable_if::value && !std::is_same::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::Environment const& env, storm::storage::SymbolicModelDescription const&, storm::modelchecker::CheckTask const&, AbstractionRefinementOptions const& = AbstractionRefinementOptions()) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Abstraction-refinement engine does not support data type."); } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value && !std::is_same::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task, AbstractionRefinementOptions const& options = AbstractionRefinementOptions()) { + Environment env; + return verifyWithAbstractionRefinementEngine(env, model, task, options); + } + + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::Environment const& env, std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; if (model->getType() == storm::models::ModelType::Dtmc) { storm::modelchecker::BisimulationAbstractionRefinementModelChecker> modelchecker(*model->template as>()); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } } else if (model->getType() == storm::models::ModelType::Mdp) { storm::modelchecker::BisimulationAbstractionRefinementModelChecker> modelchecker(*model->template as>()); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "The model type is not supported by the dd engine."); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithAbstractionRefinementEngine(env, model, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(storm::Environment const&, std::shared_ptr> const&, storm::modelchecker::CheckTask const&) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Abstraction-refinement engine does not support data type."); } - + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithAbstractionRefinementEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithAbstractionRefinementEngine(env, model, task); + } + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithExplorationEngine(storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithExplorationEngine(storm::Environment const& env, storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task) { STORM_LOG_THROW(model.isPrismProgram(), storm::exceptions::NotSupportedException, "Exploration engine is currently only applicable to PRISM models."); storm::prism::Program const& program = model.asPrismProgram(); STORM_LOG_THROW(program.getModelType() == storm::prism::Program::ModelType::DTMC || program.getModelType() == storm::prism::Program::ModelType::MDP, storm::exceptions::NotSupportedException, "Currently exploration-based verification is only available for DTMCs and MDPs."); @@ -111,71 +138,107 @@ namespace storm { if (program.getModelType() == storm::prism::Program::ModelType::DTMC) { storm::modelchecker::SparseExplorationModelChecker> checker(program); if (checker.canHandle(task)) { - result = checker.check(task); + result = checker.check(env, task); } } else { storm::modelchecker::SparseExplorationModelChecker> checker(program); if (checker.canHandle(task)) { - result = checker.check(task); + result = checker.check(env, task); } } return result; } - + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithExplorationEngine(storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithExplorationEngine(env, model, task); + } + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithExplorationEngine(storm::storage::SymbolicModelDescription const&, storm::modelchecker::CheckTask const&) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithExplorationEngine(storm::Environment const&, storm::storage::SymbolicModelDescription const&, storm::modelchecker::CheckTask const&) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Exploration engine does not support data type."); } - + template - std::unique_ptr verifyWithSparseEngine(std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithExplorationEngine(storm::storage::SymbolicModelDescription const& model, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithExplorationEngine(env, model, task); + } + + template + std::unique_ptr verifyWithSparseEngine(storm::Environment const& env, std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; if (storm::settings::getModule().getEquationSolver() == storm::solver::EquationSolverType::Elimination && storm::settings::getModule().isUseDedicatedModelCheckerSet()) { storm::modelchecker::SparseDtmcEliminationModelChecker> modelchecker(*dtmc); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } } else { storm::modelchecker::SparseDtmcPrctlModelChecker> modelchecker(*dtmc); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } } return result; } - + template - std::unique_ptr verifyWithSparseEngine(std::shared_ptr> const& ctmc, storm::modelchecker::CheckTask const& task) { + std::unique_ptr verifyWithSparseEngine(std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithSparseEngine(env, dtmc, task); + } + + template + std::unique_ptr verifyWithSparseEngine(storm::Environment const& env, std::shared_ptr> const& ctmc, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::SparseCtmcCslModelChecker> modelchecker(*ctmc); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + std::unique_ptr verifyWithSparseEngine(std::shared_ptr> const& ctmc, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithSparseEngine(env, ctmc, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(storm::Environment const& env, std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::SparseMdpPrctlModelChecker> modelchecker(*mdp); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithSparseEngine(env, mdp, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(storm::Environment const& env, std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::SparsePropositionalModelChecker> modelchecker(*mdp); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& ma, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithSparseEngine(env, mdp, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(storm::Environment const& env, std::shared_ptr> const& ma, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; // Close the MA, if it is not already closed. @@ -186,120 +249,192 @@ namespace storm { storm::modelchecker::SparseMarkovAutomatonCslModelChecker> modelchecker(*ma); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& ma, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& ma, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithSparseEngine(env, ma, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(storm::Environment const&, std::shared_ptr> const& , storm::modelchecker::CheckTask const& ) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Sparse engine cannot verify MAs with this data type."); } - + template - std::unique_ptr verifyWithSparseEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithSparseEngine(std::shared_ptr> const& ma, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithSparseEngine(env, ma, task); + } + + template + std::unique_ptr verifyWithSparseEngine(storm::Environment const& env, std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; if (model->getType() == storm::models::ModelType::Dtmc) { - result = verifyWithSparseEngine(model->template as>(), task); + result = verifyWithSparseEngine(env, model->template as>(), task); } else if (model->getType() == storm::models::ModelType::Mdp) { - result = verifyWithSparseEngine(model->template as>(), task); + result = verifyWithSparseEngine(env, model->template as>(), task); } else if (model->getType() == storm::models::ModelType::Ctmc) { - result = verifyWithSparseEngine(model->template as>(), task); + result = verifyWithSparseEngine(env, model->template as>(), task); } else if (model->getType() == storm::models::ModelType::MarkovAutomaton) { - result = verifyWithSparseEngine(model->template as>(), task); + result = verifyWithSparseEngine(env, model->template as>(), task); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "The model type " << model->getType() << " is not supported."); } return result; } - + + template + std::unique_ptr verifyWithSparseEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithSparseEngine(env, model, task); + } + template - std::unique_ptr verifyWithHybridEngine(std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { + std::unique_ptr verifyWithHybridEngine(storm::Environment const& env, std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::HybridDtmcPrctlModelChecker> modelchecker(*dtmc); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - std::unique_ptr verifyWithHybridEngine(std::shared_ptr> const& ctmc, storm::modelchecker::CheckTask const& task) { + std::unique_ptr verifyWithHybridEngine(std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithHybridEngine(env, dtmc, task); + } + + template + std::unique_ptr verifyWithHybridEngine(storm::Environment const& env, std::shared_ptr> const& ctmc, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::HybridCtmcCslModelChecker> modelchecker(*ctmc); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithHybridEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + std::unique_ptr verifyWithHybridEngine(std::shared_ptr> const& ctmc, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithHybridEngine(env, ctmc, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithHybridEngine(storm::Environment const& env, std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::HybridMdpPrctlModelChecker> modelchecker(*mdp); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithHybridEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithHybridEngine(env, mdp, task); + } + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithHybridEngine(std::shared_ptr> const&, storm::modelchecker::CheckTask const&) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithHybridEngine(storm::Environment const& , std::shared_ptr> const&, storm::modelchecker::CheckTask const&) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Hybrid engine cannot verify MDPs with this data type."); } - + template - std::unique_ptr verifyWithHybridEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithHybridEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithHybridEngine(env, mdp, task); + } + + template + std::unique_ptr verifyWithHybridEngine(storm::Environment const& env, std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; if (model->getType() == storm::models::ModelType::Dtmc) { - result = verifyWithHybridEngine(model->template as>(), task); + result = verifyWithHybridEngine(env, model->template as>(), task); } else if (model->getType() == storm::models::ModelType::Ctmc) { - result = verifyWithHybridEngine(model->template as>(), task); + result = verifyWithHybridEngine(env, model->template as>(), task); } else if (model->getType() == storm::models::ModelType::Mdp) { - result = verifyWithHybridEngine(model->template as>(), task); + result = verifyWithHybridEngine(env, model->template as>(), task); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "The model type is not supported by the hybrid engine."); } return result; } - + template - std::unique_ptr verifyWithDdEngine(std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { + std::unique_ptr verifyWithHybridEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithHybridEngine(env, model, task); + } + + template + std::unique_ptr verifyWithDdEngine(storm::Environment const& env, std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::SymbolicDtmcPrctlModelChecker> modelchecker(*dtmc); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithDdEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + std::unique_ptr verifyWithDdEngine(std::shared_ptr> const& dtmc, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithDdEngine(env, dtmc, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithDdEngine(storm::Environment const& env, std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; storm::modelchecker::SymbolicMdpPrctlModelChecker> modelchecker(*mdp); if (modelchecker.canHandle(task)) { - result = modelchecker.check(task); + result = modelchecker.check(env, task); } return result; } - + template - typename std::enable_if::value, std::unique_ptr>::type verifyWithDdEngine(std::shared_ptr> const&, storm::modelchecker::CheckTask const&) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithDdEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithDdEngine(env, mdp, task); + } + + template + typename std::enable_if::value, std::unique_ptr>::type verifyWithDdEngine(storm::Environment const&, std::shared_ptr> const&, storm::modelchecker::CheckTask const&) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Dd engine cannot verify MDPs with this data type."); } - + template - std::unique_ptr verifyWithDdEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + typename std::enable_if::value, std::unique_ptr>::type verifyWithDdEngine(std::shared_ptr> const& mdp, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithDdEngine(env, mdp, task); + } + + template + std::unique_ptr verifyWithDdEngine(storm::Environment const& env, std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { std::unique_ptr result; if (model->getType() == storm::models::ModelType::Dtmc) { - result = verifyWithDdEngine(model->template as>(), task); + result = verifyWithDdEngine(env, model->template as>(), task); } else if (model->getType() == storm::models::ModelType::Mdp) { - result = verifyWithDdEngine(model->template as>(), task); + result = verifyWithDdEngine(env, model->template as>(), task); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "The model type is not supported by the dd engine."); } return result; } + + template + std::unique_ptr verifyWithDdEngine(std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { + Environment env; + return verifyWithDdEngine(env, model, task); + } } }