Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ValidatingSparseParameterLiftingModelChecker.cpp
Go to the documentation of this file.
2
11
12namespace storm {
13namespace modelchecker {
14
15template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
20
21template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
23 STORM_LOG_STATISTICS("Validating Parameter Lifting Model Checker detected " << numOfWrongRegions << " regions where the imprecise method was wrong.\n");
24}
25
26template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
28 std::shared_ptr<storm::models::ModelBase> parametricModel, CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask) const {
29 return impreciseChecker.canHandle(parametricModel, checkTask) && preciseChecker.canHandle(parametricModel, checkTask);
30}
31
32template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
34 Environment const& env, std::shared_ptr<storm::models::ModelBase> parametricModel, CheckTask<storm::logic::Formula, ParametricType> const& checkTask,
35 std::optional<RegionSplitEstimateKind> generateRegionSplitEstimates, std::shared_ptr<MonotonicityBackend<ParametricType>> monotonicityBackend,
36 bool allowModelSimplifications, storm::pars::analysis::GraphPreservationStatus graphPreservationStatus) {
37 STORM_LOG_THROW(this->canHandle(parametricModel, checkTask), storm::exceptions::NotSupportedException,
38 "Combination of model " << parametricModel->getType() << " and formula '" << checkTask.getFormula() << "' is not supported.");
39 STORM_LOG_THROW(storm::pars::analysis::isGraphPreserving(graphPreservationStatus), storm::exceptions::NotImplementedException,
40 "Non-graph-preserving regions not implemented for validating PLA.");
41 this->specifySplitEstimates(generateRegionSplitEstimates, checkTask);
43
44 auto specifyUnderlyingCheckers = [&](auto pm, auto const& ct) {
45 // TODO: Consider taking split estimates from the imprecise checker?
46 // Do not perform simplification (again) in the underlying model checkers
47 impreciseChecker.specify(env, pm, ct, std::nullopt, monotonicityBackend, false);
48 preciseChecker.specify(env, pm, ct, std::nullopt, monotonicityBackend, false);
49 };
50
51 if (allowModelSimplifications) {
52 auto dtmcOrMdp = parametricModel->template as<SparseModelType>();
54 STORM_LOG_THROW(simplifier.simplify(checkTask.getFormula()), storm::exceptions::UnexpectedException, "Simplifying the model was not successfull.");
55 auto simplifiedTask = checkTask.substituteFormula(*simplifier.getSimplifiedFormula());
56 specifyUnderlyingCheckers(simplifier.getSimplifiedModel(), simplifiedTask);
57 } else {
58 specifyUnderlyingCheckers(parametricModel, checkTask);
59 }
60}
61
62template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
65 RegionResultHypothesis const& hypothesis,
66 bool sampleVerticesOfRegion) {
67 // Do not add annotations from the potentiallty imprecise model checker
68 auto impreciseAnnotatedRegion = region;
69 RegionResult currentResult = impreciseChecker.analyzeRegion(env, impreciseAnnotatedRegion, hypothesis, false);
70
71 if (currentResult == RegionResult::AllSat || currentResult == RegionResult::AllViolated) {
72 applyHintsToPreciseChecker();
73
74 storm::solver::OptimizationDirection parameterOptDir = preciseChecker.getCurrentCheckTask().getOptimizationDirection();
75 if (currentResult == RegionResult::AllViolated) {
76 parameterOptDir = storm::solver::invert(parameterOptDir);
77 }
78
79 bool preciseResult =
80 preciseChecker.check(env, region, parameterOptDir)
81 ->template asExplicitQualitativeCheckResult<PreciseType>()[*preciseChecker.getConsideredParametricModel().getInitialStates().begin()];
82 bool preciseResultAgrees = preciseResult == (currentResult == RegionResult::AllSat);
83
84 if (!preciseResultAgrees) {
85 // Imprecise result is wrong!
86 currentResult = RegionResult::Unknown;
87 ++numOfWrongRegions;
88
89 // Check the other direction in case no hypothesis was given
90 if (hypothesis == RegionResultHypothesis::Unknown) {
91 parameterOptDir = storm::solver::invert(parameterOptDir);
92 preciseResult =
93 preciseChecker.check(env, region, parameterOptDir)
94 ->template asExplicitQualitativeCheckResult<PreciseType>()[*preciseChecker.getConsideredParametricModel().getInitialStates().begin()];
95 if (preciseResult && parameterOptDir == preciseChecker.getCurrentCheckTask().getOptimizationDirection()) {
96 currentResult = RegionResult::AllSat;
97 } else if (!preciseResult && parameterOptDir == storm::solver::invert(preciseChecker.getCurrentCheckTask().getOptimizationDirection())) {
98 currentResult = RegionResult::AllViolated;
99 }
100 }
101 }
102 }
103
104 if (sampleVerticesOfRegion && currentResult != RegionResult::AllSat && currentResult != RegionResult::AllViolated) {
105 currentResult = preciseChecker.sampleVertices(env, region.region, currentResult);
106 }
107
108 return currentResult;
109}
110
111template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
112typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::ExtendedCoefficientType
117
118template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
119std::pair<typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::ExtendedCoefficientType,
120 typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::Valuation>
125
126template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
129 // Currently, we do not support any interaction with the monotonicity backend
130 return !backend.requiresInteractionWithRegionModelChecker() && impreciseChecker.isMonotonicitySupported(backend, checkTask) &&
131 preciseChecker.isMonotonicitySupported(backend, checkTask);
132}
133
134template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
135void ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::applyHintsToPreciseChecker() {
136 if (impreciseChecker.getCurrentMaxScheduler()) {
137 preciseChecker.getCurrentMaxScheduler() = impreciseChecker.getCurrentMaxScheduler()->template toValueType<PreciseType>();
138 }
139 if (impreciseChecker.getCurrentMinScheduler()) {
140 preciseChecker.getCurrentMinScheduler() = impreciseChecker.getCurrentMinScheduler()->template toValueType<PreciseType>();
141 }
142 if constexpr (IsMDP) {
143 if (impreciseChecker.getCurrentPlayer1Scheduler()) {
144 preciseChecker.getCurrentPlayer1Scheduler() = impreciseChecker.getCurrentPlayer1Scheduler()->template toValueType<PreciseType>();
145 }
146 }
147}
148
151
152} // namespace modelchecker
153} // namespace storm
CheckTask< NewFormulaType, ValueType > substituteFormula(NewFormulaType const &newFormula) const
Copies the check task from the source while replacing the formula with the new one.
Definition CheckTask.h:53
FormulaType const & getFormula() const
Retrieves the formula from this task.
Definition CheckTask.h:141
virtual bool requiresInteractionWithRegionModelChecker() const
Returns true, if a region model checker needs to implement specific methods to properly use this back...
virtual void specifyMonotonicity(std::shared_ptr< MonotonicityBackend< SparseModelType::ValueType > > backend, CheckTask< storm::logic::Formula, SparseModelType::ValueType > const &checkTask)
std::shared_ptr< MonotonicityBackend< SparseModelType::ValueType > > monotonicityBackend
virtual void specifySplitEstimates(std::optional< RegionSplitEstimateKind > splitEstimates, CheckTask< storm::logic::Formula, SparseModelType::ValueType > const &checkTask)
virtual void specify(Environment const &env, std::shared_ptr< storm::models::ModelBase > parametricModel, CheckTask< storm::logic::Formula, ParametricType > const &checkTask, std::optional< RegionSplitEstimateKind > generateRegionSplitEstimates=std::nullopt, std::shared_ptr< MonotonicityBackend< ParametricType > > monotonicityBackend={}, bool allowModelSimplifications=true, storm::pars::analysis::GraphPreservationStatus graphPreservationStatus=storm::pars::analysis::GraphPreservationStatus::GraphPreserving) override
virtual RegionResult analyzeRegion(Environment const &env, AnnotatedRegion< ParametricType > &region, RegionResultHypothesis const &hypothesis=RegionResultHypothesis::Unknown, bool sampleVerticesOfRegion=false) override
Analyzes the given region.
virtual std::pair< ExtendedCoefficientType, Valuation > getAndEvaluateGoodPoint(Environment const &env, AnnotatedRegion< ParametricType > &region, storm::solver::OptimizationDirection const &dirForParameters) override
Heuristically finds a point within the region and computes the value at the initial state for that po...
virtual ExtendedCoefficientType getBoundAtInitState(Environment const &env, AnnotatedRegion< ParametricType > &region, storm::solver::OptimizationDirection const &dirForParameters) override
Over-approximates the value within the given region.
virtual bool isMonotonicitySupported(MonotonicityBackend< ParametricType > const &backend, CheckTask< storm::logic::Formula, ParametricType > const &checkTask) const override
Returns whether this region model checker can work together with the given monotonicity backend.
virtual bool canHandle(std::shared_ptr< storm::models::ModelBase > parametricModel, CheckTask< storm::logic::Formula, typename SparseModelType::ValueType > const &checkTask) const override
This class performs different steps to simplify the given (parametric) model.
#define STORM_LOG_STATISTICS(message)
Definition logging.h:48
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
RegionResult
The results for a single Parameter Region.
@ AllSat
the formula is satisfied for all well-defined parameters in the given region
@ AllViolated
the formula is violated for all well-defined parameters in the given region
@ Unknown
the result is unknown
RegionResultHypothesis
hypothesis for the result for a single Parameter Region
GraphPreservationStatus
Describes to what extent a set of regions is known to be well-defined and to preserve the graph struc...
bool isGraphPreserving(GraphPreservationStatus status)
Returns whether the given status guarantees that the graph structure of the model is preserved.
OptimizationDirection constexpr invert(OptimizationDirection d)