1#include "storm-config.h"
26enum class PreprocessingType {
None, SelfloopReduction, QualitativeReduction,
All };
28class DefaultDoubleVIEnvironment {
30 typedef double POMDPValueType;
31 typedef double BeliefValueType;
32 typedef double BeliefMDPValueType;
34 static storm::Environment createEnvironment() {
35 storm::Environment env;
40 static bool const isExactModelChecking =
false;
41 static POMDPValueType precision() {
44 static PreprocessingType
const preprocessingType = PreprocessingType::None;
45 static uint64_t overApproxResolution() {
50class SelfloopReductionDefaultDoubleVIEnvironment {
52 typedef double POMDPValueType;
53 typedef double BeliefValueType;
54 typedef double BeliefMDPValueType;
55 static storm::Environment createEnvironment() {
56 storm::Environment env;
61 static bool const isExactModelChecking =
false;
62 static POMDPValueType precision() {
65 static PreprocessingType
const preprocessingType = PreprocessingType::SelfloopReduction;
66 static uint64_t overApproxResolution() {
71class QualitativeReductionDefaultDoubleVIEnvironment {
73 typedef double POMDPValueType;
74 typedef double BeliefValueType;
75 typedef double BeliefMDPValueType;
76 static storm::Environment createEnvironment() {
77 storm::Environment env;
82 static bool const isExactModelChecking =
false;
83 static POMDPValueType precision() {
86 static PreprocessingType
const preprocessingType = PreprocessingType::QualitativeReduction;
87 static uint64_t overApproxResolution() {
92class PreprocessedDefaultDoubleVIEnvironment {
94 typedef double POMDPValueType;
95 typedef double BeliefValueType;
96 typedef double BeliefMDPValueType;
97 static storm::Environment createEnvironment() {
98 storm::Environment env;
103 static bool const isExactModelChecking =
false;
104 static POMDPValueType precision() {
107 static PreprocessingType
const preprocessingType = PreprocessingType::All;
108 static uint64_t overApproxResolution() {
113class FineDoubleVIEnvironment {
115 typedef double POMDPValueType;
116 typedef double BeliefValueType;
117 typedef double BeliefMDPValueType;
118 static storm::Environment createEnvironment() {
119 storm::Environment env;
124 static bool const isExactModelChecking =
false;
125 static POMDPValueType precision() {
128 static PreprocessingType
const preprocessingType = PreprocessingType::None;
129 static uint64_t overApproxResolution() {
134class DefaultDoubleOVIEnvironment {
136 typedef double POMDPValueType;
137 typedef double BeliefValueType;
138 typedef double BeliefMDPValueType;
139 static storm::Environment createEnvironment() {
140 storm::Environment env;
146 static bool const isExactModelChecking =
false;
147 static POMDPValueType precision() {
150 static PreprocessingType
const preprocessingType = PreprocessingType::None;
151 static uint64_t overApproxResolution() {
156class DefaultDoubleSVIEnvironment {
158 typedef double POMDPValueType;
159 typedef double BeliefValueType;
160 typedef double BeliefMDPValueType;
161 static storm::Environment createEnvironment() {
162 storm::Environment env;
168 static bool const isExactModelChecking =
false;
169 static POMDPValueType precision() {
172 static PreprocessingType
const preprocessingType = PreprocessingType::None;
173 static uint64_t overApproxResolution() {
178class DefaultRationalPIEnvironment {
180 typedef storm::RationalNumber POMDPValueType;
181 typedef storm::RationalNumber BeliefValueType;
182 typedef storm::RationalNumber BeliefMDPValueType;
184 static storm::Environment createEnvironment() {
185 storm::Environment env;
190 static bool const isExactModelChecking =
true;
191 static POMDPValueType precision() {
194 static PreprocessingType
const preprocessingType = PreprocessingType::None;
195 static uint64_t overApproxResolution() {
200class PreprocessedDefaultRationalPIEnvironment {
202 typedef storm::RationalNumber POMDPValueType;
203 typedef storm::RationalNumber BeliefValueType;
204 typedef storm::RationalNumber BeliefMDPValueType;
206 static storm::Environment createEnvironment() {
207 storm::Environment env;
212 static bool const isExactModelChecking =
true;
213 static POMDPValueType precision() {
216 static PreprocessingType
const preprocessingType = PreprocessingType::All;
217 static uint64_t overApproxResolution() {
222template<
typename TestType>
223class BeliefBasedModelCheckerTest :
public ::testing::Test {
225 typedef typename TestType::POMDPValueType POMDPValueType;
226 typedef typename TestType::BeliefValueType BeliefValueType;
227 typedef typename TestType::BeliefMDPValueType BeliefMDPValueType;
230 BeliefBasedModelCheckerTest() : _environment(TestType::createEnvironment()) {}
232 void SetUp()
override {
234 GTEST_SKIP() <<
"Z3 not available.";
238 storm::Environment
const& env()
const {
242 template<
typename ValueType>
247 std::shared_ptr<storm::models::sparse::Pomdp<POMDPValueType>> model;
248 std::shared_ptr<storm::logic::Formula const> formula;
249 std::shared_ptr<storm::pomdp::beliefs::PropertyInformation> propertyInfo = std::make_shared<storm::pomdp::beliefs::PropertyInformation>();
251 Input buildPrism(std::string
const& programFile, std::string
const& formulaAsString, std::string
const& constantsAsString =
"")
const {
254 program = program.
preprocess(constantsAsString);
258 bool const isBoundedProbability =
259 input.formula->isProbabilityOperatorFormula() && input.formula->asProbabilityOperatorFormula().getSubformula().isBoundedUntilFormula();
262 storm::transformer::MakePOMDPCanonic<POMDPValueType> makeCanonic(*input.model);
263 input.model = makeCanonic.transform();
264 EXPECT_TRUE(input.model->isCanonic());
265 if (!isBoundedProbability &&
266 (TestType::preprocessingType == PreprocessingType::SelfloopReduction || TestType::preprocessingType == PreprocessingType::All)) {
267 storm::transformer::GlobalPOMDPSelfLoopEliminator<POMDPValueType> selfLoopEliminator(*input.model);
268 if (selfLoopEliminator.preservesFormula(*input.formula)) {
269 input.model = selfLoopEliminator.transform();
271 EXPECT_TRUE(input.formula->isOperatorFormula());
272 EXPECT_TRUE(input.formula->asOperatorFormula().hasOptimalityType());
275 EXPECT_TRUE(maximizing || input.formula->isProbabilityOperatorFormula());
276 EXPECT_TRUE(!maximizing || input.formula->isRewardOperatorFormula());
279 if (!isBoundedProbability &&
280 (TestType::preprocessingType == PreprocessingType::QualitativeReduction || TestType::preprocessingType == PreprocessingType::All)) {
281 EXPECT_TRUE(input.formula->isOperatorFormula());
282 EXPECT_TRUE(input.formula->asOperatorFormula().hasOptimalityType());
283 if (input.formula->isProbabilityOperatorFormula() &&
storm::solver::maximize(input.formula->asOperatorFormula().getOptimalityType())) {
284 storm::analysis::QualitativeAnalysisOnGraphs<POMDPValueType> qualitativeAnalysis(*input.model);
285 storm::storage::BitVector prob0States = qualitativeAnalysis.analyseProb0(input.formula->asProbabilityOperatorFormula());
286 storm::storage::BitVector prob1States = qualitativeAnalysis.analyseProb1(input.formula->asProbabilityOperatorFormula());
287 storm::pomdp::transformer::KnownProbabilityTransformer<POMDPValueType> kpt;
288 input.model = kpt.
transform(*input.model, prob0States, prob1States);
291 EXPECT_TRUE(input.model->isCanonic());
293 std::optional<std::string> rewardModelName;
294 std::set<uint32_t> targetObservations;
295 EXPECT_TRUE(formulaInfo.isNonNestedReachabilityProbability() || formulaInfo.isNonNestedExpectedRewardFormula());
296 if (formulaInfo.getTargetStates().observationClosed) {
297 targetObservations = formulaInfo.getTargetStates().observations;
299 storm::transformer::MakeStateSetObservationClosed<POMDPValueType> obsCloser(input.model);
300 std::tie(input.model, targetObservations) = obsCloser.transform(formulaInfo.getTargetStates().states);
302 if (formulaInfo.isNonNestedReachabilityProbability()) {
303 if (!formulaInfo.getSinkStates().empty()) {
304 storm::storage::sparse::ModelComponents<POMDPValueType> components;
306 components.
rewardModels = input.model->getRewardModels();
307 auto matrix = input.model->getTransitionMatrix();
308 matrix.makeRowGroupsAbsorbing(formulaInfo.getSinkStates().states);
311 if (input.model->hasChoiceLabeling()) {
314 if (input.model->hasObservationValuations()) {
317 input.model = std::make_shared<storm::models::sparse::Pomdp<POMDPValueType>>(std::move(components),
true);
318 auto reachableFromSinkStates =
320 formulaInfo.getSinkStates().states, ~formulaInfo.getSinkStates().states);
321 reachableFromSinkStates &= ~formulaInfo.getSinkStates().states;
322 STORM_LOG_THROW(reachableFromSinkStates.empty(), storm::exceptions::NotSupportedException,
323 "There are sink states that can reach non-sink states. This is currently not supported");
327 rewardModelName = formulaInfo.getRewardModelName();
330 if (rewardModelName) {
332 input.propertyInfo->rewardModelName = rewardModelName;
333 }
else if (formulaInfo.isBounded()) {
335 auto const& boundedFormula = input.formula->asProbabilityOperatorFormula().getSubformula().asBoundedUntilFormula();
336 for (uint64_t i = 0;
i < boundedFormula.getDimension(); ++
i) {
337 auto const& reference = boundedFormula.getTimeBoundReference(i);
338 input.propertyInfo->rewardBounds.push_back({.rewardModelName = reference.getOptionalRewardModelName().get_value_or(
""),
339 .lowerBound = boundedFormula.getLowerBoundAsOptionalTimeBound(i),
340 .upperBound = boundedFormula.getUpperBoundAsOptionalTimeBound(i)});
345 input.propertyInfo->dir = formulaInfo.getOptimizationDirection();
346 input.propertyInfo->targetObservations = targetObservations;
350 POMDPValueType precision()
const {
351 return TestType::precision();
353 uint64_t overApproxResolution()
const {
354 return TestType::overApproxResolution();
356 template<
typename ValueType>
357 ValueType modelcheckingPrecision()
const {
358 if (TestType::isExactModelChecking) {
364 bool isExact()
const {
365 return TestType::isExactModelChecking;
369 storm::Environment _environment;
372typedef ::testing::Types<DefaultDoubleVIEnvironment, SelfloopReductionDefaultDoubleVIEnvironment, QualitativeReductionDefaultDoubleVIEnvironment,
373 PreprocessedDefaultDoubleVIEnvironment, FineDoubleVIEnvironment, DefaultDoubleOVIEnvironment, DefaultDoubleSVIEnvironment,
374 DefaultRationalPIEnvironment, PreprocessedDefaultRationalPIEnvironment>
379TYPED_TEST(BeliefBasedModelCheckerTest, cut_zero_gap) {
380 using POMDPValueType =
typename TestFixture::POMDPValueType;
381 using BeliefValueType =
typename TestFixture::BeliefValueType;
382 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
385 auto check = [&](std::string
const& formula, std::string
const& expectedValue) {
386 SCOPED_TRACE(formula);
387 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism", formula,
"slippery=0");
388 ASSERT_EQ(data.model->getInitialStates().getNumberOfSetBits(), 1ul);
389 auto const initialState = data.model->getInitialStates().getNextSetIndex(0);
390 auto const expected = this->
template parseNumber<BeliefMDPValueType>(expectedValue);
391 auto const initialValue = this->
template parseNumber<POMDPValueType>(expectedValue);
392 auto const delta = this->
template parseNumber<POMDPValueType>(
"1/100000000");
397 auto setInitialBounds = [&](POMDPValueType
const& lower, POMDPValueType
const& upper) {
399 values[initialState] = lower;
402 values[initialState] = upper;
410 auto propertyInfo = *data.propertyInfo;
414 for (
bool const useClipping : {
false,
true}) {
415 SCOPED_TRACE(useClipping);
417 STORM_SILENT_EXPECT_THROW(checker.checkUnfold(this->env(), propertyInfo, options, bounds), storm::exceptions::NotSupportedException);
421 for (
int const mode : {0, 1, 2}) {
424 return mode == 0 ? checker.checkUnfold(this->env(), propertyInfo, options, bounds)
425 : checker.checkDiscretize(this->env(), propertyInfo, options, this->overApproxResolution(), mode == 2, bounds);
428 setInitialBounds(initialValue, initialValue);
430 auto const cut = run();
431 EXPECT_TRUE(cut.completedExploration);
432 EXPECT_EQ(cut.statistics.discoveredBeliefs, 1ul);
433 EXPECT_EQ(cut.statistics.exploredBeliefs, 0ul);
434 EXPECT_LE(
storm::utility::abs(cut.value - expected), this->template modelcheckingPrecision<BeliefMDPValueType>());
437 auto const uncut = run();
438 EXPECT_TRUE(uncut.completedExploration);
439 EXPECT_GT(uncut.statistics.discoveredBeliefs, 1ul);
440 EXPECT_GT(uncut.statistics.exploredBeliefs, 0ul);
443 setInitialBounds(initialValue - delta, initialValue + delta);
445 auto const positiveGap = run();
446 EXPECT_TRUE(positiveGap.completedExploration);
447 EXPECT_GT(positiveGap.statistics.discoveredBeliefs, 1ul);
448 EXPECT_GT(positiveGap.statistics.exploredBeliefs, 0ul);
452 check(
"Pmax=? [F \"goal\" ]",
"7/10");
453 check(
"Pmin=? [F \"goal\" ]",
"3/10");
454 check(
"Rmax=? [F s>4 ]",
"29/50");
455 check(
"Rmin=? [F s>4 ]",
"19/50");
458TYPED_TEST(BeliefBasedModelCheckerTest, policy_requires_matching_cutoff_schedulers) {
459 using POMDPValueType =
typename TestFixture::POMDPValueType;
460 using BeliefValueType =
typename TestFixture::BeliefValueType;
461 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
464 for (std::string
const formula : {
"Pmax=? [F \"goal\"]",
"Pmin=? [F \"goal\"]"}) {
465 SCOPED_TRACE(formula);
466 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism", formula,
"slippery=0");
474 STORM_SILENT_EXPECT_THROW(checker.checkUnfold(this->env(), *data.propertyInfo, options, bounds), storm::exceptions::IllegalArgumentException);
476 ASSERT_NO_THROW(bounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula));
479 auto const originalSchedulers = schedulers;
480 ASSERT_FALSE(originalSchedulers.empty());
483 for (
bool const useClipping : {
false,
true}) {
484 SCOPED_TRACE(useClipping);
486 for (
auto const schedulerCount : {0ul, originalSchedulers.size() + 1}) {
487 SCOPED_TRACE(schedulerCount);
488 schedulers = originalSchedulers;
489 schedulers.resize(schedulerCount, originalSchedulers.front());
490 STORM_SILENT_EXPECT_THROW(checker.checkUnfold(this->env(), *data.propertyInfo, options, bounds), storm::exceptions::IllegalArgumentException);
494 schedulers = originalSchedulers;
495 auto const result = checker.checkUnfold(this->env(), *data.propertyInfo, options, bounds);
496 EXPECT_TRUE(result.policy.has_value());
500 EXPECT_NO_THROW(checker.checkUnfold(this->env(), *data.propertyInfo, options, bounds));
504TYPED_TEST(BeliefBasedModelCheckerTest, generated_policy_preserves_truncated_frontier_bound) {
505 using POMDPValueType =
typename TestFixture::POMDPValueType;
506 using BeliefValueType =
typename TestFixture::BeliefValueType;
507 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
510 for (std::string
const formula : {
"Pmax=? [F \"goal\"]",
"Pmin=? [F \"goal\"]"}) {
511 SCOPED_TRACE(formula);
512 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism", formula,
"slippery=0");
525 auto const result = checker.checkUnfold(this->env(), *data.propertyInfo, options, bounds);
526 ASSERT_FALSE(result.completedExploration);
527 ASSERT_EQ(result.statistics.exploredBeliefs, 2ul);
528 ASSERT_GT(result.statistics.discoveredBeliefs, result.statistics.exploredBeliefs);
529 ASSERT_TRUE(result.policy.has_value());
537 auto const dtmcResult = dtmcChecker.check(this->env(), *data.formula);
538 ASSERT_TRUE(dtmcResult);
539 ASSERT_TRUE(dtmcResult->isExplicitQuantitativeCheckResult());
540 auto const initialState = inducedDtmc.getInitialStates().getNextSetIndex(0);
541 auto const policyValue = dtmcResult->template asExplicitQuantitativeCheckResult<POMDPValueType>()[initialState];
543 POMDPValueType
const tolerance = 2 * this->
template modelcheckingPrecision<POMDPValueType>();
545 EXPECT_GE(policyValue + tolerance, bound);
547 EXPECT_LE(policyValue, bound + tolerance);
554TYPED_TEST(BeliefBasedModelCheckerTest, terminal_initial_policy) {
555 using POMDPValueType =
typename TestFixture::POMDPValueType;
556 using BeliefValueType =
typename TestFixture::BeliefValueType;
557 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
560 for (std::string
const formula : {
"Pmax=? [F s=0]",
"Rmin=? [F s=0]"}) {
561 SCOPED_TRACE(formula);
562 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism", formula,
"slippery=0");
568 bounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
575 for (
bool const useClipping : {
false,
true}) {
576 SCOPED_TRACE(useClipping);
578 auto const result = checker.checkUnfold(this->env(), *data.propertyInfo, options, bounds);
579 EXPECT_EQ(result.value, this->template parseNumber<BeliefMDPValueType>(formula.front() ==
'P' ?
"1" :
"0"));
580 EXPECT_TRUE(result.completedExploration);
581 EXPECT_EQ(result.statistics.exploredBeliefs, 0ul);
582 ASSERT_TRUE(result.policy.has_value());
583 auto const initialObservation = data.model->getObservation(data.model->getInitialStates().getNextSetIndex(0));
584 EXPECT_TRUE(result.policy->hasOutputForObservationInNode(result.policy->getInitialNodeId(), initialObservation));
585 std::stringstream policyJson;
586 EXPECT_NO_THROW(result.policy->writeJsonToStream(policyJson));
587 EXPECT_FALSE(policyJson.str().empty());
592TYPED_TEST(BeliefBasedModelCheckerTest, simple_Pmax) {
594 typedef typename TestFixture::POMDPValueType POMDPValueType;
595 typedef typename TestFixture::BeliefValueType BeliefValueType;
596 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
598 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmax=? [F \"goal\" ]",
"slippery=0");
603 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
609 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
610 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
612 auto expected = this->
template parseNumber<BeliefMDPValueType>(
"7/10");
613 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
614 overResultValue = overCheckResult.value;
615 EXPECT_GT(overCheckResult.statistics.discoveredBeliefs, 0ul);
616 EXPECT_GT(overCheckResult.statistics.exploredBeliefs, 0ul);
617 EXPECT_GT(overCheckResult.statistics.beliefMdpStates, 0ul);
618 EXPECT_GT(overCheckResult.statistics.beliefMdpChoices, 0ul);
619 EXPECT_GT(overCheckResult.statistics.beliefMdpTransitions, 0ul);
620 EXPECT_GE(overResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
622 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
623 underResultValue = underCheckResult.value;
624 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
626 <<
"Result [" << underResultValue <<
", " << overResultValue
627 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
630TYPED_TEST(BeliefBasedModelCheckerTest, simple_Pmin) {
632 typedef typename TestFixture::POMDPValueType POMDPValueType;
633 typedef typename TestFixture::BeliefValueType BeliefValueType;
634 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
636 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmin=? [F \"goal\" ]",
"slippery=0");
641 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
647 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
648 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
650 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"3/10");
651 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
652 overResultValue = overCheckResult.value;
653 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
655 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
656 underResultValue = underCheckResult.value;
657 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
659 <<
"Result [" << overResultValue <<
", " << underResultValue
660 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
663TYPED_TEST(BeliefBasedModelCheckerTest, discretization_rejects_exploration_limits) {
664 using POMDPValueType =
typename TestFixture::POMDPValueType;
665 using BeliefValueType =
typename TestFixture::BeliefValueType;
666 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
669 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmin=? [F \"goal\" ]",
"slippery=0");
680 STORM_SILENT_EXPECT_THROW(checker.checkDiscretize(this->env(), *data.propertyInfo, options, 10,
false, bounds), storm::exceptions::NotSupportedException);
682 auto const unfolded = checker.checkUnfold(this->env(), *data.propertyInfo, options, bounds);
683 EXPECT_FALSE(unfolded.completedExploration);
686 auto const discretized = checker.checkDiscretize(this->env(), *data.propertyInfo, options, 10,
false, bounds);
687 EXPECT_TRUE(discretized.completedExploration);
688 EXPECT_GT(discretized.statistics.exploredBeliefs, 1);
691TYPED_TEST(BeliefBasedModelCheckerTest, simple_slippery_Pmax) {
693 typedef typename TestFixture::POMDPValueType POMDPValueType;
694 typedef typename TestFixture::BeliefValueType BeliefValueType;
695 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
697 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmax=? [F \"goal\" ]",
"slippery=0.4");
702 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
707 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
708 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
710 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"7/10");
711 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
712 overResultValue = overCheckResult.value;
713 EXPECT_GE(overResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
714 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
716 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
717 underResultValue = underCheckResult.value;
718 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
720 <<
"Result [" << underResultValue <<
", " << overResultValue
721 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
724TYPED_TEST(BeliefBasedModelCheckerTest, simple_slippery_Pmin) {
726 typedef typename TestFixture::POMDPValueType POMDPValueType;
727 typedef typename TestFixture::BeliefValueType BeliefValueType;
728 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
730 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmin=? [F \"goal\" ]",
"slippery=0.4");
735 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
739 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
740 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
742 POMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"3/10");
743 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
744 overResultValue = overCheckResult.value;
746 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
747 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
748 underResultValue = underCheckResult.value;
749 if (this->isExact()) {
753 EXPECT_GE(underResultValue, expected - approxPrecision);
754 EXPECT_LE(overResultValue, expected + approxPrecision);
756 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
757 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
760 <<
"Result [" << underResultValue <<
", " << overResultValue
761 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
764TYPED_TEST(BeliefBasedModelCheckerTest, simple_Rmax) {
766 typedef typename TestFixture::POMDPValueType POMDPValueType;
767 typedef typename TestFixture::BeliefValueType BeliefValueType;
768 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
770 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmax=? [F s>4 ]",
"slippery=0");
775 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
780 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
781 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
783 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"29/50");
784 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
785 overResultValue = overCheckResult.value;
786 EXPECT_GE(overResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
788 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
789 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
790 underResultValue = underCheckResult.value;
791 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
793 <<
"Result [" << underResultValue <<
", " << overResultValue
794 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
797TYPED_TEST(BeliefBasedModelCheckerTest, simple_Rmin) {
799 typedef typename TestFixture::POMDPValueType POMDPValueType;
800 typedef typename TestFixture::BeliefValueType BeliefValueType;
801 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
803 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmin=? [F s>4 ]",
"slippery=0");
808 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
813 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
814 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
816 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"19/50");
817 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
818 overResultValue = overCheckResult.value;
819 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
821 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
822 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
823 underResultValue = underCheckResult.value;
824 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
826 <<
"Result [" << overResultValue <<
", " << underResultValue
827 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
830TYPED_TEST(BeliefBasedModelCheckerTest, simple_slippery_Rmax) {
832 typedef typename TestFixture::POMDPValueType POMDPValueType;
833 typedef typename TestFixture::BeliefValueType BeliefValueType;
834 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
836 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmax=? [F s>4 ]",
"slippery=0.4");
840 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
845 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
846 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
848 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"29/30");
849 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
850 overResultValue = overCheckResult.value;
851 EXPECT_GE(overResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
853 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
854 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
855 underResultValue = underCheckResult.value;
856 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
858 <<
"Result [" << underResultValue <<
", " << overResultValue
859 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
862TYPED_TEST(BeliefBasedModelCheckerTest, simple_slippery_Rmin) {
864 typedef typename TestFixture::POMDPValueType POMDPValueType;
865 typedef typename TestFixture::BeliefValueType BeliefValueType;
866 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
868 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmin=? [F s>4 ]",
"slippery=0.4");
873 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
878 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
879 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
881 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"19/30");
882 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
883 overResultValue = overCheckResult.value;
884 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
886 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
887 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
888 underResultValue = underCheckResult.value;
889 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
891 <<
"Result [" << overResultValue <<
", " << underResultValue
892 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
895TYPED_TEST(BeliefBasedModelCheckerTest, maze2_Rmin) {
897 typedef typename TestFixture::POMDPValueType POMDPValueType;
898 typedef typename TestFixture::BeliefValueType BeliefValueType;
899 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
901 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmin=? [F \"goal\"]",
"sl=0");
906 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
911 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
912 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
914 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"74/91");
915 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
916 overResultValue = overCheckResult.value;
917 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
919 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
920 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
921 underResultValue = underCheckResult.value;
922 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
924 <<
"Result [" << overResultValue <<
", " << underResultValue
925 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
928TYPED_TEST(BeliefBasedModelCheckerTest, maze2_Rmax) {
930 typedef typename TestFixture::POMDPValueType POMDPValueType;
931 typedef typename TestFixture::BeliefValueType BeliefValueType;
932 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
934 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmax=? [F \"goal\"]",
"sl=0");
939 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
944 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
945 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
947 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
948 overResultValue = overCheckResult.value;
951 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
952 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
953 underResultValue = underCheckResult.value;
957TYPED_TEST(BeliefBasedModelCheckerTest, maze2_slippery_Rmin) {
959 typedef typename TestFixture::POMDPValueType POMDPValueType;
960 typedef typename TestFixture::BeliefValueType BeliefValueType;
961 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
963 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmin=? [F \"goal\"]",
"sl=0.075");
968 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
973 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
974 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
976 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"80/91");
977 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
978 overResultValue = overCheckResult.value;
979 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
981 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
982 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
983 underResultValue = underCheckResult.value;
984 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
986 <<
"Result [" << overResultValue <<
", " << underResultValue
987 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
990TYPED_TEST(BeliefBasedModelCheckerTest, maze2_slippery_Rmax) {
992 typedef typename TestFixture::POMDPValueType POMDPValueType;
993 typedef typename TestFixture::BeliefValueType BeliefValueType;
994 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
996 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmax=? [F \"goal\"]",
"sl=0.075");
1001 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1006 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
1007 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1009 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
1010 overResultValue = overCheckResult.value;
1013 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1014 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1015 underResultValue = underCheckResult.value;
1019TYPED_TEST(BeliefBasedModelCheckerTest, refuel_Pmax) {
1021 typedef typename TestFixture::POMDPValueType POMDPValueType;
1022 typedef typename TestFixture::BeliefValueType BeliefValueType;
1023 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1025 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/refuel.prism",
"Pmax=?[\"notbad\" U \"goal\"]",
"N=4");
1030 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1035 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
1036 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1038 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"38/155");
1039 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
1040 overResultValue = overCheckResult.value;
1041 EXPECT_GE(overResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1043 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1044 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1045 underResultValue = underCheckResult.value;
1046 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1048 <<
"Result [" << underResultValue <<
", " << overResultValue
1049 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
1052TYPED_TEST(BeliefBasedModelCheckerTest, refuel_Pmin) {
1054 typedef typename TestFixture::POMDPValueType POMDPValueType;
1055 typedef typename TestFixture::BeliefValueType BeliefValueType;
1056 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1058 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/refuel.prism",
"Pmin=?[\"notbad\" U \"goal\"]",
"N=4");
1063 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1068 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
1069 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1071 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"0");
1072 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
1073 overResultValue = overCheckResult.value;
1074 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1076 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1077 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1078 underResultValue = underCheckResult.value;
1079 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1081 <<
"Result [" << overResultValue <<
", " << underResultValue
1082 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
1085TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_simple_min_max) {
1087 typedef typename TestFixture::POMDPValueType POMDPValueType;
1088 typedef typename TestFixture::BeliefValueType BeliefValueType;
1089 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1091 auto check = [
this](std::string
const& formula, std::string
const& expectedValue) {
1092 SCOPED_TRACE(formula);
1093 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple_unit_rewards.prism", formula,
"slippery=0");
1103 std::vector<std::string> rewardModelNames;
1104 for (
auto const& rewardBound : data.propertyInfo->rewardBounds) {
1105 rewardModelNames.push_back(rewardBound.rewardModelName);
1107 auto const expected = this->
template parseNumber<BeliefMDPValueType>(expectedValue);
1108 for (
bool const discretize : {
false,
true}) {
1109 SCOPED_TRACE(discretize ?
"discretize" :
"unfold");
1112 discretize ? checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 10,
false, precomputedBeliefBounds, rewardModelNames)
1113 : checker.checkRewardAwareUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds, rewardModelNames);
1114 EXPECT_TRUE(result.completedExploration);
1115 EXPECT_LE(
storm::utility::abs(result.value - expected), this->template modelcheckingPrecision<BeliefMDPValueType>());
1120 check(
"Pmax=? [ true Urew{\"rew\"}<=3 \"goal\" ]",
"7/10");
1121 check(
"Pmin=? [ true Urew{\"rew\"}<=3 \"goal\" ]",
"3/10");
1122 check(
"Pmax=? [ true Urew{\"rew\"}<=2 \"goal\" ]",
"0");
1123 check(
"Pmin=? [ true Urew{\"rew\"}<=2 \"goal\" ]",
"0");
1125 check(
"Pmax=? [ true Urew{\"rew\"}>=4 \"goal\" ]",
"7/10");
1126 check(
"Pmin=? [ true Urew{\"rew\"}>=4 \"goal\" ]",
"3/10");
1129TYPED_TEST(BeliefBasedModelCheckerTest, reused_explorer_clears_reward_model) {
1132 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
1139 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmax=? [F s>4 ]",
"slippery=0");
1140 Explorer explorer(*data.model);
1141 std::string
const rewardModelName;
1142 auto const selectRewardModel = [&]() {
1143 auto info = explorer.template initializeExploration<StandardInfo>(data.model->getNrObservations());
1145 EXPECT_GT(info.matrix.rows(), 0ul);
1146 EXPECT_EQ(info.actionRewards.size(), info.matrix.rows());
1149 selectRewardModel();
1150 auto ordinary = explorer.template initializeExploration<StandardInfo>(data.model->getNrObservations());
1152 EXPECT_GT(ordinary.matrix.rows(), 0ul);
1153 EXPECT_TRUE(ordinary.actionRewards.empty());
1155 selectRewardModel();
1156 auto clipping = explorer.template initializeExploration<ClippingInfo>(data.model->getNrObservations());
1158 EXPECT_GT(clipping.matrix.rows(), 0ul);
1159 EXPECT_TRUE(clipping.actionRewards.empty());
1161 selectRewardModel();
1163 splitter.setRewardModel();
1164 auto rewardAware = explorer.template initializeExploration<RewardAwareInfo>(data.model->getNrObservations());
1166 EXPECT_GT(rewardAware.matrix.rows(), 0ul);
1167 EXPECT_TRUE(rewardAware.actionRewards.empty());
1168 ASSERT_FALSE(rewardAware.matrix.transitions.empty());
1169 for (
auto const& transition : rewardAware.matrix.transitions) {
1170 EXPECT_EQ(transition.data.size(), 1ul);
1174TYPED_TEST(BeliefBasedModelCheckerTest, reward_aware_resume_preserves_observation_indices) {
1177 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
1184 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmax=? [F s>4 ]",
"slippery=0");
1185 Explorer explorer(*data.model);
1186 Splitter uninterruptedSplitter(*data.model);
1187 uninterruptedSplitter.setRewardModel();
1191 Splitter resumedSplitter(*data.model);
1192 resumedSplitter.setRewardModel();
1194 for (uint64_t steps = 0; resumed.queue.hasNext() && steps < 100; ++steps) {
1195 auto const limit = resumed.exploredBeliefs.size() + 1;
1196 explorer.resumeRewardAwareExploration(
1199 ASSERT_FALSE(resumed.queue.hasNext());
1200 ASSERT_EQ(resumed.discoveredBeliefs.getNumberOfBeliefIds(), uninterrupted.discoveredBeliefs.getNumberOfBeliefIds());
1201 for (uint64_t
id = 0;
id < uninterrupted.discoveredBeliefs.getNumberOfBeliefIds(); ++id) {
1202 EXPECT_TRUE(resumed.discoveredBeliefs.containsBelief(uninterrupted.discoveredBeliefs.getBeliefFromId(
id)));
1204 ASSERT_EQ(resumed.matrix.transitions.size(), uninterrupted.matrix.transitions.size());
1205 for (uint64_t i = 0;
i < uninterrupted.matrix.transitions.size(); ++
i) {
1206 auto const& expected = uninterrupted.matrix.transitions[
i];
1207 auto const& actual = resumed.matrix.transitions[
i];
1208 EXPECT_EQ(actual.probability, expected.probability);
1209 EXPECT_EQ(actual.data, expected.data);
1210 EXPECT_EQ(resumed.discoveredBeliefs.getBeliefFromId(actual.targetBelief), uninterrupted.discoveredBeliefs.getBeliefFromId(expected.targetBelief));
1214TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_requires_explicit_reward_model_name) {
1215 auto const programFile = STORM_TEST_RESOURCES_DIR
"/pomdp/simple_unit_rewards.prism";
1216 auto data = this->buildPrism(programFile,
"Pmax=? [ true Urew{\"rew\"}<=3 \"goal\" ]",
"slippery=0");
1222 auto unnamedProperty = *data.propertyInfo;
1223 unnamedProperty.rewardBounds.front().rewardModelName.clear();
1225 typename TestFixture::BeliefMDPValueType>
1226 checker(*data.model);
1229 STORM_SILENT_EXPECT_THROW(checker.checkRewardAwareUnfold(this->env(), unnamedProperty, options, bounds, {
"rew"}), storm::exceptions::NotSupportedException);
1232TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_requires_matching_reward_model_selection) {
1235 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
1236 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple_unit_rewards.prism",
"Pmax=? [ true Urew{\"rew\"}<=3 \"goal\" ]",
"slippery=0");
1242 storm::exceptions::IllegalArgumentException);
1243 STORM_SILENT_EXPECT_THROW(checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 10,
false, bounds, {}),
1244 storm::exceptions::IllegalArgumentException);
1246 storm::exceptions::IllegalArgumentException);
1247 STORM_SILENT_EXPECT_THROW(checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 10,
false, bounds, {
"other",
"rew"}),
1248 storm::exceptions::IllegalArgumentException);
1254TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_allows_additional_observed_reward_model) {
1255 using POMDPValueType =
typename TestFixture::POMDPValueType;
1256 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
1258 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple_unit_rewards.prism",
"Pmax=? [ true Urew{\"rew\"}<=3 \"goal\" ]",
"slippery=0");
1259 auto extraRewardModel = data.model->getRewardModel(
"rew");
1260 data.model->addRewardModel(
"extra", extraRewardModel);
1269 auto const expected = this->
template parseNumber<BeliefMDPValueType>(
"7/10");
1270 for (
bool const discretize : {
false,
true}) {
1271 auto const result = discretize ? checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 10,
false, bounds, {
"rew",
"extra"})
1272 : checker.checkRewardAwareUnfold(this->env(), *data.propertyInfo, options, bounds, {
"rew",
"extra"});
1273 EXPECT_TRUE(result.completedExploration);
1274 EXPECT_LE(
storm::utility::abs(result.value - expected), this->template modelcheckingPrecision<BeliefMDPValueType>());
1278TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_simple_early_frontier_uses_cutoff) {
1280 typedef typename TestFixture::POMDPValueType POMDPValueType;
1281 typedef typename TestFixture::BeliefValueType BeliefValueType;
1282 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1284 auto check = [
this](std::string
const& formula, std::string
const& frontierValue, std::string
const& completeValue) {
1285 SCOPED_TRACE(formula);
1286 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple_unit_rewards.prism", formula,
"slippery=0");
1298 std::vector<std::string> rewardModelNames;
1299 for (
auto const& rewardBound : data.propertyInfo->rewardBounds) {
1300 rewardModelNames.push_back(rewardBound.rewardModelName);
1302 for (
bool const discretize : {
false,
true}) {
1303 SCOPED_TRACE(discretize ?
"discretize" :
"unfold");
1306 checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 10,
false, precomputedBeliefBounds, rewardModelNames),
1307 storm::exceptions::NotSupportedException);
1311 discretize ? checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 10,
false, precomputedBeliefBounds, rewardModelNames)
1312 : checker.checkRewardAwareUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds, rewardModelNames);
1313 EXPECT_EQ(result.completedExploration, discretize);
1315 EXPECT_GT(result.statistics.exploredBeliefs, 1);
1317 EXPECT_EQ(result.statistics.exploredBeliefs, 1);
1318 EXPECT_GT(result.statistics.discoveredBeliefs, result.statistics.exploredBeliefs);
1320 auto const expected = this->
template parseNumber<BeliefMDPValueType>(discretize ? completeValue : frontierValue);
1321 EXPECT_LE(
storm::utility::abs(result.value - expected), this->template modelcheckingPrecision<BeliefMDPValueType>());
1326 check(
"Pmin=? [ true Urew{\"rew\"}<=3 \"goal\" ]",
"1",
"3/10");
1327 check(
"Pmax=? [ true Urew{\"rew\"}<=3 \"goal\" ]",
"0",
"7/10");
1329 check(
"Pmin=? [ true Urew{\"rew\"}<=0 \"goal\" ]",
"0",
"0");
1330 check(
"Pmax=? [ true Urew{\"rew\"}<=0 \"goal\" ]",
"0",
"0");
1333TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_hidden_transition_costs) {
1334 using POMDPValueType =
typename TestFixture::POMDPValueType;
1335 using BeliefValueType =
typename TestFixture::BeliefValueType;
1336 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
1339 auto check = [
this](std::string
const& formula, std::string
const& expectedValue,
bool stopAtTargetFrontier, std::string
const& completedValue =
"") {
1340 SCOPED_TRACE(formula);
1341 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/hidden_transition_rewards.prism", formula);
1350 if (stopAtTargetFrontier) {
1355 for (
bool const discretize : {
false,
true}) {
1356 SCOPED_TRACE(discretize ?
"discretize" :
"unfold");
1357 if (stopAtTargetFrontier && discretize) {
1358 STORM_SILENT_EXPECT_THROW(checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 2,
false, bounds, {
"cost"}),
1359 storm::exceptions::NotSupportedException);
1362 auto const result = discretize ? checker.checkRewardAwareDiscretize(this->env(), *data.propertyInfo, options, 2,
false, bounds, {
"cost"})
1363 : checker.checkRewardAwareUnfold(this->env(), *data.propertyInfo, options, bounds, {
"cost"});
1364 EXPECT_EQ(result.completedExploration, discretize || !stopAtTargetFrontier);
1365 if (stopAtTargetFrontier && !discretize) {
1366 EXPECT_EQ(result.statistics.exploredBeliefs, 2);
1367 EXPECT_GT(result.statistics.discoveredBeliefs, result.statistics.exploredBeliefs);
1369 auto const expected = this->
template parseNumber<BeliefMDPValueType>(discretize && !completedValue.empty() ? completedValue : expectedValue);
1370 EXPECT_LE(
storm::utility::abs(result.value - expected), this->template modelcheckingPrecision<BeliefMDPValueType>())
1371 <<
"actual: " << result.value <<
", expected: " << expected;
1376 check(
"Pmin=? [ true Urew{\"cost\"}<=1 \"goal\" ]",
"1/2",
false);
1377 check(
"Pmax=? [ true Urew{\"cost\"}<=1 \"goal\" ]",
"1/2",
false);
1378 check(
"Pmin=? [ true Urew{\"cost\"}<=2 \"goal\" ]",
"1",
false);
1379 check(
"Pmax=? [ true Urew{\"cost\"}<=2 \"goal\" ]",
"1",
false);
1381 check(
"Pmin=? [ true Urew{\"cost\"}>=2 \"goal\" ]",
"1",
false);
1382 check(
"Pmax=? [ true Urew{\"cost\"}>=2 \"goal\" ]",
"1",
false);
1384 check(
"Pmin=? [ true Urew{\"cost\"}<=1 \"goal\" ]",
"1/2",
true);
1385 check(
"Pmax=? [ true Urew{\"cost\"}<=1 \"goal\" ]",
"1/2",
true);
1387 check(
"Pmin=? [ true Urew{\"cost\"}>=2 \"goal\" ]",
"1",
true);
1388 check(
"Pmax=? [ true Urew{\"cost\"}>=2 \"goal\" ]",
"1/2",
true,
"1");
1391TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_min_lower_bound_frontier_collects_reward) {
1392 using POMDPValueType =
typename TestFixture::POMDPValueType;
1393 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
1396 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/hidden_transition_rewards.prism",
"Pmin=? [ true Urew{\"cost\"}>=2 \"goal\" ]");
1397 auto extraRewardModel = data.model->getRewardModel(
"cost");
1398 data.model->addRewardModel(
"extra", extraRewardModel);
1405 std::vector<storm::pomdp::beliefs::PropertyInformation> properties{*data.propertyInfo};
1406 auto strictProperty = *data.propertyInfo;
1407 strictProperty.rewardBounds.front().lowerBound =
storm::logic::TimeBound(
true, data.propertyInfo->rewardBounds.front().lowerBound->getBound());
1408 properties.push_back(strictProperty);
1409 auto zeroBoundData = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/hidden_transition_rewards.prism",
"Pmin=? [ true Urew{\"cost\"}>=0 \"goal\" ]");
1410 properties.push_back(*zeroBoundData.propertyInfo);
1411 auto multidimensionalProperty = *data.propertyInfo;
1412 auto extraLowerBound = strictProperty.rewardBounds.front();
1413 extraLowerBound.rewardModelName =
"extra";
1414 multidimensionalProperty.rewardBounds.push_back(extraLowerBound);
1415 properties.push_back(multidimensionalProperty);
1419 for (uint64_t
const sizeLimit : {1, 2}) {
1420 SCOPED_TRACE(sizeLimit);
1423 for (std::size_t i = 0;
i < properties.size(); ++
i) {
1425 std::vector<std::string> rewardModelNames;
1426 for (
auto const& rewardBound : properties[i].rewardBounds) {
1427 rewardModelNames.push_back(rewardBound.rewardModelName);
1429 auto const result = checker.checkRewardAwareUnfold(this->env(), properties[i], options, bounds, rewardModelNames);
1430 EXPECT_FALSE(result.completedExploration);
1431 EXPECT_EQ(result.statistics.exploredBeliefs, sizeLimit);
1433 this->template modelcheckingPrecision<BeliefMDPValueType>());
1438 auto upperBoundData = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/hidden_transition_rewards.prism",
"Pmin=? [ true Urew{\"cost\"}<=1 \"goal\" ]");
1439 auto upperOnlyBound = upperBoundData.propertyInfo->rewardBounds.front();
1440 upperOnlyBound.rewardModelName =
"extra";
1441 auto mixedProperty = strictProperty;
1442 mixedProperty.rewardBounds.insert(mixedProperty.rewardBounds.begin(), upperOnlyBound);
1444 auto const mixedResult = checker.checkRewardAwareUnfold(this->env(), mixedProperty, options, bounds, {
"extra",
"cost"});
1445 EXPECT_FALSE(mixedResult.completedExploration);
1446 auto const mixedExpected = this->
template parseNumber<BeliefMDPValueType>(
"1/2");
1447 EXPECT_LE(
storm::utility::abs(mixedResult.value - mixedExpected), this->template modelcheckingPrecision<BeliefMDPValueType>());
1450 for (
auto const criterion :
1452 SCOPED_TRACE(criterion);
1461 auto const result = checker.checkRewardAwareUnfold(this->env(), *data.propertyInfo, options, bounds, {
"cost"});
1462 EXPECT_TRUE(result.completedExploration);
1467TYPED_TEST(BeliefBasedModelCheckerTest, reward_bounded_min_rejects_two_sided_dimensions) {
1468 using POMDPValueType =
typename TestFixture::POMDPValueType;
1469 using BeliefMDPValueType =
typename TestFixture::BeliefMDPValueType;
1472 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/hidden_transition_rewards.prism",
"Pmin=? [ true Urew{\"cost\"}>=2 \"goal\" ]");
1473 auto extraRewardModel = data.model->getRewardModel(
"cost");
1474 data.model->addRewardModel(
"extra", extraRewardModel);
1477 auto intervalProperty = *data.propertyInfo;
1478 intervalProperty.rewardBounds.front().upperBound = intervalProperty.rewardBounds.front().lowerBound;
1479 auto zeroBoundData = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/hidden_transition_rewards.prism",
"Pmin=? [ true Urew{\"cost\"}>=0 \"goal\" ]");
1480 auto zeroIntervalProperty = intervalProperty;
1481 zeroIntervalProperty.rewardBounds.front().lowerBound = zeroBoundData.propertyInfo->rewardBounds.front().lowerBound;
1482 auto multidimensionalProperty = *data.propertyInfo;
1483 auto extraIntervalBound = intervalProperty.rewardBounds.front();
1484 extraIntervalBound.rewardModelName =
"extra";
1485 multidimensionalProperty.rewardBounds.push_back(extraIntervalBound);
1490 for (
auto const& property : {intervalProperty, zeroIntervalProperty, multidimensionalProperty}) {
1491 std::vector<std::string> rewardModelNames;
1492 for (
auto const& rewardBound : property.rewardBounds) {
1493 rewardModelNames.push_back(rewardBound.rewardModelName);
1495 for (
bool const limited : {
false,
true}) {
1496 SCOPED_TRACE(limited);
1499 storm::exceptions::NotSupportedException);
1500 STORM_SILENT_EXPECT_THROW(checker.checkRewardAwareDiscretize(this->env(), property, options, 2,
false, bounds, rewardModelNames),
1501 storm::exceptions::NotSupportedException);
1506 intervalProperty.dir = storm::OptimizationDirection::Maximize;
1511 for (
bool const discretize : {
false,
true}) {
1512 SCOPED_TRACE(discretize);
1513 auto check = [&]() {
1516 checker.checkRewardAwareDiscretize(this->env(), intervalProperty, options, 2,
false, bounds, {
"cost"});
1518 checker.checkRewardAwareUnfold(this->env(), intervalProperty, options, bounds, {
"cost"});
1520 }
catch (storm::exceptions::NotSupportedException
const& exception) {
1521 EXPECT_NE(std::string(exception.what()).find(
"Bounded until formulas are only supported by this method"), std::string::npos);
1529#if defined STORM_HAVE_LP_SOLVER
1530TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_Pmax) {
1532 typedef typename TestFixture::POMDPValueType POMDPValueType;
1533 typedef typename TestFixture::BeliefValueType BeliefValueType;
1534 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1536 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmax=? [F \"goal\" ]",
"slippery=0");
1541 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1549 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
1550 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1552 auto expected = this->
template parseNumber<BeliefMDPValueType>(
"7/10");
1554 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
1555 overResultValue = overCheckResult.value;
1556 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1558 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1559 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1560 underResultValue = underCheckResult.value;
1561 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1563 <<
"Result [" << underResultValue <<
", " << overResultValue
1564 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
1567TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_Pmin) {
1569 typedef typename TestFixture::POMDPValueType POMDPValueType;
1570 typedef typename TestFixture::BeliefValueType BeliefValueType;
1571 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1573 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmin=? [F \"goal\" ]",
"slippery=0");
1578 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1586 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
1587 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1589 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"3/10");
1591 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
1592 overResultValue = overCheckResult.value;
1593 EXPECT_GE(overResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1595 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1596 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1597 underResultValue = underCheckResult.value;
1598 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1600 <<
"Result [" << overResultValue <<
", " << underResultValue
1601 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
1604TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_Pmin_early_clipping_is_sound) {
1606 typedef typename TestFixture::POMDPValueType POMDPValueType;
1607 typedef typename TestFixture::BeliefValueType BeliefValueType;
1608 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1610 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmin=? [F \"goal\" ]",
"slippery=0");
1615 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1623 auto underResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1624 auto expected = this->
template parseNumber<BeliefMDPValueType>(
"3/10");
1625 EXPECT_GE(underResult.value, expected - this->template modelcheckingPrecision<BeliefMDPValueType>());
1628TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_slippery_Pmax) {
1630 typedef typename TestFixture::POMDPValueType POMDPValueType;
1631 typedef typename TestFixture::BeliefValueType BeliefValueType;
1632 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1634 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmax=? [F \"goal\" ]",
"slippery=0.4");
1639 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1647 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1649 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"7/10");
1651 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1653 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1654 underResultValue = underCheckResult.value;
1655 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1658TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_slippery_Pmin) {
1660 typedef typename TestFixture::POMDPValueType POMDPValueType;
1661 typedef typename TestFixture::BeliefValueType BeliefValueType;
1662 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1664 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Pmin=? [F \"goal\" ]",
"slippery=0.4");
1669 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1676 typename TestFixture::ExtendedBeliefMDPValueType overResultValue;
1677 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1679 POMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"3/10");
1680 auto overCheckResult = checker.checkDiscretize(this->env(), *data.propertyInfo, options, this->overApproxResolution(),
true, precomputedBeliefBounds);
1681 overResultValue = overCheckResult.value;
1683 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1684 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1685 underResultValue = underCheckResult.value;
1686 if (this->isExact()) {
1690 EXPECT_GE(underResultValue, expected - approxPrecision);
1691 EXPECT_LE(overResultValue, expected + approxPrecision);
1693 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1694 EXPECT_LE(overResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1697 <<
"Result [" << underResultValue <<
", " << overResultValue
1698 <<
"] is not precise enough. If (only) this fails, the result bounds are still correct, but they might be unexpectedly imprecise.\n";
1701TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_Rmax) {
1703 typedef typename TestFixture::POMDPValueType POMDPValueType;
1704 typedef typename TestFixture::BeliefValueType BeliefValueType;
1705 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1707 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmax=? [F s>4 ]",
"slippery=0");
1712 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1713 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1721 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1723 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"29/50");
1725 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1726 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1727 underResultValue = underCheckResult.value;
1728 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1731TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_Rmin) {
1733 typedef typename TestFixture::POMDPValueType POMDPValueType;
1734 typedef typename TestFixture::BeliefValueType BeliefValueType;
1735 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1737 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmin=? [F s>4 ]",
"slippery=0");
1742 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1743 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1751 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1753 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"19/50");
1755 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1756 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1757 underResultValue = underCheckResult.value;
1758 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1761TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_slippery_Rmax) {
1763 typedef typename TestFixture::POMDPValueType POMDPValueType;
1764 typedef typename TestFixture::BeliefValueType BeliefValueType;
1765 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1767 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmax=? [F s>4 ]",
"slippery=0.4");
1772 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1773 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1781 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1783 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"29/30");
1785 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1786 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1787 underResultValue = underCheckResult.value;
1788 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1791TYPED_TEST(BeliefBasedModelCheckerTest, clip_simple_slippery_Rmin) {
1793 typedef typename TestFixture::POMDPValueType POMDPValueType;
1794 typedef typename TestFixture::BeliefValueType BeliefValueType;
1795 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1797 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/simple.prism",
"Rmin=? [F s>4 ]",
"slippery=0.4");
1802 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1803 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1811 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1813 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"19/30");
1815 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1816 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1817 underResultValue = underCheckResult.value;
1818 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1821TYPED_TEST(BeliefBasedModelCheckerTest, clip_maze2_Rmin) {
1823 typedef typename TestFixture::POMDPValueType POMDPValueType;
1824 typedef typename TestFixture::BeliefValueType BeliefValueType;
1825 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1827 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmin=? [F \"goal\"]",
"sl=0");
1832 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1833 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1841 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1843 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"74/91");
1844 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1845 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1846 underResultValue = underCheckResult.value;
1847 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1850TYPED_TEST(BeliefBasedModelCheckerTest, clip_maze2_Rmax) {
1852 typedef typename TestFixture::POMDPValueType POMDPValueType;
1853 typedef typename TestFixture::BeliefValueType BeliefValueType;
1854 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1856 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmax=? [F \"goal\"]",
"sl=0");
1861 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1862 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1870 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1872 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1873 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1874 underResultValue = underCheckResult.value;
1878TYPED_TEST(BeliefBasedModelCheckerTest, clip_maze2_slippery_Rmin) {
1880 typedef typename TestFixture::POMDPValueType POMDPValueType;
1881 typedef typename TestFixture::BeliefValueType BeliefValueType;
1882 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1884 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmin=? [F \"goal\"]",
"sl=0.075");
1889 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1890 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1898 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1900 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"80/91");
1902 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1903 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1904 underResultValue = underCheckResult.value;
1905 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
1908TYPED_TEST(BeliefBasedModelCheckerTest, clip_maze2_slippery_Rmax) {
1910 typedef typename TestFixture::POMDPValueType POMDPValueType;
1911 typedef typename TestFixture::BeliefValueType BeliefValueType;
1912 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1914 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/maze2.prism",
"Rmax=? [F \"goal\"]",
"sl=0.075");
1919 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1920 precomputedBeliefBounds.
extremeBounds = preprocessChecker.getExtremeValueBound(this->env(), *data.formula);
1928 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1930 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1931 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1932 underResultValue = underCheckResult.value;
1936TYPED_TEST(BeliefBasedModelCheckerTest, clip_refuel_Pmax) {
1938 typedef typename TestFixture::POMDPValueType POMDPValueType;
1939 typedef typename TestFixture::BeliefValueType BeliefValueType;
1940 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1942 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/refuel.prism",
"Pmax=?[\"notbad\" U \"goal\"]",
"N=4");
1947 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1955 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1957 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"38/155");
1959 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1960 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1961 underResultValue = underCheckResult.value;
1962 EXPECT_LE(underResultValue, expected + this->
template modelcheckingPrecision<BeliefMDPValueType>());
1965TYPED_TEST(BeliefBasedModelCheckerTest, clip_refuel_Pmin) {
1967 typedef typename TestFixture::POMDPValueType POMDPValueType;
1968 typedef typename TestFixture::BeliefValueType BeliefValueType;
1969 typedef typename TestFixture::BeliefMDPValueType BeliefMDPValueType;
1971 auto data = this->buildPrism(STORM_TEST_RESOURCES_DIR
"/pomdp/refuel.prism",
"Pmin=?[\"notbad\" U \"goal\"]",
"N=4");
1976 precomputedBeliefBounds.
preprocessingBounds = preprocessChecker.getValueBounds(this->env(), *data.formula);
1984 typename TestFixture::ExtendedBeliefMDPValueType underResultValue;
1986 BeliefMDPValueType expected = this->
template parseNumber<BeliefMDPValueType>(
"0");
1988 options.
maxExplorationSize = data.model->getNumberOfStates() * data.model->getMaxNrStatesWithSameObservation();
1989 auto underCheckResult = checker.checkUnfold(this->env(), *data.propertyInfo, options, precomputedBeliefBounds);
1990 underResultValue = underCheckResult.value;
1991 EXPECT_GE(underResultValue, expected - this->
template modelcheckingPrecision<BeliefMDPValueType>());
SolverEnvironment & solver()
void setPrecision(storm::RationalNumber value)
void setMethod(storm::solver::MinMaxMethod value, bool isSetFromDefault=false)
Helper class that optionally holds a reference to an object of type T.
MinMaxSolverEnvironment & minMax()
void setForceSoundness(bool value)
void setForceExact(bool value)
This class represents a partially observable Markov decision process.
Builds and checks a finite belief MDP approximation of a POMDP.
Class to perform belief exploration.
Represents a belief of a Pomdp, i.e.
Abstracts a given belief by splitting it into sub-beliefs based on the (state-action) reward of the P...
Program preprocess(std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions) const
Preprocesses the program by defining the given constant definitions, substituting constants and formu...
#define STORM_LOG_THROW(cond, exception, message)
std::vector< storm::jani::Property > parsePropertiesForPrismProgram(std::string const &inputString, storm::prism::Program const &program, boost::optional< std::set< std::string > > const &propertyFilter)
storm::prism::Program parseProgram(std::string const &filename, bool prismCompatibility, bool simplify)
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildSparseModel(storm::languages::SymbolicModelDescription const &model, storm::builder::BuilderOptions const &options, typename storm::builder::ExplicitModelBuilder< ValueType >::Options const &explorationOptions=typename storm::builder::ExplicitModelBuilder< ValueType >::Options())
SFTBDDChecker::ValueType ValueType
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
NumberType parseNumber(std::string const &value)
Parse number from string.
FormulaInformation getFormulaInformation(PomdpType const &pomdp, storm::logic::ProbabilityOperatorFormula const &formula)
constexpr NoAbstractionType NoAbstraction
ExplorationInformation< BeliefMdpValueType, BeliefType, std::optional< BeliefMdpValueType >, std::optional< BeliefMdpValueType > > ClippingExplorationInformation
Exploration information that stores optional clipping probability and reward-adjustment metadata.
ExplorationInformation< BeliefMdpValueType, BeliefType > StandardExplorationInformation
Exploration information without transition metadata.
@ MAX_EXPLORATION_SIZE_AND_TIME
ExplorationInformation< BeliefMdpValueType, BeliefType, std::vector< BeliefMdpValueType > > RewardAwareExplorationInformation
Exploration information that stores a reward vector on each transition.
storm::models::sparse::Dtmc< PomdpValueType > applyObservationBasedFSCToPomdp(storm::models::sparse::Pomdp< PomdpValueType > const &pomdp, storm::pomdp::policy::ObservationBasedFiniteStateController< FscValueType > const &fsc, bool treatUnspecifiedChoiceAsDontCare)
Applies an observation-based finite-state controller to a POMDP and constructs the induced DTMC.
bool constexpr maximize(OptimizationDirection d)
bool constexpr minimize(OptimizationDirection d)
storm::storage::BitVector getReachableStates(storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::BitVector const &initialStates, storm::storage::BitVector const &constraintStates, storm::storage::BitVector const &targetStates, bool useStepBound, uint_fast64_t maximalSteps, boost::optional< storm::storage::BitVector > const &choiceFilter)
Performs a forward depth-first search through the underlying graph structure to identify the states t...
ExtendedValueType< ValueType > positiveInfinity()
bool isFinite(ExtendedNumber< ValueType > const &value)
ValueType abs(ValueType const &number)
std::conditional_t< storm::NumberTraits< ValueType >::HasInfinity, ValueType, ExtendedNumber< ValueType > > ExtendedValueType
The type to use for values that may be infinite.
ValueType const & getFinite(ExtendedNumber< ValueType > const &value)
TargetType convertNumber(SourceType const &number)
constexpr NullRefType NullRef
TYPED_TEST(GraphTestAR, SymbolicProb01StochasticGameDieSmall)
TYPED_TEST_SUITE(GraphTestAR, TestingTypes,)
::testing::Types< Cudd, Sylvan > TestingTypes
#define STORM_SILENT_EXPECT_THROW(statement, expected_exception)
std::optional< std::vector< uint64_t > > clippingResolutions
std::optional< uint64_t > maxExplorationTime
ExplorationQueueOrder explorationQueueOrder
bool cutZeroGap
Cut non-target beliefs only when their preprocessing lower and upper bounds have exactly zero gap....
std::optional< uint64_t > maxExplorationSize
Auxiliary struct used to identify cases where no abstraction of beliefs shall be applied.
Struct for storing precomputed values bounding the actual values on the POMDP.
std::optional< ExtremePOMDPValueBound< POMDPValueType > > extremeBounds
std::optional< PreprocessingPomdpValueBounds< POMDPValueType > > preprocessingBounds
std::unordered_map< std::string, RewardModelType > rewardModels
storm::storage::SparseMatrix< ValueType > transitionMatrix
std::optional< storm::storage::sparse::Valuations > observationValuations
std::optional< storm::models::sparse::ChoiceLabeling > choiceLabeling
storm::models::sparse::StateLabeling stateLabeling
std::optional< std::vector< uint32_t > > observabilityClasses