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(
49 storm::logic::prctlstar().setBoundedUntilFormulasAllowed(true).setTimeOperatorsAllowed(true).setReachbilityTimeFormulasAllowed(true))) {
50 return true;
51 }
52 } else {
54 .setLongRunAverageRewardFormulasAllowed(true)
55 .setLongRunAverageProbabilitiesAllowed(true)
56 .setConditionalProbabilityFormulasAllowed(true)
57 .setOnlyEventuallyFormuluasInConditionalFormulasAllowed(true)
58 .setTotalRewardFormulasAllowed(true)
59 .setRewardBoundedUntilFormulasAllowed(true)
60 .setRewardBoundedCumulativeRewardFormulasAllowed(true)
61 .setMultiDimensionalBoundedUntilFormulasAllowed(true)
62 .setMultiDimensionalCumulativeRewardFormulasAllowed(true)
63 .setTimeOperatorsAllowed(true)
64 .setReachbilityTimeFormulasAllowed(true)
65 .setRewardAccumulationAllowed(true)
66 .setDiscountedTotalRewardFormulasAllowed(true)
67 .setDiscountedCumulativeRewardFormulasAllowed(true))) {
68 return true;
69 } else if (checkTask.isOnlyInitialStatesRelevantSet()) {
70 auto multiObjectiveFragment = storm::logic::multiObjective()
71 .setTimeAllowed(true)
82 auto lexObjectiveFragment = storm::logic::lexObjective()
94
95 if (formula.isInFragment(multiObjectiveFragment) || formula.isInFragment(storm::logic::quantiles()) || formula.isInFragment(lexObjectiveFragment)) {
96 if (requiresSingleInitialState) {
97 *requiresSingleInitialState = true;
98 }
99 return true;
100 }
101 }
102 }
103 return false;
104}
105
106template<typename SparseMdpModelType>
108 bool requiresSingleInitialState = false;
109 if (canHandleStatic(checkTask, &requiresSingleInitialState)) {
110 return !requiresSingleInitialState || this->getModel().getInitialStates().getNumberOfSetBits() == 1;
111 } else {
112 return false;
113 }
114}
115
116template<typename SparseMdpModelType>
119 storm::logic::BoundedUntilFormula const& pathFormula = checkTask.getFormula();
120 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
121 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
122 if (pathFormula.isMultiDimensional() || pathFormula.getTimeBoundReference().isRewardBound()) {
123 if constexpr (storm::IsIntervalType<ValueType>) {
124 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented multi dimensional bounded until with intervals.");
125 return nullptr;
126 } else {
127 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
128 "Checking non-trivial bounded until probabilities can only be computed for the initial states of the model.");
129 STORM_LOG_WARN_COND(!checkTask.isQualitativeSet(), "Checking non-trivial bounded until formulas is not optimized w.r.t. qualitative queries");
131 if (checkTask.isBoundSet()) {
132 opInfo.bound = checkTask.getBound();
133 }
134 auto formula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(checkTask.getFormula().asSharedPointer(), opInfo);
137 env, checkTask.getOptimizationDirection(), rewardUnfolding, this->getModel().getInitialStates());
138 // The helper returns one value per initial state, in the order in which the bit vector selects them.
139 return std::unique_ptr<CheckResult>(
140 new ExplicitQuantitativeCheckResult<SolutionType>(this->getModel().getInitialStates(), std::move(numericResult)));
141 }
142 } else {
143 STORM_LOG_THROW(pathFormula.hasUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have (a single) upper step bound.");
144 STORM_LOG_THROW(pathFormula.hasIntegerLowerBound(), storm::exceptions::InvalidPropertyException, "Formula lower step bound must be discrete/integral.");
145 STORM_LOG_THROW(pathFormula.hasIntegerUpperBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have discrete upper time bound.");
146 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
147 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
148 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
149 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
151 std::vector<SolutionType> numericResult = helper.computeStepBoundedUntilProbabilities(
152 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
153 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(),
154 pathFormula.getNonStrictLowerBound<uint64_t>(), pathFormula.getNonStrictUpperBound<uint64_t>(), checkTask.getHint());
155 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
156 result->setValuesExact();
157 return result;
158 }
159}
160
161template<typename SparseMdpModelType>
164 storm::logic::NextFormula const& pathFormula = checkTask.getFormula();
165 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
166 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
167 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
168 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
170 env, checkTask.getOptimizationDirection(), checkTask.getUncertaintyResolutionMode(), this->getModel().getTransitionMatrix(),
171 subResult.getTruthValuesVector());
172 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
173 result->setValuesExact();
174 return result;
175}
176
177template<typename SparseMdpModelType>
180 storm::logic::UntilFormula const& pathFormula = checkTask.getFormula();
181 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
182 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
183 if constexpr (storm::IsIntervalType<ValueType>) {
184 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
185 "Computing until probabilities on uncertain model requires graph-preservation.");
186 }
187 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, pathFormula.getLeftSubformula());
188 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, pathFormula.getRightSubformula());
189 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
190 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
192 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
193 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(), rightResult.getTruthValuesVector(), checkTask.isQualitativeSet(),
194 checkTask.isProduceSchedulersSet(), checkTask.getHint());
195 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
196 result->asExplicitQuantitativeCheckResult<SolutionType>().setBounds(std::move(ret.solutionBounds));
197 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
198 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
199 }
200 return result;
201}
202
203template<typename SparseMdpModelType>
206 storm::logic::GloballyFormula const& pathFormula = checkTask.getFormula();
207 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
208 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
209 std::unique_ptr<CheckResult> subResultPointer = this->check(env, pathFormula.getSubformula());
210 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
212 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
213 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet());
214 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
215 result->asExplicitQuantitativeCheckResult<SolutionType>().setBounds(std::move(ret.solutionBounds));
216 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
217 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
218 }
219 return result;
220}
221
222template<typename SparseMdpModelType>
225 if constexpr (storm::IsIntervalType<ValueType>) {
226 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented automata-props with intervals.");
227 } else {
228 storm::logic::HOAPathFormula const& pathFormula = checkTask.getFormula();
229
232
233 auto formulaChecker = [&](storm::logic::Formula const& formula) {
234 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
235 };
236 auto apSets = helper.computeApSets(pathFormula.getAPMapping(), formulaChecker);
237 std::vector<SolutionType> numericResult = helper.computeDAProductProbabilities(env, *pathFormula.readAutomaton(), apSets);
238
239 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
240 if (checkTask.isProduceSchedulersSet()) {
241 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
242 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler(this->getModel())));
243 }
244
245 return result;
246 }
247}
248
249template<typename SparseMdpModelType>
252 if constexpr (storm::IsIntervalType<ValueType>) {
253 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LTL with intervals.");
254 } else {
255 storm::logic::PathFormula const& pathFormula = checkTask.getFormula();
256
257 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
258 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
259
262
263 auto formulaChecker = [&](storm::logic::Formula const& formula) {
264 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
265 };
266 std::vector<SolutionType> numericResult = helper.computeLTLProbabilities(env, pathFormula, formulaChecker);
267
268 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(numericResult)));
269 if (checkTask.isProduceSchedulersSet()) {
270 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
271 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler(this->getModel())));
272 }
273
274 return result;
275 }
276}
277
278template<typename SparseMdpModelType>
281 storm::logic::ConditionalFormula const& conditionalFormula = checkTask.getFormula();
282 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
283 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
284 STORM_LOG_THROW(this->getModel().getInitialStates().hasUniqueSetBit(), storm::exceptions::InvalidPropertyException,
285 "Cannot compute conditional probabilities on MDPs with more than one initial state.");
286 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidPropertyException,
287 "Conditional probabilities can only be computed for the initial states of the model.");
288 STORM_LOG_THROW(conditionalFormula.getSubformula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
289 "Illegal conditional probability formula.");
290 STORM_LOG_THROW(conditionalFormula.getConditionFormula().isEventuallyFormula(), storm::exceptions::InvalidPropertyException,
291 "Illegal conditional probability formula.");
292
293 std::unique_ptr<CheckResult> leftResultPointer = this->check(env, conditionalFormula.getSubformula().asEventuallyFormula().getSubformula());
294 std::unique_ptr<CheckResult> rightResultPointer = this->check(env, conditionalFormula.getConditionFormula().asEventuallyFormula().getSubformula());
295 ExplicitQualitativeCheckResult<SolutionType> const& leftResult = leftResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
296 ExplicitQualitativeCheckResult<SolutionType> const& rightResult = rightResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
297 if constexpr (storm::IsIntervalType<ValueType>) {
298 STORM_LOG_THROW(false, exceptions::NotSupportedException, "Conditional Probabilities are not supported with interval models.");
299 } else {
301 checkTask.isProduceSchedulersSet(), this->getModel().getTransitionMatrix(),
302 this->getModel().getBackwardTransitions(), leftResult.getTruthValuesVector(),
303 rightResult.getTruthValuesVector());
304 }
305}
306
307template<typename SparseMdpModelType>
310 storm::logic::CumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
311 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
312 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
313 if (rewardPathFormula.isMultiDimensional() || rewardPathFormula.getTimeBoundReference().isRewardBound()) {
314 if constexpr (storm::IsIntervalType<ValueType>) {
315 STORM_LOG_THROW_UNCONDITIONALLY(storm::exceptions::NotImplementedException,
316 "We have not yet implemented multi-dimensional or reward-bounded cumulative rewards with intervals.");
317 } else {
318 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
319 "Checking reward bounded cumulative reward formulas can only be done for the initial states of the model.");
320 STORM_LOG_THROW(!checkTask.getFormula().hasRewardAccumulation(), storm::exceptions::InvalidOperationException,
321 "Checking reward bounded cumulative reward formulas is not supported if reward accumulations are given.");
322 STORM_LOG_WARN_COND(!checkTask.isQualitativeSet(), "Checking reward bounded until formulas is not optimized w.r.t. qualitative queries");
324 if (checkTask.isBoundSet()) {
325 opInfo.bound = checkTask.getBound();
326 }
327 auto formula = std::make_shared<storm::logic::RewardOperatorFormula>(checkTask.getFormula().asSharedPointer(), checkTask.getRewardModel(), opInfo);
330 env, checkTask.getOptimizationDirection(), rewardUnfolding, this->getModel().getInitialStates());
331 // The helper returns one value per initial state, in the order in which the bit vector selects them.
332 return std::unique_ptr<CheckResult>(
333 new ExplicitQuantitativeCheckResult<SolutionType>(this->getModel().getInitialStates(), std::move(numericResult)));
334 }
335 } else {
336 if constexpr (storm::IsIntervalType<ValueType>) {
337 STORM_LOG_THROW(checkTask.isUncertaintyResolutionModeSet(), storm::exceptions::InvalidSettingsException,
338 "Uncertainty resolution mode must be set for uncertain (interval) models.");
339 }
340 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
341 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
343 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
344 rewardPathFormula.getNonStrictBound<uint64_t>());
345 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
346 result->setValuesExact();
347 return result;
348 }
349}
350
351template<>
354 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
355}
356
357template<>
360 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
361}
362
363template<typename SparseMdpModelType>
366 storm::logic::DiscountedCumulativeRewardFormula const& rewardPathFormula = checkTask.getFormula();
367 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
368 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
369 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
370 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
372 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(), rewardModel.get(),
373 rewardPathFormula.getNonStrictBound<uint64_t>(), rewardPathFormula.getDiscountFactor<ValueType>());
374 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
375 result->setValuesExact();
376 return result;
377}
378
379template<typename SparseMdpModelType>
382 storm::logic::InstantaneousRewardFormula const& rewardPathFormula = checkTask.getFormula();
383 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
384 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
385 STORM_LOG_THROW(rewardPathFormula.hasIntegerBound(), storm::exceptions::InvalidPropertyException, "Formula needs to have a discrete time bound.");
387 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
388 checkTask.isRewardModelSet() ? this->getModel().getRewardModel(checkTask.getRewardModel()) : this->getModel().getRewardModel(""),
389 rewardPathFormula.getBound<uint64_t>());
390 auto result = std::make_unique<ExplicitQuantitativeCheckResult<SolutionType>>(std::move(numericResult));
391 result->setValuesExact();
392 return result;
393}
394
395template<typename SparseMdpModelType>
398 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
399 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
400 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
401 if constexpr (storm::IsIntervalType<ValueType>) {
402 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
403 "Computing rewards on uncertain model requires graph-preservation.");
404 }
405 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
406 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
407 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
409 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
410 this->getModel().getBackwardTransitions(), rewardModel.get(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(),
411 checkTask.isProduceSchedulersSet(), checkTask.getHint());
412 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
413 result->asExplicitQuantitativeCheckResult<SolutionType>().setBounds(std::move(ret.solutionBounds));
414 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
415 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
416 }
417 return result;
418}
419
420template<typename SparseMdpModelType>
423 storm::logic::EventuallyFormula const& eventuallyFormula = checkTask.getFormula();
424 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
425 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
426 if constexpr (storm::IsIntervalType<ValueType>) {
427 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
428 "Computing reachability times on uncertain model requires graph-preservation.");
429 }
430 std::unique_ptr<CheckResult> subResultPointer = this->check(env, eventuallyFormula.getSubformula());
431 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
433 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
434 this->getModel().getBackwardTransitions(), subResult.getTruthValuesVector(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet(),
435 checkTask.getHint());
436 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
437 result->asExplicitQuantitativeCheckResult<SolutionType>().setBounds(std::move(ret.solutionBounds));
438 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
439 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
440 }
441 return result;
442}
443
444template<typename SparseMdpModelType>
447 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
448 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
449 if constexpr (storm::IsIntervalType<ValueType>) {
450 STORM_LOG_THROW(this->getModel().getTransitionMatrix().isProbabilisticGraphPreserving(), storm::exceptions::InvalidSettingsException,
451 "Computing total rewards on uncertain model requires graph-preservation.");
452 }
453 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
455 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
456 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet(), checkTask.getHint());
457 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
458 result->asExplicitQuantitativeCheckResult<SolutionType>().setBounds(std::move(ret.solutionBounds));
459 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
460 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
461 }
462 return result;
463}
464
465template<>
468 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
469}
470
471template<>
474 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Discounted properties are not implemented for interval models.");
475}
476
477template<typename SparseMdpModelType>
480 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
481 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
482 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
483 storm::logic::DiscountedTotalRewardFormula const& rewardPathFormula = checkTask.getFormula();
484 auto discountFactor = rewardPathFormula.getDiscountFactor<ValueType>();
486 env, storm::solver::SolveGoal<ValueType, SolutionType>(this->getModel(), checkTask), this->getModel().getTransitionMatrix(),
487 this->getModel().getBackwardTransitions(), rewardModel.get(), checkTask.isQualitativeSet(), checkTask.isProduceSchedulersSet(), discountFactor,
488 checkTask.getHint());
489 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(ret.values)));
490 result->asExplicitQuantitativeCheckResult<SolutionType>().setBounds(std::move(ret.solutionBounds));
491 if (checkTask.isProduceSchedulersSet() && ret.scheduler) {
492 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(std::move(ret.scheduler));
493 }
494 return result;
495}
496
497template<typename SparseMdpModelType>
500 if constexpr (storm::IsIntervalType<ValueType>) {
501 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented LRA probabilities with intervals.");
502 } else {
503 storm::logic::StateFormula const& stateFormula = checkTask.getFormula();
504 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
505 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
506 std::unique_ptr<CheckResult> subResultPointer = this->check(env, stateFormula);
507 ExplicitQualitativeCheckResult<SolutionType> const& subResult = subResultPointer->template asExplicitQualitativeCheckResult<SolutionType>();
508
511 auto values = helper.computeLongRunAverageProbabilities(env, subResult.getTruthValuesVector());
512
513 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(values)));
514 if (checkTask.isProduceSchedulersSet()) {
515 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
516 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler()));
517 }
518 return result;
519 }
520}
521
522template<typename SparseMdpModelType>
525 if constexpr (storm::IsIntervalType<ValueType>) {
526 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented lra with intervals.");
527 } else {
528 STORM_LOG_THROW(checkTask.isOptimizationDirectionSet(), storm::exceptions::InvalidPropertyException,
529 "Formula needs to specify whether minimal or maximal values are to be computed on nondeterministic model.");
530 auto rewardModel = storm::utility::createFilteredRewardModel(this->getModel(), checkTask);
533 auto values = helper.computeLongRunAverageRewards(env, rewardModel.get());
534 std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<SolutionType>(std::move(values)));
535 if (checkTask.isProduceSchedulersSet()) {
536 result->asExplicitQuantitativeCheckResult<SolutionType>().setScheduler(
537 std::make_unique<storm::storage::Scheduler<SolutionType>>(helper.extractScheduler()));
538 }
539 return result;
540 }
541}
542
543template<typename SparseMdpModelType>
546 if constexpr (storm::IsIntervalType<ValueType>) {
547 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented multi-objective with intervals.");
548 } else {
550 }
551}
552
553template<class SparseMdpModelType>
556 if constexpr (storm::IsIntervalType<ValueType>) {
557 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented lexicographic model checking with intervals.");
558 } else {
559 auto formulaChecker = [&](storm::logic::Formula const& formula) {
560 return this->check(env, formula)->template asExplicitQualitativeCheckResult<SolutionType>().getTruthValuesVector();
561 };
562 auto ret = lexicographic::check(env, this->getModel(), checkTask, formulaChecker);
563 std::unique_ptr<CheckResult> result(new LexicographicCheckResult<SolutionType>(ret.values, *this->getModel().getInitialStates().begin()));
564 return result;
565 }
566}
567
568template<typename SparseMdpModelType>
571 if constexpr (storm::IsIntervalType<ValueType>) {
572 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "We have not yet implemented quantile formulas with intervals.");
573 } else {
574 STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::InvalidOperationException,
575 "Computing quantiles is only supported for the initial states of a model.");
576 STORM_LOG_THROW(this->getModel().getInitialStates().getNumberOfSetBits() == 1, storm::exceptions::InvalidOperationException,
577 "Quantiles not supported on models with multiple initial states.");
578 uint64_t initialState = *this->getModel().getInitialStates().begin();
579
581 auto res = qHelper.computeQuantile(env);
582
583 if (res.size() == 1 && res.front().size() == 1) {
584 return std::unique_ptr<CheckResult>(new ExplicitQuantitativeCheckResult<SolutionType>(initialState, std::move(res.front().front())));
585 } else {
586 return std::unique_ptr<CheckResult>(new ExplicitParetoCurveCheckResult<SolutionType>(initialState, std::move(res)));
587 }
588 }
589}
590
595} // namespace modelchecker
596} // 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:371
bool isInFragment(FragmentSpecification const &fragment) const
Definition Formula.cpp:218
virtual bool isEventuallyFormula() const
Definition Formula.cpp:102
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 isUncertaintyResolutionModeSet() const
Returns whether the mode, which decides how the uncertainty will be resolved, is set.
Definition CheckTask.h:319
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
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 > 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 ExtendedReturnType 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 ExtendedReturnType 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())
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 ExtendedReturnType 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 std::vector< SolutionType > computeNextProbabilities(Environment const &env, OptimizationDirection dir, UncertaintyResolutionMode uncertaintyResolutionMode, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::BitVector const &nextStates)
static ExtendedReturnType 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 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 std::vector< SolutionType > computeRewardBoundedValues(Environment const &env, OptimizationDirection dir, rewardbounded::MultiDimensionalRewardUnfolding< ValueType, true > &rewardUnfolding, storm::storage::BitVector const &initialStates)
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)
Helper class for model checking queries that depend on the long run behavior of the (nondeterministic...
std::vector< std::vector< storm::utility::ExtendedValueType< 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_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 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 &env, 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