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.

629 lines
53 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/SettingMemento.h"
  4. #include "src/parser/PrismParser.h"
  5. #include "src/parser/FormulaParser.h"
  6. #include "src/logic/Formulas.h"
  7. #include "src/builder/DdPrismModelBuilder.h"
  8. #include "src/storage/dd/DdType.h"
  9. #include "src/solver/GmmxxLinearEquationSolver.h"
  10. #include "src/models/symbolic/StandardRewardModel.h"
  11. #include "src/modelchecker/csl/HybridCtmcCslModelChecker.h"
  12. #include "src/modelchecker/results/HybridQuantitativeCheckResult.h"
  13. #include "src/modelchecker/results/SymbolicQualitativeCheckResult.h"
  14. #include "src/modelchecker/results/SymbolicQuantitativeCheckResult.h"
  15. #include "src/settings/SettingsManager.h"
  16. #include "src/settings/modules/GeneralSettings.h"
  17. #include "src/settings/modules/IOSettings.h"
  18. #include "src/settings/modules/GmmxxEquationSolverSettings.h"
  19. #include "src/settings/modules/NativeEquationSolverSettings.h"
  20. TEST(GmmxxHybridCtmcCslModelCheckerTest, Cluster_Cudd) {
  21. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  22. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  23. // Parse the model description.
  24. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/cluster2.sm");
  25. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  26. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  27. // Build the model.
  28. #ifdef WINDOWS
  29. storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  30. #else
  31. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  32. #endif
  33. options.buildAllRewardModels = false;
  34. options.rewardModelsToBuild.insert("num_repairs");
  35. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options);
  36. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  37. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>>();
  38. // Create model checker.
  39. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::CUDD, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  40. // Start checking properties.
  41. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=100 !\"minimum\"]");
  42. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  43. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  44. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  45. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  46. EXPECT_NEAR(5.5461254704419085E-5, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  47. EXPECT_NEAR(5.5461254704419085E-5, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  48. formula = formulaParser.parseSingleFormulaFromString("P=? [ F[100,100] !\"minimum\"]");
  49. checkResult = modelchecker.check(*formula);
  50. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  51. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  52. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  53. EXPECT_NEAR(2.3397873548343415E-6, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  54. EXPECT_NEAR(2.3397873548343415E-6, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  55. formula = formulaParser.parseSingleFormulaFromString("P=? [ F[100,2000] !\"minimum\"]");
  56. checkResult = modelchecker.check(*formula);
  57. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  58. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  59. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult3 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  60. EXPECT_NEAR(0.001105335651670241, quantitativeCheckResult3.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  61. EXPECT_NEAR(0.001105335651670241, quantitativeCheckResult3.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  62. formula = formulaParser.parseSingleFormulaFromString("P=? [ \"minimum\" U<=10 \"premium\"]");
  63. checkResult = modelchecker.check(*formula);
  64. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  65. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  66. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult4 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  67. EXPECT_NEAR(1, quantitativeCheckResult4.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  68. EXPECT_NEAR(1, quantitativeCheckResult4.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  69. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"minimum\" U[1,inf] \"minimum\"]");
  70. checkResult = modelchecker.check(*formula);
  71. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  72. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  73. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult5 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  74. EXPECT_NEAR(0, quantitativeCheckResult5.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  75. EXPECT_NEAR(0, quantitativeCheckResult5.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  76. formula = formulaParser.parseSingleFormulaFromString("P=? [ \"minimum\" U[1,inf] !\"minimum\"]");
  77. checkResult = modelchecker.check(*formula);
  78. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  79. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  80. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult6 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  81. EXPECT_NEAR(0.9999999033633374, quantitativeCheckResult6.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  82. EXPECT_NEAR(0.9999999033633374, quantitativeCheckResult6.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  83. formula = formulaParser.parseSingleFormulaFromString("R=? [C<=100]");
  84. checkResult = modelchecker.check(*formula);
  85. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  86. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  87. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult7 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  88. EXPECT_NEAR(0.8602815057967503, quantitativeCheckResult7.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  89. EXPECT_NEAR(0.8602815057967503, quantitativeCheckResult7.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  90. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"minimum\"]");
  91. checkResult = modelchecker.check(*formula);
  92. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  93. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult8 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  94. EXPECT_NEAR(0.99999766034263426, quantitativeCheckResult8.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  95. EXPECT_NEAR(0.99999766034263426, quantitativeCheckResult8.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  96. }
  97. TEST(GmmxxHybridCtmcCslModelCheckerTest, Cluster_Sylvan) {
  98. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  99. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  100. // Parse the model description.
  101. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/cluster2.sm");
  102. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  103. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  104. // Build the model.
  105. #ifdef WINDOWS
  106. storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  107. #else
  108. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  109. #endif
  110. options.buildAllRewardModels = false;
  111. options.rewardModelsToBuild.insert("num_repairs");
  112. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program, options);
  113. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  114. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>>();
  115. // Create model checker.
  116. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::Sylvan, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  117. // Start checking properties.
  118. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=100 !\"minimum\"]");
  119. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  120. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  121. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  122. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  123. EXPECT_NEAR(5.5461254704419085E-5, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  124. EXPECT_NEAR(5.5461254704419085E-5, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  125. formula = formulaParser.parseSingleFormulaFromString("P=? [ F[100,100] !\"minimum\"]");
  126. checkResult = modelchecker.check(*formula);
  127. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  128. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  129. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  130. EXPECT_NEAR(2.3397873548343415E-6, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  131. EXPECT_NEAR(2.3397873548343415E-6, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  132. formula = formulaParser.parseSingleFormulaFromString("P=? [ F[100,2000] !\"minimum\"]");
  133. checkResult = modelchecker.check(*formula);
  134. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  135. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  136. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult3 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  137. EXPECT_NEAR(0.001105335651670241, quantitativeCheckResult3.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  138. EXPECT_NEAR(0.001105335651670241, quantitativeCheckResult3.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  139. formula = formulaParser.parseSingleFormulaFromString("P=? [ \"minimum\" U<=10 \"premium\"]");
  140. checkResult = modelchecker.check(*formula);
  141. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  142. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  143. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult4 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  144. EXPECT_NEAR(1, quantitativeCheckResult4.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  145. EXPECT_NEAR(1, quantitativeCheckResult4.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  146. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"minimum\" U[1,inf] \"minimum\"]");
  147. checkResult = modelchecker.check(*formula);
  148. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  149. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  150. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult5 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  151. EXPECT_NEAR(0, quantitativeCheckResult5.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  152. EXPECT_NEAR(0, quantitativeCheckResult5.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  153. formula = formulaParser.parseSingleFormulaFromString("P=? [ \"minimum\" U[1,inf] !\"minimum\"]");
  154. checkResult = modelchecker.check(*formula);
  155. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  156. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  157. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult6 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  158. EXPECT_NEAR(0.9999999033633374, quantitativeCheckResult6.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  159. EXPECT_NEAR(0.9999999033633374, quantitativeCheckResult6.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  160. formula = formulaParser.parseSingleFormulaFromString("R=? [C<=100]");
  161. checkResult = modelchecker.check(*formula);
  162. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  163. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  164. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult7 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  165. EXPECT_NEAR(0.8602815057967503, quantitativeCheckResult7.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  166. EXPECT_NEAR(0.8602815057967503, quantitativeCheckResult7.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  167. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"minimum\"]");
  168. checkResult = modelchecker.check(*formula);
  169. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  170. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult8 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  171. EXPECT_NEAR(0.99999766034263426, quantitativeCheckResult8.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  172. EXPECT_NEAR(0.99999766034263426, quantitativeCheckResult8.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  173. }
  174. TEST(GmmxxHybridCtmcCslModelCheckerTest, Embedded_Cudd) {
  175. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  176. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  177. // Parse the model description.
  178. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/embedded2.sm");
  179. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  180. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  181. // Build the model.
  182. #ifdef WINDOWS
  183. storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  184. #else
  185. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  186. #endif
  187. options.buildAllRewardModels = false;
  188. options.rewardModelsToBuild.insert("up");
  189. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options);
  190. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  191. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>>();
  192. // Create model checker.
  193. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::CUDD, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  194. // Start checking properties.
  195. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=10000 \"down\"]");
  196. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  197. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  198. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  199. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  200. EXPECT_NEAR(0.0019216435246119591, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  201. EXPECT_NEAR(0.0019216435246119591, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  202. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"down\" U<=10000 \"fail_actuators\"]");
  203. checkResult = modelchecker.check(*formula);
  204. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  205. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  206. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  207. EXPECT_NEAR(3.7079151806696567E-6, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  208. EXPECT_NEAR(3.7079151806696567E-6, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  209. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"down\" U<=10000 \"fail_io\"]");
  210. checkResult = modelchecker.check(*formula);
  211. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  212. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  213. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult3 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  214. EXPECT_NEAR(0.001556839327673734, quantitativeCheckResult3.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  215. EXPECT_NEAR(0.001556839327673734, quantitativeCheckResult3.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  216. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"down\" U<=10000 \"fail_sensors\"]");
  217. checkResult = modelchecker.check(*formula);
  218. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  219. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  220. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult4 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  221. EXPECT_NEAR(4.429620626755424E-5, quantitativeCheckResult4.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  222. EXPECT_NEAR(4.429620626755424E-5, quantitativeCheckResult4.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  223. formula = formulaParser.parseSingleFormulaFromString("R=? [C<=10000]");
  224. checkResult = modelchecker.check(*formula);
  225. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  226. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  227. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult5 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  228. EXPECT_NEAR(2.7745274082080154, quantitativeCheckResult5.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  229. EXPECT_NEAR(2.7745274082080154, quantitativeCheckResult5.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  230. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"fail_sensors\"]");
  231. checkResult = modelchecker.check(*formula);
  232. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  233. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult6 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  234. EXPECT_NEAR(0.934586179, quantitativeCheckResult6.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  235. EXPECT_NEAR(0.934586179, quantitativeCheckResult6.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  236. }
  237. TEST(GmmxxHybridCtmcCslModelCheckerTest, Embedded_Sylvan) {
  238. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  239. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  240. // Parse the model description.
  241. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/embedded2.sm");
  242. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  243. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  244. // Build the model.
  245. #ifdef WINDOWS
  246. storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  247. #else
  248. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  249. #endif
  250. options.buildAllRewardModels = false;
  251. options.rewardModelsToBuild.insert("up");
  252. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program, options);
  253. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  254. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>>();
  255. // Create model checker.
  256. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::Sylvan, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  257. // Start checking properties.
  258. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=10000 \"down\"]");
  259. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  260. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  261. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  262. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  263. EXPECT_NEAR(0.0019216435246119591, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  264. EXPECT_NEAR(0.0019216435246119591, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  265. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"down\" U<=10000 \"fail_actuators\"]");
  266. checkResult = modelchecker.check(*formula);
  267. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  268. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  269. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  270. EXPECT_NEAR(3.7079151806696567E-6, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  271. EXPECT_NEAR(3.7079151806696567E-6, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  272. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"down\" U<=10000 \"fail_io\"]");
  273. checkResult = modelchecker.check(*formula);
  274. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  275. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  276. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult3 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  277. EXPECT_NEAR(0.001556839327673734, quantitativeCheckResult3.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  278. EXPECT_NEAR(0.001556839327673734, quantitativeCheckResult3.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  279. formula = formulaParser.parseSingleFormulaFromString("P=? [ !\"down\" U<=10000 \"fail_sensors\"]");
  280. checkResult = modelchecker.check(*formula);
  281. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  282. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  283. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult4 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  284. EXPECT_NEAR(4.429620626755424E-5, quantitativeCheckResult4.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  285. EXPECT_NEAR(4.429620626755424E-5, quantitativeCheckResult4.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  286. formula = formulaParser.parseSingleFormulaFromString("R=? [C<=10000]");
  287. checkResult = modelchecker.check(*formula);
  288. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  289. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  290. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult5 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  291. EXPECT_NEAR(2.7745274082080154, quantitativeCheckResult5.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  292. EXPECT_NEAR(2.7745274082080154, quantitativeCheckResult5.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  293. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"fail_sensors\"]");
  294. checkResult = modelchecker.check(*formula);
  295. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  296. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult6 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  297. EXPECT_NEAR(0.934586179, quantitativeCheckResult6.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  298. EXPECT_NEAR(0.934586179, quantitativeCheckResult6.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  299. }
  300. TEST(GmmxxHybridCtmcCslModelCheckerTest, Polling_Cudd) {
  301. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  302. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  303. // Parse the model description.
  304. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/polling2.sm");
  305. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  306. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  307. // Build the model.
  308. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program);
  309. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  310. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>>();
  311. // Create model checker.
  312. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::CUDD, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  313. // Start checking properties.
  314. formula = formulaParser.parseSingleFormulaFromString("P=?[ F<=10 \"target\"]");
  315. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  316. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  317. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  318. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  319. EXPECT_NEAR(1, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  320. EXPECT_NEAR(1, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  321. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"target\"]");
  322. checkResult = modelchecker.check(*formula);
  323. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  324. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  325. EXPECT_NEAR(0.20079750055570736, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  326. EXPECT_NEAR(0.20079750055570736, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  327. }
  328. TEST(GmmxxHybridCtmcCslModelCheckerTest, Polling_Sylvan) {
  329. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  330. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  331. // Parse the model description.
  332. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/polling2.sm");
  333. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  334. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  335. // Build the model.
  336. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program);
  337. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  338. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>>();
  339. // Create model checker.
  340. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::Sylvan, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  341. // Start checking properties.
  342. formula = formulaParser.parseSingleFormulaFromString("P=?[ F<=10 \"target\"]");
  343. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  344. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  345. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  346. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  347. EXPECT_NEAR(1, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  348. EXPECT_NEAR(1, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  349. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"target\"]");
  350. checkResult = modelchecker.check(*formula);
  351. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  352. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  353. EXPECT_NEAR(0.20079750055570736, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  354. EXPECT_NEAR(0.20079750055570736, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  355. }
  356. TEST(GmmxxHybridCtmcCslModelCheckerTest, Fms) {
  357. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  358. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  359. // No properties to check at this point.
  360. }
  361. TEST(GmmxxHybridCtmcCslModelCheckerTest, Tandem_Cudd) {
  362. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  363. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  364. // Parse the model description.
  365. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/tandem5.sm");
  366. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  367. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  368. // Build the model with the customers reward structure.
  369. #ifdef WINDOWS
  370. storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  371. #else
  372. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options;
  373. #endif
  374. options.buildAllRewardModels = false;
  375. options.rewardModelsToBuild.insert("customers");
  376. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options);
  377. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  378. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::CUDD>>();
  379. // Create model checker.
  380. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::CUDD, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  381. // Start checking properties.
  382. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=10 \"network_full\" ]");
  383. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  384. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  385. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  386. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  387. EXPECT_NEAR(0.015446370562428037, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  388. EXPECT_NEAR(0.015446370562428037, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  389. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=10 \"first_queue_full\" ]");
  390. checkResult = modelchecker.check(*formula);
  391. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  392. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  393. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  394. EXPECT_NEAR(0.999999837225515, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  395. EXPECT_NEAR(0.999999837225515, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  396. formula = formulaParser.parseSingleFormulaFromString("P=? [\"second_queue_full\" U<=1 !\"second_queue_full\"]");
  397. checkResult = modelchecker.check(*formula);
  398. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  399. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  400. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult3 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  401. EXPECT_NEAR(1, quantitativeCheckResult3.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  402. EXPECT_NEAR(1, quantitativeCheckResult3.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  403. formula = formulaParser.parseSingleFormulaFromString("R=? [I=10]");
  404. checkResult = modelchecker.check(*formula);
  405. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  406. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  407. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult4 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  408. EXPECT_NEAR(5.679243850315877, quantitativeCheckResult4.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  409. EXPECT_NEAR(5.679243850315877, quantitativeCheckResult4.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  410. formula = formulaParser.parseSingleFormulaFromString("R=? [C<=10]");
  411. checkResult = modelchecker.check(*formula);
  412. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  413. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  414. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult5 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  415. EXPECT_NEAR(55.44792186036232, quantitativeCheckResult5.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  416. EXPECT_NEAR(55.44792186036232, quantitativeCheckResult5.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  417. formula = formulaParser.parseSingleFormulaFromString("R=? [F \"first_queue_full\"&\"second_queue_full\"]");
  418. checkResult = modelchecker.check(*formula);
  419. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  420. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  421. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult6 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  422. EXPECT_NEAR(262.85103498583413, quantitativeCheckResult6.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  423. EXPECT_NEAR(262.85103498583413, quantitativeCheckResult6.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  424. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"first_queue_full\"]");
  425. checkResult = modelchecker.check(*formula);
  426. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  427. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::CUDD> quantitativeCheckResult7 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::CUDD, double>();
  428. EXPECT_NEAR(0.9100373532, quantitativeCheckResult7.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  429. EXPECT_NEAR(0.9100373532, quantitativeCheckResult7.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  430. }
  431. TEST(GmmxxHybridCtmcCslModelCheckerTest, Tandem_Sylvan) {
  432. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  433. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableIOSettings().overridePrismCompatibilityMode(true);
  434. // Parse the model description.
  435. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/tandem5.sm");
  436. storm::parser::FormulaParser formulaParser(program.getManager().getSharedPointer());
  437. std::shared_ptr<storm::logic::Formula const> formula(nullptr);
  438. // Build the model with the customers reward structure.
  439. #ifdef WINDOWS
  440. storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  441. #else
  442. typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options;
  443. #endif
  444. options.buildAllRewardModels = false;
  445. options.rewardModelsToBuild.insert("customers");
  446. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program, options);
  447. ASSERT_EQ(storm::models::ModelType::Ctmc, model->getType());
  448. std::shared_ptr<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>> ctmc = model->as<storm::models::symbolic::Ctmc<storm::dd::DdType::Sylvan>>();
  449. // Create model checker.
  450. storm::modelchecker::HybridCtmcCslModelChecker<storm::dd::DdType::Sylvan, double> modelchecker(*ctmc, std::make_unique<storm::solver::GmmxxLinearEquationSolverFactory<double>>());
  451. // Start checking properties.
  452. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=10 \"network_full\" ]");
  453. std::unique_ptr<storm::modelchecker::CheckResult> checkResult = modelchecker.check(*formula);
  454. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  455. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  456. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult1 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  457. EXPECT_NEAR(0.015446370562428037, quantitativeCheckResult1.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  458. EXPECT_NEAR(0.015446370562428037, quantitativeCheckResult1.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  459. formula = formulaParser.parseSingleFormulaFromString("P=? [ F<=10 \"first_queue_full\" ]");
  460. checkResult = modelchecker.check(*formula);
  461. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  462. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  463. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult2 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  464. EXPECT_NEAR(0.999999837225515, quantitativeCheckResult2.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  465. EXPECT_NEAR(0.999999837225515, quantitativeCheckResult2.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  466. formula = formulaParser.parseSingleFormulaFromString("P=? [\"second_queue_full\" U<=1 !\"second_queue_full\"]");
  467. checkResult = modelchecker.check(*formula);
  468. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  469. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  470. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult3 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  471. EXPECT_NEAR(1, quantitativeCheckResult3.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  472. EXPECT_NEAR(1, quantitativeCheckResult3.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  473. formula = formulaParser.parseSingleFormulaFromString("R=? [I=10]");
  474. checkResult = modelchecker.check(*formula);
  475. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  476. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  477. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult4 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  478. EXPECT_NEAR(5.679243850315877, quantitativeCheckResult4.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  479. EXPECT_NEAR(5.679243850315877, quantitativeCheckResult4.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  480. formula = formulaParser.parseSingleFormulaFromString("R=? [C<=10]");
  481. checkResult = modelchecker.check(*formula);
  482. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  483. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  484. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult5 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  485. EXPECT_NEAR(55.44792186036232, quantitativeCheckResult5.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  486. EXPECT_NEAR(55.44792186036232, quantitativeCheckResult5.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  487. formula = formulaParser.parseSingleFormulaFromString("R=? [F \"first_queue_full\"&\"second_queue_full\"]");
  488. checkResult = modelchecker.check(*formula);
  489. ASSERT_TRUE(checkResult->isHybridQuantitativeCheckResult());
  490. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  491. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult6 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  492. EXPECT_NEAR(262.85103498583413, quantitativeCheckResult6.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  493. EXPECT_NEAR(262.85103498583413, quantitativeCheckResult6.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  494. formula = formulaParser.parseSingleFormulaFromString("LRA=? [\"first_queue_full\"]");
  495. checkResult = modelchecker.check(*formula);
  496. checkResult->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(ctmc->getReachableStates(), ctmc->getInitialStates()));
  497. storm::modelchecker::HybridQuantitativeCheckResult<storm::dd::DdType::Sylvan> quantitativeCheckResult7 = checkResult->asHybridQuantitativeCheckResult<storm::dd::DdType::Sylvan, double>();
  498. EXPECT_NEAR(0.9100373532, quantitativeCheckResult7.getMin(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  499. EXPECT_NEAR(0.9100373532, quantitativeCheckResult7.getMax(), storm::settings::getModule<storm::settings::modules::GeneralSettings>().getPrecision());
  500. }