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.1 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/settings/SettingsManager.h"
  4. #include "src/parser/AutoParser.h"
  5. #include "src/utility/graph.h"
  6. #include "src/storage/StronglyConnectedComponentDecomposition.h"
  7. #include "src/models/sparse/Mdp.h"
  8. #include "src/models/sparse/Dtmc.h"
  9. #include "src/models/sparse/StandardRewardModel.h"
  10. TEST(GraphTest, ExplicitProb01) {
  11. 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", "", "");
  12. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  13. storm::storage::BitVector trueStates(dtmc->getNumberOfStates(), true);
  14. std::pair<storm::storage::BitVector, storm::storage::BitVector> prob01(storm::utility::graph::performProb01(*dtmc, trueStates, dtmc->getStates("observe0Greater1")));
  15. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 1724414ull);
  16. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 46046ull);
  17. prob01 = storm::utility::graph::performProb01(*dtmc, trueStates, dtmc->getStates("observeIGreater1"));
  18. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 574016ull);
  19. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 825797ull);
  20. prob01 = storm::utility::graph::performProb01(*dtmc, trueStates, dtmc->getStates("observeOnlyTrueSender"));
  21. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 1785309ull);
  22. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 40992ull);
  23. dtmc = nullptr;
  24. 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", "", "");
  25. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc2 = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  26. trueStates = storm::storage::BitVector(dtmc2->getNumberOfStates(), true);
  27. prob01 = storm::utility::graph::performProb01(*dtmc2, trueStates, storm::storage::BitVector(dtmc2->getStates("elected")));
  28. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  29. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 1312334ull);
  30. dtmc2 = nullptr;
  31. }
  32. TEST(GraphTest, PerformProb01MinMax) {
  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::BitVector trueStates(mdp->getNumberOfStates(), true);
  36. std::pair<storm::storage::BitVector, storm::storage::BitVector> prob01(storm::utility::graph::performProb01Min(*mdp, trueStates, mdp->getStates("elected")));
  37. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  38. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 2095783ull);
  39. prob01 = storm::utility::graph::performProb01Max(*mdp, trueStates, mdp->getStates("elected"));
  40. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  41. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 2095783ull);
  42. mdp = nullptr;
  43. 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", "", "");
  44. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp2 = abstractModel->as<storm::models::sparse::Mdp<double>>();
  45. trueStates = storm::storage::BitVector(mdp2->getNumberOfStates(), true);
  46. prob01 = storm::utility::graph::performProb01Min(*mdp2, trueStates, mdp2->getStates("finished"));
  47. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  48. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 63616ull);
  49. prob01 = storm::utility::graph::performProb01Max(*mdp2, trueStates, mdp2->getStates("finished"));
  50. ASSERT_EQ(prob01.first.getNumberOfSetBits(), 0ull);
  51. ASSERT_EQ(prob01.second.getNumberOfSetBits(), 63616ull);
  52. mdp2 = nullptr;
  53. }