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.

73 lines
4.5 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/parser/AutoParser.h"
  4. #include "src/storage/StronglyConnectedComponentDecomposition.h"
  5. TEST(StronglyConnectedComponentDecomposition, FullSystem1) {
  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::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  9. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton));
  10. ASSERT_EQ(5, sccDecomposition.size());
  11. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true));
  12. ASSERT_EQ(2, sccDecomposition.size());
  13. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, true));
  14. ASSERT_EQ(2, sccDecomposition.size());
  15. markovAutomaton = nullptr;
  16. }
  17. TEST(StronglyConnectedComponentDecomposition, FullSystem2) {
  18. storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny2.tra", STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny2.lab", "", "");
  19. std::shared_ptr<storm::models::MarkovAutomaton<double>> markovAutomaton = parser.getModel<storm::models::MarkovAutomaton<double>>();
  20. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  21. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, false));
  22. ASSERT_EQ(sccDecomposition.size(), 2);
  23. // Now, because there is no ordering we have to check the contents of the MECs in a symmetrical way.
  24. storm::storage::StateBlock const& scc1 = sccDecomposition[0];
  25. storm::storage::StateBlock const& scc2 = sccDecomposition[1];
  26. std::vector<uint_fast64_t> correctScc1 = {1, 3, 8, 9, 10};
  27. std::vector<uint_fast64_t> correctScc2 = {4, 5, 6, 7};
  28. ASSERT_TRUE(scc1 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc1 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end()));
  29. ASSERT_TRUE(scc2 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc2 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end()));
  30. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, true));
  31. ASSERT_EQ(1, sccDecomposition.size());
  32. markovAutomaton = nullptr;
  33. }
  34. TEST(StronglyConnectedComponentDecomposition, MatrixBasedSystem) {
  35. storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/dtmc/scc/scc.tra", STORM_CPP_BASE_PATH "/examples/dtmc/scc/scc.lab", "", "");
  36. std::shared_ptr<storm::models::Dtmc<double>> dtmc = parser.getModel<storm::models::Dtmc<double>>();
  37. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  38. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true, false));
  39. ASSERT_EQ(sccDecomposition.size(), 3);
  40. // Now, because there is no ordering we have to check the contents of the MECs in a symmetrical way.
  41. storm::storage::StateBlock const& scc1 = sccDecomposition[0];
  42. storm::storage::StateBlock const& scc2 = sccDecomposition[1];
  43. storm::storage::StateBlock const& scc3 = sccDecomposition[2];
  44. std::vector<uint_fast64_t> correctScc1 = { 1, 2, 3, 4 };
  45. std::vector<uint_fast64_t> correctScc2 = { 5, 6, 7, 8 };
  46. std::vector<uint_fast64_t> correctScc3 = { 0 };
  47. ASSERT_TRUE(scc1 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc1 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end()) || scc1 == storm::storage::StateBlock(correctScc3.begin(), correctScc3.end()));
  48. ASSERT_TRUE(scc2 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc2 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end()) || scc2 == storm::storage::StateBlock(correctScc3.begin(), correctScc3.end()));
  49. ASSERT_TRUE(scc3 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc3 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end()) || scc3 == storm::storage::StateBlock(correctScc3.begin(), correctScc3.end()));
  50. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true, true));
  51. ASSERT_EQ(2, sccDecomposition.size());
  52. dtmc = nullptr;
  53. }