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