#include "gtest/gtest.h" #include "storm-config.h" #include "src/utility/Settings.h" #include "src/modelchecker/GmmxxMdpPrctlModelChecker.h" #include "src/parser/AutoParser.h" TEST(GmmxxMdpPrctModelCheckerTest, AsynchronousLeader) { storm::settings::Settings* s = storm::settings::instance(); storm::parser::AutoParser parser(STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.tra", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.lab", "", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader7.trans.rew"); ASSERT_EQ(parser.getType(), storm::models::MDP); std::shared_ptr> mdp = parser.getModel>(); ASSERT_EQ(mdp->getNumberOfStates(), 2095783u); ASSERT_EQ(mdp->getNumberOfTransitions(), 7714385u); storm::modelchecker::GmmxxMdpPrctlModelChecker mc(*mdp); storm::property::prctl::Ap* apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::Eventually* eventuallyFormula = new storm::property::prctl::Eventually(apFormula); storm::property::prctl::ProbabilisticNoBoundOperator* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, true); std::vector* result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[0] - 1), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("elected"); eventuallyFormula = new storm::property::prctl::Eventually(apFormula); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, false); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[0] - 1), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::BoundedEventually* boundedEventuallyFormula = new storm::property::prctl::BoundedEventually(apFormula, 25); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(boundedEventuallyFormula, true); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[0] - 0), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("elected"); boundedEventuallyFormula = new storm::property::prctl::BoundedEventually(apFormula, 25); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(boundedEventuallyFormula, false); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[0] - 0), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("elected"); storm::property::prctl::ReachabilityReward* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); storm::property::prctl::RewardNoBoundOperator* rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, true); result = mc.checkNoBoundOperator(*rewardFormula); ASSERT_LT(std::abs((*result)[0] - 6.172433512), s->get("precision")); delete rewardFormula; delete result; apFormula = new storm::property::prctl::Ap("elected"); reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, false); result = mc.checkNoBoundOperator(*rewardFormula);; ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[0] - 6.1724344), s->get("precision")); delete rewardFormula; delete result; } TEST(GmmxxMdpPrctModelCheckerTest, Consensus) { storm::settings::Settings* s = storm::settings::instance(); storm::parser::AutoParser parser(STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.tra", STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.lab", STORM_CPP_BASE_PATH "/examples/mdp/consensus/coin4_6.steps.state.rew", ""); ASSERT_EQ(parser.getType(), storm::models::MDP); std::shared_ptr> mdp = parser.getModel>(); ASSERT_EQ(mdp->getNumberOfStates(), 63616u); ASSERT_EQ(mdp->getNumberOfTransitions(), 213472u); storm::modelchecker::GmmxxMdpPrctlModelChecker mc(*mdp); storm::property::prctl::Ap* apFormula = new storm::property::prctl::Ap("finished"); storm::property::prctl::Eventually* eventuallyFormula = new storm::property::prctl::Eventually(apFormula); storm::property::prctl::ProbabilisticNoBoundOperator* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, true); std::vector* result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[31168] - 1), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("finished"); storm::property::prctl::Ap* apFormula2 = new storm::property::prctl::Ap("all_coins_equal_0"); storm::property::prctl::And* andFormula = new storm::property::prctl::And(apFormula, apFormula2); eventuallyFormula = new storm::property::prctl::Eventually(andFormula); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, true); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[31168] - 0.4370098591707694546393), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("finished"); apFormula2 = new storm::property::prctl::Ap("all_coins_equal_1"); andFormula = new storm::property::prctl::And(apFormula, apFormula2); eventuallyFormula = new storm::property::prctl::Eventually(andFormula); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, false); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[31168] - 0.5282872761373342829216), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("finished"); apFormula2 = new storm::property::prctl::Ap("agree"); storm::property::prctl::Not* notFormula = new storm::property::prctl::Not(apFormula2); andFormula = new storm::property::prctl::And(apFormula, notFormula); eventuallyFormula = new storm::property::prctl::Eventually(andFormula); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, false); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[31168] - 0.10343451035775527713), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("finished"); storm::property::prctl::BoundedEventually* boundedEventuallyFormula = new storm::property::prctl::BoundedEventually(apFormula, 50); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(boundedEventuallyFormula, true); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[31168] - 0), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("finished"); boundedEventuallyFormula = new storm::property::prctl::BoundedEventually(apFormula, 50); probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(boundedEventuallyFormula, false); result = mc.checkNoBoundOperator(*probFormula); ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[31168] - 0), s->get("precision")); delete probFormula; delete result; apFormula = new storm::property::prctl::Ap("finished"); storm::property::prctl::ReachabilityReward* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); storm::property::prctl::RewardNoBoundOperator* rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, true); result = mc.checkNoBoundOperator(*rewardFormula); ASSERT_LT(std::abs((*result)[31168] - 1725.5933133943854045), s->get("precision")); delete rewardFormula; delete result; apFormula = new storm::property::prctl::Ap("finished"); reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, false); result = mc.checkNoBoundOperator(*rewardFormula);; ASSERT_NE(nullptr, result); ASSERT_LT(std::abs((*result)[31168] - 2179.014847073392047605011), s->get("precision")); delete rewardFormula; delete result; }