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.

113 lines
5.9 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/Settings.h"
  4. #include "src/settings/InternalOptionMemento.h"
  5. #include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
  6. #include "src/solver/GmmxxLinearEquationSolver.h"
  7. #include "src/parser/AutoParser.h"
  8. TEST(GmmxxDtmcPrctlModelCheckerTest, Crowds) {
  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/crowds/crowds20_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.lab", "", "");
  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(), 2036647ull);
  16. ASSERT_EQ(dtmc->getNumberOfTransitions(), 8973900ull);
  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>("observe0Greater1");
  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. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observe0Greater1] on crowds/crowds20_5...");
  22. std::vector<double> result = probFormula->check(mc);
  23. LOG4CPLUS_WARN(logger, "Done.");
  24. ASSERT_LT(std::abs(result[0] - 0.2296800237), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  25. delete probFormula;
  26. apFormula = new storm::property::prctl::Ap<double>("observeIGreater1");
  27. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  28. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  29. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observeIGreater1] on crowds/crowds20_5...");
  30. result = probFormula->check(mc);
  31. LOG4CPLUS_WARN(logger, "Done.");
  32. ASSERT_LT(std::abs(result[0] - 0.05073232193), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  33. delete probFormula;
  34. apFormula = new storm::property::prctl::Ap<double>("observeOnlyTrueSender");
  35. eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
  36. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula);
  37. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observeOnlyTrueSender] on crowds/crowds20_5...");
  38. result = probFormula->check(mc);
  39. LOG4CPLUS_WARN(logger, "Done.");
  40. ASSERT_LT(std::abs(result[0] - 0.22742171078), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  41. delete probFormula;
  42. }
  43. TEST(GmmxxDtmcPrctlModelCheckerTest, SynchronousLeader) {
  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/synchronous_leader/leader6_8.tra", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.lab", "", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.pick.trans.rew");
  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(), 1312334ull);
  51. ASSERT_EQ(dtmc->getNumberOfTransitions(), 2886810ull);
  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>("elected");
  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. LOG4CPLUS_WARN(logger, "Model Checking P=? [F elected] on synchronous_leader/leader6_8...");
  57. std::vector<double> result = probFormula->check(mc);
  58. LOG4CPLUS_WARN(logger, "Done.");
  59. ASSERT_LT(std::abs(result[0] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  60. delete probFormula;
  61. apFormula = new storm::property::prctl::Ap<double>("elected");
  62. storm::property::prctl::BoundedUntil<double>* boundedUntilFormula = new storm::property::prctl::BoundedUntil<double>(new storm::property::prctl::Ap<double>("true"), apFormula, 20);
  63. probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(boundedUntilFormula);
  64. LOG4CPLUS_WARN(logger, "Model Checking P=? [F<=20 elected] on synchronous_leader/leader6_8...");
  65. result = probFormula->check(mc);
  66. LOG4CPLUS_WARN(logger, "Done.");
  67. ASSERT_LT(std::abs(result[0] - 0.9993949793), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  68. delete probFormula;
  69. apFormula = new storm::property::prctl::Ap<double>("elected");
  70. storm::property::prctl::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
  71. storm::property::prctl::RewardNoBoundOperator<double>* rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula);
  72. LOG4CPLUS_WARN(logger, "Model Checking R=? [F elected] on synchronous_leader/leader6_8...");
  73. result = rewardFormula->check(mc);
  74. LOG4CPLUS_WARN(logger, "Done.");
  75. ASSERT_LT(std::abs(result[0] - 1.025106273), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  76. delete rewardFormula;
  77. }