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.

128 lines
7.1 KiB

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