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.

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