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.

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