diff --git a/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp b/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp index f484cee52..e457919cb 100644 --- a/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp +++ b/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp @@ -1,8 +1,10 @@ #include "SparseDtmcInstantiationModelChecker.h" -#include "storm/exceptions/InvalidArgumentException.h" -#include "storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h" +#include "storm/logic/FragmentSpecification.h" +#include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h" +#include "storm/exceptions/InvalidArgumentException.h" +#include "storm/exceptions/InvalidStateException.h" namespace storm { namespace modelchecker { namespace parametric { @@ -12,23 +14,54 @@ namespace storm { //Intentionally left empty } - template - bool SparseDtmcInstantiationModelChecker::canHandle(storm::modelchecker::CheckTask const& checkTask) const { - storm::modelchecker::SparseDtmcPrctlModelChecker> mc(this->parametricModel); - return mc.canHandle(checkTask); - } - template std::unique_ptr SparseDtmcInstantiationModelChecker::check(storm::utility::parametric::Valuation const& valuation) { + STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException, "Checking has been invoked but no property has been specified before."); auto const& instantiatedModel = modelInstantiator.instantiate(valuation); - storm::modelchecker::SparseDtmcPrctlModelChecker> mc(instantiatedModel); + storm::modelchecker::SparseDtmcPrctlModelChecker> modelChecker(instantiatedModel); + + // Check if there are some optimizations implemented for the specified property + if(!this->currentCheckTask->isQualitativeSet() && this->currentCheckTask->getFormula().isInFragment(storm::logic::reachability().setRewardOperatorsAllowed(true).setReachabilityRewardFormulasAllowed(true))) { + return checkWithResultHint(modelChecker); + } else { + return modelChecker.check(*this->currentCheckTask); + } + } + + + template + std::unique_ptr SparseDtmcInstantiationModelChecker::checkWithResultHint(storm::modelchecker::SparseDtmcPrctlModelChecker>& modelchecker) { - // todo check whether the model checker supports hints on the specified property and if this is the case, + // Insert the hint if it exists + if(resultOfLastCheck) { + this->currentCheckTask->setResultHint(std::move(*resultOfLastCheck)); + } - return mc.check(*this->currentCheckTask); + // Check the formula and store the result as a hint for the next call. + // For qualitative properties, we still want a quantitative result hint. Hence we perform the subformula + if(this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) { + std::unique_ptr result = modelchecker.check(*this->currentCheckTask); + resultOfLastCheck = result->template asExplicitQuantitativeCheckResult().getValueVector(); + return result; + } else { + std::unique_ptr quantitativeResult; + auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula()).setOnlyInitialStatesRelevant(false); + if(this->currentCheckTask->getFormula().isProbabilityOperatorFormula()) { + quantitativeResult = modelchecker.computeProbabilities(newCheckTask); + } else if (this->currentCheckTask->getFormula().isRewardOperatorFormula()) { + quantitativeResult = modelchecker.computeRewards(this->currentCheckTask->getFormula().asRewardOperatorFormula().getMeasureType(), newCheckTask); + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Checking with result hint is only implemented for probability or reward operator formulas"); + } + std::unique_ptr qualitativeResult = quantitativeResult->template asExplicitQuantitativeCheckResult().compareAgainstBound(this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(), this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs()); + resultOfLastCheck = std::move(quantitativeResult->template asExplicitQuantitativeCheckResult().getValueVector()); + return qualitativeResult; + } } - + + template class SparseDtmcInstantiationModelChecker, double>; + } } } \ No newline at end of file diff --git a/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h b/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h index affa734c4..2a88f39b3 100644 --- a/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h +++ b/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h @@ -1,9 +1,12 @@ #pragma once #include +#include #include "storm/models/sparse/Dtmc.h" +#include "storm/models/sparse/StandardRewardModel.h" #include "storm/modelchecker/parametric/SparseInstantiationModelChecker.h" +#include "storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h" #include "storm/utility/ModelInstantiator.h" namespace storm { @@ -18,14 +21,18 @@ namespace storm { public: SparseDtmcInstantiationModelChecker(SparseModelType const& parametricModel); - virtual bool canHandle(CheckTask const& checkTask) const override; - - virtual void specifyFormula(CheckTask const& checkTask) override; - virtual std::unique_ptr check(storm::utility::parametric::Valuation const& valuation) override; protected: + + // Considers the result of the last check as a hint for the current check + std::unique_ptr checkWithResultHint(storm::modelchecker::SparseDtmcPrctlModelChecker>& modelChecker); + + storm::utility::ModelInstantiator> modelInstantiator; + + // Stores the result of the last check in order to use it as a hint for the next check. (If this is supported by the property) + boost::optional> resultOfLastCheck; }; } } diff --git a/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.cpp b/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.cpp index feb34eeba..c42e5cef6 100644 --- a/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.cpp +++ b/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.cpp @@ -1,5 +1,10 @@ #include "SparseInstantiationModelChecker.h" +#include "storm/adapters/CarlAdapter.h" +#include "storm/models/sparse/Dtmc.h" +#include "storm/models/sparse/Mdp.h" +#include "storm/models/sparse/StandardRewardModel.h" + #include "storm/exceptions/InvalidArgumentException.h" namespace storm { @@ -14,13 +19,14 @@ namespace storm { template void SparseInstantiationModelChecker::specifyFormula(storm::modelchecker::CheckTask const& checkTask) { - storm::logic::Formula const& formula = checkTask.getFormula(); - STORM_LOG_THROW(this->canHandle(checkTask), storm::exceptions::InvalidArgumentException, "The model checker is not able to check the formula '" << formula << "'."); - - currentCheckTask = std::make_unique>(checkTask.getFormula(), checkTask.isOnlyInitialStatesRelevantSet()); + currentFormula = checkTask.getFormula().asSharedPointer(); + currentCheckTask = std::make_unique>(*currentFormula, checkTask.isOnlyInitialStatesRelevantSet()); currentCheckTask->setProduceSchedulers(checkTask.isProduceSchedulersSet()); } + template class SparseInstantiationModelChecker, double>; + template class SparseInstantiationModelChecker, double>; + } } } \ No newline at end of file diff --git a/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h b/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h index c77341edd..b1513b667 100644 --- a/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h +++ b/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h @@ -17,8 +17,6 @@ namespace storm { public: SparseInstantiationModelChecker(SparseModelType const& parametricModel); - virtual bool canHandle(CheckTask const& checkTask) const = 0; - void specifyFormula(CheckTask const& checkTask); virtual std::unique_ptr check(storm::utility::parametric::Valuation const& valuation) = 0; @@ -28,6 +26,10 @@ namespace storm { SparseModelType const& parametricModel; std::unique_ptr> currentCheckTask; + private: + // store the current formula. Note that currentCheckTask only stores a reference to the formula. + std::shared_ptr currentFormula; + }; } } diff --git a/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp b/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp new file mode 100644 index 000000000..6dbaea1dd --- /dev/null +++ b/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp @@ -0,0 +1,67 @@ +#include "SparseMdpInstantiationModelChecker.h" + +#include "storm/logic/FragmentSpecification.h" +#include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h" + +#include "storm/exceptions/InvalidArgumentException.h" +#include "storm/exceptions/InvalidStateException.h" + +namespace storm { + namespace modelchecker { + namespace parametric { + + template + SparseMdpInstantiationModelChecker::SparseMdpInstantiationModelChecker(SparseModelType const& parametricModel) : SparseInstantiationModelChecker(parametricModel), modelInstantiator(parametricModel) { + //Intentionally left empty + } + + template + std::unique_ptr SparseMdpInstantiationModelChecker::check(storm::utility::parametric::Valuation const& valuation) { + STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException, "Checking has been invoked but no property has been specified before."); + auto const& instantiatedModel = modelInstantiator.instantiate(valuation); + storm::modelchecker::SparseMdpPrctlModelChecker> modelChecker(instantiatedModel); + + // Check if there are some optimizations implemented for the specified property + if(!this->currentCheckTask->isQualitativeSet() && this->currentCheckTask->getFormula().isInFragment(storm::logic::reachability().setRewardOperatorsAllowed(true).setReachabilityRewardFormulasAllowed(true))) { + return checkWithResultHint(modelChecker); + } else { + return modelChecker.check(*this->currentCheckTask); + } + } + + + template + std::unique_ptr SparseMdpInstantiationModelChecker::checkWithResultHint(storm::modelchecker::SparseMdpPrctlModelChecker>& modelchecker) { + + // Insert the hint if it exists + if(resultOfLastCheck) { + this->currentCheckTask->setResultHint(std::move(*resultOfLastCheck)); + } + + // Check the formula and store the result as a hint for the next call. + // For qualitative properties, we still want a quantitative result hint. Hence we perform the subformula + if(this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) { + std::unique_ptr result = modelchecker.check(*this->currentCheckTask); + resultOfLastCheck = result->template asExplicitQuantitativeCheckResult().getValueVector(); + return result; + } else { + std::unique_ptr quantitativeResult; + auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula()).setOnlyInitialStatesRelevant(false); + if(this->currentCheckTask->getFormula().isProbabilityOperatorFormula()) { + quantitativeResult = modelchecker.computeProbabilities(newCheckTask); + } else if (this->currentCheckTask->getFormula().isRewardOperatorFormula()) { + quantitativeResult = modelchecker.computeRewards(this->currentCheckTask->getFormula().asRewardOperatorFormula().getMeasureType(), newCheckTask); + } else { + STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Checking with result hint is only implemented for probability or reward operator formulas"); + } + std::unique_ptr qualitativeResult = quantitativeResult->template asExplicitQuantitativeCheckResult().compareAgainstBound(this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(), this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs()); + resultOfLastCheck = std::move(quantitativeResult->template asExplicitQuantitativeCheckResult().getValueVector()); + return qualitativeResult; + } + } + + template class SparseMdpInstantiationModelChecker, double>; + + } + } +} \ No newline at end of file diff --git a/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.h b/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.h new file mode 100644 index 000000000..72e5120ba --- /dev/null +++ b/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.h @@ -0,0 +1,39 @@ +#pragma once + +#include + +#include "storm/models/sparse/Mdp.h" +#include "storm/models/sparse/Dtmc.h" +#include "storm/models/sparse/StandardRewardModel.h" +#include "storm/modelchecker/parametric/SparseInstantiationModelChecker.h" +#include "storm/modelchecker/prctl/SparseMdpPrctlModelChecker.h" +#include "storm/utility/ModelInstantiator.h" +#include "storm/storage/TotalScheduler.h" + +namespace storm { + namespace modelchecker { + namespace parametric { + + /*! + * Class to efficiently check a formula on a parametric model with different parameter instantiations + */ + template + class SparseMdpInstantiationModelChecker : public SparseInstantiationModelChecker { + public: + SparseMdpInstantiationModelChecker(SparseModelType const& parametricModel); + + virtual std::unique_ptr check(storm::utility::parametric::Valuation const& valuation) override; + + protected: + // Considers the result of the last check as a hint for the current check + std::unique_ptr checkWithResultHint(storm::modelchecker::SparseMdpPrctlModelChecker>& modelChecker); + + storm::utility::ModelInstantiator> modelInstantiator; + + + // Stores the result of the last check in order to use it as a hint for the next check. (If this is supported by the property) + boost::optional> resultOfLastCheck; + }; + } + } +} diff --git a/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp b/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp index 891ff0b53..d02a43a88 100644 --- a/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp +++ b/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp @@ -32,6 +32,7 @@ #include "storm/logic/FragmentSpecification.h" #include "storm/transformer/SparseParametricDtmcSimplifier.h" +#include "storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h" namespace storm { namespace modelchecker { @@ -84,7 +85,7 @@ namespace storm { this->reachabilityFunction=nullptr; //Preprocessing depending on the type of the considered formula - storm::storage::BitVector maybeStates, targetStates; + /* storm::storage::BitVector maybeStates, targetStates; boost::optional> stateRewards; if (this->isComputeRewards()) { std::vector stateRewardsAsVector; @@ -97,7 +98,7 @@ namespace storm { //The result is already known. Nothing else to do here return; } - + */ storm::transformer::SparseParametricDtmcSimplifier simplifier(*this->getModel()); if(!simplifier.simplify(*this->getSpecifiedFormula())) { STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Simplification was not possible"); @@ -409,6 +410,23 @@ namespace storm { constantResult = storm::utility::region::convertNumber(-1.0); } } + + template + void SparseDtmcRegionModelChecker::initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr formula) { + STORM_LOG_DEBUG("Initializing the Sampling Model...."); + std::chrono::high_resolution_clock::time_point timeInitSamplingModelStart = std::chrono::high_resolution_clock::now(); + this->samplingModel=std::make_shared>(model); + // replace bounds by optimization direction to obtain a quantitative formula + if(formula->isProbabilityOperatorFormula()) { + auto quantitativeFormula = std::make_shared(formula->getSubformula().asSharedPointer(), storm::logic::OperatorInformation(storm::logic::isLowerBound(formula->getComparisonType()) ? storm::solver::OptimizationDirection::Minimize : storm::solver::OptimizationDirection::Maximize)); + this->samplingModel->specifyFormula(*quantitativeFormula); + } else { + auto quantitativeFormula = std::make_shared(formula->getSubformula().asSharedPointer(), formula->asRewardOperatorFormula().getOptionalRewardModelName(), storm::logic::OperatorInformation(storm::logic::isLowerBound(formula->getComparisonType()) ? storm::solver::OptimizationDirection::Minimize : storm::solver::OptimizationDirection::Maximize)); + this->samplingModel->specifyFormula(*quantitativeFormula); + } + std::chrono::high_resolution_clock::time_point timeInitSamplingModelEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Initialized Sampling Model"); + } template void SparseDtmcRegionModelChecker::computeReachabilityFunction(storm::models::sparse::Dtmc const& simpleModel){ diff --git a/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.h b/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.h index 7fcf92124..ecdad8c5b 100644 --- a/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.h +++ b/src/storm/modelchecker/region/SparseDtmcRegionModelChecker.h @@ -55,6 +55,12 @@ namespace storm { * @note this->specifiedFormula and this->computeRewards has to be set accordingly before calling this function */ virtual void preprocess(std::shared_ptr& simpleModel, std::shared_ptr& simpleFormula, bool& isApproximationApplicable, boost::optional& constantResult); + + + /*! + * initializes the Sampling Model + */ + virtual void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr formula) override; private: /*! diff --git a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp index 7222c866b..350604ba1 100644 --- a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp +++ b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp @@ -32,6 +32,7 @@ #include "storm/logic/FragmentSpecification.h" #include "storm/transformer/SparseParametricMdpSimplifier.h" +#include "storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.h" namespace storm { @@ -80,13 +81,14 @@ namespace storm { boost::optional& constantResult){ STORM_LOG_DEBUG("Preprocessing for MDPs started."); STORM_LOG_THROW(this->getModel()->getInitialStates().getNumberOfSetBits() == 1, storm::exceptions::InvalidArgumentException, "Input model is required to have exactly one initial state."); + /* storm::storage::BitVector maybeStates, targetStates; preprocessForProbabilities(maybeStates, targetStates, isApproximationApplicable, constantResult); if(constantResult && constantResult.get()>=storm::utility::zero()){ //The result is already known. Nothing else to do here return; } - + */ storm::transformer::SparseParametricMdpSimplifier simplifier(*this->getModel()); if(!simplifier.simplify(*this->getSpecifiedFormula())) { STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Simplification was not possible"); @@ -268,6 +270,22 @@ namespace storm { } } + template + void SparseMdpRegionModelChecker::initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr formula) { + STORM_LOG_DEBUG("Initializing the Sampling Model...."); + std::chrono::high_resolution_clock::time_point timeInitSamplingModelStart = std::chrono::high_resolution_clock::now(); + this->samplingModel=std::make_shared>(model); + if(formula->isProbabilityOperatorFormula()) { + auto quantitativeFormula = std::make_shared(formula->getSubformula().asSharedPointer(), storm::logic::OperatorInformation(storm::logic::isLowerBound(formula->getComparisonType()) ? storm::solver::OptimizationDirection::Minimize : storm::solver::OptimizationDirection::Maximize)); + this->samplingModel->specifyFormula(*quantitativeFormula); + } else { + auto quantitativeFormula = std::make_shared(formula->getSubformula().asSharedPointer(), formula->asRewardOperatorFormula().getOptionalRewardModelName(), storm::logic::OperatorInformation(storm::logic::isLowerBound(formula->getComparisonType()) ? storm::solver::OptimizationDirection::Minimize : storm::solver::OptimizationDirection::Maximize)); + this->samplingModel->specifyFormula(*quantitativeFormula); + } + std::chrono::high_resolution_clock::time_point timeInitSamplingModelEnd = std::chrono::high_resolution_clock::now(); + STORM_LOG_DEBUG("Initialized Sampling Model"); + } + template bool SparseMdpRegionModelChecker::checkPoint(ParameterRegion& region, std::mapconst& point, bool /*favorViaFunction*/) { if(this->checkFormulaOnSamplingPoint(point)){ diff --git a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h index 6ceb020b3..accebefe2 100644 --- a/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h +++ b/src/storm/modelchecker/region/SparseMdpRegionModelChecker.h @@ -78,6 +78,13 @@ namespace storm { * The region checkResult of the given region is changed accordingly. */ virtual bool checkSmt(ParameterRegion& /*region*/); + + + + /*! + * initializes the Sampling Model + */ + virtual void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr formula) override; }; } //namespace region diff --git a/src/storm/modelchecker/region/SparseRegionModelChecker.cpp b/src/storm/modelchecker/region/SparseRegionModelChecker.cpp index 1724335cc..3f7dbde59 100644 --- a/src/storm/modelchecker/region/SparseRegionModelChecker.cpp +++ b/src/storm/modelchecker/region/SparseRegionModelChecker.cpp @@ -182,7 +182,7 @@ namespace storm { STORM_LOG_DEBUG("The Result is constant and will be computed now."); initializeSamplingModel(*this->getSimpleModel(), this->getSimpleFormula()); std::map emptySubstitution; - this->constantResult = this->getSamplingModel()->computeInitialStateValue(emptySubstitution); + this->constantResult = this->getReachabilityValue(emptySubstitution); } //some more information for statistics... @@ -201,17 +201,6 @@ namespace storm { this->timeInitApproxModel=timeInitApproxModelEnd - timeInitApproxModelStart; STORM_LOG_DEBUG("Initialized Approximation Model"); } - - template - void SparseRegionModelChecker::initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr formula) { - STORM_LOG_DEBUG("Initializing the Sampling Model...."); - std::chrono::high_resolution_clock::time_point timeInitSamplingModelStart = std::chrono::high_resolution_clock::now(); - this->samplingModel=std::make_shared>(model, formula); - std::chrono::high_resolution_clock::time_point timeInitSamplingModelEnd = std::chrono::high_resolution_clock::now(); - this->timeInitSamplingModel = timeInitSamplingModelEnd - timeInitSamplingModelStart; - STORM_LOG_DEBUG("Initialized Sampling Model"); - } - template void SparseRegionModelChecker::checkRegions(std::vector>& regions) { @@ -448,7 +437,7 @@ namespace storm { if(this->isResultConstant()){ return this->constantResult.get(); } - return this->getSamplingModel()->computeInitialStateValue(point); + return this->getSamplingModel()->check(point)->template asExplicitQuantitativeCheckResult()[*this->simpleModel->getInitialStates().begin()]; } template @@ -456,11 +445,11 @@ namespace storm { if(this->isResultConstant()){ return this->valueIsInBoundOfFormula(this->constantResult.get()); } - return this->getSamplingModel()->checkFormulaOnSamplingPoint(point); + return this->valueIsInBoundOfFormula(getReachabilityValue(point)); } template - std::shared_ptr> const& SparseRegionModelChecker::getSamplingModel() { + std::shared_ptr> const& SparseRegionModelChecker::getSamplingModel() { if(this->samplingModel==nullptr){ STORM_LOG_WARN("Sampling model requested but it has not been initialized when specifying the formula. Will initialize it now."); initializeSamplingModel(*this->getSimpleModel(), this->getSimpleFormula()); diff --git a/src/storm/modelchecker/region/SparseRegionModelChecker.h b/src/storm/modelchecker/region/SparseRegionModelChecker.h index 4fcf18551..992317055 100644 --- a/src/storm/modelchecker/region/SparseRegionModelChecker.h +++ b/src/storm/modelchecker/region/SparseRegionModelChecker.h @@ -7,7 +7,7 @@ #include "storm/modelchecker/region/AbstractSparseRegionModelChecker.h" #include "storm/modelchecker/region/ParameterRegion.h" #include "storm/modelchecker/region/ApproximationModel.h" -#include "storm/modelchecker/region/SamplingModel.h" +#include "storm/modelchecker/parametric/SparseInstantiationModelChecker.h" #include "storm/models/sparse/StandardRewardModel.h" #include "storm/models/sparse/Model.h" @@ -218,7 +218,7 @@ namespace storm { * Returns the sampling model. * If it is not yet available, it is computed. */ - std::shared_ptr> const& getSamplingModel(); + std::shared_ptr> const& getSamplingModel(); /*! * Starts the SMTSolver to get the result. @@ -228,8 +228,18 @@ namespace storm { * A Sat- or Violated point is set, if the solver has found one (not yet implemented!). * The region checkResult of the given region is changed accordingly. */ - virtual bool checkSmt(ParameterRegion& region)=0; + virtual bool checkSmt(ParameterRegion& region)=0; + + + /*! + * initializes the Sampling Model + */ + virtual void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr formula) = 0; + + // the model that can be instantiated to check the value at a certain point + std::shared_ptr> samplingModel; + private: /*! * initializes the Approximation Model @@ -238,10 +248,6 @@ namespace storm { */ void initializeApproximationModel(ParametricSparseModelType const& model, std::shared_ptr formula); - /*! - * initializes the Sampling Model - */ - void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr formula); // The model this model checker is supposed to analyze. std::shared_ptr model; @@ -257,8 +263,7 @@ namespace storm { bool isApproximationApplicable; // the model that is used to approximate the reachability values std::shared_ptr> approximationModel; - // the model that can be instantiated to check the value at a certain point - std::shared_ptr> samplingModel; + // a flag that is true iff the resulting reachability function is constant boost::optional constantResult; diff --git a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp index 5ea662a57..9e487550c 100644 --- a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp +++ b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp @@ -47,6 +47,11 @@ namespace storm { return boost::get(values); } + template + typename ExplicitQuantitativeCheckResult::vector_type& ExplicitQuantitativeCheckResult::getValueVector() { + return boost::get(values); + } + template typename ExplicitQuantitativeCheckResult::map_type const& ExplicitQuantitativeCheckResult::getValueMap() const { return boost::get(values); diff --git a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h index 9fe1e2c29..9af78dbe8 100644 --- a/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h +++ b/src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h @@ -45,6 +45,7 @@ namespace storm { virtual bool isExplicitQuantitativeCheckResult() const override; vector_type const& getValueVector() const; + vector_type& getValueVector(); map_type const& getValueMap() const; virtual std::ostream& writeToStream(std::ostream& out) const override;