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.

96 lines
5.6 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/builder/ExplicitPrismModelBuilder.h"
  6. TEST(ExplicitPrismModelBuilderTest, Dtmc) {
  7. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm");
  8. std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  9. EXPECT_EQ(13, model->getNumberOfStates());
  10. EXPECT_EQ(20, model->getNumberOfTransitions());
  11. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/brp-16-2.pm");
  12. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  13. EXPECT_EQ(677, model->getNumberOfStates());
  14. EXPECT_EQ(867, model->getNumberOfTransitions());
  15. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/crowds-5-5.pm");
  16. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  17. EXPECT_EQ(8607, model->getNumberOfStates());
  18. EXPECT_EQ(15113, model->getNumberOfTransitions());
  19. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader-3-5.pm");
  20. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  21. EXPECT_EQ(273, model->getNumberOfStates());
  22. EXPECT_EQ(397, model->getNumberOfTransitions());
  23. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/nand-5-2.pm");
  24. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  25. EXPECT_EQ(1728, model->getNumberOfStates());
  26. EXPECT_EQ(2505, model->getNumberOfTransitions());
  27. }
  28. TEST(ExplicitPrismModelBuilderTest, Ctmc) {
  29. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  30. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableGeneralSettings().overridePrismCompatibilityMode(true);
  31. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/cluster2.sm");
  32. std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  33. EXPECT_EQ(276, model->getNumberOfStates());
  34. EXPECT_EQ(1120, model->getNumberOfTransitions());
  35. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/embedded2.sm");
  36. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  37. EXPECT_EQ(3478, model->getNumberOfStates());
  38. EXPECT_EQ(14639, model->getNumberOfTransitions());
  39. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/polling2.sm");
  40. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  41. EXPECT_EQ(12, model->getNumberOfStates());
  42. EXPECT_EQ(22, model->getNumberOfTransitions());
  43. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/fms2.sm");
  44. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  45. EXPECT_EQ(810, model->getNumberOfStates());
  46. EXPECT_EQ(3699, model->getNumberOfTransitions());
  47. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/tandem5.sm");
  48. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  49. EXPECT_EQ(66, model->getNumberOfStates());
  50. EXPECT_EQ(189, model->getNumberOfTransitions());
  51. }
  52. TEST(ExplicitPrismModelBuilderTest, Mdp) {
  53. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/two_dice.nm");
  54. std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  55. EXPECT_EQ(169, model->getNumberOfStates());
  56. EXPECT_EQ(436, model->getNumberOfTransitions());
  57. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader3.nm");
  58. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  59. EXPECT_EQ(364, model->getNumberOfStates());
  60. EXPECT_EQ(654, model->getNumberOfTransitions());
  61. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/coin2-2.nm");
  62. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  63. EXPECT_EQ(272, model->getNumberOfStates());
  64. EXPECT_EQ(492, model->getNumberOfTransitions());
  65. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/csma2-2.nm");
  66. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  67. EXPECT_EQ(1038, model->getNumberOfStates());
  68. EXPECT_EQ(1282, model->getNumberOfTransitions());
  69. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/firewire3-0.5.nm");
  70. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  71. EXPECT_EQ(4093, model->getNumberOfStates());
  72. EXPECT_EQ(5585, model->getNumberOfTransitions());
  73. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/wlan0-2-2.nm");
  74. model = storm::builder::ExplicitPrismModelBuilder<double>::translateProgram(program);
  75. EXPECT_EQ(37, model->getNumberOfStates());
  76. EXPECT_EQ(59, model->getNumberOfTransitions());
  77. }