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.

132 lines
7.3 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/SettingMemento.h"
  4. #include "src/settings/SettingsManager.h"
  5. #include "src/settings/modules/GeneralSettings.h"
  6. #include "src/models/symbolic/Dtmc.h"
  7. #include "src/models/symbolic/Mdp.h"
  8. #include "src/storage/dd/CuddDd.h"
  9. #include "src/storage/dd/CuddAdd.h"
  10. #include "src/storage/dd/CuddBdd.h"
  11. #include "src/parser/PrismParser.h"
  12. #include "src/builder/DdPrismModelBuilder.h"
  13. TEST(DdPrismModelBuilderTest, Dtmc) {
  14. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm");
  15. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  16. EXPECT_EQ(13ul, model->getNumberOfStates());
  17. EXPECT_EQ(20ul, model->getNumberOfTransitions());
  18. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/brp-16-2.pm");
  19. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  20. EXPECT_EQ(677ul, model->getNumberOfStates());
  21. EXPECT_EQ(867ul, model->getNumberOfTransitions());
  22. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/crowds-5-5.pm");
  23. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  24. EXPECT_EQ(8607ul, model->getNumberOfStates());
  25. EXPECT_EQ(15113ul, model->getNumberOfTransitions());
  26. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader-3-5.pm");
  27. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  28. EXPECT_EQ(273ul, model->getNumberOfStates());
  29. EXPECT_EQ(397ul, model->getNumberOfTransitions());
  30. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/nand-5-2.pm");
  31. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  32. EXPECT_EQ(1728ul, model->getNumberOfStates());
  33. EXPECT_EQ(2505ul, model->getNumberOfTransitions());
  34. }
  35. TEST(DdPrismModelBuilderTest, Ctmc) {
  36. // Set the PRISM compatibility mode temporarily. It is set to its old value once the returned object is destructed.
  37. std::unique_ptr<storm::settings::SettingMemento> enablePrismCompatibility = storm::settings::mutableGeneralSettings().overridePrismCompatibilityMode(true);
  38. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/cluster2.sm");
  39. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  40. EXPECT_EQ(276ul, model->getNumberOfStates());
  41. EXPECT_EQ(1120ul, model->getNumberOfTransitions());
  42. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/embedded2.sm");
  43. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  44. EXPECT_EQ(3478ul, model->getNumberOfStates());
  45. EXPECT_EQ(14639ul, model->getNumberOfTransitions());
  46. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/polling2.sm");
  47. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  48. EXPECT_EQ(12ul, model->getNumberOfStates());
  49. EXPECT_EQ(22ul, model->getNumberOfTransitions());
  50. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/fms2.sm");
  51. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  52. EXPECT_EQ(810ul, model->getNumberOfStates());
  53. EXPECT_EQ(3699ul, model->getNumberOfTransitions());
  54. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/tandem5.sm");
  55. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  56. EXPECT_EQ(66ul, model->getNumberOfStates());
  57. EXPECT_EQ(189ul, model->getNumberOfTransitions());
  58. }
  59. TEST(DdPrismModelBuilderTest, Mdp) {
  60. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/two_dice.nm");
  61. std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  62. EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp);
  63. std::shared_ptr<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>> mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>();
  64. EXPECT_EQ(169ul, mdp->getNumberOfStates());
  65. EXPECT_EQ(436ul, mdp->getNumberOfTransitions());
  66. EXPECT_EQ(254ul, mdp->getNumberOfChoices());
  67. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader3.nm");
  68. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  69. EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp);
  70. mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>();
  71. EXPECT_EQ(364ul, mdp->getNumberOfStates());
  72. EXPECT_EQ(654ul, mdp->getNumberOfTransitions());
  73. EXPECT_EQ(573ul, mdp->getNumberOfChoices());
  74. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/coin2-2.nm");
  75. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  76. EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp);
  77. mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>();
  78. EXPECT_EQ(272ul, mdp->getNumberOfStates());
  79. EXPECT_EQ(492ul, mdp->getNumberOfTransitions());
  80. EXPECT_EQ(400ul, mdp->getNumberOfChoices());
  81. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/csma2-2.nm");
  82. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  83. EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp);
  84. mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>();
  85. EXPECT_EQ(1038ul, mdp->getNumberOfStates());
  86. EXPECT_EQ(1282ul, mdp->getNumberOfTransitions());
  87. EXPECT_EQ(1054ul, mdp->getNumberOfChoices());
  88. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/firewire3-0.5.nm");
  89. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  90. EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp);
  91. mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>();
  92. EXPECT_EQ(4093ul, mdp->getNumberOfStates());
  93. EXPECT_EQ(5585ul, mdp->getNumberOfTransitions());
  94. EXPECT_EQ(5519ul, mdp->getNumberOfChoices());
  95. program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/wlan0-2-2.nm");
  96. model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::translateProgram(program);
  97. EXPECT_TRUE(model->getType() == storm::models::ModelType::Mdp);
  98. mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>();
  99. EXPECT_EQ(37ul, mdp->getNumberOfStates());
  100. EXPECT_EQ(59ul, mdp->getNumberOfTransitions());
  101. EXPECT_EQ(59ul, mdp->getNumberOfChoices());
  102. }