7 changed files with 158 additions and 26 deletions
-
6src/storm-pars-cli/storm-pars.cpp
-
72src/storm-pars/analysis/AssumptionChecker.cpp
-
35src/storm-pars/analysis/AssumptionChecker.h
-
58src/storm-pars/analysis/AssumptionMaker.cpp
-
7src/storm-pars/analysis/AssumptionMaker.h
-
4src/storm-pars/analysis/LatticeExtender.cpp
-
2src/storm-pars/analysis/MonotonicityChecker.cpp
@ -0,0 +1,72 @@ |
|||||
|
//
|
||||
|
// Created by Jip Spel on 12.09.18.
|
||||
|
//
|
||||
|
|
||||
|
#include <storm-pars/utility/ModelInstantiator.h>
|
||||
|
#include <storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.h>
|
||||
|
#include <storm/exceptions/NotSupportedException.h>
|
||||
|
#include "AssumptionChecker.h"
|
||||
|
#include "storm/modelchecker/CheckTask.h"
|
||||
|
#include "storm/environment/Environment.h"
|
||||
|
#include "storm/modelchecker/results/CheckResult.h"
|
||||
|
#include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h"
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace analysis { |
||||
|
template <typename ValueType> |
||||
|
AssumptionChecker<ValueType>::AssumptionChecker(std::shared_ptr<storm::logic::Formula const> formula, std::shared_ptr<storm::models::sparse::Dtmc<ValueType>> model, uint_fast64_t numberOfSamples) { |
||||
|
this->formula = formula; |
||||
|
|
||||
|
auto instantiator = storm::utility::ModelInstantiator<storm::models::sparse::Dtmc<ValueType>, storm::models::sparse::Dtmc<double>>(*model.get()); |
||||
|
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) { |
||||
|
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::Dtmc<double> sampleModel = instantiator.instantiate(valuation); |
||||
|
auto checker = storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<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); |
||||
|
} |
||||
|
this->numberOfStates = model->getNumberOfStates(); |
||||
|
this->initialStates = model->getInitialStates(); |
||||
|
} |
||||
|
|
||||
|
template <typename ValueType> |
||||
|
bool AssumptionChecker<ValueType>::checkOnSamples(uint_fast64_t val1, uint_fast64_t val2) { |
||||
|
bool result = true; |
||||
|
for (auto itr = results.begin(); result && itr != results.end(); ++itr) { |
||||
|
// TODO: als expressie
|
||||
|
auto values = (*itr); |
||||
|
result &= (values[val1] >= values[val2]); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
template class AssumptionChecker<storm::RationalFunction>; |
||||
|
} |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
// |
||||
|
// Created by Jip Spel on 12.09.18. |
||||
|
// |
||||
|
|
||||
|
#ifndef STORM_ASSUMPTIONCHECKER_H |
||||
|
#define STORM_ASSUMPTIONCHECKER_H |
||||
|
|
||||
|
#include <storm/logic/Formula.h> |
||||
|
#include <storm/models/sparse/Dtmc.h> |
||||
|
#include "storm/environment/Environment.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace analysis { |
||||
|
template<typename ValueType> |
||||
|
class AssumptionChecker { |
||||
|
public: |
||||
|
AssumptionChecker(std::shared_ptr<storm::logic::Formula const> formula, std::shared_ptr<storm::models::sparse::Dtmc<ValueType>> model, uint_fast64_t numberOfSamples); |
||||
|
|
||||
|
bool checkOnSamples(uint_fast64_t val1, uint_fast64_t val2); |
||||
|
private: |
||||
|
std::shared_ptr<storm::logic::Formula const> formula; |
||||
|
|
||||
|
std::vector<storm::models::sparse::Dtmc<double>> sampleModels; |
||||
|
|
||||
|
std::vector<std::vector<double>> results; |
||||
|
|
||||
|
uint_fast64_t numberOfStates; |
||||
|
|
||||
|
storm::storage::BitVector initialStates; |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#endif //STORM_ASSUMPTIONCHECKER_H |
Write
Preview
Loading…
Cancel
Save
Reference in new issue