#include "gtest/gtest.h" #include "storm-config.h" #include "src/parser/AutoParser.h" #include "storage/DeterministicModelBisimulationDecomposition.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(13, result->getNumberOfStates()); EXPECT_EQ(20, 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(5, result->getNumberOfStates()); EXPECT_EQ(8, 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(5, result->getNumberOfStates()); EXPECT_EQ(8, 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(5, result->getNumberOfStates()); EXPECT_EQ(8, 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(334, result->getNumberOfStates()); EXPECT_EQ(546, 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(65, result->getNumberOfStates()); EXPECT_EQ(105, 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(43, result->getNumberOfStates()); EXPECT_EQ(83, 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(64, result->getNumberOfStates()); EXPECT_EQ(104, 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(64, result->getNumberOfStates()); EXPECT_EQ(104, 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(65, result->getNumberOfStates()); EXPECT_EQ(105, result->getNumberOfTransitions()); }