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.

105 lines
4.6 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/parser/AutoParser.h"
  4. #include "src/storage/MaximalEndComponentDecomposition.h"
  5. TEST(MaximalEndComponentDecomposition, FullSystem) {
  6. storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.tra", STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.lab", "", "");
  7. std::shared_ptr<storm::models::MarkovAutomaton<double>> markovAutomaton = parser.getModel<storm::models::MarkovAutomaton<double>>();
  8. storm::storage::MaximalEndComponentDecomposition<double> mecDecomposition;
  9. ASSERT_NO_THROW(mecDecomposition = storm::storage::MaximalEndComponentDecomposition<double>(*markovAutomaton));
  10. ASSERT_EQ(2, mecDecomposition.size());
  11. // Now, because there is no ordering we have to check the contents of the MECs in a symmetrical way.
  12. storm::storage::MaximalEndComponent const& mec1 = mecDecomposition[0];
  13. if (mec1.containsState(3)) {
  14. ASSERT_TRUE(mec1.containsState(8));
  15. ASSERT_TRUE(mec1.containsState(9));
  16. ASSERT_TRUE(mec1.containsState(10));
  17. ASSERT_FALSE(mec1.containsState(0));
  18. ASSERT_FALSE(mec1.containsState(1));
  19. ASSERT_FALSE(mec1.containsState(2));
  20. ASSERT_FALSE(mec1.containsState(4));
  21. ASSERT_FALSE(mec1.containsState(5));
  22. ASSERT_FALSE(mec1.containsState(6));
  23. ASSERT_FALSE(mec1.containsState(7));
  24. } else if (mec1.containsState(4)) {
  25. ASSERT_TRUE(mec1.containsState(5));
  26. ASSERT_TRUE(mec1.containsState(6));
  27. ASSERT_TRUE(mec1.containsState(7));
  28. ASSERT_FALSE(mec1.containsState(0));
  29. ASSERT_FALSE(mec1.containsState(1));
  30. ASSERT_FALSE(mec1.containsState(2));
  31. ASSERT_FALSE(mec1.containsState(3));
  32. ASSERT_FALSE(mec1.containsState(8));
  33. ASSERT_FALSE(mec1.containsState(9));
  34. ASSERT_FALSE(mec1.containsState(10));
  35. } else {
  36. // This case must never happen as the only two existing MECs contain either 3 or 4.
  37. ASSERT_TRUE(false);
  38. }
  39. storm::storage::MaximalEndComponent const& mec2 = mecDecomposition[1];
  40. if (mec2.containsState(3)) {
  41. ASSERT_TRUE(mec2.containsState(8));
  42. ASSERT_TRUE(mec2.containsState(9));
  43. ASSERT_TRUE(mec2.containsState(10));
  44. ASSERT_FALSE(mec2.containsState(0));
  45. ASSERT_FALSE(mec2.containsState(1));
  46. ASSERT_FALSE(mec2.containsState(2));
  47. ASSERT_FALSE(mec2.containsState(4));
  48. ASSERT_FALSE(mec2.containsState(5));
  49. ASSERT_FALSE(mec2.containsState(6));
  50. ASSERT_FALSE(mec2.containsState(7));
  51. } else if (mec2.containsState(4)) {
  52. ASSERT_TRUE(mec2.containsState(5));
  53. ASSERT_TRUE(mec2.containsState(6));
  54. ASSERT_TRUE(mec2.containsState(7));
  55. ASSERT_FALSE(mec2.containsState(0));
  56. ASSERT_FALSE(mec2.containsState(1));
  57. ASSERT_FALSE(mec2.containsState(2));
  58. ASSERT_FALSE(mec2.containsState(3));
  59. ASSERT_FALSE(mec2.containsState(8));
  60. ASSERT_FALSE(mec2.containsState(9));
  61. ASSERT_FALSE(mec2.containsState(10));
  62. } else {
  63. // This case must never happen as the only two existing MECs contain either 3 or 4.
  64. ASSERT_TRUE(false);
  65. }
  66. }
  67. TEST(MaximalEndComponentDecomposition, Subsystem) {
  68. storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.tra", STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.lab", "", "");
  69. std::shared_ptr<storm::models::MarkovAutomaton<double>> markovAutomaton = parser.getModel<storm::models::MarkovAutomaton<double>>();
  70. storm::storage::BitVector subsystem(markovAutomaton->getNumberOfStates(), true);
  71. subsystem.set(7, false);
  72. storm::storage::MaximalEndComponentDecomposition<double> mecDecomposition;
  73. ASSERT_NO_THROW(mecDecomposition = storm::storage::MaximalEndComponentDecomposition<double>(*markovAutomaton, subsystem));
  74. ASSERT_EQ(1, mecDecomposition.size());
  75. storm::storage::MaximalEndComponent const& mec1 = mecDecomposition[0];
  76. std::cout << mec1 << std::endl;
  77. if (mec1.containsState(3)) {
  78. ASSERT_TRUE(mec1.containsState(8));
  79. ASSERT_TRUE(mec1.containsState(9));
  80. ASSERT_TRUE(mec1.containsState(10));
  81. ASSERT_FALSE(mec1.containsState(0));
  82. ASSERT_FALSE(mec1.containsState(1));
  83. ASSERT_FALSE(mec1.containsState(2));
  84. ASSERT_FALSE(mec1.containsState(4));
  85. ASSERT_FALSE(mec1.containsState(5));
  86. ASSERT_FALSE(mec1.containsState(6));
  87. ASSERT_FALSE(mec1.containsState(7));
  88. } else {
  89. // This case must never happen as the only two existing MEC contains 3.
  90. ASSERT_TRUE(false);
  91. }
  92. }