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.

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