#include "gtest/gtest.h" #include "storm-config.h" #include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h" #include "src/utility/solver.h" #include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h" #include "src/settings/SettingsManager.h" #include "src/settings/SettingMemento.h" #include "src/parser/AutoParser.h" TEST(DISABLED_TopologicalValueIterationMdpPrctlModelCheckerTest, AsynchronousLeader) { std::shared_ptr> mdp = storm::parser::AutoParser::parseModel(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")->as>(); ASSERT_EQ(mdp->getNumberOfStates(), 2095783ull); ASSERT_EQ(mdp->getNumberOfTransitions(), 7714385ull); storm::modelchecker::SparseMdpPrctlModelChecker mc(*mdp, std::unique_ptr>(new storm::utility::solver::TopologicalMinMaxLinearEquationSolverFactory())); auto apFormula = std::make_shared("elected"); auto eventuallyFormula = std::make_shared(apFormula); auto probFormula = std::make_shared(storm::logic::OptimalityType::Minimize, eventuallyFormula); std::unique_ptr result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[0] - 1.0), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("elected"); eventuallyFormula = std::make_shared(apFormula); probFormula = std::make_shared(storm::logic::OptimalityType::Maximize, eventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[0] - 1.0), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("elected"); auto boundedEventuallyFormula = std::make_shared(std::make_shared(true), apFormula, 25); probFormula = std::make_shared(storm::logic::OptimalityType::Minimize, boundedEventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[0] - 0.0), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("elected"); boundedEventuallyFormula = std::make_shared(std::make_shared(true), apFormula, 25); probFormula = std::make_shared(storm::logic::OptimalityType::Maximize, boundedEventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[0] - 0.0), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("elected"); auto reachabilityRewardFormula = std::make_shared(apFormula); auto rewardFormula = std::make_shared(storm::logic::OptimalityType::Minimize, reachabilityRewardFormula); result = mc.check(*rewardFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[0] - 6.172433512), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); rewardFormula.reset(); apFormula = std::make_shared("elected"); reachabilityRewardFormula = std::make_shared(apFormula); rewardFormula = std::make_shared(storm::logic::OptimalityType::Maximize, reachabilityRewardFormula); result = mc.check(*rewardFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[0] - 6.1724344), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); rewardFormula.reset(); } TEST(DISABLED_TopologicalValueIterationMdpPrctlModelCheckerTest, Consensus) { // Increase the maximal number of iterations, because the solver does not converge otherwise. // This is done in the main cpp unit std::shared_ptr> mdp = storm::parser::AutoParser::parseModel(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", "")->as>(); ASSERT_EQ(mdp->getNumberOfStates(), 63616ull); ASSERT_EQ(mdp->getNumberOfTransitions(), 213472ull); storm::modelchecker::SparseMdpPrctlModelChecker mc(*mdp, std::unique_ptr>(new storm::utility::solver::TopologicalMinMaxLinearEquationSolverFactory())); auto apFormula = std::make_shared("finished"); auto eventuallyFormula = std::make_shared(apFormula); auto probFormula = std::make_shared(storm::logic::OptimalityType::Minimize, eventuallyFormula); auto result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 1.0), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("finished"); auto apFormula2 = std::make_shared("all_coins_equal_0"); auto andFormula = std::make_shared(storm::logic::BinaryBooleanStateFormula::OperatorType::And, apFormula, apFormula2); eventuallyFormula = std::make_shared(andFormula); probFormula = std::make_shared(storm::logic::OptimalityType::Minimize, eventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 0.4374282832), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("finished"); apFormula2 = std::make_shared("all_coins_equal_1"); andFormula = std::make_shared(storm::logic::BinaryBooleanStateFormula::OperatorType::And, apFormula, apFormula2); eventuallyFormula = std::make_shared(andFormula); probFormula = std::make_shared(storm::logic::OptimalityType::Maximize, eventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 0.5293286369), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("finished"); apFormula2 = std::make_shared("agree"); auto notFormula = std::make_shared(storm::logic::UnaryBooleanStateFormula::OperatorType::Not, apFormula2); andFormula = std::make_shared(storm::logic::BinaryBooleanStateFormula::OperatorType::And, apFormula, notFormula); eventuallyFormula = std::make_shared(andFormula); probFormula = std::make_shared(storm::logic::OptimalityType::Maximize, eventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 0.10414097), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("finished"); auto boundedEventuallyFormula = std::make_shared(std::make_shared(true), apFormula, 50ull); probFormula = std::make_shared(storm::logic::OptimalityType::Minimize, eventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 0.0), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("finished"); boundedEventuallyFormula = std::make_shared(std::make_shared(true), apFormula, 50ull); probFormula = std::make_shared(storm::logic::OptimalityType::Maximize, eventuallyFormula); result = mc.check(*probFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 0.0), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("finished"); auto reachabilityRewardFormula = std::make_shared(apFormula); auto rewardFormula = std::make_shared(storm::logic::OptimalityType::Minimize, reachabilityRewardFormula); result = mc.check(*rewardFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 1725.593313), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); apFormula = std::make_shared("finished"); reachabilityRewardFormula = std::make_shared(apFormula); rewardFormula = std::make_shared(storm::logic::OptimalityType::Maximize, reachabilityRewardFormula); result = mc.check(*rewardFormula); ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult()[31168] - 2183.142422), storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision()); probFormula.reset(); }