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.

49 lines
2.8 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/parser/AutoParser.h"
  4. #include "src/storage/StronglyConnectedComponentDecomposition.h"
  5. #include "src/models/MarkovAutomaton.h"
  6. TEST(StronglyConnectedComponentDecomposition, FullSystem1) {
  7. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.tra", STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny1.lab", "", "");
  8. std::shared_ptr<storm::models::MarkovAutomaton<double>> markovAutomaton = abstractModel->as<storm::models::MarkovAutomaton<double>>();
  9. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  10. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton));
  11. ASSERT_EQ(5, sccDecomposition.size());
  12. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true));
  13. ASSERT_EQ(2, sccDecomposition.size());
  14. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, true));
  15. ASSERT_EQ(2, sccDecomposition.size());
  16. markovAutomaton = nullptr;
  17. }
  18. TEST(StronglyConnectedComponentDecomposition, FullSystem2) {
  19. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny2.tra", STORM_CPP_BASE_PATH "/examples/ma/tiny/tiny2.lab", "", "");
  20. std::shared_ptr<storm::models::MarkovAutomaton<double>> markovAutomaton = abstractModel->as<storm::models::MarkovAutomaton<double>>();
  21. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  22. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, false));
  23. ASSERT_EQ(sccDecomposition.size(), 2);
  24. // Now, because there is no ordering we have to check the contents of the MECs in a symmetrical way.
  25. storm::storage::StateBlock const& scc1 = sccDecomposition[0];
  26. storm::storage::StateBlock const& scc2 = sccDecomposition[1];
  27. std::vector<uint_fast64_t> correctScc1 = {1, 3, 8, 9, 10};
  28. std::vector<uint_fast64_t> correctScc2 = {4, 5, 6, 7};
  29. ASSERT_TRUE(scc1 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc1 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end()));
  30. ASSERT_TRUE(scc2 == storm::storage::StateBlock(correctScc1.begin(), correctScc1.end()) || scc2 == storm::storage::StateBlock(correctScc2.begin(), correctScc2.end()));
  31. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*markovAutomaton, true, true));
  32. ASSERT_EQ(1, sccDecomposition.size());
  33. markovAutomaton = nullptr;
  34. }