#include "gtest/gtest.h" #include "storm-config.h" #include "src/parser/PrismParser.h" #include "src/parser/FormulaParser.h" #include "src/builder/ExplicitPrismModelBuilder.h" #include "src/storage/bisimulation/NondeterministicModelBisimulationDecomposition.h" #include "src/models/sparse/Mdp.h" #include "src/models/sparse/StandardRewardModel.h" TEST(NondeterministicModelBisimulationDecomposition, TwoDice) { storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/two_dice.nm"); // Build the die model without its reward model. std::shared_ptr> model = storm::builder::ExplicitPrismModelBuilder().translateProgram(program); ASSERT_EQ(model->getType(), storm::models::ModelType::Mdp); std::shared_ptr> mdp = model->as>(); storm::storage::NondeterministicModelBisimulationDecomposition> bisim(*mdp); ASSERT_NO_THROW(bisim.computeBisimulationDecomposition()); std::shared_ptr> result; ASSERT_NO_THROW(result = bisim.getQuotient()); EXPECT_EQ(storm::models::ModelType::Mdp, result->getType()); EXPECT_EQ(77ul, result->getNumberOfStates()); EXPECT_EQ(183ul, result->getNumberOfTransitions()); EXPECT_EQ(97ul, result->as>()->getNumberOfChoices()); typename storm::storage::NondeterministicModelBisimulationDecomposition>::Options options; options.respectedAtomicPropositions = std::set({"two"}); storm::storage::NondeterministicModelBisimulationDecomposition> bisim2(*mdp, options); ASSERT_NO_THROW(bisim2.computeBisimulationDecomposition()); ASSERT_NO_THROW(result = bisim2.getQuotient()); EXPECT_EQ(storm::models::ModelType::Mdp, result->getType()); EXPECT_EQ(11ul, result->getNumberOfStates()); EXPECT_EQ(26ul, result->getNumberOfTransitions()); EXPECT_EQ(14ul, result->as>()->getNumberOfChoices()); // A parser that we use for conveniently constructing the formulas. storm::parser::FormulaParser formulaParser; std::shared_ptr formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"two\"]"); typename storm::storage::NondeterministicModelBisimulationDecomposition>::Options options2(*mdp, *formula); storm::storage::NondeterministicModelBisimulationDecomposition> bisim3(*mdp, options2); ASSERT_NO_THROW(bisim3.computeBisimulationDecomposition()); ASSERT_NO_THROW(result = bisim3.getQuotient()); EXPECT_EQ(storm::models::ModelType::Mdp, result->getType()); EXPECT_EQ(11ul, result->getNumberOfStates()); EXPECT_EQ(26ul, result->getNumberOfTransitions()); EXPECT_EQ(14ul, result->as>()->getNumberOfChoices()); }