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.

116 lines
6.2 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/SettingsManager.h"
  6. #include "src/settings/SettingMemento.h"
  7. #include "src/parser/AutoParser.h"
  8. TEST(GmmxxDtmcPrctlModelCheckerTest, Die) {
  9. 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");
  10. ASSERT_EQ(abstractModel->getType(), storm::models::DTMC);
  11. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  12. ASSERT_EQ(dtmc->getNumberOfStates(), 13ull);
  13. ASSERT_EQ(dtmc->getNumberOfTransitions(), 20ull);
  14. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, std::unique_ptr<storm::solver::LinearEquationSolver<double>>(new storm::solver::GmmxxLinearEquationSolver<double>()));
  15. auto apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("one");
  16. auto eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  17. std::vector<double> result = eventuallyFormula->check(mc, false);
  18. ASSERT_LT(std::abs(result[0] - ((double)1.0/6.0)), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  19. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("two");
  20. eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  21. result = eventuallyFormula->check(mc, false);
  22. ASSERT_LT(std::abs(result[0] - ((double)1.0/6.0)), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  23. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("three");
  24. eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  25. result = eventuallyFormula->check(mc, false);
  26. ASSERT_LT(std::abs(result[0] - ((double)1.0/6.0)), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  27. auto done = std::make_shared<storm::properties::prctl::Ap<double>>("done");
  28. auto reachabilityRewardFormula = std::make_shared<storm::properties::prctl::ReachabilityReward<double>>(done);
  29. result = reachabilityRewardFormula->check(mc, false);
  30. ASSERT_LT(std::abs(result[0] - ((double)11/3)), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  31. }
  32. TEST(GmmxxDtmcPrctlModelCheckerTest, Crowds) {
  33. 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", "", "");
  34. ASSERT_EQ(abstractModel->getType(), storm::models::DTMC);
  35. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  36. ASSERT_EQ(8607ull, dtmc->getNumberOfStates());
  37. ASSERT_EQ(15113ull, dtmc->getNumberOfTransitions());
  38. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, std::unique_ptr<storm::solver::LinearEquationSolver<double>>(new storm::solver::GmmxxLinearEquationSolver<double>()));
  39. auto apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("observe0Greater1");
  40. auto eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  41. std::vector<double> result = eventuallyFormula->check(mc, false);
  42. ASSERT_LT(std::abs(result[0] - 0.3328800375801578281), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  43. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("observeIGreater1");
  44. eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  45. result = eventuallyFormula->check(mc, false);
  46. ASSERT_LT(std::abs(result[0] - 0.1522194965), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  47. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("observeOnlyTrueSender");
  48. eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  49. result = eventuallyFormula->check(mc, false);
  50. ASSERT_LT(std::abs(result[0] - 0.32153724292835045), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  51. }
  52. TEST(GmmxxDtmcPrctlModelCheckerTest, SynchronousLeader) {
  53. 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");
  54. ASSERT_EQ(abstractModel->getType(), storm::models::DTMC);
  55. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  56. ASSERT_EQ(12400ull, dtmc->getNumberOfStates());
  57. ASSERT_EQ(16495ull, dtmc->getNumberOfTransitions());
  58. storm::modelchecker::prctl::SparseDtmcPrctlModelChecker<double> mc(*dtmc, std::unique_ptr<storm::solver::LinearEquationSolver<double>>(new storm::solver::GmmxxLinearEquationSolver<double>()));
  59. auto apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("elected");
  60. auto eventuallyFormula = std::make_shared<storm::properties::prctl::Eventually<double>>(apFormula);
  61. std::vector<double> result = eventuallyFormula->check(mc, false);
  62. ASSERT_LT(std::abs(result[0] - 1.0), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  63. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("elected");
  64. auto boundedUntilFormula = std::make_shared<storm::properties::prctl::BoundedUntil<double>>(std::make_shared<storm::properties::prctl::Ap<double>>("true"), apFormula, 20);
  65. result = boundedUntilFormula->check(mc, false);
  66. ASSERT_LT(std::abs(result[0] - 0.9999965911265462636), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  67. apFormula = std::make_shared<storm::properties::prctl::Ap<double>>("elected");
  68. auto reachabilityRewardFormula = std::make_shared<storm::properties::prctl::ReachabilityReward<double>>(apFormula);
  69. result = reachabilityRewardFormula->check(mc, false);
  70. ASSERT_LT(std::abs(result[0] - 1.044879046), storm::settings::gmmxxEquationSolverSettings().getPrecision());
  71. }