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.

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