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.

78 lines
4.2 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/Mdp.h"
  6. #include "src/models/Dtmc.h"
  7. TEST(StronglyConnectedComponentDecomposition, Crowds) {
  8. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.lab", "", "");
  9. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  10. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  11. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc));
  12. ASSERT_EQ(1290297ull, sccDecomposition.size());
  13. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true));
  14. ASSERT_EQ(1290297, sccDecomposition.size());
  15. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true, true));
  16. ASSERT_EQ(425040, sccDecomposition.size());
  17. dtmc = nullptr;
  18. }
  19. TEST(StronglyConnectedComponentDecomposition, SynchronousLeader) {
  20. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_9.tra", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_9.lab", "", "");
  21. std::shared_ptr<storm::models::Dtmc<double>> dtmc = abstractModel->as<storm::models::Dtmc<double>>();
  22. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  23. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc));
  24. ASSERT_EQ(2611835, sccDecomposition.size());
  25. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true));
  26. ASSERT_EQ(2611835, sccDecomposition.size());
  27. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true, true));
  28. ASSERT_EQ(1, sccDecomposition.size());
  29. dtmc = nullptr;
  30. }
  31. TEST(StronglyConnectedComponentDecomposition, AsynchronousLeader) {
  32. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.tra", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.lab", "", "");
  33. std::shared_ptr<storm::models::Mdp<double>> mdp = abstractModel->as<storm::models::Mdp<double>>();
  34. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  35. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp));
  36. ASSERT_EQ(1461930, sccDecomposition.size());
  37. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true));
  38. ASSERT_EQ(127, sccDecomposition.size());
  39. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true));
  40. ASSERT_EQ(127, sccDecomposition.size());
  41. mdp = nullptr;
  42. }
  43. TEST(StronglyConnectedComponentDecomposition, Consensus) {
  44. std::shared_ptr<storm::models::AbstractModel<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin6_4.tra", STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin6_4.lab", "", "");
  45. std::shared_ptr<storm::models::Mdp<double>> mdp = abstractModel->as<storm::models::Mdp<double>>();
  46. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  47. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp));
  48. ASSERT_EQ(121251, sccDecomposition.size());
  49. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true));
  50. ASSERT_EQ(1049, sccDecomposition.size());
  51. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true, true));
  52. ASSERT_EQ(384, sccDecomposition.size());
  53. mdp = nullptr;
  54. }