Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ValidatingSparseParameterLiftingModelChecker.cpp
Go to the documentation of this file.
2
12
13namespace storm {
14namespace modelchecker {
15
16template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
21
22template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
24 STORM_LOG_STATISTICS("Validating Parameter Lifting Model Checker detected " << numOfWrongRegions << " regions where the imprecise method was wrong.\n");
25}
26
27template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
29 std::shared_ptr<storm::models::ModelBase> parametricModel, CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask) const {
30 return impreciseChecker.canHandle(parametricModel, checkTask) && preciseChecker.canHandle(parametricModel, checkTask);
31}
32
33template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
35 Environment const& env, std::shared_ptr<storm::models::ModelBase> parametricModel, CheckTask<storm::logic::Formula, ParametricType> const& checkTask,
36 std::optional<RegionSplitEstimateKind> generateRegionSplitEstimates, std::shared_ptr<MonotonicityBackend<ParametricType>> monotonicityBackend,
37 bool allowModelSimplifications, bool graphPreserving) {
38 STORM_LOG_THROW(this->canHandle(parametricModel, checkTask), storm::exceptions::NotSupportedException,
39 "Combination of model " << parametricModel->getType() << " and formula '" << checkTask.getFormula() << "' is not supported.");
40 STORM_LOG_THROW(graphPreserving, storm::exceptions::NotImplementedException, "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>();
53 if constexpr (IsMDP) {
55 STORM_LOG_THROW(simplifier.simplify(checkTask.getFormula()), storm::exceptions::UnexpectedException, "Simplifying the model was not successfull.");
56 auto simplifiedTask = checkTask.substituteFormula(*simplifier.getSimplifiedFormula());
57 specifyUnderlyingCheckers(simplifier.getSimplifiedModel(), simplifiedTask);
58 } else {
60 STORM_LOG_THROW(simplifier.simplify(checkTask.getFormula()), storm::exceptions::UnexpectedException, "Simplifying the model was not successfull.");
61 auto simplifiedTask = checkTask.substituteFormula(*simplifier.getSimplifiedFormula());
62 specifyUnderlyingCheckers(simplifier.getSimplifiedModel(), simplifiedTask);
63 }
64 } else {
65 specifyUnderlyingCheckers(parametricModel, checkTask);
66 }
67}
68
69template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
72 RegionResultHypothesis const& hypothesis,
73 bool sampleVerticesOfRegion) {
74 // Do not add annotations from the potentiallty imprecise model checker
75 auto impreciseAnnotatedRegion = region;
76 RegionResult currentResult = impreciseChecker.analyzeRegion(env, impreciseAnnotatedRegion, hypothesis, false);
77
78 if (currentResult == RegionResult::AllSat || currentResult == RegionResult::AllViolated) {
79 applyHintsToPreciseChecker();
80
81 storm::solver::OptimizationDirection parameterOptDir = preciseChecker.getCurrentCheckTask().getOptimizationDirection();
82 if (currentResult == RegionResult::AllViolated) {
83 parameterOptDir = storm::solver::invert(parameterOptDir);
84 }
85
86 bool preciseResult =
87 preciseChecker.check(env, region, parameterOptDir)
88 ->template asExplicitQualitativeCheckResult<PreciseType>()[*preciseChecker.getConsideredParametricModel().getInitialStates().begin()];
89 bool preciseResultAgrees = preciseResult == (currentResult == RegionResult::AllSat);
90
91 if (!preciseResultAgrees) {
92 // Imprecise result is wrong!
93 currentResult = RegionResult::Unknown;
94 ++numOfWrongRegions;
95
96 // Check the other direction in case no hypothesis was given
97 if (hypothesis == RegionResultHypothesis::Unknown) {
98 parameterOptDir = storm::solver::invert(parameterOptDir);
99 preciseResult =
100 preciseChecker.check(env, region, parameterOptDir)
101 ->template asExplicitQualitativeCheckResult<PreciseType>()[*preciseChecker.getConsideredParametricModel().getInitialStates().begin()];
102 if (preciseResult && parameterOptDir == preciseChecker.getCurrentCheckTask().getOptimizationDirection()) {
103 currentResult = RegionResult::AllSat;
104 } else if (!preciseResult && parameterOptDir == storm::solver::invert(preciseChecker.getCurrentCheckTask().getOptimizationDirection())) {
105 currentResult = RegionResult::AllViolated;
106 }
107 }
108 }
109 }
110
111 if (sampleVerticesOfRegion && currentResult != RegionResult::AllSat && currentResult != RegionResult::AllViolated) {
112 currentResult = preciseChecker.sampleVertices(env, region.region, currentResult);
113 }
114
115 return currentResult;
116}
117
118template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
119typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::CoefficientType
124
125template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
126std::pair<typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::CoefficientType,
127 typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::Valuation>
132
133template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
136 // Currently, we do not support any interaction with the monotonicity backend
137 return !backend.requiresInteractionWithRegionModelChecker() && impreciseChecker.isMonotonicitySupported(backend, checkTask) &&
138 preciseChecker.isMonotonicitySupported(backend, checkTask);
139}
140
141template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
142void ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::applyHintsToPreciseChecker() {
143 if (impreciseChecker.getCurrentMaxScheduler()) {
144 preciseChecker.getCurrentMaxScheduler() = impreciseChecker.getCurrentMaxScheduler()->template toValueType<PreciseType>();
145 }
146 if (impreciseChecker.getCurrentMinScheduler()) {
147 preciseChecker.getCurrentMinScheduler() = impreciseChecker.getCurrentMinScheduler()->template toValueType<PreciseType>();
148 }
149 if constexpr (IsMDP) {
150 if (impreciseChecker.getCurrentPlayer1Scheduler()) {
151 preciseChecker.getCurrentPlayer1Scheduler() = impreciseChecker.getCurrentPlayer1Scheduler()->template toValueType<PreciseType>();
152 }
153 }
154}
155
158
159} // namespace modelchecker
160} // 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 RegionResult analyzeRegion(Environment const &env, AnnotatedRegion< ParametricType > &region, RegionResultHypothesis const &hypothesis=RegionResultHypothesis::Unknown, bool sampleVerticesOfRegion=false) override
Analyzes the given region.
virtual CoefficientType getBoundAtInitState(Environment const &env, AnnotatedRegion< ParametricType > &region, storm::solver::OptimizationDirection const &dirForParameters) override
Over-approximates the value within the given region.
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, bool graphPreserving=true) override
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 std::pair< CoefficientType, 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 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.
This class performs different steps to simplify the given (parametric) model.
#define STORM_LOG_STATISTICS(message)
Definition logging.h:41
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
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
OptimizationDirection constexpr invert(OptimizationDirection d)