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.

111 lines
6.9 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h"
  4. #include "src/utility/solver.h"
  5. #include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
  6. #include "src/settings/SettingsManager.h"
  7. #include "src/settings/modules/TopologicalValueIterationEquationSolverSettings.h"
  8. #include "src/settings/SettingMemento.h"
  9. #include "src/parser/AutoParser.h"
  10. #include "src/models/sparse/StandardRewardModel.h"
  11. #include "src/parser/FormulaParser.h"
  12. TEST(DISABLED_TopologicalValueIterationMdpPrctlModelCheckerTest, AsynchronousLeader) {
  13. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::parser::AutoParser<>::parseModel(STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.tra", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.lab", "", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.trans.rew")->as<storm::models::sparse::Mdp<double>>();
  14. // A parser that we use for conveniently constructing the formulas.
  15. storm::parser::FormulaParser formulaParser;
  16. ASSERT_EQ(mdp->getNumberOfStates(), 2095783ull);
  17. ASSERT_EQ(mdp->getNumberOfTransitions(), 7714385ull);
  18. storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<double>> checker(*mdp, std::unique_ptr<storm::utility::solver::MinMaxLinearEquationSolverFactory<double>>(new storm::utility::solver::MinMaxLinearEquationSolverFactory<double>(storm::solver::EquationSolverTypeSelection::Topological)));
  19. std::shared_ptr<const storm::logic::Formula> formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"elected\"]");
  20. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  21. ASSERT_NEAR(1.0, result->asExplicitQuantitativeCheckResult<double>()[0], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  22. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"elected\"]");
  23. result = checker.check(*formula);
  24. ASSERT_NEAR(1.0, result->asExplicitQuantitativeCheckResult<double>()[0], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  25. formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F<=25 \"elected\"]");
  26. result = checker.check(*formula);
  27. ASSERT_NEAR(0.0, result->asExplicitQuantitativeCheckResult<double>()[0], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  28. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F<=25 \"elected\"]");
  29. result = checker.check(*formula);
  30. ASSERT_NEAR(0.0, result->asExplicitQuantitativeCheckResult<double>()[0], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  31. formula = formulaParser.parseSingleFormulaFromString("Rmin=? [F \"elected\"]");
  32. result = checker.check(*formula);
  33. ASSERT_NEAR(6.172433512, result->asExplicitQuantitativeCheckResult<double>()[0], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  34. formula = formulaParser.parseSingleFormulaFromString("Rmax=? [F \"elected\"]");
  35. result = checker.check(*formula);
  36. ASSERT_NEAR(6.1724344, result->asExplicitQuantitativeCheckResult<double>()[0], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  37. }
  38. TEST(DISABLED_TopologicalValueIterationMdpPrctlModelCheckerTest, Consensus) {
  39. // Increase the maximal number of iterations, because the solver does not converge otherwise.
  40. // This is done in the main cpp unit
  41. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = storm::parser::AutoParser<>::parseModel(STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.tra", STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.lab", STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.steps.state.rew", "")->as<storm::models::sparse::Mdp<double>>();
  42. // A parser that we use for conveniently constructing the formulas.
  43. storm::parser::FormulaParser formulaParser;
  44. ASSERT_EQ(mdp->getNumberOfStates(), 63616ull);
  45. ASSERT_EQ(mdp->getNumberOfTransitions(), 213472ull);
  46. storm::modelchecker::SparseMdpPrctlModelChecker<storm::models::sparse::Mdp<double>> checker(*mdp, std::unique_ptr<storm::utility::solver::MinMaxLinearEquationSolverFactory<double>>(new storm::utility::solver::MinMaxLinearEquationSolverFactory<double>(storm::solver::EquationSolverTypeSelection::Topological)));
  47. std::shared_ptr<const storm::logic::Formula> formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"finished\"]");
  48. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  49. ASSERT_NEAR(1.0, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  50. formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"finished\" & \"all_coins_equal_0\"]");
  51. result = checker.check(*formula);
  52. ASSERT_NEAR(0.4374282832, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  53. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"finished\" & \"all_coins_equal_1\"]");
  54. result = checker.check(*formula);
  55. ASSERT_NEAR(0.5293286369, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  56. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"finished\" & !\"agree\"]");
  57. result = checker.check(*formula);
  58. ASSERT_NEAR(0.10414097, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  59. formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F<=50 \"finished\"]");
  60. result = checker.check(*formula);
  61. ASSERT_NEAR(0.0, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  62. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F<=50 \"finished\"]");
  63. result = checker.check(*formula);
  64. ASSERT_NEAR(0.0, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  65. formula = formulaParser.parseSingleFormulaFromString("Rmin=? [F \"finished\"]");
  66. result = checker.check(*formula);
  67. ASSERT_NEAR(1725.593313, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  68. formula = formulaParser.parseSingleFormulaFromString("Rmax=? [F \"finished\"\"]");
  69. result = checker.check(*formula);
  70. ASSERT_NEAR(2183.142422, result->asExplicitQuantitativeCheckResult<double>()[31168], storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
  71. }