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.

46 lines
2.6 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. }