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.

164 lines
6.8 KiB

  1. /*
  2. #include "gtest/gtest.h"
  3. #include "storm-config.h"
  4. #include "src/utility/Settings.h"
  5. #include "src/modelchecker/EigenDtmcPrctlModelChecker.h"
  6. #include "src/parser/AutoParser.h"
  7. TEST(EigenDtmcPrctlModelCheckerTest, Die) {
  8. storm::settings::Settings* s = storm::settings::instance();
  9. s->set("fix-deadlocks");
  10. storm::parser::AutoParser<double> parser(STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/die/die.tra", STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/die/die.lab", "", STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/die/die.coin_flips.trans.rew");
  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(), 14);
  14. ASSERT_EQ(dtmc->getNumberOfTransitions(), 28);
  15. storm::modelChecker::EigenDtmcPrctlModelChecker<double> mc(*dtmc);
  16. storm::property::Ap<double>* apFormula = new storm::property::Ap<double>("one");
  17. storm::property::Eventually<double>* eventuallyFormula = new storm::property::Eventually<double>(apFormula);
  18. storm::property::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  19. std::vector<double>* result = probFormula->check(mc);
  20. ASSERT_LT(std::abs((*result)[1] - ((double)1/6)), s->get<double>("precision"));
  21. delete probFormula;
  22. delete result;
  23. apFormula = new storm::property::Ap<double>("two");
  24. eventuallyFormula = new storm::property::Eventually<double>(apFormula);
  25. probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  26. result = probFormula->check(mc);
  27. ASSERT_LT(std::abs((*result)[1] - ((double)1/6)), s->get<double>("precision"));
  28. delete probFormula;
  29. delete result;
  30. apFormula = new storm::property::Ap<double>("three");
  31. eventuallyFormula = new storm::property::Eventually<double>(apFormula);
  32. probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  33. result = probFormula->check(mc);
  34. ASSERT_LT(std::abs((*result)[1] - ((double)1/6)), s->get<double>("precision"));
  35. delete probFormula;
  36. delete result;
  37. storm::property::Ap<double>* done = new storm::property::Ap<double>("done");
  38. storm::property::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::ReachabilityReward<double>(done);
  39. storm::property::RewardNoBoundOperator<double>* rewardFormula = new storm::property::RewardNoBoundOperator<double>(reachabilityRewardFormula);
  40. result = rewardFormula->check(mc);
  41. ASSERT_LT(std::abs((*result)[1] - ((double)11/3)), s->get<double>("precision"));
  42. delete rewardFormula;
  43. delete result;
  44. }
  45. TEST(EigenDtmcPrctlModelCheckerTest, Crowds) {
  46. storm::settings::Settings* s = storm::settings::instance();
  47. s->set("fix-deadlocks");
  48. storm::parser::AutoParser<double> parser(STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/crowds/crowds5_5.tra", STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/crowds/crowds5_5.lab", "", "");
  49. ASSERT_EQ(parser.getType(), storm::models::DTMC);
  50. std::shared_ptr<storm::models::Dtmc<double>> dtmc = parser.getModel<storm::models::Dtmc<double>>();
  51. ASSERT_EQ(dtmc->getNumberOfStates(), 8608);
  52. ASSERT_EQ(dtmc->getNumberOfTransitions(), 22461);
  53. storm::modelChecker::EigenDtmcPrctlModelChecker<double> mc(*dtmc);
  54. storm::property::Ap<double>* apFormula = new storm::property::Ap<double>("observe0Greater1");
  55. storm::property::Eventually<double>* eventuallyFormula = new storm::property::Eventually<double>(apFormula);
  56. storm::property::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  57. std::vector<double>* result = probFormula->check(mc);
  58. ASSERT_LT(std::abs((*result)[1] - 0.3328800375801578281), s->get<double>("precision"));
  59. delete probFormula;
  60. delete result;
  61. apFormula = new storm::property::Ap<double>("observeIGreater1");
  62. eventuallyFormula = new storm::property::Eventually<double>(apFormula);
  63. probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  64. result = probFormula->check(mc);
  65. ASSERT_LT(std::abs((*result)[1] - 0.1522173670950556501), s->get<double>("precision"));
  66. delete probFormula;
  67. delete result;
  68. apFormula = new storm::property::Ap<double>("observeOnlyTrueSender");
  69. eventuallyFormula = new storm::property::Eventually<double>(apFormula);
  70. probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  71. result = probFormula->check(mc);
  72. ASSERT_LT(std::abs((*result)[1] - 0.32153724292835045), s->get<double>("precision"));
  73. delete probFormula;
  74. delete result;
  75. }
  76. TEST(EigenDtmcPrctlModelCheckerTest, SynchronousLeader) {
  77. storm::settings::Settings* s = storm::settings::instance();
  78. s->set("fix-deadlocks");
  79. storm::parser::AutoParser<double> parser(STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/synchronous_leader/leader4_8.tra", STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/synchronous_leader/leader4_8.lab", "", STORM_CPP_TESTS_BASE_PATH "/functional/modelchecker/synchronous_leader/leader4_8.pick.trans.rew");
  80. ASSERT_EQ(parser.getType(), storm::models::DTMC);
  81. std::shared_ptr<storm::models::Dtmc<double>> dtmc = parser.getModel<storm::models::Dtmc<double>>();
  82. ASSERT_EQ(dtmc->getNumberOfStates(), 12401);
  83. ASSERT_EQ(dtmc->getNumberOfTransitions(), 28895);
  84. storm::modelChecker::EigenDtmcPrctlModelChecker<double> mc(*dtmc);
  85. storm::property::Ap<double>* apFormula = new storm::property::Ap<double>("elected");
  86. storm::property::Eventually<double>* eventuallyFormula = new storm::property::Eventually<double>(apFormula);
  87. storm::property::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  88. std::vector<double>* result = probFormula->check(mc);
  89. ASSERT_LT(std::abs((*result)[1] - 1), s->get<double>("precision"));
  90. delete probFormula;
  91. delete result;
  92. apFormula = new storm::property::Ap<double>("elected");
  93. storm::property::BoundedUntil<double>* boundedUntilFormula = new storm::property::BoundedUntil<double>(new storm::property::Ap<double>("true"), apFormula, 20);
  94. probFormula = new storm::property::ProbabilisticNoBoundOperator<double>(boundedUntilFormula);
  95. result = probFormula->check(mc);
  96. ASSERT_LT(std::abs((*result)[1] - 0.9999965911265462636), s->get<double>("precision"));
  97. delete probFormula;
  98. delete result;
  99. apFormula = new storm::property::Ap<double>("elected");
  100. storm::property::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::ReachabilityReward<double>(apFormula);
  101. storm::property::RewardNoBoundOperator<double>* rewardFormula = new storm::property::RewardNoBoundOperator<double>(reachabilityRewardFormula);
  102. result = rewardFormula->check(mc);
  103. ASSERT_LT(std::abs((*result)[1] - 1.0448979591835938496), s->get<double>("precision"));
  104. delete rewardFormula;
  105. delete result;
  106. }
  107. */