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.

85 lines
5.3 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/SettingsManager.h"
  4. #include "src/settings/modules/GmmxxEquationSolverSettings.h"
  5. #include "src/settings/SettingMemento.h"
  6. #include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
  7. #include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
  8. #include "src/utility/solver.h"
  9. #include "src/parser/AutoParser.h"
  10. TEST(NativeDtmcPrctlModelCheckerTest, Crowds) {
  11. std::shared_ptr<storm::models::sparse::Model<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", "", "");
  12. ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
  13. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  14. ASSERT_EQ(2036647ull, dtmc->getNumberOfStates());
  15. ASSERT_EQ(7362293ull, dtmc->getNumberOfTransitions());
  16. storm::modelchecker::SparseDtmcPrctlModelChecker<double> checker(*dtmc, std::unique_ptr<storm::utility::solver::LinearEquationSolverFactory<double>>(new storm::utility::solver::NativeLinearEquationSolverFactory<double>()));
  17. auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("observe0Greater1");
  18. auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula);
  19. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*eventuallyFormula);
  20. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>();
  21. EXPECT_NEAR(0.22968140721646868, quantitativeResult1[0], storm::settings::gmmxxEquationSolverSettings().getPrecision());
  22. labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("observeIGreater1");
  23. eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula);
  24. result = checker.check(*eventuallyFormula);
  25. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>();
  26. EXPECT_NEAR(0.05073232193, quantitativeResult2[0], storm::settings::gmmxxEquationSolverSettings().getPrecision());
  27. labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("observeOnlyTrueSender");
  28. eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula);
  29. result = checker.check(*eventuallyFormula);
  30. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>();
  31. EXPECT_NEAR(0.22742305378217331, quantitativeResult3[0], storm::settings::gmmxxEquationSolverSettings().getPrecision());
  32. }
  33. TEST(NativeDtmcPrctlModelCheckerTest, SynchronousLeader) {
  34. std::shared_ptr<storm::models::sparse::Model<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");
  35. ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
  36. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  37. ASSERT_EQ(1312334ull, dtmc->getNumberOfStates());
  38. ASSERT_EQ(1574477ull, dtmc->getNumberOfTransitions());
  39. storm::modelchecker::SparseDtmcPrctlModelChecker<double> checker(*dtmc, std::unique_ptr<storm::utility::solver::LinearEquationSolverFactory<double>>(new storm::utility::solver::NativeLinearEquationSolverFactory<double>()));
  40. auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected");
  41. auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula);
  42. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*eventuallyFormula);
  43. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>();
  44. EXPECT_NEAR(1.0, quantitativeResult1[0], storm::settings::gmmxxEquationSolverSettings().getPrecision());
  45. labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected");
  46. auto trueFormula = std::make_shared<storm::logic::BooleanLiteralFormula>(true);
  47. auto boundedUntilFormula = std::make_shared<storm::logic::BoundedUntilFormula>(trueFormula, labelFormula, 20);
  48. result = checker.check(*boundedUntilFormula);
  49. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>();
  50. EXPECT_NEAR(0.9993949793, quantitativeResult2[0], storm::settings::gmmxxEquationSolverSettings().getPrecision());
  51. labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected");
  52. auto reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(labelFormula);
  53. result = checker.check(*reachabilityRewardFormula);
  54. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>();
  55. EXPECT_NEAR(1.0252174454896057, quantitativeResult3[0], storm::settings::gmmxxEquationSolverSettings().getPrecision());
  56. }