diff --git a/test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp b/test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp new file mode 100644 index 000000000..6efb4653a --- /dev/null +++ b/test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp @@ -0,0 +1,259 @@ +#include "gtest/gtest.h" +#include "storm-config.h" + +#include "src/utility/Settings.h" +#include "src/modelchecker/SparseMdpPrctlModelChecker.h" +#include "src/parser/AutoParser.h" + +TEST(SparseMdpPrctlModelCheckerTest, Dice) { + storm::settings::Settings* s = storm::settings::instance(); + storm::parser::AutoParser parser(STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.tra", STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.lab", "", STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.flip.trans.rew"); + + ASSERT_EQ(parser.getType(), storm::models::MDP); + + std::shared_ptr> mdp = parser.getModel>(); + + ASSERT_EQ(mdp->getNumberOfStates(), 169u); + ASSERT_EQ(mdp->getNumberOfTransitions(), 436u); + + storm::modelchecker::SparseMdpPrctlModelChecker mc(*mdp); + + storm::property::prctl::Ap* apFormula = new storm::property::prctl::Ap("two"); + 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] - 0.0277777612209320068), s->get("precision")); + + delete probFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("two"); + eventuallyFormula = new storm::property::prctl::Eventually(apFormula); + probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, false); + + result = mc.checkNoBoundOperator(*probFormula); + + ASSERT_LT(std::abs((*result)[0] - 0.0277777612209320068), s->get("precision")); + + delete probFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("three"); + eventuallyFormula = new storm::property::prctl::Eventually(apFormula); + probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, true); + + result = mc.checkNoBoundOperator(*probFormula); + + ASSERT_LT(std::abs((*result)[0] - 0.0555555224418640136), s->get("precision")); + + delete probFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("three"); + eventuallyFormula = new storm::property::prctl::Eventually(apFormula); + probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, false); + + result = mc.checkNoBoundOperator(*probFormula); + + ASSERT_LT(std::abs((*result)[0] - 0.0555555224418640136), s->get("precision")); + + delete probFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("four"); + eventuallyFormula = new storm::property::prctl::Eventually(apFormula); + probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, true); + + result = mc.checkNoBoundOperator(*probFormula); + + ASSERT_LT(std::abs((*result)[0] - 0.083333283662796020508), s->get("precision")); + + delete probFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("four"); + eventuallyFormula = new storm::property::prctl::Eventually(apFormula); + probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator(eventuallyFormula, false); + + result = mc.checkNoBoundOperator(*probFormula); + + ASSERT_LT(std::abs((*result)[0] - 0.083333283662796020508), s->get("precision")); + + delete probFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("done"); + 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] - 7.3333294987678527832), s->get("precision")); + + delete rewardFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("done"); + reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); + rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, false); + + result = mc.checkNoBoundOperator(*rewardFormula);; + + ASSERT_LT(std::abs((*result)[0] - 7.3333294987678527832), s->get("precision")); + + delete rewardFormula; + delete result; + + storm::parser::AutoParser stateRewardParser(STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.tra", STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.lab", STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.flip.state.rew", ""); + + ASSERT_EQ(stateRewardParser.getType(), storm::models::MDP); + + std::shared_ptr> stateRewardMdp = stateRewardParser.getModel>(); + + storm::modelchecker::SparseMdpPrctlModelChecker stateRewardModelChecker(*stateRewardMdp); + + apFormula = new storm::property::prctl::Ap("done"); + reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); + rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, true); + + result = stateRewardModelChecker.checkNoBoundOperator(*rewardFormula); + + ASSERT_LT(std::abs((*result)[0] - 7.3333294987678527832), s->get("precision")); + + delete rewardFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("done"); + reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); + rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, false); + + result = stateRewardModelChecker.checkNoBoundOperator(*rewardFormula); + + ASSERT_LT(std::abs((*result)[0] - 7.3333294987678527832), s->get("precision")); + + delete rewardFormula; + delete result; + + storm::parser::AutoParser stateAndTransitionRewardParser(STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.tra", STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.lab", STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.flip.state.rew", STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.flip.trans.rew"); + + ASSERT_EQ(stateAndTransitionRewardParser.getType(), storm::models::MDP); + + std::shared_ptr> stateAndTransitionRewardMdp = stateAndTransitionRewardParser.getModel>(); + + storm::modelchecker::SparseMdpPrctlModelChecker stateAndTransitionRewardModelChecker(*stateAndTransitionRewardMdp); + + apFormula = new storm::property::prctl::Ap("done"); + reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); + rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, true); + + result = stateAndTransitionRewardModelChecker.checkNoBoundOperator(*rewardFormula); + + ASSERT_LT(std::abs((*result)[0] - (2 * 7.3333294987678527832)), s->get("precision")); + + delete rewardFormula; + delete result; + + apFormula = new storm::property::prctl::Ap("done"); + reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward(apFormula); + rewardFormula = new storm::property::prctl::RewardNoBoundOperator(reachabilityRewardFormula, false); + + result = stateAndTransitionRewardModelChecker.checkNoBoundOperator(*rewardFormula); + + ASSERT_LT(std::abs((*result)[0] - (2 * 7.3333294987678527832)), s->get("precision")); + + delete rewardFormula; + delete result; +} + +TEST(SparseMdpPrctlModelCheckerTest, AsynchronousLeader) { + storm::settings::Settings* s = storm::settings::instance(); + storm::parser::AutoParser parser(STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader4.tra", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader4.lab", "", STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader4.trans.rew"); + + ASSERT_EQ(parser.getType(), storm::models::MDP); + + std::shared_ptr> mdp = parser.getModel>(); + + ASSERT_EQ(mdp->getNumberOfStates(), 3172u); + ASSERT_EQ(mdp->getNumberOfTransitions(), 7144u); + + storm::modelchecker::SparseMdpPrctlModelChecker 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.0625), 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.0625), 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] - 4.28568908480604982), 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] - 4.2856904354441400784), s->get("precision")); + + delete rewardFormula; + delete result; +} diff --git a/test/functional/storm-functional-tests.cpp b/test/functional/storm-functional-tests.cpp index abfb5a125..f2ebcc8a4 100644 --- a/test/functional/storm-functional-tests.cpp +++ b/test/functional/storm-functional-tests.cpp @@ -31,39 +31,21 @@ void setUpLogging() { } /*! - * Function that parses the command line options. - * @param argc The argc argument of main(). - * @param argv The argv argument of main(). - * @return True iff the program should continue to run after parsing the options. + * Creates an empty settings object as the standard instance of the Settings class. */ -bool parseOptions(int const argc, char const * const argv[]) { - storm::settings::Settings* s = nullptr; - try { - storm::settings::Settings::registerModule>(); - s = storm::settings::newInstance(argc, argv, nullptr, true); - } catch (storm::exceptions::InvalidSettingsException& e) { - std::cout << "Could not recover from settings error: " << e.what() << "." << std::endl; - std::cout << std::endl << storm::settings::help; - return false; - } - - if (s->isSet("help")) { - std::cout << storm::settings::help; - return false; - } - - return true; +void createEmptyOptions() { + storm::settings::Settings::registerModule>(); + const char* newArgv[] = {"storm-performance-tests"}; + storm::settings::Settings* s = storm::settings::newInstance(1, newArgv, nullptr, true); } int main(int argc, char* argv[]) { setUpLogging(); - if (!parseOptions(argc, argv)) { - return 0; - } + createEmptyOptions(); std::cout << "StoRM (Functional) Testing Suite" << std::endl; testing::InitGoogleTest(&argc, argv); - + int result = RUN_ALL_TESTS(); logger.closeNestedAppenders(); diff --git a/test/performance/modelchecker/GmmxxDtmcPrctModelCheckerTest.cpp b/test/performance/modelchecker/GmmxxDtmcPrctModelCheckerTest.cpp index bf0a72403..8eabed62f 100644 --- a/test/performance/modelchecker/GmmxxDtmcPrctModelCheckerTest.cpp +++ b/test/performance/modelchecker/GmmxxDtmcPrctModelCheckerTest.cpp @@ -4,7 +4,7 @@ #include "src/modelchecker/GmmxxDtmcPrctlModelChecker.h" #include "src/parser/AutoParser.h" -TEST(GmmxxDtmcPrctModelCheckerTest, Crowds) { +TEST(GmmxxDtmcPrctlModelCheckerTest, Crowds) { storm::settings::Settings* s = storm::settings::instance(); s->set("fix-deadlocks"); storm::parser::AutoParser parser(STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.lab", "", ""); @@ -65,7 +65,7 @@ TEST(GmmxxDtmcPrctModelCheckerTest, Crowds) { } -TEST(GmmxxDtmcPrctModelCheckerTest, SynchronousLeader) { +TEST(GmmxxDtmcPrctlModelCheckerTest, SynchronousLeader) { storm::settings::Settings* s = storm::settings::instance(); s->set("fix-deadlocks"); storm::parser::AutoParser parser(STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.tra", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.lab", "", STORM_CPP_BASE_PATH "/examples/dtmc/synchronous_leader/leader6_8.pick.trans.rew"); diff --git a/test/performance/modelchecker/GmmxxMdpPrctModelCheckerTest.cpp b/test/performance/modelchecker/GmmxxMdpPrctModelCheckerTest.cpp index 971c7ec09..c67fa0080 100644 --- a/test/performance/modelchecker/GmmxxMdpPrctModelCheckerTest.cpp +++ b/test/performance/modelchecker/GmmxxMdpPrctModelCheckerTest.cpp @@ -5,7 +5,7 @@ #include "src/modelchecker/GmmxxMdpPrctlModelChecker.h" #include "src/parser/AutoParser.h" -TEST(GmmxxMdpPrctModelCheckerTest, AsynchronousLeader) { +TEST(GmmxxMdpPrctlModelCheckerTest, 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"); @@ -107,7 +107,7 @@ TEST(GmmxxMdpPrctModelCheckerTest, AsynchronousLeader) { delete result; } -TEST(GmmxxMdpPrctModelCheckerTest, Consensus) { +TEST(GmmxxMdpPrctlModelCheckerTest, Consensus) { storm::settings::Settings* s = storm::settings::instance(); s->set("maxiter", 20000); @@ -164,8 +164,8 @@ TEST(GmmxxMdpPrctModelCheckerTest, Consensus) { result = mc.checkNoBoundOperator(*probFormula); LOG4CPLUS_WARN(logger, "Done."); - ASSERT_NE(nullptr, result); - ASSERT_LT(std::abs((*result)[31168] - 0.5282872761373342829216), s->get("precision")); + ASSERT_NE(nullptr, result); + ASSERT_LT(std::abs((*result)[31168] - 0.52932863686144482340267813924583606421947479248047), s->get("precision")); delete probFormula; delete result; @@ -182,7 +182,7 @@ TEST(GmmxxMdpPrctModelCheckerTest, Consensus) { LOG4CPLUS_WARN(logger, "Done."); ASSERT_NE(nullptr, result); - ASSERT_LT(std::abs((*result)[31168] - 0.10343451035775527713), s->get("precision")); + ASSERT_LT(std::abs((*result)[31168] - 0.1041409700076474653673841), s->get("precision")); delete probFormula; delete result; @@ -238,7 +238,7 @@ TEST(GmmxxMdpPrctModelCheckerTest, Consensus) { LOG4CPLUS_WARN(logger, "Done."); ASSERT_NE(nullptr, result); - ASSERT_LT(std::abs((*result)[31168] - 2179.014847073392047605011), s->get("precision")); + ASSERT_LT(std::abs((*result)[31168] - 2183.1424220082612919213715), s->get("precision")); delete rewardFormula; delete result; diff --git a/test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp b/test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp new file mode 100644 index 000000000..961996899 --- /dev/null +++ b/test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp @@ -0,0 +1,244 @@ +#include "gtest/gtest.h" +#include "storm-config.h" + +#include "src/utility/Settings.h" +#include "src/modelchecker/SparseMdpPrctlModelChecker.h" +#include "src/parser/AutoParser.h" + +TEST(SparseMdpPrctlModelCheckerTest, 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::SparseMdpPrctlModelChecker 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F elected] on asynchronous_leader/leader7..."); + std::vector* result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F elected] on asynchronous_leader/leader7..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F<=25 elected] on asynchronous_leader/leader7..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F<=25 elected] on asynchronous_leader/leader7..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Rmin=? [F elected] on asynchronous_leader/leader7..."); + result = mc.checkNoBoundOperator(*rewardFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Rmax=? [F elected] on asynchronous_leader/leader7..."); + result = mc.checkNoBoundOperator(*rewardFormula); + LOG4CPLUS_WARN(logger, "Done"); + + ASSERT_NE(nullptr, result); + + ASSERT_LT(std::abs((*result)[0] - 6.1724344), s->get("precision")); + + delete rewardFormula; + delete result; +} + +TEST(SparseMdpPrctlModelCheckerTest, Consensus) { + storm::settings::Settings* s = storm::settings::instance(); + // Increase the maximal number of iterations, because the solver does not converge otherwise. + s->set("maxiter", 20000); + + 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::SparseMdpPrctlModelChecker 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F finished] on consensus/coin4_6..."); + std::vector* result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F finished & all_coins_equal_0] on consensus/coin4_6..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + ASSERT_NE(nullptr, result); + ASSERT_LT(std::abs((*result)[31168] - 0.43742828319177884388579), 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F finished & all_coins_equal_1] on consensus/coin4_6..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + ASSERT_NE(nullptr, result); + ASSERT_LT(std::abs((*result)[31168] - 0.52932863686144482340267813924583606421947479248047), 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F finished & !agree] on consensus/coin4_6..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + ASSERT_NE(nullptr, result); + ASSERT_LT(std::abs((*result)[31168] - 0.1041409700076474653673841), 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmin=? [F<=50 finished] on consensus/coin4_6..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Pmax=? [F<=50 finished] on consensus/coin4_6..."); + result = mc.checkNoBoundOperator(*probFormula); + LOG4CPLUS_WARN(logger, "Done."); + + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Rmin=? [F finished] on consensus/coin4_6..."); + result = mc.checkNoBoundOperator(*rewardFormula); + LOG4CPLUS_WARN(logger, "Done."); + + ASSERT_NE(nullptr, result); + 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); + + LOG4CPLUS_WARN(logger, "Model Checking Rmax=? [F finished] on consensus/coin4_6..."); + result = mc.checkNoBoundOperator(*rewardFormula); + LOG4CPLUS_WARN(logger, "Done."); + + ASSERT_NE(nullptr, result); + ASSERT_LT(std::abs((*result)[31168] - 2183.1424220082612919213715), s->get("precision")); + + delete rewardFormula; + delete result; + +} \ No newline at end of file diff --git a/test/performance/storm-performance-tests.cpp b/test/performance/storm-performance-tests.cpp index 49983a9e1..b35e4f1aa 100644 --- a/test/performance/storm-performance-tests.cpp +++ b/test/performance/storm-performance-tests.cpp @@ -31,34 +31,17 @@ void setUpLogging() { } /*! - * Function that parses the command line options. - * @param argc The argc argument of main(). - * @param argv The argv argument of main(). - * @return True iff the program should continue to run after parsing the options. + * Creates an empty settings object as the standard instance of the Settings class. */ -bool parseOptions(int const argc, char const * const argv[]) { - storm::settings::Settings* s = nullptr; - try { - storm::settings::Settings::registerModule>(); - s = storm::settings::newInstance(argc, argv, nullptr, true); - } catch (storm::exceptions::InvalidSettingsException& e) { - // Ignore this case. - return true; - } - - if (s->isSet("help")) { - std::cout << storm::settings::help; - return false; - } - - return true; +void createEmptyOptions() { + storm::settings::Settings::registerModule>(); + const char* newArgv[] = {"storm-performance-tests"}; + storm::settings::Settings* s = storm::settings::newInstance(1, newArgv, nullptr, true); } int main(int argc, char* argv[]) { setUpLogging(); - if (!parseOptions(argc, argv)) { - return 0; - } + createEmptyOptions(); std::cout << "StoRM (Performance) Testing Suite" << std::endl; testing::InitGoogleTest(&argc, argv);