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.

126 lines
5.9 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/Settings.h"
  4. #include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
  5. #include "src/solver/GmmxxLinearEquationSolver.h"
  6. #include "src/parser/AutoParser.h"
  7. TEST(GmmxxDtmcPrctlModelCheckerTest, Crowds) {
  8. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  9. s->set("fixDeadlocks");
  10. storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.lab", "", "");
  11. ASSERT_EQ(parser.getType(), storm::models::DTMC);
  12. std::shared_ptr<storm::models::Dtmc<double>> dtmc = parser.getModel<storm::models::Dtmc<double>>();
  13. ASSERT_EQ(dtmc->getNumberOfStates(), 2036647u);
  14. ASSERT_EQ(dtmc->getNumberOfTransitions(), 8973900u);
  15. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, new storm::solver::GmmxxLinearEquationSolver<double>());
  16. storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("observe0Greater1");
  17. storm::property::prctl::Eventually<double>* eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  18. storm::property::prctl::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  19. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observe0Greater1] on crowds/crowds20_5...");
  20. std::vector<double>* result = probFormula->check(mc);
  21. LOG4CPLUS_WARN(logger, "Done.");
  22. ASSERT_NE(nullptr, result);
  23. ASSERT_LT(std::abs((*result)[0] - 0.2296803699), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  24. delete probFormula;
  25. delete result;
  26. apFormula = new storm::property::prctl::Ap<double>("observeIGreater1");
  27. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  28. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  29. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observeIGreater1] on crowds/crowds20_5...");
  30. result = probFormula->check(mc);
  31. LOG4CPLUS_WARN(logger, "Done.");
  32. ASSERT_NE(nullptr, result);
  33. ASSERT_LT(std::abs((*result)[0] - 0.05072232915), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  34. delete probFormula;
  35. delete result;
  36. apFormula = new storm::property::prctl::Ap<double>("observeOnlyTrueSender");
  37. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  38. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  39. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observeOnlyTrueSender] on crowds/crowds20_5...");
  40. result = probFormula->check(mc);
  41. LOG4CPLUS_WARN(logger, "Done.");
  42. ASSERT_NE(nullptr, result);
  43. ASSERT_LT(std::abs((*result)[0] - 0.2274230551), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  44. delete probFormula;
  45. delete result;
  46. }
  47. TEST(GmmxxDtmcPrctlModelCheckerTest, SynchronousLeader) {
  48. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  49. s->set("fixDeadlocks");
  50. storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.tra", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.lab", "", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.pick.trans.rew");
  51. ASSERT_EQ(parser.getType(), storm::models::DTMC);
  52. std::shared_ptr<storm::models::Dtmc<double>> dtmc = parser.getModel<storm::models::Dtmc<double>>();
  53. ASSERT_EQ(dtmc->getNumberOfStates(), 1312334u);
  54. ASSERT_EQ(dtmc->getNumberOfTransitions(), 2886810u);
  55. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, new storm::solver::GmmxxLinearEquationSolver<double>());
  56. storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("elected");
  57. storm::property::prctl::Eventually<double>* eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  58. storm::property::prctl::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  59. LOG4CPLUS_WARN(logger, "Model Checking P=? [F elected] on synchronous_leader/leader6_8...");
  60. std::vector<double>* result = probFormula->check(mc);
  61. LOG4CPLUS_WARN(logger, "Done.");
  62. ASSERT_NE(nullptr, result);
  63. ASSERT_LT(std::abs((*result)[0] - 1), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  64. delete probFormula;
  65. delete result;
  66. apFormula = new storm::property::prctl::Ap<double>("elected");
  67. storm::property::prctl::BoundedUntil<double>* boundedUntilFormula = new storm::property::prctl::BoundedUntil<double>(new storm::property::prctl::Ap<double>("true"), apFormula, 20);
  68. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(boundedUntilFormula);
  69. LOG4CPLUS_WARN(logger, "Model Checking P=? [F<=20 elected] on synchronous_leader/leader6_8...");
  70. result = probFormula->check(mc);
  71. LOG4CPLUS_WARN(logger, "Done.");
  72. ASSERT_NE(nullptr, result);
  73. ASSERT_LT(std::abs((*result)[0] - 0.999394979327824395376467), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  74. delete probFormula;
  75. delete result;
  76. apFormula = new storm::property::prctl::Ap<double>("elected");
  77. storm::property::prctl::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
  78. storm::property::prctl::RewardNoBoundOperator<double>* rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula);
  79. LOG4CPLUS_WARN(logger, "Model Checking R=? [F elected] on synchronous_leader/leader6_8...");
  80. result = rewardFormula->check(mc);
  81. LOG4CPLUS_WARN(logger, "Done.");
  82. ASSERT_NE(nullptr, result);
  83. ASSERT_LT(std::abs((*result)[0] - 1.02521744572240791626427), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  84. delete rewardFormula;
  85. delete result;
  86. }