#include "gtest/gtest.h" #include "storm-config.h" #include "src/parser/AutoParser.h" #include "src/storage/DeterministicModelBisimulationDecomposition.h" #include "src/models/sparse/StandardRewardModel.h" TEST(DeterministicModelBisimulationDecomposition, Die) { std::shared_ptr> abstractModel = storm::parser::AutoParser<>::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/die/die.tra", STORM_CPP_BASE_PATH "/examples/dtmc/die/die.lab", "", ""); ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc); std::shared_ptr> dtmc = abstractModel->as>(); storm::storage::DeterministicModelBisimulationDecomposition bisim(*dtmc); std::shared_ptr> result; ASSERT_NO_THROW(result = bisim.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(13ul, result->getNumberOfStates()); EXPECT_EQ(20ul, result->getNumberOfTransitions()); #ifdef WINDOWS storm::storage::DeterministicModelBisimulationDecomposition::Options options; #else typename storm::storage::DeterministicModelBisimulationDecomposition::Options options; #endif options.respectedAtomicPropositions = std::set({"one"}); storm::storage::DeterministicModelBisimulationDecomposition bisim2(*dtmc, options); ASSERT_NO_THROW(result = bisim2.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(5ul, result->getNumberOfStates()); EXPECT_EQ(8ul, result->getNumberOfTransitions()); options.bounded = false; options.weak = true; storm::storage::DeterministicModelBisimulationDecomposition bisim3(*dtmc, options); ASSERT_NO_THROW(result = bisim3.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(5ul, result->getNumberOfStates()); EXPECT_EQ(8ul, result->getNumberOfTransitions()); auto labelFormula = std::make_shared("one"); auto eventuallyFormula = std::make_shared(labelFormula); #ifdef WINDOWS storm::storage::DeterministicModelBisimulationDecomposition::Options options2(*dtmc, *eventuallyFormula); #else typename storm::storage::DeterministicModelBisimulationDecomposition::Options options2(*dtmc, *eventuallyFormula); #endif storm::storage::DeterministicModelBisimulationDecomposition bisim4(*dtmc, options2); ASSERT_NO_THROW(result = bisim4.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(5ul, result->getNumberOfStates()); EXPECT_EQ(8ul, result->getNumberOfTransitions()); } TEST(DeterministicModelBisimulationDecomposition, Crowds) { std::shared_ptr> 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", "", ""); ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc); std::shared_ptr> dtmc = abstractModel->as>(); storm::storage::DeterministicModelBisimulationDecomposition bisim(*dtmc); std::shared_ptr> result; ASSERT_NO_THROW(result = bisim.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(334ul, result->getNumberOfStates()); EXPECT_EQ(546ul, result->getNumberOfTransitions()); #ifdef WINDOWS storm::storage::DeterministicModelBisimulationDecomposition::Options options; #else typename storm::storage::DeterministicModelBisimulationDecomposition::Options options; #endif options.respectedAtomicPropositions = std::set({"observe0Greater1"}); storm::storage::DeterministicModelBisimulationDecomposition bisim2(*dtmc, options); ASSERT_NO_THROW(result = bisim2.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(65ul, result->getNumberOfStates()); EXPECT_EQ(105ul, result->getNumberOfTransitions()); options.bounded = false; options.weak = true; storm::storage::DeterministicModelBisimulationDecomposition bisim3(*dtmc, options); ASSERT_NO_THROW(result = bisim3.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(43ul, result->getNumberOfStates()); EXPECT_EQ(83ul, result->getNumberOfTransitions()); auto labelFormula = std::make_shared("observe0Greater1"); auto eventuallyFormula = std::make_shared(labelFormula); #ifdef WINDOWS storm::storage::DeterministicModelBisimulationDecomposition::Options options2(*dtmc, *eventuallyFormula); #else typename storm::storage::DeterministicModelBisimulationDecomposition::Options options2(*dtmc, *eventuallyFormula); #endif storm::storage::DeterministicModelBisimulationDecomposition bisim4(*dtmc, options2); ASSERT_NO_THROW(result = bisim4.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(64ul, result->getNumberOfStates()); EXPECT_EQ(104ul, result->getNumberOfTransitions()); auto probabilityOperatorFormula = std::make_shared(eventuallyFormula); #ifdef WINDOWS storm::storage::DeterministicModelBisimulationDecomposition::Options options3(*dtmc, *probabilityOperatorFormula); #else typename storm::storage::DeterministicModelBisimulationDecomposition::Options options3(*dtmc, *probabilityOperatorFormula); #endif storm::storage::DeterministicModelBisimulationDecomposition bisim5(*dtmc, options3); ASSERT_NO_THROW(result = bisim5.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(64ul, result->getNumberOfStates()); EXPECT_EQ(104ul, result->getNumberOfTransitions()); auto boundedUntilFormula = std::make_shared(std::make_shared(true), labelFormula, 50); #ifdef WINDOWS storm::storage::DeterministicModelBisimulationDecomposition::Options options4(*dtmc, *boundedUntilFormula); #else typename storm::storage::DeterministicModelBisimulationDecomposition::Options options4(*dtmc, *boundedUntilFormula); #endif storm::storage::DeterministicModelBisimulationDecomposition bisim6(*dtmc, options4); ASSERT_NO_THROW(result = bisim6.getQuotient()); EXPECT_EQ(storm::models::ModelType::Dtmc, result->getType()); EXPECT_EQ(65ul, result->getNumberOfStates()); EXPECT_EQ(105ul, result->getNumberOfTransitions()); }