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.

353 lines
26 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/parser/FormulaParser.h"
  4. #include "src/logic/Formulas.h"
  5. #include "src/solver/GmmxxLinearEquationSolver.h"
  6. #include "src/modelchecker/prctl/HybridDtmcPrctlModelChecker.h"
  7. #include "src/modelchecker/results/HybridQuantitativeCheckResult.h"
  8. #include "src/modelchecker/results/SymbolicQualitativeCheckResult.h"
  9. #include "src/modelchecker/results/SymbolicQuantitativeCheckResult.h"
  10. #include "src/parser/PrismParser.h"
  11. #include "src/builder/DdPrismModelBuilder.h"
  12. #include "src/models/symbolic/Dtmc.h"
  13. #include "src/models/symbolic/StandardRewardModel.h"
  14. #include "src/storage/SymbolicModelDescription.h"
  15. #include "src/storage/expressions/ExpressionManager.h"
  16. #include "src/settings/SettingsManager.h"
  17. #include "src/settings/modules/GeneralSettings.h"
  18. #include "src/settings/modules/GmmxxEquationSolverSettings.h"
  19. #include "src/settings/modules/NativeEquationSolverSettings.h"
  20. TEST(GmmxxHybridDtmcPrctlModelCheckerTest, Die_Cudd) {
  21. storm::storage::SymbolicModelDescription modelDescription = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm");
  22. storm::prism::Program program = modelDescription.preprocess().asPrismProgram();
  23. // A parser that we use for conveniently constructing the formulas.
  24. auto expManager = std::make_shared<storm::expressions::ExpressionManager>();
  25. storm::parser::FormulaParser formulaParser(expManager);
  26. // Build the die model with its reward model.
  27. #ifdef WINDOWS
  28. storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  29. #else
  30. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  31. #endif
  32. options.buildAllRewardModels = false;
  33. options.rewardModelsToBuild.insert("coin_flips");
  34. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options);
  35. EXPECT_EQ(13ul, model->getNumberOfStates());
  36. EXPECT_EQ(20ul, model->getNumberOfTransitions());
  37. ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc);
  38. std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>();
  39. storm::modelchecker::HybridDtmcPrctlModelChecker<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD, double>> checker(*dtmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  40. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"one\"]");
  41. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  42. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  43. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult1 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  44. EXPECT_NEAR(1.0/6.0, quantitativeResult1.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  45. EXPECT_NEAR(1.0/6.0, quantitativeResult1.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  46. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"two\"]");
  47. result = checker.check(*formula);
  48. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  49. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult2 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  50. EXPECT_NEAR(1.0/6.0, quantitativeResult2.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  51. EXPECT_NEAR(1.0/6.0, quantitativeResult2.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  52. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"three\"]");
  53. result = checker.check(*formula);
  54. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  55. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult3 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  56. EXPECT_NEAR(1.0/6.0, quantitativeResult3.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  57. EXPECT_NEAR(1.0/6.0, quantitativeResult3.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  58. formula = formulaParser.parseSingleFormulaFromString("R=? [F \"done\"]");
  59. result = checker.check(*formula);
  60. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  61. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult4 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  62. EXPECT_NEAR(11.0/3.0, quantitativeResult4.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  63. EXPECT_NEAR(11.0/3.0, quantitativeResult4.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  64. }
  65. TEST(GmmxxHybridDtmcPrctlModelCheckerTest, Die_Sylvan) {
  66. storm::storage::SymbolicModelDescription modelDescription = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm");
  67. storm::prism::Program program = modelDescription.preprocess().asPrismProgram();
  68. // A parser that we use for conveniently constructing the formulas.
  69. auto expManager = std::make_shared<storm::expressions::ExpressionManager>();
  70. storm::parser::FormulaParser formulaParser(expManager);
  71. // Build the die model with its reward model.
  72. #ifdef WINDOWS
  73. storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  74. #else
  75. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  76. #endif
  77. options.buildAllRewardModels = false;
  78. options.rewardModelsToBuild.insert("coin_flips");
  79. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program, options);
  80. EXPECT_EQ(13ul, model->getNumberOfStates());
  81. EXPECT_EQ(20ul, model->getNumberOfTransitions());
  82. ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc);
  83. std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>();
  84. storm::modelchecker::HybridDtmcPrctlModelChecker<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan, double>> checker(*dtmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  85. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"one\"]");
  86. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  87. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  88. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult1 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  89. EXPECT_NEAR(1.0/6.0, quantitativeResult1.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  90. EXPECT_NEAR(1.0/6.0, quantitativeResult1.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  91. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"two\"]");
  92. result = checker.check(*formula);
  93. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  94. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult2 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  95. EXPECT_NEAR(1.0/6.0, quantitativeResult2.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  96. EXPECT_NEAR(1.0/6.0, quantitativeResult2.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  97. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"three\"]");
  98. result = checker.check(*formula);
  99. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  100. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult3 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  101. EXPECT_NEAR(1.0/6.0, quantitativeResult3.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  102. EXPECT_NEAR(1.0/6.0, quantitativeResult3.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  103. formula = formulaParser.parseSingleFormulaFromString("R=? [F \"done\"]");
  104. result = checker.check(*formula);
  105. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  106. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult4 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  107. EXPECT_NEAR(11.0/3.0, quantitativeResult4.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  108. EXPECT_NEAR(11.0/3.0, quantitativeResult4.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  109. }
  110. TEST(GmmxxHybridDtmcPrctlModelCheckerTest, Crowds_Cudd) {
  111. storm::storage::SymbolicModelDescription modelDescription = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/crowds-5-5.pm");
  112. storm::prism::Program program = modelDescription.preprocess().asPrismProgram();
  113. // A parser that we use for conveniently constructing the formulas.
  114. auto expManager = std::make_shared<storm::expressions::ExpressionManager>();
  115. storm::parser::FormulaParser formulaParser(expManager);
  116. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program);
  117. EXPECT_EQ(8607ul, model->getNumberOfStates());
  118. EXPECT_EQ(15113ul, model->getNumberOfTransitions());
  119. ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc);
  120. std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>();
  121. storm::modelchecker::HybridDtmcPrctlModelChecker<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD, double>> checker(*dtmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  122. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observe0Greater1\"]");
  123. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  124. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  125. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult1 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  126. EXPECT_NEAR(0.3328800375801578281, quantitativeResult1.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  127. EXPECT_NEAR(0.3328800375801578281, quantitativeResult1.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  128. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeIGreater1\"]");
  129. result = checker.check(*formula);
  130. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  131. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult2 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  132. EXPECT_NEAR(0.1522194965, quantitativeResult2.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  133. EXPECT_NEAR(0.1522194965, quantitativeResult2.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  134. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeOnlyTrueSender\"]");
  135. result = checker.check(*formula);
  136. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  137. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult3 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  138. EXPECT_NEAR(0.32153724292835045, quantitativeResult3.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  139. EXPECT_NEAR(0.32153724292835045, quantitativeResult3.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  140. }
  141. TEST(GmmxxHybridDtmcPrctlModelCheckerTest, Crowds_Sylvan) {
  142. storm::storage::SymbolicModelDescription modelDescription = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/crowds-5-5.pm");
  143. storm::prism::Program program = modelDescription.preprocess().asPrismProgram();
  144. // A parser that we use for conveniently constructing the formulas.
  145. auto expManager = std::make_shared<storm::expressions::ExpressionManager>();
  146. storm::parser::FormulaParser formulaParser(expManager);
  147. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program);
  148. EXPECT_EQ(8607ul, model->getNumberOfStates());
  149. EXPECT_EQ(15113ul, model->getNumberOfTransitions());
  150. ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc);
  151. std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>();
  152. storm::modelchecker::HybridDtmcPrctlModelChecker<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan, double>> checker(*dtmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  153. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observe0Greater1\"]");
  154. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  155. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  156. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult1 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  157. EXPECT_NEAR(0.3328800375801578281, quantitativeResult1.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  158. EXPECT_NEAR(0.3328800375801578281, quantitativeResult1.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  159. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeIGreater1\"]");
  160. result = checker.check(*formula);
  161. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  162. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult2 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  163. EXPECT_NEAR(0.1522194965, quantitativeResult2.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  164. EXPECT_NEAR(0.1522194965, quantitativeResult2.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  165. formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeOnlyTrueSender\"]");
  166. result = checker.check(*formula);
  167. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  168. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult3 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  169. EXPECT_NEAR(0.32153724292835045, quantitativeResult3.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  170. EXPECT_NEAR(0.32153724292835045, quantitativeResult3.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  171. }
  172. TEST(GmmxxHybridDtmcPrctlModelCheckerTest, SynchronousLeader_Cudd) {
  173. storm::storage::SymbolicModelDescription modelDescription = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader-3-5.pm");
  174. storm::prism::Program program = modelDescription.preprocess().asPrismProgram();
  175. // A parser that we use for conveniently constructing the formulas.
  176. auto expManager = std::make_shared<storm::expressions::ExpressionManager>();
  177. storm::parser::FormulaParser formulaParser(expManager);
  178. // Build the die model with its reward model.
  179. #ifdef WINDOWS
  180. storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  181. #else
  182. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  183. #endif
  184. options.buildAllRewardModels = false;
  185. options.rewardModelsToBuild.insert("num_rounds");
  186. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options);
  187. EXPECT_EQ(273ul, model->getNumberOfStates());
  188. EXPECT_EQ(397ul, model->getNumberOfTransitions());
  189. ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc);
  190. std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>();
  191. storm::modelchecker::HybridDtmcPrctlModelChecker<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD, double>> checker(*dtmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  192. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"elected\"]");
  193. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  194. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  195. storm::modelchecker::SymbolicQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult1 = result->asSymbolicQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  196. EXPECT_NEAR(1.0, quantitativeResult1.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  197. EXPECT_NEAR(1.0, quantitativeResult1.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  198. formula = formulaParser.parseSingleFormulaFromString("P=? [F<=20 \"elected\"]");
  199. result = checker.check(*formula);
  200. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  201. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult2 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  202. EXPECT_NEAR(0.99999989760000074, quantitativeResult2.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  203. EXPECT_NEAR(0.99999989760000074, quantitativeResult2.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  204. formula = formulaParser.parseSingleFormulaFromString("R=? [F \"elected\"]");
  205. result = checker.check(*formula);
  206. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
  207. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD>& quantitativeResult3 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  208. EXPECT_NEAR(1.0416666666666643, quantitativeResult3.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  209. EXPECT_NEAR(1.0416666666666643, quantitativeResult3.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  210. }
  211. TEST(GmmxxHybridDtmcPrctlModelCheckerTest, SynchronousLeader_Sylvan) {
  212. storm::storage::SymbolicModelDescription modelDescription = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader-3-5.pm");
  213. storm::prism::Program program = modelDescription.preprocess().asPrismProgram();
  214. // A parser that we use for conveniently constructing the formulas.
  215. auto expManager = std::make_shared<storm::expressions::ExpressionManager>();
  216. storm::parser::FormulaParser formulaParser(expManager);
  217. // Build the die model with its reward model.
  218. #ifdef WINDOWS
  219. storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  220. #else
  221. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  222. #endif
  223. options.buildAllRewardModels = false;
  224. options.rewardModelsToBuild.insert("num_rounds");
  225. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program, options);
  226. EXPECT_EQ(273ul, model->getNumberOfStates());
  227. EXPECT_EQ(397ul, model->getNumberOfTransitions());
  228. ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc);
  229. std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>();
  230. storm::modelchecker::HybridDtmcPrctlModelChecker<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan, double>> checker(*dtmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  231. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"elected\"]");
  232. std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*formula);
  233. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  234. storm::modelchecker::SymbolicQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult1 = result->asSymbolicQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  235. EXPECT_NEAR(1.0, quantitativeResult1.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  236. EXPECT_NEAR(1.0, quantitativeResult1.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  237. formula = formulaParser.parseSingleFormulaFromString("P=? [F<=20 \"elected\"]");
  238. result = checker.check(*formula);
  239. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  240. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult2 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  241. EXPECT_NEAR(0.99999989760000074, quantitativeResult2.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  242. EXPECT_NEAR(0.99999989760000074, quantitativeResult2.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  243. formula = formulaParser.parseSingleFormulaFromString("R=? [F \"elected\"]");
  244. result = checker.check(*formula);
  245. result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
  246. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan>& quantitativeResult3 = result->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  247. EXPECT_NEAR(1.0416666666666643, quantitativeResult3.getMin(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  248. EXPECT_NEAR(1.0416666666666643, quantitativeResult3.getMax(), storm::settings::getModule<storm::settings::modules::GmmxxEquationSolverSettings>().getPrecision());
  249. }