Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseMdpPrctlModelChecker.cpp
Go to the documentation of this file.
2
25#include "storm/utility/graph.h"
28
29namespace storm {
30namespace modelchecker {
31template<typename SparseMdpModelType>
33 : SparsePropositionalModelChecker<SparseMdpModelType>(model) {
34 // Intentionally left empty.
35}
36
37template<typename SparseMdpModelType>
39 bool* requiresSingleInitialState) {
40 storm::logic::Formula const& formula = checkTask.getFormula();
43 return true;
44 }
46 return true;
47 }
48 if (formula.isInFragment(storm::logic::prctlstar().setBoundedUntilFormulasAllowed(true))) {
49 return true;
50 }
51 } else {
53 .setLongRunAverageRewardFormulasAllowed(true)
54 .setLongRunAverageProbabilitiesAllowed(true)
55 .setConditionalProbabilityFormulasAllowed(true)
56 .setOnlyEventuallyFormuluasInConditionalFormulasAllowed(true)
57 .setTotalRewardFormulasAllowed(true)
58 .setRewardBoundedUntilFormulasAllowed(true)
59 .setRewardBoundedCumulativeRewardFormulasAllowed(true)
60 .setMultiDimensionalBoundedUntilFormulasAllowed(true)
61 .setMultiDimensionalCumulativeRewardFormulasAllowed(true)
62 .setTimeOperatorsAllowed(true)
63 .setReachbilityTimeFormulasAllowed(true)
64 .setRewardAccumulationAllowed(true)
65 .setDiscountedTotalRewardFormulasAllowed(true)
66 .setDiscountedCumulativeRewardFormulasAllowed(true))) {
67 return true;
68 } else if (checkTask.isOnlyInitialStatesRelevantSet()) {
69 auto multiObjectiveFragment = storm::logic::multiObjective()
70 .setTimeAllowed(true)
81 auto lexObjectiveFragment = storm::logic::lexObjective()
93
94 if (formula.isInFragment(multiObjectiveFragment) || formula.isInFragment(storm::logic::quantiles()) || formula.isInFragment(lexObjectiveFragment)) {
95 if (requiresSingleInitialState) {
96 *requiresSingleInitialState = true;
97 }
98 return true;
99 }
100 }
101 }
102 return false;
103}
104
105template<typename SparseMdpModelType>
107 bool requiresSingleInitialState = false;
108 if (canHandleStatic(checkTask, &requiresSingleInitialState)) {
109 return !requiresSingleInitialState || this->getModel().getInitialStates().getNumberOfSetBits() == 1;
110 } else {
111 return false;
112 }
113}
114
115template<typename SparseMdpModelType>
118 storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula();
119 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
120 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
121 if (pathFormula.isMultiDimensional() || pathFormula.getTimeBoundReference().isRewardBound()) {
122 if constexpr (storm::IsIntervalType<ValueType>) {
123 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented multi dimensional bounded until with intervals.");
124 return nullptr;
125 } else {
126 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
127 "Checking non-trivial bounded until probabilities can only be computed for the initial states of the model.");
128 STORM_LOG_WARN_COND(!checkTask.isQualitativeSet(), "Checking non-trivial bounded until formulas is not optimized w.r.t. qualitative queries");
130 if (checkTask.isBoundSet()) {
131 opInfo.bound = checkTask.getBound();
132 }
133 auto formula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(checkTask.getFormula().asSharedPointer(), opInfo);
136 env, checkTask.getOptimizationDirection(), rewardUnfolding, this->getModel().getInitialStates());
137 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
138 }
139 } else {
140 STORM_LOG_THROW(pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have (a single) upper step bound.");
141 STORM_LOG_THROW(pathFormula.hasIntegerLowerBound(), storm::exceptions::InvalidPropertyException, "Formula lower step bound must be discrete/integral.");
142 STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound.");
143 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
144 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
145 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
146 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
148 std::vector<SolutionType> numericResult = helper.computeStepBoundedUntilProbabilities(
149 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
150 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(),
151 pathFormula.getNonStrictLowerBound<uint64_t>(), pathFormula.getNonStrictUpperBound<uint64_t>(), checkTask.getHint());
152 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
153 }
154}
155
156template<typename SparseMdpModelType>
159 storm::logic::NextFormula const& pathFormula = checkTask.getFormula();
160 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
161 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
162 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
163 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
165 env, checkTask.getOptimizationDirection(), checkTask.getUncertaintyResolutionMode(), this->getModel().getTransitionMatrix(),
166 subResult.getTruthValuesVector());
167 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
168}
169
170template<typename SparseMdpModelType>
173 storm::logic::UntilFormula const& pathFormula = checkTask.getFormula();
174 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
175 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
176 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
177 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
178 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
179 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
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.isProduceSchedulersSet(), checkTask.getHint());
184 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
185 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
186 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
187 }
188 return result;
189}
190
191template<typename SparseMdpModelType>
194 storm::logic::GloballyFormula const& pathFormula = checkTask.getFormula();
195 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
196 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
197 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
198 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
200 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
201 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet());
202 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
203 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
204 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
205 }
206 return result;
207}
208
209template<typename SparseMdpModelType>
212 if constexpr (storm::IsIntervalType<ValueType>) {
213 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented automata-props with intervals.");
214 } else {
215 storm::logic::HOAPathFormula const& pathFormula = checkTask.getFormula();
216
219
220 auto formulaChecker = [&](storm::logic::Formula const& formula) {
221 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
222 };
223 auto apSets = helper.computeApSets(pathFormula.getAPMapping(), formulaChecker);
224 std::vector<SolutionType> numericResult = helper.computeDAProductProbabilities(env, *pathFormula.readAutomaton(), apSets);
225
226 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
227 if (checkTask.isProduceSchedulersSet()) {
228 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
229 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler(this->getModel())));
230 }
231
232 return result;
233 }
234}
235
236template<typename SparseMdpModelType>
239 if constexpr (storm::IsIntervalType<ValueType>) {
240 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LTL with intervals.");
241 } else {
242 storm::logic::PathFormula const& pathFormula = checkTask.getFormula();
243
244 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
245 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
246
249
250 auto formulaChecker = [&](storm::logic::Formula const& formula) {
251 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
252 };
253 std::vector<SolutionType> numericResult = helper.computeLTLProbabilities(env, pathFormula, formulaChecker);
254
255 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
256 if (checkTask.isProduceSchedulersSet()) {
257 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
258 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler(this->getModel())));
259 }
260
261 return result;
262 }
263}
264
265template<typename SparseMdpModelType>
268 storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula();
269 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
270 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
271 STORM_LOG_THROW(this->getModel().getInitialStates().hasUniqueSetBit(), storm::exceptions::InvalidPropertyException,
272 "Cannot compute conditional probabilities on MDPs with more than one initial state.");
273 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidPropertyException,
274 "Conditional probabilities can only be computed for the initial states of the model.");
275 STORM_LOG_THROW(conditionalFormula.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
276 "Illegal conditional probability formula.");
277 STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
278 "Illegal conditional probability formula.");
279
280 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, conditionalFormula.getSubformula().asEventuallyFormula().getSubformula());
281 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, conditionalFormula.getConditionFormula().asEventuallyFormula().getSubformula());
282 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
283 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
284 if constexpr (storm::IsIntervalType<ValueType>) {
285 STORM_LOG_THROW(false, exceptions::NotSupportedException, "Conditional Probabilities are not supported with interval models.");
286 } else {
288 checkTask.isProduceSchedulersSet(), this->getModel().getTransitionMatrix(),
289 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(),
290 rightResult.getTruthValuesVector());
291 }
292}
293
294template<typename SparseMdpModelType>
297 if constexpr (storm::IsIntervalType<ValueType>) {
298 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Cumulative reward properties are not implemented for interval models.");
299 }
300 storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
301 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
302 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
303 if (rewardPathFormula.isMultiDimensional() || rewardPathFormula.getTimeBoundReference().isRewardBound()) {
304 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
305 "Checking reward bounded cumulative reward formulas can only be done for the initial states of the model.");
306 STORM_LOG_THROW(!checkTask.getFormula().hasRewardAccumulation(), storm::exceptions::InvalidOperationException,
307 "Checking reward bounded cumulative reward formulas is not supported if reward accumulations are given.");
308 STORM_LOG_WARN_COND(!checkTask.isQualitativeSet(), "Checking reward bounded until formulas is not optimized w.r.t. qualitative queries");
310 if (checkTask.isBoundSet()) {
311 opInfo.bound = checkTask.getBound();
312 }
313 auto formula = std::make_shared<storm::logic::RewardOperatorFormula>(checkTask.getFormula().asSharedPointer(), checkTask.getRewardModel(), opInfo);
316 env, checkTask.getOptimizationDirection(), rewardUnfolding, this->getModel().getInitialStates());
317 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
318 } else {
319 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
320 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
322 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
323 rewardPathFormula.getNonStrictBound<uint64_t>());
324 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
325 }
326}
327
328template<>
331 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
332}
333
334template<>
337 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
338}
339
340template<typename SparseMdpModelType>
343 storm::logic::DiscountedCumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
344 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
345 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
346 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
347 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
349 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
350 rewardPathFormula.getNonStrictBound<uint64_t>(), rewardPathFormula.getDiscountFactor<ValueType>());
351 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
352}
353
354template<typename SparseMdpModelType>
357 storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula();
358 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
359 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
360 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
362 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
363 checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""),
364 rewardPathFormula.getBound<uint64_t>());
365 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
366}
367
368template<typename SparseMdpModelType>
371 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
372 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
373 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
374 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
375 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
376 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
378 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
379 this->getModel().getBackwardTransitions(), rewardModel.get(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(),
380 checkTask.isProduceSchedulersSet(), checkTask.getHint());
381 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
382 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
383 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
384 }
385 return result;
386}
387
388template<typename SparseMdpModelType>
391 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
392 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
393 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
394 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
395 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
397 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
398 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet(),
399 checkTask.getHint());
400 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
401 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
402 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
403 }
404 return result;
405}
406
407template<typename SparseMdpModelType>
410 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
411 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
412 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
414 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
415 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet(), checkTask.getHint());
416 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
417 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
418 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
419 }
420 return result;
421}
422
423template<>
426 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
427}
428
429template<>
432 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
433}
434
435template<typename SparseMdpModelType>
438 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
439 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
440 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
441 storm::logic::DiscountedTotalRewardFormula const& rewardPathFormula = checkTask.getFormula();
442 auto discountFactor = rewardPathFormula.getDiscountFactor<ValueType>();
444 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
445 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet(), discountFactor,
446 checkTask.getHint());
447 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
448 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
449 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
450 }
451 return result;
452}
453
454template<typename SparseMdpModelType>
457 if constexpr (storm::IsIntervalType<ValueType>) {
458 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LRA probabilities with intervals.");
459 } else {
460 storm::logic::StateFormula const& stateFormula = checkTask.getFormula();
461 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
462 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
463 std::unique_ptr<CheckResult> subResultPointer = this->check(env, stateFormula);
464 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
465
468 auto values = helper.computeLongRunAverageProbabilities(env, subResult.getTruthValuesVector());
469
470 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(values)));
471 if (checkTask.isProduceSchedulersSet()) {
472 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
473 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler()));
474 }
475 return result;
476 }
477}
478
479template<typename SparseMdpModelType>
482 if constexpr (storm::IsIntervalType<ValueType>) {
483 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented lra with intervals.");
484 } else {
485 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
486 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
487 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
490 auto values = helper.computeLongRunAverageRewards(env, rewardModel.get());
491 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(values)));
492 if (checkTask.isProduceSchedulersSet()) {
493 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
494 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler()));
495 }
496 return result;
497 }
498}
499
500template<typename SparseMdpModelType>
503 if constexpr (storm::IsIntervalType<ValueType>) {
504 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented multi-objective with intervals.");
505 } else {
507 }
508}
509
510template<class SparseMdpModelType>
513 if constexpr (storm::IsIntervalType<ValueType>) {
514 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented lexicographic model checking with intervals.");
515 } else {
516 auto formulaChecker = [&](storm::logic::Formula const& formula) {
517 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
518 };
519 auto ret = lexicographic::check(env, this->getModel(), checkTask, formulaChecker);
520 std::unique_ptr<CheckResult> result(new LexicographicCheckResult<SolutionType>(ret.values, *this->getModel().getInitialStates().begin()));
521 return result;
522 }
523}
524
525template<typename SparseMdpModelType>
528 if constexpr (storm::IsIntervalType<ValueType>) {
529 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented quantile formulas with intervals.");
530 } else {
531 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
532 "Computing quantiles is only supported for the initial states of a model.");
533 STORM_LOG_THROW(this->getModel().getInitialStates().getNumberOfSetBits() == 1, storm::exceptions::InvalidOperationException,
534 "Quantiles not supported on models with multiple initial states.");
535 uint64_t initialState = *this->getModel().getInitialStates().begin();
536
538 auto res = qHelper.computeQuantile(env);
539
540 if (res.size() == 1 && res.front().size() == 1) {
541 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(initialState, std::move(res.front().front())));
542 } else {
543 return std::unique_ptr<CheckResult>(new ExplicitParetoCurveCheckResult<SolutionType>(initialState, std::move(res)));
544 }
545 }
546}
547
552} // namespace modelchecker
553} // 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
EventuallyFormula & asEventuallyFormula()
Definition Formula.cpp:341
bool isInFragment(FragmentSpecification const &fragment) const
Definition Formula.cpp:204
virtual bool isEventuallyFormula() const
Definition Formula.cpp:88
FragmentSpecification & setStepBoundedUntilFormulasAllowed(bool newValue)
FragmentSpecification & setRewardBoundedCumulativeRewardFormulasAllowed(bool newValue)
FragmentSpecification & setRewardAccumulationAllowed(bool newValue)
FragmentSpecification & setMultiDimensionalBoundedUntilFormulasAllowed(bool newValue)
FragmentSpecification & setTimeBoundedUntilFormulasAllowed(bool newValue)
FragmentSpecification & setCumulativeRewardFormulasAllowed(bool newValue)
FragmentSpecification & setMultiDimensionalCumulativeRewardFormulasAllowed(bool newValue)
FragmentSpecification & setRewardBoundedUntilFormulasAllowed(bool newValue)
FragmentSpecification & setTimeBoundedCumulativeRewardFormulasAllowed(bool newValue)
FragmentSpecification & setHOAPathFormulasAllowed(bool newValue)
FragmentSpecification & setTimeAllowed(bool newValue)
FragmentSpecification & setStepBoundedCumulativeRewardFormulasAllowed(bool newValue)
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 isOptimizationDirectionSet() const
Retrieves whether an optimization direction was set.
Definition CheckTask.h:148
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 isProduceSchedulersSet() const
Retrieves whether scheduler(s) are to be produced (if supported).
Definition CheckTask.h:280
storm::logic::Bound const & getBound() const
Retrieves the bound (if set).
Definition CheckTask.h:243
storm::OptimizationDirection const & getOptimizationDirection() const
Retrieves the optimization direction (if set).
Definition CheckTask.h:155
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
virtual std::unique_ptr< CheckResult > computeLongRunAverageProbabilities(Environment const &env, CheckTask< storm::logic::StateFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeCumulativeRewards(Environment const &env, CheckTask< storm::logic::CumulativeRewardFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeLongRunAverageRewards(Environment const &env, CheckTask< storm::logic::LongRunAverageRewardFormula, 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 > checkMultiObjectiveFormula(Environment const &env, CheckTask< storm::logic::MultiObjectiveFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeReachabilityTimes(Environment const &env, CheckTask< storm::logic::EventuallyFormula, 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 > computeLTLProbabilities(Environment const &env, CheckTask< storm::logic::PathFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeGloballyProbabilities(Environment const &env, CheckTask< storm::logic::GloballyFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeUntilProbabilities(Environment const &env, CheckTask< storm::logic::UntilFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > checkQuantileFormula(Environment const &env, CheckTask< storm::logic::QuantileFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > checkLexObjectiveFormula(Environment const &env, CheckTask< storm::logic::MultiObjectiveFormula, SolutionType > const &checkTask) override
virtual bool canHandle(CheckTask< storm::logic::Formula, SolutionType > const &checkTask) const override
virtual std::unique_ptr< CheckResult > computeReachabilityRewards(Environment const &env, CheckTask< storm::logic::EventuallyFormula, 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 > 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 > computeDiscountedTotalRewards(Environment const &env, CheckTask< storm::logic::DiscountedTotalRewardFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeTotalRewards(Environment const &env, CheckTask< storm::logic::TotalRewardFormula, SolutionType > const &checkTask) override
virtual std::unique_ptr< CheckResult > computeBoundedUntilProbabilities(Environment const &env, CheckTask< storm::logic::BoundedUntilFormula, SolutionType > const &checkTask) override
Helper class for LTL model checking.
static MDPSparseModelCheckingHelperReturnType< SolutionType > 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, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
static MDPSparseModelCheckingHelperReturnType< SolutionType > 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, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
static MDPSparseModelCheckingHelperReturnType< 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, bool produceScheduler, bool useMecBasedTechnique=false)
static std::vector< SolutionType > computeNextProbabilities(Environment const &env, OptimizationDirection dir, UncertaintyResolutionMode uncertaintyResolutionMode, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::BitVector const &nextStates)
static std::map< storm::storage::sparse::state_type, SolutionType > computeRewardBoundedValues(Environment const &env, OptimizationDirection dir, rewardbounded::MultiDimensionalRewardUnfolding< ValueType, true > &rewardUnfolding, storm::storage::BitVector const &initialStates)
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 MDPSparseModelCheckingHelperReturnType< 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, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
static MDPSparseModelCheckingHelperReturnType< 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, bool produceScheduler, ValueType discountFactor, ModelCheckerHint const &hint=ModelCheckerHint())
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 > 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 MDPSparseModelCheckingHelperReturnType< SolutionType > 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, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
Helper class for model checking queries that depend on the long run behavior of the (nondeterministic...
std::vector< std::vector< ValueType > > computeQuantile(Environment const &env)
This class defines which action is chosen in a particular state of a non-deterministic model.
Definition Scheduler.h:18
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:36
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
FragmentSpecification prctlstar()
FragmentSpecification propositional()
FragmentSpecification lexObjective()
FragmentSpecification multiObjective()
FragmentSpecification reachability()
FragmentSpecification quantiles()
void setInformationFromCheckTaskNondeterministic(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.
helper::MDPSparseModelCheckingHelperReturnType< ValueType > check(Environment const &, SparseModelType const &model, CheckTask< storm::logic::MultiObjectiveFormula, ValueType > const &checkTask, CheckFormulaCallback const &formulaChecker)
check a lexicographic LTL-formula
std::unique_ptr< CheckResult > performMultiObjectiveModelChecking(Environment const &env, SparseModelType const &model, storm::logic::MultiObjectiveFormula const &formula, bool produceScheduler)
std::unique_ptr< CheckResult > computeConditionalProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, bool produceSchedulers, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &targetStates, storm::storage::BitVector const &conditionStates)
FilteredRewardModel< RewardModelType > createFilteredRewardModel(RewardModelType const &baseRewardModel, storm::logic::RewardAccumulation const &acc, bool isDiscreteTimeModel)
constexpr bool IsIntervalType
Helper to check if a type is an interval.
boost::optional< Bound > bound