Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseDtmcPrctlModelChecker.cpp
Go to the documentation of this file.
2
3#include <memory>
4#include <vector>
5
24
25namespace storm {
26namespace modelchecker {
27template<typename SparseDtmcModelType>
29 : SparsePropositionalModelChecker<SparseDtmcModelType>(model) {
30 // Intentionally left empty.
31}
32
33template<typename SparseDtmcModelType>
35 bool* requiresSingleInitialState) {
36 storm::logic::Formula const& formula = checkTask.getFormula();
39 return true;
40 }
41 if (formula.isInFragment(storm::logic::reachability().setReachabilityRewardFormulasAllowed(true).setRewardOperatorsAllowed(true))) {
42 return true;
43 }
44 if (formula.isInFragment(
45 storm::logic::prctlstar().setBoundedUntilFormulasAllowed(true).setTimeOperatorsAllowed(true).setReachbilityTimeFormulasAllowed(true))) {
46 return true;
47 }
48 } else {
50 .setLongRunAverageRewardFormulasAllowed(true)
51 .setLongRunAverageProbabilitiesAllowed(true)
52 .setConditionalProbabilityFormulasAllowed(true)
53 .setConditionalRewardFormulasAllowed(true)
54 .setTotalRewardFormulasAllowed(true)
55 .setOnlyEventuallyFormuluasInConditionalFormulasAllowed(true)
56 .setRewardBoundedUntilFormulasAllowed(true)
57 .setRewardBoundedCumulativeRewardFormulasAllowed(true)
58 .setMultiDimensionalBoundedUntilFormulasAllowed(true)
59 .setMultiDimensionalCumulativeRewardFormulasAllowed(true)
60 .setTimeOperatorsAllowed(true)
61 .setReachbilityTimeFormulasAllowed(true)
62 .setRewardAccumulationAllowed(true)
63 .setHOAPathFormulasAllowed(true)
64 .setDiscountedTotalRewardFormulasAllowed(true)
65 .setDiscountedCumulativeRewardFormulasAllowed(true))) {
66 return true;
67 } else if (checkTask.isOnlyInitialStatesRelevantSet() && formula.isInFragment(storm::logic::quantiles())) {
68 if (requiresSingleInitialState) {
69 *requiresSingleInitialState = true;
70 }
71 return true;
72 }
73 }
74
75 return false;
76}
77
78template<typename SparseDtmcModelType>
80 bool requiresSingleInitialState = false;
81 if (canHandleStatic(checkTask, &requiresSingleInitialState)) {
82 return !requiresSingleInitialState || this->getModel().getInitialStates().getNumberOfSetBits() == 1;
83 } else {
84 return false;
85 }
86}
87
88template<typename SparseDtmcModelType>
91 storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula();
92 if (pathFormula.isMultiDimensional() || pathFormula.getTimeBoundReference().isRewardBound()) {
93 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
94 "Checking non-trivial bounded until probabilities can only be computed for the initial states of the model.");
96 if (checkTask.isBoundSet()) {
97 opInfo.bound = checkTask.getBound();
98 }
99 auto formula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(checkTask.getFormula().asSharedPointer(), opInfo);
101 env, this->getModel(), formula);
102 // The helper returns one value per initial state, in the order in which the bit vector selects them.
103 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(this->getModel().getInitialStates(), std::move(numericResult)));
104 } else {
105 STORM_LOG_THROW(pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have (a single) upper step bound.");
106 STORM_LOG_THROW(pathFormula.hasIntegerLowerBound(), storm::exceptions::InvalidPropertyException, "Formula lower step bound must be discrete/integral.");
107 STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper step bound.");
108 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
109 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
110 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
111 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
113 std::vector<SolutionType> numericResult = helper.computeStepBoundedUntilProbabilities(
114 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
115 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(),
116 pathFormula.getNonStrictLowerBound<uint64_t>(), pathFormula.getNonStrictUpperBound<uint64_t>(), checkTask.getHint());
117
118 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
119 result->setValuesExact();
120 return result;
121 }
122}
123
124template<typename SparseDtmcModelType>
127 if constexpr (storm::IsIntervalType<ValueType>) {
128 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented next probabilities with intervals.");
129 } else {
130 storm::logic::NextFormula const& pathFormula = checkTask.getFormula();
131 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
132 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
133 std::vector<SolutionType> numericResult =
135 env, this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector());
136 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
137 result->setValuesExact();
138 return result;
139 }
140}
141
142template<typename SparseDtmcModelType>
145 storm::logic::UntilFormula const& pathFormula = checkTask.getFormula();
146 if constexpr (storm::IsIntervalType<ValueType>) {
147 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
148 "Uncertainty resolution mode must be set for uncertain (interval) models.");
149 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
150 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
151 storm::exceptions::InvalidSettingsException,
152 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
153 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
154 "Computing until probabilities on uncertain model requires graph-preservation.");
155 }
156 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
157 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
158 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
159 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
161 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
162 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet(),
163 checkTask.getHint());
164 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
165 result->setBounds(std::move(ret.solutionBounds));
166 return result;
167}
168
169template<typename SparseDtmcModelType>
172 if constexpr (storm::IsIntervalType<ValueType>) {
173 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented globally probabilities with intervals.");
174 } else {
175 storm::logic::GloballyFormula const& pathFormula = checkTask.getFormula();
176 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
177 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
179 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
180 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet());
181 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
182 result->setBounds(std::move(ret.solutionBounds));
183 return result;
184 }
185}
186
187template<typename SparseDtmcModelType>
190 if constexpr (storm::IsIntervalType<ValueType>) {
191 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented automata-props with intervals.");
192 } else {
193 storm::logic::HOAPathFormula const& pathFormula = checkTask.getFormula();
194
197
198 auto formulaChecker = [&](storm::logic::Formula const& formula) {
199 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
200 };
201 auto apSets = helper.computeApSets(pathFormula.getAPMapping(), formulaChecker);
202 std::vector<ValueType> numericResult = helper.computeDAProductProbabilities(env, *pathFormula.readAutomaton(), apSets);
203
204 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(std::move(numericResult)));
205 }
206}
207
208template<typename SparseDtmcModelType>
211 if constexpr (storm::IsIntervalType<ValueType>) {
212 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LTL with interval models.");
213 } else {
214 storm::logic::PathFormula const& pathFormula = checkTask.getFormula();
215
218
219 auto formulaChecker = [&](storm::logic::Formula const& formula) {
220 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
221 };
222 std::vector<ValueType> numericResult = helper.computeLTLProbabilities(env, pathFormula, formulaChecker);
223
224 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(std::move(numericResult)));
225 }
226}
227
228template<typename SparseDtmcModelType>
231 storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
232 if (rewardPathFormula.isMultiDimensional() || rewardPathFormula.getTimeBoundReference().isRewardBound()) {
233 if constexpr (storm::IsIntervalType<ValueType>) {
234 STORM_LOG_THROW_UNCONDITIONALLY(storm::exceptions::NotImplementedException,
235 "We have not yet implemented multi-dimensional or reward-bounded cumulative rewards with intervals.");
236 } else {
237 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
238 "Checking non-trivial bounded until probabilities can only be computed for the initial states of the model.");
239 STORM_LOG_THROW(!checkTask.getFormula().hasRewardAccumulation(), storm::exceptions::InvalidOperationException,
240 "Checking reward bounded cumulative reward formulas is not supported if reward accumulations are given.");
242 if (checkTask.isBoundSet()) {
243 opInfo.bound = checkTask.getBound();
244 }
245 auto formula = std::make_shared<storm::logic::RewardOperatorFormula>(checkTask.getFormula().asSharedPointer(), checkTask.getRewardModel(), opInfo);
247 env, this->getModel(), formula);
248 // The helper returns one value per initial state, in the order in which the bit vector selects them.
249 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(this->getModel().getInitialStates(), std::move(numericResult)));
250 }
251 } else {
252 if constexpr (storm::IsIntervalType<ValueType>) {
253 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
254 "Uncertainty resolution mode must be set for uncertain (interval) models.");
255 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
256 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
257 storm::exceptions::InvalidSettingsException,
258 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
259 }
260 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
261 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
262 std::vector<SolutionType> numericResult =
264 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
265 rewardPathFormula.getNonStrictBound<uint64_t>());
266 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
267 result->setValuesExact();
268 return result;
269 }
270}
271
272template<>
275 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for parametric models.");
276}
277
278template<typename SparseDtmcModelType>
281 if constexpr (storm::IsIntervalType<ValueType>) {
282 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented discounted cumulative rewards with intervals.");
283 } else {
284 storm::logic::DiscountedCumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
285 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
286 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
287 std::vector<SolutionType> numericResult =
289 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
290 rewardPathFormula.getNonStrictBound<uint64_t>(), rewardPathFormula.getDiscountFactor<SolutionType>());
291 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
292 result->setValuesExact();
293 return result;
294 }
295}
296
297template<typename SparseDtmcModelType>
300 if constexpr (storm::IsIntervalType<ValueType>) {
301 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented instantaneous rewards with intervals.");
302 } else {
303 storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula();
304 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
305 std::vector<SolutionType> numericResult =
307 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
308 checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""),
309 rewardPathFormula.getBound<uint64_t>());
310 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
311 result->setValuesExact();
312 return result;
313 }
314}
315
316template<typename SparseDtmcModelType>
319 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
320 if constexpr (storm::IsIntervalType<ValueType>) {
321 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
322 "Uncertainty resolution mode must be set for uncertain (interval) models.");
323 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
324 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
325 storm::exceptions::InvalidSettingsException,
326 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
327 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
328 "Computing rewards on uncertain model requires graph-preservation.");
329 }
330 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
331 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
332 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
334 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
335 this->getModel().getBackwardTransitions(), rewardModel.get(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.getHint());
336 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
337 result->setBounds(std::move(ret.solutionBounds));
338 return result;
339}
340
341template<typename SparseDtmcModelType>
344 if constexpr (storm::IsIntervalType<ValueType>) {
345 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
346 "Uncertainty resolution mode must be set for uncertain (interval) models.");
347 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
348 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
349 storm::exceptions::InvalidSettingsException,
350 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
351 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
352 "Computing reachability times on uncertain model requires graph-preservation.");
353 }
354 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
355 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
356 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
358 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
359 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.getHint());
360 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
361 result->setBounds(std::move(ret.solutionBounds));
362 return result;
363}
364
365template<typename SparseDtmcModelType>
368 if constexpr (storm::IsIntervalType<ValueType>) {
369 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented total rewards with intervals.");
370 } else {
371 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
373 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
374 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), checkTask.getHint());
375 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
376 result->setBounds(std::move(ret.solutionBounds));
377 return result;
378 }
379}
380
381template<>
384 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for parametric models.");
385}
386
387template<typename SparseDtmcModelType>
390 if constexpr (storm::IsIntervalType<ValueType>) {
391 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented discounted total rewards with intervals.");
392 } else {
393 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
394 storm::logic::DiscountedTotalRewardFormula const& rewardPathFormula = checkTask.getFormula();
395 auto discountFactor = rewardPathFormula.getDiscountFactor<SolutionType>();
397 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
398 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), discountFactor, checkTask.getHint());
399 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret)));
400 return result;
401 }
402}
403
404template<typename SparseDtmcModelType>
407 if constexpr (storm::IsIntervalType<ValueType>) {
408 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LRA probabilities with intervals.");
409 } else {
410 storm::logic::StateFormula const& stateFormula = checkTask.getFormula();
411 std::unique_ptr<CheckResult> subResultPointer = this->check(env, stateFormula);
412 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
413
416 auto values = helper.computeLongRunAverageProbabilities(env, subResult.getTruthValuesVector());
417
418 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(values)));
419 }
420}
421
422template<typename SparseDtmcModelType>
425 if constexpr (storm::IsIntervalType<ValueType>) {
426 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented lra with intervals.");
427 } else {
428 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
431 auto values = helper.computeLongRunAverageRewards(env, rewardModel.get());
432 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(std::move(values)));
433 }
434}
435
436template<typename SparseDtmcModelType>
439 if constexpr (storm::IsIntervalType<ValueType>) {
440 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented conditional probabilities with intervals.");
441 } else {
442 storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula();
443 STORM_LOG_THROW(conditionalFormula.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
444 "Illegal conditional probability formula.");
445 STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
446 "Illegal conditional probability formula.");
447
448 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, conditionalFormula.getSubformula().asEventuallyFormula().getSubformula());
449 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, conditionalFormula.getConditionFormula().asEventuallyFormula().getSubformula());
450 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
451 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
452
453 std::vector<ExtendedSolutionType> numericResult =
455 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
456 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet());
457 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
458 }
459}
460
461template<typename SparseDtmcModelType>
464 if constexpr (storm::IsIntervalType<ValueType>) {
465 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented conditional rewards with intervals.");
466 } else {
467 storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula();
468 STORM_LOG_THROW(conditionalFormula.getSubformula().isReachabilityRewardFormula(), storm::exceptions::InvalidPropertyException,
469 "Illegal conditional probability formula.");
470 STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
471 "Illegal conditional probability formula.");
472
473 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, conditionalFormula.getSubformula().asReachabilityRewardFormula().getSubformula());
474 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, conditionalFormula.getConditionFormula().asEventuallyFormula().getSubformula());
475 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
476 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
477
478 std::vector<ExtendedSolutionType> numericResult =
480 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
481 this->getModel().getBackwardTransitions(),
482 checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""),
483 leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet());
484 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
485 }
486}
487
488template<>
491 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Quantiles for parametric models are not implemented.");
492}
493
494template<typename SparseDtmcModelType>
497 if constexpr (storm::IsIntervalType<ValueType>) {
498 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented quantile formulas with intervals.");
499 } else {
500 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
501 "Computing quantiles is only supported for the initial states of a model.");
502 STORM_LOG_THROW(this->getModel().getInitialStates().getNumberOfSetBits() == 1, storm::exceptions::InvalidOperationException,
503 "Quantiles not supported on models with multiple initial states.");
504 uint64_t initialState = *this->getModel().getInitialStates().begin();
505
507 auto res = qHelper.computeQuantile(env);
508
509 if (res.size() == 1 && res.front().size() == 1) {
510 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(initialState, std::move(res.front().front())));
511 } else {
512 return std::unique_ptr<CheckResult>(new ExplicitParetoCurveCheckResult<ValueType>(initialState, std::move(res)));
513 }
514 }
515}
516
517template<typename SparseDtmcModelType>
519 if constexpr (storm::IsIntervalType<ValueType>) {
520 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented steady state distributions with intervals.");
521 } else {
522 // Initialize helper
524
525 // Compute result
526 std::vector<SolutionType> result;
527 auto const& initialStates = this->getModel().getInitialStates();
528 uint64_t numInitStates = initialStates.getNumberOfSetBits();
529 if (numInitStates == 1) {
530 result = helper.computeLongRunAverageStateDistribution(env, *initialStates.begin());
531 } else {
532 STORM_LOG_WARN("Multiple initial states found. A uniform distribution over initial states is assumed.");
534 result = helper.computeLongRunAverageStateDistribution(env, [&initialStates, &initProb](uint64_t const& stateIndex) {
535 return initialStates.get(stateIndex) ? initProb : storm::utility::zero<ValueType>();
536 });
537 }
538
539 // Return CheckResult
540 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(result)));
541 }
542}
543
544template<typename SparseDtmcModelType>
546 if constexpr (storm::IsIntervalType<ValueType>) {
547 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented expected visiting times with intervals.");
548 } else {
549 // Initialize helper
551
552 // Compute result
553 std::vector<ExtendedSolutionType> result;
554 auto const& initialStates = this->getModel().getInitialStates();
555 uint64_t numInitStates = initialStates.getNumberOfSetBits();
556 STORM_LOG_THROW(numInitStates > 0, storm::exceptions::InvalidOperationException, "No initial states given. Cannot compute expected visiting times.");
557 STORM_LOG_WARN_COND(numInitStates == 1, "Multiple initial states found. A uniform distribution over initial states is assumed.");
558 result = helper.computeExpectedVisitingTimes(env, initialStates);
559
560 // Return CheckResult
561 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(result)));
562 }
563}
564
570} // namespace modelchecker
571} // namespace storm
Formula const & getRightSubformula() const
Formula const & getLeftSubformula() const
ValueType getNonStrictLowerBound(unsigned i=0) const
TimeBoundReference const & getTimeBoundReference(unsigned i=0) const
ValueType getNonStrictUpperBound(unsigned i=0) const
bool hasIntegerUpperBound(unsigned i=0) const
bool hasIntegerLowerBound(unsigned i=0) const
Formula const & getConditionFormula() const
Formula const & getSubformula() const
TimeBoundReference const & getTimeBoundReference() const
storm::expressions::Expression const & getDiscountFactor() const
storm::expressions::Expression const & getDiscountFactor() const
virtual bool isReachabilityRewardFormula() const
Definition Formula.cpp:170
EventuallyFormula & asEventuallyFormula()
Definition Formula.cpp:371
bool isInFragment(FragmentSpecification const &fragment) const
Definition Formula.cpp:218
virtual bool isEventuallyFormula() const
Definition Formula.cpp:102
EventuallyFormula & asReachabilityRewardFormula()
Definition Formula.cpp:379
const ap_to_formula_map & getAPMapping() const
std::shared_ptr< storm::automata::DeterministicAutomaton > readAutomaton() const
storm::expressions::Expression const & getBound() const
Formula const & getSubformula() const
virtual std::unique_ptr< CheckResult > check(Environment const &env, CheckTask< storm::logic::Formula, SolutionType > const &checkTask)
bool isBoundSet() const
Retrieves whether there is a bound with which the values for the states will be compared.
Definition CheckTask.h:220
bool isRewardModelSet() const
Retrieves whether a reward model was set.
Definition CheckTask.h:191
bool isQualitativeSet() const
Retrieves whether the computation only needs to be performed qualitatively, because the values will o...
Definition CheckTask.h:258
std::string const & getRewardModel() const
Retrieves the reward model over which to perform the checking (if set).
Definition CheckTask.h:198
FormulaType const & getFormula() const
Retrieves the formula from this task.
Definition CheckTask.h:141
ModelCheckerHint const & getHint() const
Retrieves a hint that might contain information that speeds up the modelchecking process (if supporte...
Definition CheckTask.h:294
bool isUncertaintyResolutionModeSet() const
Returns whether the mode, which decides how the uncertainty will be resolved, is set.
Definition CheckTask.h:319
storm::logic::Bound const & getBound() const
Retrieves the bound (if set).
Definition CheckTask.h:243
bool isOnlyInitialStatesRelevantSet() const
Retrieves whether only the initial states are relevant in the computation.
Definition CheckTask.h:205
UncertaintyResolutionMode getUncertaintyResolutionMode() const
Retrieves the mode which decides how the uncertainty will be resolved.
Definition CheckTask.h:305
A qualitative check result over the states of a sparse model.
vector_type const & getTruthValuesVector() const
Retrieves the truth values, one per state this result is for.
A quantitative check result over the states of a sparse model.
virtual std::unique_ptr< CheckResult > computeReachabilityTimes(Environment const &env, CheckTask< storm::logic::EventuallyFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeLTLProbabilities(Environment const &env, CheckTask< storm::logic::PathFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeConditionalProbabilities(Environment const &env, CheckTask< storm::logic::ConditionalFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeNextProbabilities(Environment const &env, CheckTask< storm::logic::NextFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeReachabilityRewards(Environment const &env, CheckTask< storm::logic::EventuallyFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeLongRunAverageProbabilities(Environment const &env, CheckTask< storm::logic::StateFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeBoundedUntilProbabilities(Environment const &env, CheckTask< storm::logic::BoundedUntilFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeUntilProbabilities(Environment const &env, CheckTask< storm::logic::UntilFormula, SolutionType > const &checkTask) override
std::unique_ptr< CheckResult > computeExpectedVisitingTimes(Environment const &env)
Computes for each state the expected number of times we visit that state.
virtual std::unique_ptr< CheckResult > computeTotalRewards(Environment const &env, CheckTask< storm::logic::TotalRewardFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeDiscountedTotalRewards(Environment const &env, CheckTask< storm::logic::DiscountedTotalRewardFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeDiscountedCumulativeRewards(Environment const &env, CheckTask< storm::logic::DiscountedCumulativeRewardFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeHOAPathProbabilities(Environment const &env, CheckTask< storm::logic::HOAPathFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeInstantaneousRewards(Environment const &env, CheckTask< storm::logic::InstantaneousRewardFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeCumulativeRewards(Environment const &env, CheckTask< storm::logic::CumulativeRewardFormula, SolutionType > const &checkTask) override
static bool canHandleStatic(CheckTask< storm::logic::Formula, SolutionType > const &checkTask, bool *requiresSingleInitialState=nullptr)
Returns false, if this task can certainly not be handled by this model checker (independent of the co...
virtual std::unique_ptr< CheckResult > computeGloballyProbabilities(Environment const &env, CheckTask< storm::logic::GloballyFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeLongRunAverageRewards(Environment const &env, CheckTask< storm::logic::LongRunAverageRewardFormula, SolutionType > const &checkTask) override
virtual bool canHandle(CheckTask< storm::logic::Formula, SolutionType > const &checkTask) const override
std::unique_ptr< CheckResult > computeSteadyStateDistribution(Environment const &env)
Computes the long run average (or: steady state) distribution over all states Assumes a uniform distr...
virtual std::unique_ptr< CheckResult > computeConditionalRewards(Environment const &env, CheckTask< storm::logic::ConditionalFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > checkQuantileFormula(Environment const &env, CheckTask< storm::logic::QuantileFormula, SolutionType > const &checkTask) override
Helper class for model checking queries that depend on the long run behavior of the (nondeterministic...
Helper class for computing for each state the expected number of times to visit that state assuming a...
static std::vector< SolutionType > computeDiscountedCumulativeRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, RewardModelType const &rewardModel, uint_fast64_t stepBound, ValueType discountFactor)
static DTMCSparseModelCheckingHelperReturnType< ExtendedSolutionType > computeTotalRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, RewardModelType const &rewardModel, bool qualitative, ModelCheckerHint const &hint=ModelCheckerHint())
static std::vector< SolutionType > computeDiscountedTotalRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, RewardModelType const &rewardModel, bool qualitative, ValueType discountFactor, ModelCheckerHint const &hint=ModelCheckerHint())
static std::vector< SolutionType > computeRewardBoundedValues(Environment const &env, storm::models::sparse::Dtmc< ValueType > const &model, std::shared_ptr< storm::logic::OperatorFormula const > rewardBoundedFormula)
static std::vector< SolutionType > computeCumulativeRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, RewardModelType const &rewardModel, uint_fast64_t stepBound)
static std::vector< SolutionType > computeInstantaneousRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, RewardModelType const &rewardModel, uint_fast64_t stepCount)
static DTMCSparseModelCheckingHelperReturnType< ExtendedSolutionType > computeReachabilityTimes(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &targetStates, bool qualitative, ModelCheckerHint const &hint=ModelCheckerHint())
static std::vector< ExtendedSolutionType > computeConditionalProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &targetStates, storm::storage::BitVector const &conditionStates, bool qualitative)
static std::vector< SolutionType > computeNextProbabilities(Environment const &env, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::BitVector const &nextStates)
static DTMCSparseModelCheckingHelperReturnType< ExtendedSolutionType > computeReachabilityRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, RewardModelType const &rewardModel, storm::storage::BitVector const &targetStates, bool qualitative, ModelCheckerHint const &hint=ModelCheckerHint())
static DTMCSparseModelCheckingHelperReturnType< SolutionType > computeUntilProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool qualitative, ModelCheckerHint const &hint=ModelCheckerHint())
static DTMCSparseModelCheckingHelperReturnType< SolutionType > computeGloballyProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &psiStates, bool qualitative)
static std::vector< ExtendedSolutionType > computeConditionalRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, RewardModelType const &rewardModel, storm::storage::BitVector const &targetStates, storm::storage::BitVector const &conditionStates, bool qualitative)
Helper class for LTL model checking.
std::vector< std::vector< storm::utility::ExtendedValueType< ValueType > > > computeQuantile(Environment const &env)
#define STORM_LOG_WARN(message)
Definition logging.h:35
#define STORM_LOG_THROW_UNCONDITIONALLY(exception, message)
Definition macros.h:48
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:54
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:39
FragmentSpecification prctlstar()
FragmentSpecification propositional()
FragmentSpecification reachability()
FragmentSpecification quantiles()
void setInformationFromCheckTaskDeterministic(HelperType &helper, storm::modelchecker::CheckTask< FormulaType, typename ModelType::ValueType > const &checkTask, ModelType const &model)
Forwards relevant information stored in the given CheckTask to the given helper.
FilteredRewardModel< RewardModelType > createFilteredRewardModel(RewardModelType const &baseRewardModel, storm::logic::RewardAccumulation const &acc, bool isDiscreteTimeModel)
ValueType zero()
Definition constants.cpp:26
ValueType one()
Definition constants.cpp:21
TargetType convertNumber(SourceType const &number)
constexpr bool IsIntervalType
Helper to check if a type is an interval.
boost::optional< Bound > bound