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.

99 lines
5.7 KiB

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