14 changed files with 252 additions and 49 deletions
-
57src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp
-
15src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.h
-
14src/storm/modelchecker/parametric/SparseInstantiationModelChecker.cpp
-
6src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h
-
67src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp
-
39src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.h
-
22src/storm/modelchecker/region/SparseDtmcRegionModelChecker.cpp
-
6src/storm/modelchecker/region/SparseDtmcRegionModelChecker.h
-
20src/storm/modelchecker/region/SparseMdpRegionModelChecker.cpp
-
7src/storm/modelchecker/region/SparseMdpRegionModelChecker.h
-
19src/storm/modelchecker/region/SparseRegionModelChecker.cpp
-
23src/storm/modelchecker/region/SparseRegionModelChecker.h
-
5src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.cpp
-
1src/storm/modelchecker/results/ExplicitQuantitativeCheckResult.h
@ -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>; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -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; |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue