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.

140 lines
6.8 KiB

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