Browse Source

Instantiation model checker for MDPs.

Replaced the old sampling model.
main
TimQu 8 years ago
parent
commit
7a7ad8a34a
  1. 57
      src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp
  2. 15
      src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h
  3. 14
      src/storm/modelchecker/parametric/SparseInstantiationModelChecker.cpp
  4. 6
      src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h
  5. 67
      src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp
  6. 39
      src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.h
  7. 22
      src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp
  8. 6
      src/storm/modelchecker/region/SparseDtmcRegionModelChecker.h
  9. 20
      src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp
  10. 7
      src/storm/modelchecker/region/SparseMdpRegionModelChecker.h
  11. 19
      src/storm/modelchecker/region/SparseRegionModelChecker.cpp
  12. 23
      src/storm/modelchecker/region/SparseRegionModelChecker.h
  13. 5
      src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp
  14. 1
      src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h

57
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 <typename SparseModelType, typename ConstantType>
bool SparseDtmcInstantiationModelChecker<SparseModelType, ConstantType>::canHandle(storm::modelchecker::CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask) const {
storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<ConstantType>> mc(this->parametricModel);
return mc.canHandle(checkTask);
}
template <typename SparseModelType, typename ConstantType>
std::unique_ptr<CheckResult> SparseDtmcInstantiationModelChecker<SparseModelType, ConstantType>::check(storm::utility::parametric::Valuation<typename SparseModelType::ValueType> 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<storm::models::sparse::Dtmc<ConstantType>> mc(instantiatedModel);
storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<ConstantType>> 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 <typename SparseModelType, typename ConstantType>
std::unique_ptr<CheckResult> SparseDtmcInstantiationModelChecker<SparseModelType, ConstantType>::checkWithResultHint(storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<ConstantType>>& 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<storm::modelchecker::CheckResult> result = modelchecker.check(*this->currentCheckTask);
resultOfLastCheck = result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
return result;
} else {
std::unique_ptr<storm::modelchecker::CheckResult> 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<storm::modelchecker::CheckResult> qualitativeResult = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(), this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
resultOfLastCheck = std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
return qualitativeResult;
}
}
template class SparseDtmcInstantiationModelChecker<storm::models::sparse::Dtmc<storm::RationalFunction>, double>;
}
}
}

15
src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h

@ -1,9 +1,12 @@
#pragma once
#include <memory>
#include <boost/optional.hpp>
#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<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask) const override;
virtual void specifyFormula(CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask) override;
virtual std::unique_ptr<CheckResult> check(storm::utility::parametric::Valuation<typename SparseModelType::ValueType> const& valuation) override;
protected:
// Considers the result of the last check as a hint for the current check
std::unique_ptr<CheckResult> checkWithResultHint(storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<ConstantType>>& modelChecker);
storm::utility::ModelInstantiator<SparseModelType, storm::models::sparse::Dtmc<ConstantType>> 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<std::vector<ConstantType>> resultOfLastCheck;
};
}
}

14
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 <typename SparseModelType, typename ConstantType>
void SparseInstantiationModelChecker<SparseModelType, ConstantType>::specifyFormula(storm::modelchecker::CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> 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<storm::modelchecker::CheckTask<storm::logic::Formula, ConstantType>>(checkTask.getFormula(), checkTask.isOnlyInitialStatesRelevantSet());
currentFormula = checkTask.getFormula().asSharedPointer();
currentCheckTask = std::make_unique<storm::modelchecker::CheckTask<storm::logic::Formula, ConstantType>>(*currentFormula, checkTask.isOnlyInitialStatesRelevantSet());
currentCheckTask->setProduceSchedulers(checkTask.isProduceSchedulersSet());
}
template class SparseInstantiationModelChecker<storm::models::sparse::Dtmc<storm::RationalFunction>, double>;
template class SparseInstantiationModelChecker<storm::models::sparse::Mdp<storm::RationalFunction>, double>;
}
}
}

6
src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h

@ -17,8 +17,6 @@ namespace storm {
public:
SparseInstantiationModelChecker(SparseModelType const& parametricModel);
virtual bool canHandle(CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask) const = 0;
void specifyFormula(CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask);
virtual std::unique_ptr<CheckResult> check(storm::utility::parametric::Valuation<typename SparseModelType::ValueType> const& valuation) = 0;
@ -28,6 +26,10 @@ namespace storm {
SparseModelType const& parametricModel;
std::unique_ptr<CheckTask<storm::logic::Formula, ConstantType>> currentCheckTask;
private:
// store the current formula. Note that currentCheckTask only stores a reference to the formula.
std::shared_ptr<storm::logic::Formula const> currentFormula;
};
}
}

67
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 <typename SparseModelType, typename ConstantType>
SparseMdpInstantiationModelChecker<SparseModelType, ConstantType>::SparseMdpInstantiationModelChecker(SparseModelType const& parametricModel) : SparseInstantiationModelChecker<SparseModelType, ConstantType>(parametricModel), modelInstantiator(parametricModel) {
//Intentionally left empty
}
template <typename SparseModelType, typename ConstantType>
std::unique_ptr<CheckResult> SparseMdpInstantiationModelChecker<SparseModelType, ConstantType>::check(storm::utility::parametric::Valuation<typename SparseModelType::ValueType> 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<storm::models::sparse::Mdp<ConstantType>> 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 <typename SparseModelType, typename ConstantType>
std::unique_ptr<CheckResult> SparseMdpInstantiationModelChecker<SparseModelType, ConstantType>::checkWithResultHint(storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<ConstantType>>& 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<storm::modelchecker::CheckResult> result = modelchecker.check(*this->currentCheckTask);
resultOfLastCheck = result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
return result;
} else {
std::unique_ptr<storm::modelchecker::CheckResult> 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<storm::modelchecker::CheckResult> qualitativeResult = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(), this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
resultOfLastCheck = std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
return qualitativeResult;
}
}
template class SparseMdpInstantiationModelChecker<storm::models::sparse::Mdp<storm::RationalFunction>, double>;
}
}
}

39
src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.h

@ -0,0 +1,39 @@
#pragma once
#include <memory>
#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 <typename SparseModelType, typename ConstantType>
class SparseMdpInstantiationModelChecker : public SparseInstantiationModelChecker<SparseModelType, ConstantType> {
public:
SparseMdpInstantiationModelChecker(SparseModelType const& parametricModel);
virtual std::unique_ptr<CheckResult> check(storm::utility::parametric::Valuation<typename SparseModelType::ValueType> const& valuation) override;
protected:
// Considers the result of the last check as a hint for the current check
std::unique_ptr<CheckResult> checkWithResultHint(storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<ConstantType>>& modelChecker);
storm::utility::ModelInstantiator<SparseModelType, storm::models::sparse::Mdp<ConstantType>> 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<std::vector<ConstantType>> resultOfLastCheck;
};
}
}
}

22
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<std::vector<ParametricType>> stateRewards;
if (this->isComputeRewards()) {
std::vector<ParametricType> stateRewardsAsVector;
@ -97,7 +98,7 @@ namespace storm {
//The result is already known. Nothing else to do here
return;
}
*/
storm::transformer::SparseParametricDtmcSimplifier<ParametricSparseModelType> 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<ConstantType>(-1.0);
}
}
template<typename ParametricSparseModelType, typename ConstantType>
void SparseDtmcRegionModelChecker<ParametricSparseModelType, ConstantType>::initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> 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<storm::modelchecker::parametric::SparseDtmcInstantiationModelChecker<ParametricSparseModelType, ConstantType>>(model);
// replace bounds by optimization direction to obtain a quantitative formula
if(formula->isProbabilityOperatorFormula()) {
auto quantitativeFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula const>(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<storm::logic::RewardOperatorFormula>(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<typename ParametricSparseModelType, typename ConstantType>
void SparseDtmcRegionModelChecker<ParametricSparseModelType, ConstantType>::computeReachabilityFunction(storm::models::sparse::Dtmc<ParametricType> const& simpleModel){

6
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<ParametricSparseModelType>& simpleModel, std::shared_ptr<storm::logic::OperatorFormula const>& simpleFormula, bool& isApproximationApplicable, boost::optional<ConstantType>& constantResult);
/*!
* initializes the Sampling Model
*/
virtual void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> formula) override;
private:
/*!

20
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<ConstantType>& 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<ConstantType>()){
//The result is already known. Nothing else to do here
return;
}
*/
storm::transformer::SparseParametricMdpSimplifier<ParametricSparseModelType> 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<typename ParametricSparseModelType, typename ConstantType>
void SparseMdpRegionModelChecker<ParametricSparseModelType, ConstantType>::initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> 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<storm::modelchecker::parametric::SparseMdpInstantiationModelChecker<ParametricSparseModelType, ConstantType>>(model);
if(formula->isProbabilityOperatorFormula()) {
auto quantitativeFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula const>(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<storm::logic::RewardOperatorFormula>(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<typename ParametricSparseModelType, typename ConstantType>
bool SparseMdpRegionModelChecker<ParametricSparseModelType, ConstantType>::checkPoint(ParameterRegion<ParametricType>& region, std::map<VariableType, CoefficientType>const& point, bool /*favorViaFunction*/) {
if(this->checkFormulaOnSamplingPoint(point)){

7
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<ParametricType>& /*region*/);
/*!
* initializes the Sampling Model
*/
virtual void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> formula) override;
};
} //namespace region

19
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<VariableType, CoefficientType> 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<typename ParametricSparseModelType, typename ConstantType>
void SparseRegionModelChecker<ParametricSparseModelType, ConstantType>::initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> 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<SamplingModel<ParametricSparseModelType, ConstantType>>(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<typename ParametricSparseModelType, typename ConstantType>
void SparseRegionModelChecker<ParametricSparseModelType, ConstantType>::checkRegions(std::vector<ParameterRegion<ParametricType>>& 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<ConstantType>()[*this->simpleModel->getInitialStates().begin()];
}
template<typename ParametricSparseModelType, typename ConstantType>
@ -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<typename ParametricSparseModelType, typename ConstantType>
std::shared_ptr<SamplingModel<ParametricSparseModelType, ConstantType>> const& SparseRegionModelChecker<ParametricSparseModelType, ConstantType>::getSamplingModel() {
std::shared_ptr<storm::modelchecker::parametric::SparseInstantiationModelChecker<ParametricSparseModelType, ConstantType>> const& SparseRegionModelChecker<ParametricSparseModelType, ConstantType>::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());

23
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<SamplingModel<ParametricSparseModelType, ConstantType>> const& getSamplingModel();
std::shared_ptr<storm::modelchecker::parametric::SparseInstantiationModelChecker<ParametricSparseModelType, ConstantType>> 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<ParametricType>& region)=0;
virtual bool checkSmt(ParameterRegion<ParametricType>& region)=0;
/*!
* initializes the Sampling Model
*/
virtual void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> formula) = 0;
// the model that can be instantiated to check the value at a certain point
std::shared_ptr<storm::modelchecker::parametric::SparseInstantiationModelChecker<ParametricSparseModelType, ConstantType>> samplingModel;
private:
/*!
* initializes the Approximation Model
@ -238,10 +248,6 @@ namespace storm {
*/
void initializeApproximationModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> formula);
/*!
* initializes the Sampling Model
*/
void initializeSamplingModel(ParametricSparseModelType const& model, std::shared_ptr<storm::logic::OperatorFormula const> formula);
// The model this model checker is supposed to analyze.
std::shared_ptr<ParametricSparseModelType> model;
@ -257,8 +263,7 @@ namespace storm {
bool isApproximationApplicable;
// the model that is used to approximate the reachability values
std::shared_ptr<ApproximationModel<ParametricSparseModelType, ConstantType>> approximationModel;
// the model that can be instantiated to check the value at a certain point
std::shared_ptr<SamplingModel<ParametricSparseModelType, ConstantType>> samplingModel;
// a flag that is true iff the resulting reachability function is constant
boost::optional<ConstantType> constantResult;

5
src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp

@ -47,6 +47,11 @@ namespace storm {
return boost::get<vector_type>(values);
}
template<typename ValueType>
typename ExplicitQuantitativeCheckResult<ValueType>::vector_type& ExplicitQuantitativeCheckResult<ValueType>::getValueVector() {
return boost::get<vector_type>(values);
}
template<typename ValueType>
typename ExplicitQuantitativeCheckResult<ValueType>::map_type const& ExplicitQuantitativeCheckResult<ValueType>::getValueMap() const {
return boost::get<map_type>(values);

1
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;

Loading…
Cancel
Save