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.

79 lines
4.4 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/sparse/Mdp.h"
  6. #include "src/models/sparse/Dtmc.h"
  7. #include "src/models/sparse/StandardRewardModel.h"
  8. TEST(StronglyConnectedComponentDecomposition, Crowds) {
  9. std::shared_ptr<storm::models::sparse::Model<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", "", "");
  10. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  11. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  12. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc));
  13. ASSERT_EQ(1290297ul, sccDecomposition.size());
  14. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true));
  15. ASSERT_EQ(437690ul, sccDecomposition.size());
  16. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true, true));
  17. ASSERT_EQ(425040ul, sccDecomposition.size());
  18. dtmc = nullptr;
  19. }
  20. TEST(StronglyConnectedComponentDecomposition, SynchronousLeader) {
  21. std::shared_ptr<storm::models::sparse::Model<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", "", "");
  22. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  23. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  24. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc));
  25. ASSERT_EQ(2611835ul, sccDecomposition.size());
  26. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true));
  27. ASSERT_EQ(2ul, sccDecomposition.size());
  28. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*dtmc, true, true));
  29. ASSERT_EQ(1ul, sccDecomposition.size());
  30. dtmc = nullptr;
  31. }
  32. TEST(StronglyConnectedComponentDecomposition, AsynchronousLeader) {
  33. std::shared_ptr<storm::models::sparse::Model<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", "", "");
  34. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = abstractModel->as<storm::models::sparse::Mdp<double>>();
  35. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  36. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp));
  37. ASSERT_EQ(1461930ul, sccDecomposition.size());
  38. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true));
  39. ASSERT_EQ(127ul, sccDecomposition.size());
  40. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true, true));
  41. ASSERT_EQ(7ul, sccDecomposition.size());
  42. mdp = nullptr;
  43. }
  44. TEST(StronglyConnectedComponentDecomposition, Consensus) {
  45. std::shared_ptr<storm::models::sparse::Model<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", "", "");
  46. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = abstractModel->as<storm::models::sparse::Mdp<double>>();
  47. storm::storage::StronglyConnectedComponentDecomposition<double> sccDecomposition;
  48. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp));
  49. ASSERT_EQ(121251ul, sccDecomposition.size());
  50. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true));
  51. ASSERT_EQ(1049ul, sccDecomposition.size());
  52. ASSERT_NO_THROW(sccDecomposition = storm::storage::StronglyConnectedComponentDecomposition<double>(*mdp, true, true));
  53. ASSERT_EQ(384ul, sccDecomposition.size());
  54. mdp = nullptr;
  55. }