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.

155 lines
8.0 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/solver/GmmxxLinearEquationSolver.h"
  4. #include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
  5. #include "src/settings/Settings.h"
  6. #include "src/settings/InternalOptionMemento.h"
  7. #include "src/parser/AutoParser.h"
  8. TEST(GmmxxDtmcPrctlModelCheckerTest, Die) {
  9. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  10. storm::settings::InternalOptionMemento deadlockOption("fixDeadlocks", true);
  11. ASSERT_TRUE(s->isSet("fixDeadlocks"));
  12. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/die/die.tra", STORM_CPP_BASE_PATH "/examples/dtmc/die/die.lab", "", STORM_CPP_BASE_PATH "/examples/dtmc/die/die.coin_flips.trans.rew");
  13. ASSERT_EQ(abstractModel->getType(), storm::models::DTMC);
  14. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  15. ASSERT_EQ(dtmc->getNumberOfStates(), 13ull);
  16. ASSERT_EQ(dtmc->getNumberOfTransitions(), 27ull);
  17. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, new storm::solver::GmmxxLinearEquationSolver<double>());
  18. storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("one");
  19. storm::property::prctl::Eventually<double>* eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  20. storm::property::prctl::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  21. std::vector<double> result = probFormula->check(mc);
  22. ASSERT_LT(std::abs(result[0] - ((double)1.0/6.0)), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  23. delete probFormula;
  24. apFormula = new storm::property::prctl::Ap<double>("two");
  25. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  26. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  27. result = probFormula->check(mc);
  28. ASSERT_LT(std::abs(result[0] - ((double)1.0/6.0)), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  29. delete probFormula;
  30. apFormula = new storm::property::prctl::Ap<double>("three");
  31. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  32. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  33. result = probFormula->check(mc);
  34. ASSERT_LT(std::abs(result[0] - ((double)1.0/6.0)), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  35. delete probFormula;
  36. storm::property::prctl::Ap<double>* done = new storm::property::prctl::Ap<double>("done");
  37. storm::property::prctl::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(done);
  38. storm::property::prctl::RewardNoBoundOperator<double>* rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula);
  39. result = rewardFormula->check(mc);
  40. ASSERT_LT(std::abs(result[0] - ((double)11/3)), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  41. delete rewardFormula;
  42. }
  43. TEST(GmmxxDtmcPrctlModelCheckerTest, Crowds) {
  44. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  45. storm::settings::InternalOptionMemento deadlockOption("fixDeadlocks", true);
  46. ASSERT_TRUE(s->isSet("fixDeadlocks"));
  47. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds5_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds5_5.lab", "", "");
  48. ASSERT_EQ(abstractModel->getType(), storm::models::DTMC);
  49. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  50. ASSERT_EQ(dtmc->getNumberOfStates(), 8607ull);
  51. ASSERT_EQ(dtmc->getNumberOfTransitions(), 22460ull);
  52. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, new storm::solver::GmmxxLinearEquationSolver<double>());
  53. storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("observe0Greater1");
  54. storm::property::prctl::Eventually<double>* eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  55. storm::property::prctl::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  56. std::vector<double> result = probFormula->check(mc);
  57. ASSERT_LT(std::abs(result[0] - 0.3328800375801578281), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  58. delete probFormula;
  59. apFormula = new storm::property::prctl::Ap<double>("observeIGreater1");
  60. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  61. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  62. result = probFormula->check(mc);
  63. ASSERT_LT(std::abs(result[0] - 0.1522194965), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  64. delete probFormula;
  65. apFormula = new storm::property::prctl::Ap<double>("observeOnlyTrueSender");
  66. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  67. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  68. result = probFormula->check(mc);
  69. ASSERT_LT(std::abs(result[0] - 0.32153724292835045), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  70. delete probFormula;
  71. }
  72. TEST(GmmxxDtmcPrctlModelCheckerTest, SynchronousLeader) {
  73. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  74. storm::settings::InternalOptionMemento deadlockOption("fixDeadlocks", true);
  75. ASSERT_TRUE(s->isSet("fixDeadlocks"));
  76. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader4_8.tra", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader4_8.lab", "", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader4_8.pick.trans.rew");
  77. ASSERT_EQ(abstractModel->getType(), storm::models::DTMC);
  78. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  79. ASSERT_EQ(dtmc->getNumberOfStates(), 12400ull);
  80. ASSERT_EQ(dtmc->getNumberOfTransitions(), 28894ull);
  81. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, new storm::solver::GmmxxLinearEquationSolver<double>());
  82. storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("elected");
  83. storm::property::prctl::Eventually<double>* eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  84. storm::property::prctl::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  85. std::vector<double> result = probFormula->check(mc);
  86. ASSERT_LT(std::abs(result[0] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  87. delete probFormula;
  88. apFormula = new storm::property::prctl::Ap<double>("elected");
  89. storm::property::prctl::BoundedUntil<double>* boundedUntilFormula = new storm::property::prctl::BoundedUntil<double>(new storm::property::prctl::Ap<double>("true"), apFormula, 20);
  90. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(boundedUntilFormula);
  91. result = probFormula->check(mc);
  92. ASSERT_LT(std::abs(result[0] - 0.9999965911265462636), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  93. delete probFormula;
  94. apFormula = new storm::property::prctl::Ap<double>("elected");
  95. storm::property::prctl::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
  96. storm::property::prctl::RewardNoBoundOperator<double>* rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula);
  97. result = rewardFormula->check(mc);
  98. ASSERT_LT(std::abs(result[0] - 1.044879046), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  99. delete rewardFormula;
  100. }