From b14c554df26000d8aaa9c889a92740ba221f0ee1 Mon Sep 17 00:00:00 2001 From: TimQu Date: Wed, 27 Jun 2018 15:38:10 +0200 Subject: [PATCH] correct treatment of Markov Automata in scheduler evaluator --- .../MultiObjectiveSchedulerEvaluator.cpp | 23 +++++++++++++++---- .../MultiObjectiveSchedulerEvaluator.h | 4 ++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.cpp b/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.cpp index f1c78f98d..99a1b5d79 100644 --- a/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.cpp +++ b/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.cpp @@ -1,3 +1,4 @@ +#include #include "storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.h" @@ -27,9 +28,21 @@ namespace storm { template MultiObjectiveSchedulerEvaluator::MultiObjectiveSchedulerEvaluator(preprocessing::SparseMultiObjectivePreprocessorResult& preprocessorResult) : model(*preprocessorResult.preprocessedModel), objectives(preprocessorResult.objectives), currSchedHasBeenChecked(false) { - results.resize(this->objectives.size()); + results.resize(this->objectives.size(), std::vector(getModel().getNumberOfStates())); currSched.resize(this->getModel().getNumberOfStates(), 0); initializeSchedulerIndependentStates(); + if (getModel().isOfType(storm::models::ModelType::MarkovAutomaton)) { + bool transformMaToMdp = true; + for (auto const& obj : objectives) { + if (!storm::transformer::ContinuousToDiscreteTimeModelTransformer::preservesFormula(*obj.formula)) { + transformMaToMdp = false; + } + } + if (transformMaToMdp) { + auto modelAsMa = getModel().template as>(); + mdp = storm::transformer::ContinuousToDiscreteTimeModelTransformer::transform(*modelAsMa); + } + } } template @@ -71,7 +84,6 @@ namespace storm { template std::unique_ptr invokeModelChecker(Environment const& env, std::shared_ptr> const& model, storm::modelchecker::CheckTask const& task) { if (model->getType() == storm::models::ModelType::Dtmc) { - return storm::modelchecker::SparseDtmcPrctlModelChecker>(*model->template as>()).check(env, task); } else if(model->getType() == storm::models::ModelType::Ctmc) { return storm::modelchecker::SparseCtmcCslModelChecker>(*model->template as>()).check(env, task); } else { @@ -87,11 +99,12 @@ namespace storm { scheduler.setChoice(currSched[state], state); } - auto detModel = model.applyScheduler(scheduler, false); - + auto detModel = mdp ? mdp->applyScheduler(scheduler, false) : model.applyScheduler(scheduler, false); + STORM_LOG_ASSERT(detModel->isOfType(storm::models::ModelType::Dtmc), "Model is of unexpected type."); + auto const& dtmc = *(detModel->template as>()); for (uint64_t objIndex = 0; objIndex < this->objectives.size(); ++objIndex) { storm::modelchecker::CheckTask task(*this->objectives[objIndex].formula, false); - auto res = invokeModelChecker(env, detModel, task); + auto res = storm::modelchecker::SparseDtmcPrctlModelChecker>(dtmc).check(env, task); results[objIndex] = std::move(res->template asExplicitQuantitativeCheckResult().getValueVector()); } currSchedHasBeenChecked = true; diff --git a/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.h b/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.h index edb68b705..c2e4970aa 100644 --- a/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.h +++ b/src/storm/modelchecker/multiobjective/deterministicScheds/MultiObjectiveSchedulerEvaluator.h @@ -3,6 +3,7 @@ #include #include "storm/modelchecker/multiobjective/preprocessing/SparseMultiObjectivePreprocessorResult.h" +#include "storm/models/sparse/Mdp.h" namespace storm { @@ -45,6 +46,9 @@ namespace storm { void initializeSchedulerIndependentStates(); ModelType const& model; + // In case the model is a markov automaton, we transform it to an mdp + std::shared_ptr> mdp; + std::vector> const& objectives; // Indicates for each objective the set of states for which the result is fix (i.e. independent of the scheduler).