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.

84 lines
5.3 KiB

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