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.

125 lines
5.4 KiB

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