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.

167 lines
7.5 KiB

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