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.

86 lines
5.1 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/logic/Formulas.h"
  4. #include "src/modelchecker/exploration/SparseExplorationModelChecker.h"
  5. #include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
  6. #include "src/parser/PrismParser.h"
  7. #include "src/parser/FormulaParser.h"
  8. #include "src/settings/SettingsManager.h"
  9. #include "src/settings/modules/ExplorationSettings.h"
  10. TEST(SparseExplorationModelCheckerTest, Dice) {
  11. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/two_dice.nm");
  12. // A parser that we use for conveniently constructing the formulas.
  13. storm::parser::FormulaParser formulaParser;
  14. storm::modelchecker::SparseExplorationModelChecker<double, uint32_t> checker(program);
  15. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"two\"]");
  16. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  17. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>();
  18. EXPECT_NEAR(0.0277777612209320068, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  19. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"two\"]");
  20. result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  21. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>();
  22. EXPECT_NEAR(0.0277777612209320068, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  23. formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"three\"]");
  24. result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  25. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>();
  26. EXPECT_NEAR(0.0555555224418640136, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  27. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"three\"]");
  28. result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  29. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult4 = result->asExplicitQuantitativeCheckResult<double>();
  30. EXPECT_NEAR(0.0555555224418640136, quantitativeResult4[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  31. formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"four\"]");
  32. result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  33. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult5 = result->asExplicitQuantitativeCheckResult<double>();
  34. EXPECT_NEAR(0.083333283662796020508, quantitativeResult5[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  35. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"four\"]");
  36. result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  37. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult6 = result->asExplicitQuantitativeCheckResult<double>();
  38. EXPECT_NEAR(0.083333283662796020508, quantitativeResult6[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  39. }
  40. TEST(SparseExplorationModelCheckerTest, AsynchronousLeader) {
  41. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader4.nm");
  42. // A parser that we use for conveniently constructing the formulas.
  43. storm::parser::FormulaParser formulaParser;
  44. storm::modelchecker::SparseExplorationModelChecker<double, uint32_t> checker(program);
  45. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"elected\"]");
  46. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  47. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>();
  48. EXPECT_NEAR(1, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  49. formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"elected\"]");
  50. result = checker.check(storm::modelchecker::CheckTask<>(*formula, true));
  51. storm::modelchecker::ExplicitQuantitativeCheckResult<double> const& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>();
  52. EXPECT_NEAR(1, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::ExplorationSettings>().getPrecision());
  53. }