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.

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