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.

59 lines
3.4 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/ExplicitModelBuilder.h"
  9. #include "src/models/sparse/StandardRewardModel.h"
  10. #include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h"
  11. #ifdef STORM_HAVE_GUROBI
  12. TEST(MilpPermissiveSchedulerTest, DieSelection) {
  13. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die_c1.nm");
  14. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  15. auto formula02 = formulaParser.parseSingleFormulaFromString("P>=0.10 [ F \"one\"]")->asProbabilityOperatorFormula();
  16. ASSERT_TRUE(storm::logic::isLowerBound(formula02.getComparisonType()));
  17. auto formula001 = formulaParser.parseSingleFormulaFromString("P>=0.17 [ F \"one\"]")->asProbabilityOperatorFormula();
  18. auto formula02b = formulaParser.parseSingleFormulaFromString("P<=0.10 [ F \"one\"]")->asProbabilityOperatorFormula();
  19. auto formula001b = formulaParser.parseSingleFormulaFromString("P<=0.17 [ F \"one\"]")->asProbabilityOperatorFormula();
  20. // Customize and perform model-building.
  21. storm::generator::NextStateGeneratorOptions options;
  22. options.setBuildAllLabels().setBuildChoiceLabels(true);
  23. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::builder::ExplicitModelBuilder<double>(program, options).build()->as<storm::models::sparse::Mdp<double>>();
  24. boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms = storm::ps::computePermissiveSchedulerViaMILP<>(*mdp, formula02);
  25. EXPECT_NE(perms, boost::none);
  26. boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms2 = storm::ps::computePermissiveSchedulerViaMILP<>(*mdp, formula001);
  27. EXPECT_EQ(perms2, boost::none);
  28. boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms3 = storm::ps::computePermissiveSchedulerViaMILP<>(*mdp, formula02b);
  29. EXPECT_EQ(perms3, boost::none);
  30. boost::optional<storm::ps::SubMDPPermissiveScheduler<>> perms4 = storm::ps::computePermissiveSchedulerViaMILP<>(*mdp, formula001b);
  31. EXPECT_NE(perms4, boost::none);
  32. storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<double>> checker0(*mdp, std::unique_ptr<storm::solver::MinMaxLinearEquationSolverFactory<double>>(new storm::solver::MinMaxLinearEquationSolverFactory<double>(storm::solver::EquationSolverTypeSelection::Native)));
  33. std::unique_ptr<storm::modelchecker::CheckResult> result0 = checker0.check(formula02);
  34. storm::modelchecker::ExplicitQualitativeCheckResult& qualitativeResult0 = result0->asExplicitQualitativeCheckResult();
  35. ASSERT_FALSE(qualitativeResult0[0]);
  36. auto submdp = perms->apply();
  37. storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<double>> checker1(submdp, std::unique_ptr<storm::solver::MinMaxLinearEquationSolverFactory<double>>(new storm::solver::MinMaxLinearEquationSolverFactory<double>(storm::solver::EquationSolverTypeSelection::Native)));
  38. std::unique_ptr<storm::modelchecker::CheckResult> result1 = checker1.check(formula02);
  39. storm::modelchecker::ExplicitQualitativeCheckResult& qualitativeResult1 = result1->asExplicitQualitativeCheckResult();
  40. EXPECT_TRUE(qualitativeResult1[0]);
  41. //
  42. }
  43. #endif