Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ValidatingSparseParameterLiftingModelChecker.cpp
Go to the documentation of this file.
2
14
15namespace storm {
16namespace modelchecker {
17
18template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
23
24template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
26 if (storm::settings::getModule<storm::settings::modules::CoreSettings>().isShowStatisticsSet()) {
27 STORM_PRINT_AND_LOG("Validating Parameter Lifting Model Checker detected " << numOfWrongRegions << " regions where the imprecise method was wrong.\n");
28 }
29}
30
31template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
33 std::shared_ptr<storm::models::ModelBase> parametricModel, CheckTask<storm::logic::Formula, typename SparseModelType::ValueType> const& checkTask) const {
34 return impreciseChecker.canHandle(parametricModel, checkTask) && preciseChecker.canHandle(parametricModel, checkTask);
35}
36
37template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
39 Environment const& env, std::shared_ptr<storm::models::ModelBase> parametricModel, CheckTask<storm::logic::Formula, ParametricType> const& checkTask,
40 std::optional<RegionSplitEstimateKind> generateRegionSplitEstimates, std::shared_ptr<MonotonicityBackend<ParametricType>> monotonicityBackend,
41 bool allowModelSimplifications, bool graphPreserving) {
42 STORM_LOG_THROW(this->canHandle(parametricModel, checkTask), storm::exceptions::NotSupportedException,
43 "Combination of model " << parametricModel->getType() << " and formula '" << checkTask.getFormula() << "' is not supported.");
44 STORM_LOG_THROW(graphPreserving, storm::exceptions::NotImplementedException, "Non-graph-preserving regions not implemented for validating PLA");
45 this->specifySplitEstimates(generateRegionSplitEstimates, checkTask);
46 this->specifyMonotonicity(monotonicityBackend, checkTask);
47
48 auto specifyUnderlyingCheckers = [&](auto pm, auto const& ct) {
49 // TODO: Consider taking split estimates from the imprecise checker?
50 // Do not perform simplification (again) in the underlying model checkers
51 impreciseChecker.specify(env, pm, ct, std::nullopt, monotonicityBackend, false);
52 preciseChecker.specify(env, pm, ct, std::nullopt, monotonicityBackend, false);
53 };
54
55 if (allowModelSimplifications) {
56 auto dtmcOrMdp = parametricModel->template as<SparseModelType>();
57 if constexpr (IsMDP) {
59 if (!simplifier.simplify(checkTask.getFormula())) {
60 STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Simplifying the model was not successfull.");
61 }
62 auto simplifiedTask = checkTask.substituteFormula(*simplifier.getSimplifiedFormula());
63 specifyUnderlyingCheckers(simplifier.getSimplifiedModel(), simplifiedTask);
64 } else {
66 if (!simplifier.simplify(checkTask.getFormula())) {
67 STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Simplifying the model was not successfull.");
68 }
69 auto simplifiedTask = checkTask.substituteFormula(*simplifier.getSimplifiedFormula());
70 specifyUnderlyingCheckers(simplifier.getSimplifiedModel(), simplifiedTask);
71 }
72 } else {
73 specifyUnderlyingCheckers(parametricModel, checkTask);
74 }
75}
76
77template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
80 RegionResultHypothesis const& hypothesis,
81 bool sampleVerticesOfRegion) {
82 // Do not add annotations from the potentiallty imprecise model checker
83 auto impreciseAnnotatedRegion = region;
84 RegionResult currentResult = impreciseChecker.analyzeRegion(env, impreciseAnnotatedRegion, hypothesis, false);
85
86 if (currentResult == RegionResult::AllSat || currentResult == RegionResult::AllViolated) {
87 applyHintsToPreciseChecker();
88
89 storm::solver::OptimizationDirection parameterOptDir = preciseChecker.getCurrentCheckTask().getOptimizationDirection();
90 if (currentResult == RegionResult::AllViolated) {
91 parameterOptDir = storm::solver::invert(parameterOptDir);
92 }
93
94 bool preciseResult = preciseChecker.check(env, region, parameterOptDir)
95 ->asExplicitQualitativeCheckResult()[*preciseChecker.getConsideredParametricModel().getInitialStates().begin()];
96 bool preciseResultAgrees = preciseResult == (currentResult == RegionResult::AllSat);
97
98 if (!preciseResultAgrees) {
99 // Imprecise result is wrong!
100 currentResult = RegionResult::Unknown;
101 ++numOfWrongRegions;
102
103 // Check the other direction in case no hypothesis was given
104 if (hypothesis == RegionResultHypothesis::Unknown) {
105 parameterOptDir = storm::solver::invert(parameterOptDir);
106 preciseResult = preciseChecker.check(env, region, parameterOptDir)
107 ->asExplicitQualitativeCheckResult()[*preciseChecker.getConsideredParametricModel().getInitialStates().begin()];
108 if (preciseResult && parameterOptDir == preciseChecker.getCurrentCheckTask().getOptimizationDirection()) {
109 currentResult = RegionResult::AllSat;
110 } else if (!preciseResult && parameterOptDir == storm::solver::invert(preciseChecker.getCurrentCheckTask().getOptimizationDirection())) {
111 currentResult = RegionResult::AllViolated;
112 }
113 }
114 }
115 }
116
117 if (sampleVerticesOfRegion && currentResult != RegionResult::AllSat && currentResult != RegionResult::AllViolated) {
118 currentResult = preciseChecker.sampleVertices(env, region.region, currentResult);
119 }
120
121 return currentResult;
122}
123
124template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
125typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::CoefficientType
127 Environment const& env, AnnotatedRegion<ParametricType>& region, storm::solver::OptimizationDirection const& dirForParameters) {
128 return preciseChecker.getBoundAtInitState(env, region, dirForParameters);
129}
130
131template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
132std::pair<typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::CoefficientType,
133 typename ValidatingSparseParameterLiftingModelChecker<SparseModelType, ImpreciseType, PreciseType>::Valuation>
135 Environment const& env, AnnotatedRegion<ParametricType>& region, storm::solver::OptimizationDirection const& dirForParameters) {
136 return preciseChecker.getAndEvaluateGoodPoint(env, region, dirForParameters);
137}
138
139template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
142 // Currently, we do not support any interaction with the monotonicity backend
143 return !backend.requiresInteractionWithRegionModelChecker() && impreciseChecker.isMonotonicitySupported(backend, checkTask) &&
144 preciseChecker.isMonotonicitySupported(backend, checkTask);
145}
146
147template<typename SparseModelType, typename ImpreciseType, typename PreciseType>
149 if (impreciseChecker.getCurrentMaxScheduler()) {
150 preciseChecker.getCurrentMaxScheduler() = impreciseChecker.getCurrentMaxScheduler()->template toValueType<PreciseType>();
151 }
152 if (impreciseChecker.getCurrentMinScheduler()) {
153 preciseChecker.getCurrentMinScheduler() = impreciseChecker.getCurrentMinScheduler()->template toValueType<PreciseType>();
154 }
155 if constexpr (IsMDP) {
156 if (impreciseChecker.getCurrentPlayer1Scheduler()) {
157 preciseChecker.getCurrentPlayer1Scheduler() = impreciseChecker.getCurrentPlayer1Scheduler()->template toValueType<PreciseType>();
158 }
159 }
160}
161
162template class ValidatingSparseParameterLiftingModelChecker<storm::models::sparse::Dtmc<storm::RationalFunction>, double, storm::RationalNumber>;
163template class ValidatingSparseParameterLiftingModelChecker<storm::models::sparse::Mdp<storm::RationalFunction>, double, storm::RationalNumber>;
164
165} // namespace modelchecker
166} // 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:52
FormulaType const & getFormula() const
Retrieves the formula from this task.
Definition CheckTask.h:140
virtual bool requiresInteractionWithRegionModelChecker() const
Returns true, if a region model checker needs to implement specific methods to properly use this back...
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_THROW(cond, exception, message)
Definition macros.h:30
#define STORM_PRINT_AND_LOG(message)
Definition macros.h:68
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)
LabParser.cpp.
Region const region
The subregions of this region.