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.

58 lines
3.1 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/parser/PrismParser.h"
  4. #include "src/parser/FormulaParser.h"
  5. #include "src/builder/ExplicitModelBuilder.h"
  6. #include "src/storage/bisimulation/NondeterministicModelBisimulationDecomposition.h"
  7. #include "src/models/sparse/Mdp.h"
  8. #include "src/models/sparse/StandardRewardModel.h"
  9. TEST(NondeterministicModelBisimulationDecomposition, TwoDice) {
  10. storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/two_dice.nm");
  11. // Build the die model without its reward model.
  12. std::shared_ptr<storm::models::sparse::Model<double>> model = storm::builder::ExplicitModelBuilder<double>(program, storm::generator::NextStateGeneratorOptions(false, true)).build();
  13. ASSERT_EQ(model->getType(), storm::models::ModelType::Mdp);
  14. std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = model->as<storm::models::sparse::Mdp<double>>();
  15. storm::storage::NondeterministicModelBisimulationDecomposition<storm::models::sparse::Mdp<double>> bisim(*mdp);
  16. ASSERT_NO_THROW(bisim.computeBisimulationDecomposition());
  17. std::shared_ptr<storm::models::sparse::Model<double>> result;
  18. ASSERT_NO_THROW(result = bisim.getQuotient());
  19. EXPECT_EQ(storm::models::ModelType::Mdp, result->getType());
  20. EXPECT_EQ(77ul, result->getNumberOfStates());
  21. EXPECT_EQ(183ul, result->getNumberOfTransitions());
  22. EXPECT_EQ(97ul, result->as<storm::models::sparse::Mdp<double>>()->getNumberOfChoices());
  23. typename storm::storage::NondeterministicModelBisimulationDecomposition<storm::models::sparse::Mdp<double>>::Options options;
  24. options.respectedAtomicPropositions = std::set<std::string>({"two"});
  25. storm::storage::NondeterministicModelBisimulationDecomposition<storm::models::sparse::Mdp<double>> bisim2(*mdp, options);
  26. ASSERT_NO_THROW(bisim2.computeBisimulationDecomposition());
  27. ASSERT_NO_THROW(result = bisim2.getQuotient());
  28. EXPECT_EQ(storm::models::ModelType::Mdp, result->getType());
  29. EXPECT_EQ(11ul, result->getNumberOfStates());
  30. EXPECT_EQ(26ul, result->getNumberOfTransitions());
  31. EXPECT_EQ(14ul, result->as<storm::models::sparse::Mdp<double>>()->getNumberOfChoices());
  32. // A parser that we use for conveniently constructing the formulas.
  33. storm::parser::FormulaParser formulaParser;
  34. std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"two\"]");
  35. typename storm::storage::NondeterministicModelBisimulationDecomposition<storm::models::sparse::Mdp<double>>::Options options2(*mdp, *formula);
  36. storm::storage::NondeterministicModelBisimulationDecomposition<storm::models::sparse::Mdp<double>> bisim3(*mdp, options2);
  37. ASSERT_NO_THROW(bisim3.computeBisimulationDecomposition());
  38. ASSERT_NO_THROW(result = bisim3.getQuotient());
  39. EXPECT_EQ(storm::models::ModelType::Mdp, result->getType());
  40. EXPECT_EQ(11ul, result->getNumberOfStates());
  41. EXPECT_EQ(26ul, result->getNumberOfTransitions());
  42. EXPECT_EQ(14ul, result->as<storm::models::sparse::Mdp<double>>()->getNumberOfChoices());
  43. }