Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
solutionFunctions.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace storm::pars {
6
7template<typename ValueType>
9 std::vector<storm::jani::Property> const& properties,
10 std::function<std::unique_ptr<storm::modelchecker::CheckResult>(std::shared_ptr<storm::logic::Formula const> const& formula)> const& verificationCallback,
11 std::function<void(std::unique_ptr<storm::modelchecker::CheckResult> const&)> const& postprocessingCallback) {
12 for (auto const& property : properties) {
14 STORM_LOG_THROW(property.getRawFormula()->isOperatorFormula(), storm::exceptions::NotSupportedException,
15 "We only support operator formulas (P=?, R=?, etc).");
16 STORM_LOG_THROW(!property.getRawFormula()->asOperatorFormula().hasBound(), storm::exceptions::NotSupportedException,
17 "We only support unbounded operator formulas (P=?, R=?, etc).");
18 storm::utility::Stopwatch watch(true);
19 std::unique_ptr<storm::modelchecker::CheckResult> result = verificationCallback(property.getRawFormula());
20 watch.stop();
21 printInitialStatesResult<ValueType>(result, &watch);
22 postprocessingCallback(result);
23 }
24}
25
26template<typename ValueType>
28 verifyProperties<ValueType>(
29 input.properties,
30 [&model](std::shared_ptr<storm::logic::Formula const> const& formula) {
31 std::unique_ptr<storm::modelchecker::CheckResult> result =
32 storm::api::verifyWithSparseEngine<ValueType>(model, storm::api::createTask<ValueType>(formula, true));
33 if (result) {
34 result->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates()));
35 }
36 return result;
37 },
38 [&model](std::unique_ptr<storm::modelchecker::CheckResult> const& result) {
40 if (parametricSettings.exportResultToFile() && model->isOfType(storm::models::ModelType::Dtmc)) {
41 auto dtmc = model->template as<storm::models::sparse::Dtmc<ValueType>>();
42 std::optional<ValueType> rationalFunction = result->asExplicitQuantitativeCheckResult<ValueType>()[*model->getInitialStates().begin()];
43 auto constraintCollector = storm::analysis::ConstraintCollector<ValueType>(*dtmc);
44 storm::api::exportParametricResultToFile<ValueType>(rationalFunction, constraintCollector, parametricSettings.exportResultPath());
45 } else if (parametricSettings.exportResultToFile() && model->isOfType(storm::models::ModelType::Ctmc)) {
46 auto ctmc = model->template as<storm::models::sparse::Ctmc<ValueType>>();
47 std::optional<ValueType> rationalFunction = result->asExplicitQuantitativeCheckResult<ValueType>()[*model->getInitialStates().begin()];
48 auto constraintCollector = storm::analysis::ConstraintCollector<ValueType>(*ctmc);
49 storm::api::exportParametricResultToFile<ValueType>(rationalFunction, constraintCollector, parametricSettings.exportResultPath());
50 }
51 });
52}
53
54template<storm::dd::DdType DdType, typename ValueType>
56 cli::SymbolicInput const& input) {
57 verifyProperties<ValueType>(
58 input.properties,
59 [&model](std::shared_ptr<storm::logic::Formula const> const& formula) {
60 std::unique_ptr<storm::modelchecker::CheckResult> result =
61 storm::api::verifyWithDdEngine<DdType, ValueType>(model, storm::api::createTask<ValueType>(formula, true));
62 if (result) {
63 result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<DdType>(model->getReachableStates(), model->getInitialStates()));
64 }
65 return result;
66 },
67 [&model](std::unique_ptr<storm::modelchecker::CheckResult> const& result) {
69 if (parametricSettings.exportResultToFile() && model->isOfType(storm::models::ModelType::Dtmc)) {
70 STORM_LOG_WARN("For symbolic engines, we currently do not support collecting graph-preserving constraints.");
71 std::optional<ValueType> rationalFunction = result->asSymbolicQuantitativeCheckResult<DdType, ValueType>().sum();
72 storm::api::exportParametricResultToFile<ValueType>(rationalFunction, storm::NullRef, parametricSettings.exportResultPath());
73 }
74 });
75}
76} // namespace storm::pars
Class to collect constraints on parametric Markov chains.
Base class for all sparse models.
Definition Model.h:33
Base class for all symbolic models.
Definition Model.h:46
A class that provides convenience operations to display run times.
Definition Stopwatch.h:14
void stop()
Stop stopwatch and add measured time to total time.
Definition Stopwatch.cpp:42
#define STORM_LOG_WARN(message)
Definition logging.h:30
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
void printModelCheckingProperty(storm::jani::Property const &property)
void computeSolutionFunctionsWithSymbolicEngine(std::shared_ptr< storm::models::symbolic::Model< DdType, ValueType > > const &model, cli::SymbolicInput const &input)
void verifyProperties(std::vector< storm::jani::Property > const &properties, std::function< std::unique_ptr< storm::modelchecker::CheckResult >(std::shared_ptr< storm::logic::Formula const > const &formula)> const &verificationCallback, std::function< void(std::unique_ptr< storm::modelchecker::CheckResult > const &)> const &postprocessingCallback)
void computeSolutionFunctionsWithSparseEngine(std::shared_ptr< storm::models::sparse::Model< ValueType > > const &model, cli::SymbolicInput const &input)
SettingsType const & getModule()
Get module.
constexpr NullRefType NullRef
Definition OptionalRef.h:31
std::vector< storm::jani::Property > properties