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.

88 lines
4.6 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/Settings.h"
  4. #include "src/parser/AutoParser.h"
  5. #include "src/utility/graph.h"
  6. #include "src/storage/StronglyConnectedComponentDecomposition.h"
  7. TEST(GraphTest, PerformProb01) {
  8. storm::parser::AutoParser<double> parser(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 = parser.getModel<storm::models::Dtmc<double>>();
  10. storm::storage::BitVector trueStates(dtmc->getNumberOfStates(), true);
  11. LOG4CPLUS_WARN(logger, "Computing prob01 (3 times) for crowds/crowds20_5...");
  12. std::pair<storm::storage::BitVector, storm::storage::BitVector> prob01(storm::utility::graph::performProb01(*dtmc, trueStates, storm::storage::BitVector(dtmc->getLabeledStates("observe0Greater1"))));
  13. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 1724414ull);
  14. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 46046ull);
  15. prob01 = storm::utility::graph::performProb01(*dtmc, trueStates, storm::storage::BitVector(dtmc->getLabeledStates("observeIGreater1")));
  16. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 574016ull);
  17. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 825797ull);
  18. prob01 = storm::utility::graph::performProb01(*dtmc, trueStates, storm::storage::BitVector(dtmc->getLabeledStates("observeOnlyTrueSender")));
  19. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 1785309ull);
  20. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 40992ull);
  21. LOG4CPLUS_WARN(logger, "Done.");
  22. dtmc = nullptr;
  23. storm::parser::AutoParser<double> parser2(STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.tra", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.lab", "", "");
  24. std::shared_ptr<storm::models::Dtmc<double>> dtmc2 = parser2.getModel<storm::models::Dtmc<double>>();
  25. trueStates = storm::storage::BitVector(dtmc2->getNumberOfStates(), true);
  26. LOG4CPLUS_WARN(logger, "Computing prob01 for synchronous_leader/leader6_8...");
  27. prob01 = storm::utility::graph::performProb01(*dtmc2, trueStates, storm::storage::BitVector(dtmc2->getLabeledStates("elected")));
  28. LOG4CPLUS_WARN(logger, "Done.");
  29. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  30. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 1312334ull);
  31. dtmc2 = nullptr;
  32. }
  33. TEST(GraphTest, PerformProb01MinMax) {
  34. storm::parser::AutoParser<double> parser(STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.tra", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.lab", "", "");
  35. std::shared_ptr<storm::models::Mdp<double>> mdp = parser.getModel<storm::models::Mdp<double>>();
  36. storm::storage::BitVector trueStates(mdp->getNumberOfStates(), true);
  37. LOG4CPLUS_WARN(logger, "Computing prob01min for asynchronous_leader/leader7...");
  38. std::pair<storm::storage::BitVector, storm::storage::BitVector> prob01(storm::utility::graph::performProb01Min(*mdp, trueStates, mdp->getLabeledStates("elected")));
  39. LOG4CPLUS_WARN(logger, "Done.");
  40. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  41. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 2095783ull);
  42. LOG4CPLUS_WARN(logger, "Computing prob01max for asynchronous_leader/leader7...");
  43. prob01 = storm::utility::graph::performProb01Max(*mdp, trueStates, mdp->getLabeledStates("elected"));
  44. LOG4CPLUS_WARN(logger, "Done.");
  45. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  46. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 2095783ull);
  47. mdp = nullptr;
  48. storm::parser::AutoParser<double> parser2(STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.tra", STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.lab", "", "");
  49. std::shared_ptr<storm::models::Mdp<double>> mdp2 = parser2.getModel<storm::models::Mdp<double>>();
  50. trueStates = storm::storage::BitVector(mdp2->getNumberOfStates(), true);
  51. LOG4CPLUS_WARN(logger, "Computing prob01min for consensus/coin4_6...");
  52. prob01 = storm::utility::graph::performProb01Min(*mdp2, trueStates, mdp2->getLabeledStates("finished"));
  53. LOG4CPLUS_WARN(logger, "Done.");
  54. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  55. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 63616ull);
  56. LOG4CPLUS_WARN(logger, "Computing prob01max for consensus/coin4_6...");
  57. prob01 = storm::utility::graph::performProb01Max(*mdp2, trueStates, mdp2->getLabeledStates("finished"));
  58. LOG4CPLUS_WARN(logger, "Done.");
  59. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  60. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 63616ull);
  61. mdp2 = nullptr;
  62. }