You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
3.6 KiB

  1. #include "src/modelchecker/results/ExplicitQualitativeCheckResult.h"
  2. #include "gtest/gtest.h"
  3. #include "storm-config.h"
  4. #include "src/parser/PrismParser.h"
  5. #include "src/parser/FormulaParser.h"
  6. #include "src/logic/Formulas.h"
  7. #include "src/permissivesched/PermissiveSchedulers.h"
  8. #include "src/builder/ExplicitPrismModelBuilder.h"
  9. #include "src/models/sparse/StandardRewardModel.h"
  10. #include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h"
  11. TEST(SmtPermissiveSchedulerTest, DieSelection) {
  12. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die_c1.nm");
  13. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  14. // auto formula02 = formulaParser.parseSingleFormulaFromString("P>=0.10 [ F \"one\"]")->asProbabilityOperatorFormula();
  15. // ASSERT_TRUE(storm::logic::isLowerBound(formula02.getComparisonType()));
  16. // auto formula001 = formulaParser.parseSingleFormulaFromString("P>=0.17 [ F \"one\"]")->asProbabilityOperatorFormula();
  17. auto formula02b = formulaParser.parseSingleFormulaFromString("P<=0.16 [ F \"one\"]")->asProbabilityOperatorFormula();
  18. auto formula001b = formulaParser.parseSingleFormulaFromString("P<=0.05 [ F \"one\"]")->asProbabilityOperatorFormula();
  19. // Customize and perform model-building.
  20. typename storm::builder::ExplicitPrismModelBuilder<double>::Options options;
  21. options = typename storm::builder::ExplicitPrismModelBuilder<double>::Options(formula02b);
  22. options.addConstantDefinitionsFromString(program, "");
  23. options.buildCommandLabels = true;
  24. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::builder::ExplicitPrismModelBuilder<double>().translateProgram(program, options)->as<storm::models::sparse::Mdp<double>>();
  25. // boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms = storm::ps::computePermissiveSchedulerViaSMT<>(*mdp, formula02);
  26. // EXPECT_NE(perms, boost::none);
  27. // boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms2 = storm::ps::computePermissiveSchedulerViaSMT<>(*mdp, formula001);
  28. // EXPECT_EQ(perms2, boost::none);
  29. boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms3 = storm::ps::computePermissiveSchedulerViaSMT<>(*mdp, formula02b);
  30. EXPECT_NE(perms3, boost::none);
  31. boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms4 = storm::ps::computePermissiveSchedulerViaSMT<>(*mdp, formula001b);
  32. EXPECT_EQ(perms4, boost::none);
  33. storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<double>> checker0(*mdp, std::unique_ptr<storm::utility::solver::MinMaxLinearEquationSolverFactory<double>>(new storm::utility::solver::MinMaxLinearEquationSolverFactory<double>(storm::solver::EquationSolverTypeSelection::Native)));
  34. std::unique_ptr<storm::modelchecker::CheckResult> result0 = checker0.check(formula02b);
  35. storm::modelchecker::ExplicitQualitativeCheckResult& qualitativeResult0 = result0->asExplicitQualitativeCheckResult();
  36. ASSERT_FALSE(qualitativeResult0[0]);
  37. auto submdp = perms3->apply();
  38. storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<double>> checker1(submdp, std::unique_ptr<storm::utility::solver::MinMaxLinearEquationSolverFactory<double>>(new storm::utility::solver::MinMaxLinearEquationSolverFactory<double>(storm::solver::EquationSolverTypeSelection::Native)));
  39. std::unique_ptr<storm::modelchecker::CheckResult> result1 = checker1.check(formula02b);
  40. storm::modelchecker::ExplicitQualitativeCheckResult& qualitativeResult1 = result1->asExplicitQualitativeCheckResult();
  41. EXPECT_TRUE(qualitativeResult1[0]);
  42. //
  43. }