Storm 2.0.0.3
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
26
27namespace storm {
28namespace modelchecker {
29template<typename SparseDtmcModelType>
31 : SparsePropositionalModelChecker<SparseDtmcModelType>(model) {
32 // Intentionally left empty.
33}
34
35template<typename SparseDtmcModelType>
37 bool* requiresSingleInitialState) {
38 storm::logic::Formula const& formula = checkTask.getFormula();
41 return true;
42 }
43 if (formula.isInFragment(storm::logic::reachability().setReachabilityRewardFormulasAllowed(true).setRewardOperatorsAllowed(true))) {
44 return true;
45 }
46 if (formula.isInFragment(
47 storm::logic::prctlstar().setBoundedUntilFormulasAllowed(true).setTimeOperatorsAllowed(true).setReachbilityTimeFormulasAllowed(true))) {
48 return true;
49 }
50 } else {
52 .setLongRunAverageRewardFormulasAllowed(true)
53 .setLongRunAverageProbabilitiesAllowed(true)
54 .setConditionalProbabilityFormulasAllowed(true)
55 .setConditionalRewardFormulasAllowed(true)
56 .setTotalRewardFormulasAllowed(true)
57 .setOnlyEventuallyFormuluasInConditionalFormulasAllowed(true)
58 .setRewardBoundedUntilFormulasAllowed(true)
59 .setRewardBoundedCumulativeRewardFormulasAllowed(true)
60 .setMultiDimensionalBoundedUntilFormulasAllowed(true)
61 .setMultiDimensionalCumulativeRewardFormulasAllowed(true)
62 .setTimeOperatorsAllowed(true)
63 .setReachbilityTimeFormulasAllowed(true)
64 .setRewardAccumulationAllowed(true)
65 .setHOAPathFormulasAllowed(true)
66 .setDiscountedTotalRewardFormulasAllowed(true)
67 .setDiscountedCumulativeRewardFormulasAllowed(true))) {
68 return true;
69 } else if (checkTask.isOnlyInitialStatesRelevantSet() && formula.isInFragment(storm::logic::quantiles())) {
70 if (requiresSingleInitialState) {
71 *requiresSingleInitialState = true;
72 }
73 return true;
74 }
75 }
76
77 return false;
78}
79
80template<typename SparseDtmcModelType>
82 bool requiresSingleInitialState = false;
83 if (canHandleStatic(checkTask, &requiresSingleInitialState)) {
84 return !requiresSingleInitialState || this->getModel().getInitialStates().getNumberOfSetBits() == 1;
85 } else {
86 return false;
87 }
88}
89
90template<typename SparseDtmcModelType>
93 storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula();
94 if (pathFormula.isMultiDimensional() || pathFormula.getTimeBoundReference().isRewardBound()) {
95 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
96 "Checking non-trivial bounded until probabilities can only be computed for the initial states of the model.");
98 if (checkTask.isBoundSet()) {
99 opInfo.bound = checkTask.getBound();
100 }
101 auto formula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(checkTask.getFormula().asSharedPointer(), opInfo);
103 env, this->getModel(), formula);
104 // The helper returns one value per initial state, in the order in which the bit vector selects them.
105 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(this->getModel().getInitialStates(), std::move(numericResult)));
106 } else {
107 STORM_LOG_THROW(pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have (a single) upper step bound.");
108 STORM_LOG_THROW(pathFormula.hasIntegerLowerBound(), storm::exceptions::InvalidPropertyException, "Formula lower step bound must be discrete/integral.");
109 STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper step bound.");
110 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
111 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
112 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
113 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
115 std::vector<SolutionType> numericResult = helper.computeStepBoundedUntilProbabilities(
116 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
117 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(),
118 pathFormula.getNonStrictLowerBound<uint64_t>(), pathFormula.getNonStrictUpperBound<uint64_t>(), checkTask.getHint());
119
120 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
121 result->setValuesExact();
122 return result;
123 }
124}
125
126template<typename SparseDtmcModelType>
129 if constexpr (storm::IsIntervalType<ValueType>) {
130 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented next probabilities with intervals.");
131 } else {
132 storm::logic::NextFormula const& pathFormula = checkTask.getFormula();
133 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
134 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
135 std::vector<SolutionType> numericResult =
137 env, this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector());
138 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
139 result->setValuesExact();
140 return result;
141 }
142}
143
144template<typename SparseDtmcModelType>
147 storm::logic::UntilFormula const& pathFormula = checkTask.getFormula();
148 if constexpr (storm::IsIntervalType<ValueType>) {
149 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
150 "Uncertainty resolution mode must be set for uncertain (interval) models.");
151 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
152 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
153 storm::exceptions::InvalidSettingsException,
154 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
155 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
156 "Computing until probabilities on uncertain model requires graph-preservation.");
157 }
158 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
159 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
160 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
161 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
162 if (checkTask.isProduceCertificateSet()) {
164 STORM_LOG_INFO("Computing reachability probabilities with certificate ...");
165 std::optional<storm::storage::BitVector> constraintStates;
166 std::optional<std::string> constraintLabel;
167 if (!pathFormula.getLeftSubformula().isTrueFormula()) {
168 constraintStates = leftResult.getTruthValuesVector();
169 constraintLabel = pathFormula.getLeftSubformula().toString();
170 }
171 auto certificate = storm::modelchecker::computeReachabilityProbabilityCertificate(env, std::nullopt, this->getModel().getTransitionMatrix(),
172 rightResult.getTruthValuesVector(), constraintStates,
173 pathFormula.getRightSubformula().toString(), constraintLabel);
174 storm::storage::BitVector allStates(this->getModel().getNumberOfStates(), true);
175 return std::make_unique<ExplicitCertificateCheckResult<ValueType>>(std::move(certificate), std::move(allStates));
176 } else {
177 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Certificates are not implemented for this value type.");
178 }
179 }
181 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
182 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet(),
183 checkTask.getHint());
184 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
185 result->setBounds(std::move(ret.solutionBounds));
186 return result;
187}
188
189template<typename SparseDtmcModelType>
192 if constexpr (storm::IsIntervalType<ValueType>) {
193 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented globally probabilities with intervals.");
194 } else {
195 storm::logic::GloballyFormula const& pathFormula = checkTask.getFormula();
196 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
197 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
199 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
200 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet());
201 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
202 result->setBounds(std::move(ret.solutionBounds));
203 return result;
204 }
205}
206
207template<typename SparseDtmcModelType>
210 if constexpr (storm::IsIntervalType<ValueType>) {
211 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented automata-props with intervals.");
212 } else {
213 storm::logic::HOAPathFormula const& pathFormula = checkTask.getFormula();
214
217
218 auto formulaChecker = [&](storm::logic::Formula const& formula) {
219 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
220 };
221 auto apSets = helper.computeApSets(pathFormula.getAPMapping(), formulaChecker);
222 std::vector<ValueType> numericResult = helper.computeDAProductProbabilities(env, *pathFormula.readAutomaton(), apSets);
223
224 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(std::move(numericResult)));
225 }
226}
227
228template<typename SparseDtmcModelType>
231 if constexpr (storm::IsIntervalType<ValueType>) {
232 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LTL with interval models.");
233 } else {
234 storm::logic::PathFormula const& pathFormula = checkTask.getFormula();
235
238
239 auto formulaChecker = [&](storm::logic::Formula const& formula) {
240 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
241 };
242 std::vector<ValueType> numericResult = helper.computeLTLProbabilities(env, pathFormula, formulaChecker);
243
244 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(std::move(numericResult)));
245 }
246}
247
248template<typename SparseDtmcModelType>
251 storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
252 if (rewardPathFormula.isMultiDimensional() || rewardPathFormula.getTimeBoundReference().isRewardBound()) {
253 if constexpr (storm::IsIntervalType<ValueType>) {
254 STORM_LOG_THROW_UNCONDITIONALLY(storm::exceptions::NotImplementedException,
255 "We have not yet implemented multi-dimensional or reward-bounded cumulative rewards with intervals.");
256 } else {
257 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
258 "Checking non-trivial bounded until probabilities can only be computed for the initial states of the model.");
259 STORM_LOG_THROW(!checkTask.getFormula().hasRewardAccumulation(), storm::exceptions::InvalidOperationException,
260 "Checking reward bounded cumulative reward formulas is not supported if reward accumulations are given.");
262 if (checkTask.isBoundSet()) {
263 opInfo.bound = checkTask.getBound();
264 }
265 auto formula = std::make_shared<storm::logic::RewardOperatorFormula>(checkTask.getFormula().asSharedPointer(), checkTask.getRewardModel(), opInfo);
267 env, this->getModel(), formula);
268 // The helper returns one value per initial state, in the order in which the bit vector selects them.
269 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(this->getModel().getInitialStates(), std::move(numericResult)));
270 }
271 } else {
272 if constexpr (storm::IsIntervalType<ValueType>) {
273 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
274 "Uncertainty resolution mode must be set for uncertain (interval) models.");
275 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
276 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
277 storm::exceptions::InvalidSettingsException,
278 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
279 }
280 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
281 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
282 std::vector<SolutionType> numericResult =
284 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
285 rewardPathFormula.getNonStrictBound<uint64_t>());
286 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
287 result->setValuesExact();
288 return result;
289 }
290}
291
292template<>
295 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for parametric models.");
296}
297
298template<typename SparseDtmcModelType>
301 if constexpr (storm::IsIntervalType<ValueType>) {
302 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented discounted cumulative rewards with intervals.");
303 } else {
304 storm::logic::DiscountedCumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
305 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
306 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
307 std::vector<SolutionType> numericResult =
309 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
310 rewardPathFormula.getNonStrictBound<uint64_t>(), rewardPathFormula.getDiscountFactor<SolutionType>());
311 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
312 result->setValuesExact();
313 return result;
314 }
315}
316
317template<typename SparseDtmcModelType>
320 if constexpr (storm::IsIntervalType<ValueType>) {
321 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented instantaneous rewards with intervals.");
322 } else {
323 storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula();
324 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
325 std::vector<SolutionType> numericResult =
327 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
328 checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""),
329 rewardPathFormula.getBound<uint64_t>());
330 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
331 result->setValuesExact();
332 return result;
333 }
334}
335
336template<typename SparseDtmcModelType>
339 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
340 if constexpr (storm::IsIntervalType<ValueType>) {
341 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
342 "Uncertainty resolution mode must be set for uncertain (interval) models.");
343 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
344 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
345 storm::exceptions::InvalidSettingsException,
346 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
347 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
348 "Computing rewards on uncertain model requires graph-preservation.");
349 }
350 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
351 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
352 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
353 if (checkTask.isProduceCertificateSet()) {
355 STORM_LOG_INFO("Computing reachability rewards with certificate ...");
357 env, std::nullopt, this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector(),
358 rewardModel.get().getTotalRewardVector(this->getModel().getTransitionMatrix()), eventuallyFormula.getSubformula().toString(),
359 checkTask.isRewardModelSet() ? checkTask.getRewardModel() : "");
360 storm::storage::BitVector allStates(this->getModel().getNumberOfStates(), true);
361 return std::make_unique<ExplicitCertificateCheckResult<ValueType>>(std::move(certificate), std::move(allStates));
362 } else {
363 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Certificates are not implemented for this value type.");
364 }
365 }
367 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
368 this->getModel().getBackwardTransitions(), rewardModel.get(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.getHint());
369 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
370 result->setBounds(std::move(ret.solutionBounds));
371 return result;
372}
373
374template<typename SparseDtmcModelType>
377 if constexpr (storm::IsIntervalType<ValueType>) {
378 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
379 "Uncertainty resolution mode must be set for uncertain (interval) models.");
380 STORM_LOG_THROW(checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Robust &&
381 checkTask.getUncertaintyResolutionMode() != UncertaintyResolutionMode::Cooperative,
382 storm::exceptions::InvalidSettingsException,
383 "Uncertainty resolution modes robust or cooperative not allowed if optimization direction is not stated explicitly.");
384 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
385 "Computing reachability times on uncertain model requires graph-preservation.");
386 }
387 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
388 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
389 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
390 if (checkTask.isProduceCertificateSet()) {
392 STORM_LOG_INFO("Computing reachability times with certificate ...");
394 env, std::nullopt, this->getModel().getTransitionMatrix(), subResult.getTruthValuesVector(),
395 std::vector<ValueType>(this->getModel().getNumberOfStates(), storm::utility::one<ValueType>()), eventuallyFormula.getSubformula().toString(),
396 "time");
397 storm::storage::BitVector allStates(this->getModel().getNumberOfStates(), true);
398 return std::make_unique<ExplicitCertificateCheckResult<ValueType>>(std::move(certificate), std::move(allStates));
399 } else {
400 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Certificates are not implemented for this value type.");
401 }
402 }
404 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
405 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.getHint());
406 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
407 result->setBounds(std::move(ret.solutionBounds));
408 return result;
409}
410
411template<typename SparseDtmcModelType>
414 if constexpr (storm::IsIntervalType<ValueType>) {
415 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented total rewards with intervals.");
416 } else {
417 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
419 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
420 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), checkTask.getHint());
421 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(ret.values));
422 result->setBounds(std::move(ret.solutionBounds));
423 return result;
424 }
425}
426
427template<>
430 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for parametric models.");
431}
432
433template<typename SparseDtmcModelType>
436 if constexpr (storm::IsIntervalType<ValueType>) {
437 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented discounted total rewards with intervals.");
438 } else {
439 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
440 storm::logic::DiscountedTotalRewardFormula const& rewardPathFormula = checkTask.getFormula();
441 auto discountFactor = rewardPathFormula.getDiscountFactor<SolutionType>();
443 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
444 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), discountFactor, checkTask.getHint());
445 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret)));
446 return result;
447 }
448}
449
450template<typename SparseDtmcModelType>
453 if constexpr (storm::IsIntervalType<ValueType>) {
454 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LRA probabilities with intervals.");
455 } else {
456 storm::logic::StateFormula const& stateFormula = checkTask.getFormula();
457 std::unique_ptr<CheckResult> subResultPointer = this->check(env, stateFormula);
458 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
459
462 auto values = helper.computeLongRunAverageProbabilities(env, subResult.getTruthValuesVector());
463
464 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(values)));
465 }
466}
467
468template<typename SparseDtmcModelType>
471 if constexpr (storm::IsIntervalType<ValueType>) {
472 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented lra with intervals.");
473 } else {
474 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
477 auto values = helper.computeLongRunAverageRewards(env, rewardModel.get());
478 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(std::move(values)));
479 }
480}
481
482template<typename SparseDtmcModelType>
485 if constexpr (storm::IsIntervalType<ValueType>) {
486 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented conditional probabilities with intervals.");
487 } else {
488 storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula();
489 STORM_LOG_THROW(conditionalFormula.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
490 "Illegal conditional probability formula.");
491 STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
492 "Illegal conditional probability formula.");
493
494 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, conditionalFormula.getSubformula().asEventuallyFormula().getSubformula());
495 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, conditionalFormula.getConditionFormula().asEventuallyFormula().getSubformula());
496 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
497 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
498
499 std::vector<ExtendedSolutionType> numericResult =
501 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
502 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet());
503 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
504 }
505}
506
507template<typename SparseDtmcModelType>
510 if constexpr (storm::IsIntervalType<ValueType>) {
511 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented conditional rewards with intervals.");
512 } else {
513 storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula();
514 STORM_LOG_THROW(conditionalFormula.getSubformula().isReachabilityRewardFormula(), storm::exceptions::InvalidPropertyException,
515 "Illegal conditional probability formula.");
516 STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
517 "Illegal conditional probability formula.");
518
519 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, conditionalFormula.getSubformula().asReachabilityRewardFormula().getSubformula());
520 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, conditionalFormula.getConditionFormula().asEventuallyFormula().getSubformula());
521 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
522 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
523
524 std::vector<ExtendedSolutionType> numericResult =
526 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
527 this->getModel().getBackwardTransitions(),
528 checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""),
529 leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet());
530 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
531 }
532}
533
534template<>
537 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Quantiles for parametric models are not implemented.");
538}
539
540template<typename SparseDtmcModelType>
543 if constexpr (storm::IsIntervalType<ValueType>) {
544 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented quantile formulas with intervals.");
545 } else {
546 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
547 "Computing quantiles is only supported for the initial states of a model.");
548 STORM_LOG_THROW(this->getModel().getInitialStates().getNumberOfSetBits() == 1, storm::exceptions::InvalidOperationException,
549 "Quantiles not supported on models with multiple initial states.");
550 uint64_t initialState = *this->getModel().getInitialStates().begin();
551
553 auto res = qHelper.computeQuantile(env);
554
555 if (res.size() == 1 && res.front().size() == 1) {
556 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<ValueType>(initialState, std::move(res.front().front())));
557 } else {
558 return std::unique_ptr<CheckResult>(new ExplicitParetoCurveCheckResult<ValueType>(initialState, std::move(res)));
559 }
560 }
561}
562
563template<typename SparseDtmcModelType>
565 if constexpr (storm::IsIntervalType<ValueType>) {
566 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented steady state distributions with intervals.");
567 } else {
568 // Initialize helper
570
571 // Compute result
572 std::vector<SolutionType> result;
573 auto const& initialStates = this->getModel().getInitialStates();
574 uint64_t numInitStates = initialStates.getNumberOfSetBits();
575 if (numInitStates == 1) {
576 result = helper.computeLongRunAverageStateDistribution(env, *initialStates.begin());
577 } else {
578 STORM_LOG_WARN("Multiple initial states found. A uniform distribution over initial states is assumed.");
580 result = helper.computeLongRunAverageStateDistribution(env, [&initialStates, &initProb](uint64_t const& stateIndex) {
581 return initialStates.get(stateIndex) ? initProb : storm::utility::zero<ValueType>();
582 });
583 }
584
585 // Return CheckResult
586 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(result)));
587 }
588}
589
590template<typename SparseDtmcModelType>
592 if constexpr (storm::IsIntervalType<ValueType>) {
593 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented expected visiting times with intervals.");
594 } else {
595 // Initialize helper
597
598 // Compute result
599 std::vector<ExtendedSolutionType> result;
600 auto const& initialStates = this->getModel().getInitialStates();
601 uint64_t numInitStates = initialStates.getNumberOfSetBits();
602 STORM_LOG_THROW(numInitStates > 0, storm::exceptions::InvalidOperationException, "No initial states given. Cannot compute expected visiting times.");
603 STORM_LOG_WARN_COND(numInitStates == 1, "Multiple initial states found. A uniform distribution over initial states is assumed.");
604 result = helper.computeExpectedVisitingTimes(env, initialStates);
605
606 // Return CheckResult
607 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(result)));
608 }
609}
610
616} // namespace modelchecker
617} // 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
std::string toString() const
Definition Formula.cpp:617
virtual bool isTrueFormula() const
Definition Formula.cpp:70
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:221
bool isProduceCertificateSet() const
Retrieves whether certificate(s) are to be produced (if supported).
Definition CheckTask.h:295
bool isRewardModelSet() const
Retrieves whether a reward model was set.
Definition CheckTask.h:192
bool isQualitativeSet() const
Retrieves whether the computation only needs to be performed qualitatively, because the values will o...
Definition CheckTask.h:259
std::string const & getRewardModel() const
Retrieves the reward model over which to perform the checking (if set).
Definition CheckTask.h:199
FormulaType const & getFormula() const
Retrieves the formula from this task.
Definition CheckTask.h:142
ModelCheckerHint const & getHint() const
Retrieves a hint that might contain information that speeds up the modelchecking process (if supporte...
Definition CheckTask.h:309
bool isUncertaintyResolutionModeSet() const
Returns whether the mode, which decides how the uncertainty will be resolved, is set.
Definition CheckTask.h:334
storm::logic::Bound const & getBound() const
Retrieves the bound (if set).
Definition CheckTask.h:244
bool isOnlyInitialStatesRelevantSet() const
Retrieves whether only the initial states are relevant in the computation.
Definition CheckTask.h:206
UncertaintyResolutionMode getUncertaintyResolutionMode() const
Retrieves the mode which decides how the uncertainty will be resolved.
Definition CheckTask.h:320
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)
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
bool get(uint64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
#define STORM_LOG_INFO(message)
Definition logging.h:34
#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.
constexpr bool SupportsCertificates
Certificates can be computed for models with these value types.
Definition Certificate.h:27
std::unique_ptr< ReachabilityRewardCertificate< ValueType > > computeReachabilityRewardCertificate(storm::Environment const &env, std::optional< storm::OptimizationDirection > dir, storm::storage::SparseMatrix< ValueType > const &transitionProbabilityMatrix, storm::storage::BitVector targetStates, std::vector< ValueType > stateActionRewardVector, std::string targetLabel, std::string rewardModelName)
Computes a certificate for expected rewards accumulated until reaching the target states.
std::unique_ptr< ReachabilityProbabilityCertificate< ValueType > > computeReachabilityProbabilityCertificate(storm::Environment const &env, std::optional< storm::OptimizationDirection > dir, storm::storage::SparseMatrix< ValueType > const &transitionProbabilityMatrix, storm::storage::BitVector targetStates, std::optional< storm::storage::BitVector > constraintStates, std::string targetLabel, std::optional< std::string > constraintLabel)
Computes a certificate for reachability probabilities (or constrained reachability probabilities if c...
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)
The contract of a DD backend.
constexpr bool IsIntervalType
Helper to check if a type is an interval.
boost::optional< Bound > bound