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.

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