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.2 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/parser/FormulaParser.h"
  12. #include "src/models/sparse/StandardRewardModel.h"
  13. #include "src/solver/GmmxxLinearEquationSolver.h"
  14. TEST(GmmxxDtmcPrctlModelCheckerTest, Crowds) {
  15. 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", "", "");
  16. ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
  17. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  18. ASSERT_EQ(2036647ull, dtmc->getNumberOfStates());
  19. ASSERT_EQ(7362293ull, dtmc->getNumberOfTransitions());
  20. storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<double>> checker(*dtmc, std::unique_ptr<storm::solver::LinearEquationSolverFactory<double>>(new storm::solver::GmmxxLinearEquationSolverFactory<double>()));
  21. // A parser that we use for conveniently constructing the formulas.
  22. storm::parser::FormulaParser formulaParser;
  23. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observe0Greater1\"]");
  24. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  25. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>();
  26. EXPECT_NEAR(0.2296800237, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  27. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeIGreater1\"]");
  28. result = checker.check(*formula);
  29. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>();
  30. EXPECT_NEAR(0.05073232193, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  31. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeOnlyTrueSender\"]");
  32. result = checker.check(*formula);
  33. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>();
  34. EXPECT_NEAR(0.22742171078, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  35. }
  36. TEST(GmmxxDtmcPrctlModelCheckerTest, SynchronousLeader) {
  37. 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");
  38. ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
  39. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  40. ASSERT_EQ(1312334ull, dtmc->getNumberOfStates());
  41. ASSERT_EQ(1574477ull, dtmc->getNumberOfTransitions());
  42. storm::modelchecker::SparseDtmcPrctlModelChecker<storm::models::sparse::Dtmc<double>> checker(*dtmc, std::unique_ptr<storm::solver::LinearEquationSolverFactory<double>>(new storm::solver::GmmxxLinearEquationSolverFactory<double>()));
  43. // A parser that we use for conveniently constructing the formulas.
  44. storm::parser::FormulaParser formulaParser;
  45. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"elected\"]");
  46. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  47. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>();
  48. EXPECT_NEAR(1.0, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  49. formula = formulaParser.parseSingleFormulaFromString("P=? [F<=20 \"elected\"]");
  50. result = checker.check(*formula);
  51. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>();
  52. EXPECT_NEAR(0.9993949793, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  53. formula = formulaParser.parseSingleFormulaFromString("R=? [F \"elected\"]");
  54. result = checker.check(*formula);
  55. storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>();
  56. EXPECT_NEAR(1.025106273, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  57. }