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.

141 lines
6.8 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/parser/AutoParser.h"
  4. #include "src/storage/DeterministicModelBisimulationDecomposition.h"
  5. #include "src/models/sparse/StandardRewardModel.h"
  6. TEST(DeterministicModelBisimulationDecomposition, Die) {
  7. std::shared_ptr<storm::models::sparse::Model<double>> abstractModel = storm::parser::AutoParser<>::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/die/die.tra", STORM_CPP_BASE_PATH "/examples/dtmc/die/die.lab", "", "");
  8. ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
  9. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  10. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim(*dtmc);
  11. std::shared_ptr<storm::models::sparse::Model<double>> result;
  12. ASSERT_NO_THROW(result = bisim.getQuotient());
  13. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  14. EXPECT_EQ(13ul, result->getNumberOfStates());
  15. EXPECT_EQ(20ul, result->getNumberOfTransitions());
  16. #ifdef WINDOWS
  17. storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options;
  18. #else
  19. typename storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options;
  20. #endif
  21. options.respectedAtomicPropositions = std::set<std::string>({"one"});
  22. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim2(*dtmc, options);
  23. ASSERT_NO_THROW(result = bisim2.getQuotient());
  24. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  25. EXPECT_EQ(5ul, result->getNumberOfStates());
  26. EXPECT_EQ(8ul, result->getNumberOfTransitions());
  27. options.bounded = false;
  28. options.weak = true;
  29. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim3(*dtmc, options);
  30. ASSERT_NO_THROW(result = bisim3.getQuotient());
  31. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  32. EXPECT_EQ(5ul, result->getNumberOfStates());
  33. EXPECT_EQ(8ul, result->getNumberOfTransitions());
  34. auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("one");
  35. auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula);
  36. #ifdef WINDOWS
  37. storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options2(*dtmc, *eventuallyFormula);
  38. #else
  39. typename storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options2(*dtmc, *eventuallyFormula);
  40. #endif
  41. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim4(*dtmc, options2);
  42. ASSERT_NO_THROW(result = bisim4.getQuotient());
  43. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  44. EXPECT_EQ(5ul, result->getNumberOfStates());
  45. EXPECT_EQ(8ul, result->getNumberOfTransitions());
  46. }
  47. TEST(DeterministicModelBisimulationDecomposition, Crowds) {
  48. std::shared_ptr<storm::models::sparse::Model<double>> abstractModel = storm::parser::AutoParser<>::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds5_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds5_5.lab", "", "");
  49. ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc);
  50. std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>();
  51. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim(*dtmc);
  52. std::shared_ptr<storm::models::sparse::Model<double>> result;
  53. ASSERT_NO_THROW(result = bisim.getQuotient());
  54. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  55. EXPECT_EQ(334ul, result->getNumberOfStates());
  56. EXPECT_EQ(546ul, result->getNumberOfTransitions());
  57. #ifdef WINDOWS
  58. storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options;
  59. #else
  60. typename storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options;
  61. #endif
  62. options.respectedAtomicPropositions = std::set<std::string>({"observe0Greater1"});
  63. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim2(*dtmc, options);
  64. ASSERT_NO_THROW(result = bisim2.getQuotient());
  65. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  66. EXPECT_EQ(65ul, result->getNumberOfStates());
  67. EXPECT_EQ(105ul, result->getNumberOfTransitions());
  68. options.bounded = false;
  69. options.weak = true;
  70. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim3(*dtmc, options);
  71. ASSERT_NO_THROW(result = bisim3.getQuotient());
  72. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  73. EXPECT_EQ(43ul, result->getNumberOfStates());
  74. EXPECT_EQ(83ul, result->getNumberOfTransitions());
  75. auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("observe0Greater1");
  76. auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula);
  77. #ifdef WINDOWS
  78. storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options2(*dtmc, *eventuallyFormula);
  79. #else
  80. typename storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options2(*dtmc, *eventuallyFormula);
  81. #endif
  82. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim4(*dtmc, options2);
  83. ASSERT_NO_THROW(result = bisim4.getQuotient());
  84. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  85. EXPECT_EQ(64ul, result->getNumberOfStates());
  86. EXPECT_EQ(104ul, result->getNumberOfTransitions());
  87. auto probabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(eventuallyFormula);
  88. #ifdef WINDOWS
  89. storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options3(*dtmc, *probabilityOperatorFormula);
  90. #else
  91. typename storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options3(*dtmc, *probabilityOperatorFormula);
  92. #endif
  93. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim5(*dtmc, options3);
  94. ASSERT_NO_THROW(result = bisim5.getQuotient());
  95. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  96. EXPECT_EQ(64ul, result->getNumberOfStates());
  97. EXPECT_EQ(104ul, result->getNumberOfTransitions());
  98. auto boundedUntilFormula = std::make_shared<storm::logic::BoundedUntilFormula>(std::make_shared<storm::logic::BooleanLiteralFormula>(true), labelFormula, 50);
  99. #ifdef WINDOWS
  100. storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options4(*dtmc, *boundedUntilFormula);
  101. #else
  102. typename storm::storage::DeterministicModelBisimulationDecomposition<double>::Options options4(*dtmc, *boundedUntilFormula);
  103. #endif
  104. storm::storage::DeterministicModelBisimulationDecomposition<double> bisim6(*dtmc, options4);
  105. ASSERT_NO_THROW(result = bisim6.getQuotient());
  106. EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType());
  107. EXPECT_EQ(65ul, result->getNumberOfStates());
  108. EXPECT_EQ(105ul, result->getNumberOfTransitions());
  109. }