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.

94 lines
5.1 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(2036647ull, dtmc->getNumberOfStates());
  16. ASSERT_EQ(7362293ull, dtmc->getNumberOfTransitions());
  17. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, new storm::solver::GmmxxLinearEquationSolver<double>());
  18. auto apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("observe0Greater1");
  19. auto eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  20. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observe0Greater1] on crowds/crowds20_5...");
  21. std::vector<double> result = eventuallyFormula->check(mc, false);
  22. LOG4CPLUS_WARN(logger, "Done.");
  23. ASSERT_LT(std::abs(result[0] - 0.2296800237), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  24. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("observeIGreater1");
  25. eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  26. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observeIGreater1] on crowds/crowds20_5...");
  27. result = eventuallyFormula->check(mc, false);
  28. LOG4CPLUS_WARN(logger, "Done.");
  29. ASSERT_LT(std::abs(result[0] - 0.05073232193), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  30. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("observeOnlyTrueSender");
  31. eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  32. LOG4CPLUS_WARN(logger, "Model Checking P=? [F observeOnlyTrueSender] on crowds/crowds20_5...");
  33. result = eventuallyFormula->check(mc, false);
  34. LOG4CPLUS_WARN(logger, "Done.");
  35. ASSERT_LT(std::abs(result[0] - 0.22742171078), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  36. }
  37. TEST(GmmxxDtmcPrctlModelCheckerTest, SynchronousLeader) {
  38. storm::settings::Settings* s = storm::settings::Settings::getInstance();
  39. storm::settings::InternalOptionMemento deadlockOption("fixDeadlocks", true);
  40. ASSERT_TRUE(s->isSet("fixDeadlocks"));
  41. 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");
  42. ASSERT_EQ(abstractModel->getType(), storm::models::DTMC);
  43. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  44. ASSERT_EQ(1312334ull, dtmc->getNumberOfStates());
  45. ASSERT_EQ(1574477ull, dtmc->getNumberOfTransitions());
  46. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, new storm::solver::GmmxxLinearEquationSolver<double>());
  47. auto apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("elected");
  48. auto eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  49. LOG4CPLUS_WARN(logger, "Model Checking P=? [F elected] on synchronous_leader/leader6_8...");
  50. std::vector<double> result = eventuallyFormula->check(mc, false);
  51. LOG4CPLUS_WARN(logger, "Done.");
  52. ASSERT_LT(std::abs(result[0] - 1.0), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  53. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("elected");
  54. auto boundedUntilFormula = std::make_shared<storm::properties::prctl::BoundedUntil<double>>(std::make_shared<storm::properties::prctl::Ap<double>>("true"), apFormula, 20);
  55. LOG4CPLUS_WARN(logger, "Model Checking P=? [F<=20 elected] on synchronous_leader/leader6_8...");
  56. result = boundedUntilFormula->check(mc, false);
  57. LOG4CPLUS_WARN(logger, "Done.");
  58. ASSERT_LT(std::abs(result[0] - 0.9993949793), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  59. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("elected");
  60. auto reachabilityRewardFormula = std::make_shared<storm::properties::prctl::ReachabilityReward<double>>(apFormula);
  61. LOG4CPLUS_WARN(logger, "Model Checking R=? [F elected] on synchronous_leader/leader6_8...");
  62. result = reachabilityRewardFormula->check(mc, false);
  63. LOG4CPLUS_WARN(logger, "Done.");
  64. ASSERT_LT(std::abs(result[0] - 1.025106273), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
  65. }