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.

211 lines
11 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/Settings.h"
  4. #include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h"
  5. #include "src/solver/GmmxxNondeterministicLinearEquationSolver.h"
  6. #include "src/parser/AutoParser.h"
  7. TEST(GmmxxMdpPrctlModelCheckerTest, AsynchronousLeader) {
  8. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  9. storm::parser::AutoParser<double> parser(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");
  10. ASSERT_EQ(parser.getType(), storm::models::MDP);
  11. std::shared_ptr<storm::models::Mdp<double>> mdp = parser.getModel<storm::models::Mdp<double>>();
  12. ASSERT_EQ(mdp->getNumberOfStates(), 2095783ull);
  13. ASSERT_EQ(mdp->getNumberOfTransitions(), 7714385ull);
  14. storm::modelchecker::prctl::SparseMdpPrctlModelChecker<double> mc(*mdp, new storm::solver::GmmxxNondeterministicLinearEquationSolver<double>());
  15. storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("elected");
  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, true);
  18. LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F elected] on asynchronous_leader/leader7...");
  19. std::vector<double> result = mc.checkNoBoundOperator(*probFormula);
  20. LOG4CPLUS_WARN(logger, "Done.");
  21. ASSERT_LT(std::abs(result[0] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  22. delete probFormula;
  23. apFormula = new storm::property::prctl::Ap<double>("elected");
  24. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  25. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, false);
  26. LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F elected] on asynchronous_leader/leader7...");
  27. result = mc.checkNoBoundOperator(*probFormula);
  28. LOG4CPLUS_WARN(logger, "Done.");
  29. ASSERT_LT(std::abs(result[0] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  30. delete probFormula;
  31. apFormula = new storm::property::prctl::Ap<double>("elected");
  32. storm::property::prctl::BoundedEventually<double>* boundedEventuallyFormula = new storm::property::prctl::BoundedEventually<double>(apFormula, 25ull);
  33. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(boundedEventuallyFormula, true);
  34. LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F<=25 elected] on asynchronous_leader/leader7...");
  35. result = mc.checkNoBoundOperator(*probFormula);
  36. LOG4CPLUS_WARN(logger, "Done.");
  37. ASSERT_LT(std::abs(result[0] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  38. delete probFormula;
  39. apFormula = new storm::property::prctl::Ap<double>("elected");
  40. boundedEventuallyFormula = new storm::property::prctl::BoundedEventually<double>(apFormula, 25ull);
  41. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(boundedEventuallyFormula, false);
  42. LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F<=25 elected] on asynchronous_leader/leader7...");
  43. result = mc.checkNoBoundOperator(*probFormula);
  44. LOG4CPLUS_WARN(logger, "Done.");
  45. ASSERT_LT(std::abs(result[0] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  46. delete probFormula;
  47. apFormula = new storm::property::prctl::Ap<double>("elected");
  48. storm::property::prctl::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
  49. storm::property::prctl::RewardNoBoundOperator<double>* rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, true);
  50. LOG4CPLUS_WARN(logger, "Model Checking Rmin=? [F elected] on asynchronous_leader/leader7...");
  51. result = mc.checkNoBoundOperator(*rewardFormula);
  52. LOG4CPLUS_WARN(logger, "Done.");
  53. ASSERT_LT(std::abs(result[0] - 6.172433512), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  54. delete rewardFormula;
  55. apFormula = new storm::property::prctl::Ap<double>("elected");
  56. reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
  57. rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, false);
  58. LOG4CPLUS_WARN(logger, "Model Checking Rmax=? [F elected] on asynchronous_leader/leader7...");
  59. result = mc.checkNoBoundOperator(*rewardFormula);
  60. LOG4CPLUS_WARN(logger, "Done");
  61. ASSERT_LT(std::abs(result[0] - 6.1724344), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  62. delete rewardFormula;
  63. }
  64. TEST(GmmxxMdpPrctlModelCheckerTest, Consensus) {
  65. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  66. storm::parser::AutoParser<double> parser(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", "");
  67. ASSERT_EQ(parser.getType(), storm::models::MDP);
  68. std::shared_ptr<storm::models::Mdp<double>> mdp = parser.getModel<storm::models::Mdp<double>>();
  69. ASSERT_EQ(mdp->getNumberOfStates(), 63616ull);
  70. ASSERT_EQ(mdp->getNumberOfTransitions(), 213472ull);
  71. storm::modelchecker::prctl::SparseMdpPrctlModelChecker<double> mc(*mdp, new storm::solver::GmmxxNondeterministicLinearEquationSolver<double>());
  72. storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("finished");
  73. storm::property::prctl::Eventually<double>* eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  74. storm::property::prctl::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, true);
  75. LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F finished] on consensus/coin4_6...");
  76. std::vector<double> result = mc.checkNoBoundOperator(*probFormula);
  77. LOG4CPLUS_WARN(logger, "Done.");
  78. ASSERT_LT(std::abs(result[31168] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  79. delete probFormula;
  80. apFormula = new storm::property::prctl::Ap<double>("finished");
  81. storm::property::prctl::Ap<double>* apFormula2 = new storm::property::prctl::Ap<double>("all_coins_equal_0");
  82. storm::property::prctl::And<double>* andFormula = new storm::property::prctl::And<double>(apFormula, apFormula2);
  83. eventuallyFormula = new storm::property::prctl::Eventually<double>(andFormula);
  84. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, true);
  85. LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F finished & all_coins_equal_0] on consensus/coin4_6...");
  86. result = mc.checkNoBoundOperator(*probFormula);
  87. LOG4CPLUS_WARN(logger, "Done.");
  88. ASSERT_LT(std::abs(result[31168] - 0.43742828319177884388579), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  89. delete probFormula;
  90. apFormula = new storm::property::prctl::Ap<double>("finished");
  91. apFormula2 = new storm::property::prctl::Ap<double>("all_coins_equal_1");
  92. andFormula = new storm::property::prctl::And<double>(apFormula, apFormula2);
  93. eventuallyFormula = new storm::property::prctl::Eventually<double>(andFormula);
  94. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, false);
  95. LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F finished & all_coins_equal_1] on consensus/coin4_6...");
  96. result = mc.checkNoBoundOperator(*probFormula);
  97. LOG4CPLUS_WARN(logger, "Done.");
  98. ASSERT_LT(std::abs(result[31168] - 0.52932863686144482340267813924583606421947479248047), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  99. delete probFormula;
  100. apFormula = new storm::property::prctl::Ap<double>("finished");
  101. apFormula2 = new storm::property::prctl::Ap<double>("agree");
  102. storm::property::prctl::Not<double>* notFormula = new storm::property::prctl::Not<double>(apFormula2);
  103. andFormula = new storm::property::prctl::And<double>(apFormula, notFormula);
  104. eventuallyFormula = new storm::property::prctl::Eventually<double>(andFormula);
  105. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, false);
  106. LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F finished & !agree] on consensus/coin4_6...");
  107. result = mc.checkNoBoundOperator(*probFormula);
  108. LOG4CPLUS_WARN(logger, "Done.");
  109. ASSERT_LT(std::abs(result[31168] - 0.1041409700076474653673841), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  110. delete probFormula;
  111. apFormula = new storm::property::prctl::Ap<double>("finished");
  112. storm::property::prctl::BoundedEventually<double>* boundedEventuallyFormula = new storm::property::prctl::BoundedEventually<double>(apFormula, 50ull);
  113. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(boundedEventuallyFormula, true);
  114. LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F<=50 finished] on consensus/coin4_6...");
  115. result = mc.checkNoBoundOperator(*probFormula);
  116. LOG4CPLUS_WARN(logger, "Done.");
  117. ASSERT_LT(std::abs(result[31168] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  118. delete probFormula;
  119. apFormula = new storm::property::prctl::Ap<double>("finished");
  120. boundedEventuallyFormula = new storm::property::prctl::BoundedEventually<double>(apFormula, 50ull);
  121. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(boundedEventuallyFormula, false);
  122. LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F<=50 finished] on consensus/coin4_6...");
  123. result = mc.checkNoBoundOperator(*probFormula);
  124. LOG4CPLUS_WARN(logger, "Done.");
  125. ASSERT_LT(std::abs(result[31168] - 0.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  126. delete probFormula;
  127. apFormula = new storm::property::prctl::Ap<double>("finished");
  128. storm::property::prctl::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
  129. storm::property::prctl::RewardNoBoundOperator<double>* rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, true);
  130. LOG4CPLUS_WARN(logger, "Model Checking Rmin=? [F finished] on consensus/coin4_6...");
  131. result = mc.checkNoBoundOperator(*rewardFormula);
  132. LOG4CPLUS_WARN(logger, "Done.");
  133. ASSERT_LT(std::abs(result[31168] - 1725.5933133943854045), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  134. delete rewardFormula;
  135. apFormula = new storm::property::prctl::Ap<double>("finished");
  136. reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
  137. rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, false);
  138. LOG4CPLUS_WARN(logger, "Model Checking Rmax=? [F finished] on consensus/coin4_6...");
  139. result = mc.checkNoBoundOperator(*rewardFormula);
  140. LOG4CPLUS_WARN(logger, "Done.");
  141. ASSERT_LT(std::abs(result[31168] - 2183.1424220082612919213715), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  142. delete rewardFormula;
  143. }