|
|
@ -9,6 +9,7 @@ |
|
|
|
#include "storm/exceptions/NotSupportedException.h"
|
|
|
|
#include "storm/modelchecker/CheckTask.h"
|
|
|
|
#include "storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
|
|
|
|
#include "storm/modelchecker/prctl/SparseMdpPrctlModelChecker.h"
|
|
|
|
#include "storm/modelchecker/results/CheckResult.h"
|
|
|
|
#include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h"
|
|
|
|
#include "storm/storage/expressions/SimpleValuation.h"
|
|
|
@ -56,6 +57,45 @@ namespace storm { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
AssumptionChecker<ValueType>::AssumptionChecker(std::shared_ptr<storm::logic::Formula const> formula, std::shared_ptr<storm::models::sparse::Mdp<ValueType>> model, uint_fast64_t numberOfSamples) { |
|
|
|
this->formula = formula; |
|
|
|
this->matrix = model->getTransitionMatrix(); |
|
|
|
|
|
|
|
// Create sample points
|
|
|
|
auto instantiator = storm::utility::ModelInstantiator<storm::models::sparse::Mdp<ValueType>, storm::models::sparse::Mdp<double>>(*model); |
|
|
|
auto matrix = model->getTransitionMatrix(); |
|
|
|
std::set<storm::RationalFunctionVariable> variables = storm::models::sparse::getProbabilityParameters(*model); |
|
|
|
for (auto i = 0; i < numberOfSamples; ++i) { |
|
|
|
auto valuation = storm::utility::parametric::Valuation<ValueType>(); |
|
|
|
for (auto itr = variables.begin(); itr != variables.end(); ++itr) { |
|
|
|
// TODO: Type
|
|
|
|
auto val = std::pair<storm::RationalFunctionVariable, storm::RationalFunctionCoefficient>((*itr), storm::utility::convertNumber<storm::RationalFunctionCoefficient>(boost::lexical_cast<std::string>((i+1)/(double (numberOfSamples + 1))))); |
|
|
|
valuation.insert(val); |
|
|
|
} |
|
|
|
storm::models::sparse::Mdp<double> sampleModel = instantiator.instantiate(valuation); |
|
|
|
auto checker = storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<double>>(sampleModel); |
|
|
|
std::unique_ptr<storm::modelchecker::CheckResult> checkResult; |
|
|
|
if (formula->isProbabilityOperatorFormula() && |
|
|
|
formula->asProbabilityOperatorFormula().getSubformula().isUntilFormula()) { |
|
|
|
const storm::modelchecker::CheckTask<storm::logic::UntilFormula, double> checkTask = storm::modelchecker::CheckTask<storm::logic::UntilFormula, double>( |
|
|
|
(*formula).asProbabilityOperatorFormula().getSubformula().asUntilFormula()); |
|
|
|
checkResult = checker.computeUntilProbabilities(Environment(), checkTask); |
|
|
|
} else if (formula->isProbabilityOperatorFormula() && |
|
|
|
formula->asProbabilityOperatorFormula().getSubformula().isEventuallyFormula()) { |
|
|
|
const storm::modelchecker::CheckTask<storm::logic::EventuallyFormula, double> checkTask = storm::modelchecker::CheckTask<storm::logic::EventuallyFormula, double>( |
|
|
|
(*formula).asProbabilityOperatorFormula().getSubformula().asEventuallyFormula()); |
|
|
|
checkResult = checker.computeReachabilityProbabilities(Environment(), checkTask); |
|
|
|
} else { |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, |
|
|
|
"Expecting until or eventually formula"); |
|
|
|
} |
|
|
|
auto quantitativeResult = checkResult->asExplicitQuantitativeCheckResult<double>(); |
|
|
|
std::vector<double> values = quantitativeResult.getValueVector(); |
|
|
|
results.push_back(values); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template <typename ValueType> |
|
|
|
bool AssumptionChecker<ValueType>::checkOnSamples(std::shared_ptr<storm::expressions::BinaryRelationExpression> assumption) { |
|
|
|
bool result = true; |
|
|
|