Browse Source

Adapted first test to new interface. Test passes.

Former-commit-id: 49dc8228f3
tempestpy_adaptions
David_Korzeniewski 10 years ago
parent
commit
8b4309e53c
  1. 257
      test/functional/modelchecker/TopologicalValueIterationMdpPrctlModelCheckerTest.cpp

257
test/functional/modelchecker/TopologicalValueIterationMdpPrctlModelCheckerTest.cpp

@ -22,153 +22,190 @@ TEST(TopologicalValueIterationMdpPrctlModelCheckerTest, Dice) {
storm::modelchecker::prctl::TopologicalValueIterationMdpPrctlModelChecker<double> mc(*mdp);
//storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("two");
auto apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("two");
//storm::property::prctl::Ap<double>* apFormula = new storm::property::prctl::Ap<double>("two");
auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(apFormula);
//storm::property::prctl::Eventually<double>* eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
auto minProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, eventuallyFormula);
auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(apFormula);
//storm::property::prctl::ProbabilisticNoBoundOperator<double>* probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, true);
auto probabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, eventuallyFormula);
std::unique_ptr<storm::modelchecker::CheckResult> result = mc.check(*minProbabilityOperatorFormula);
//std::vector<double> result = mc.checkNoBoundOperator(*probFormula);
std::unique_ptr<storm::modelchecker::CheckResult> result = mc.check(*probabilityOperatorFormula);
//ASSERT_LT(std::abs(result[0] - 0.0277777612209320068), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 0.0277777612209320068),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
//ASSERT_LT(std::abs(result[0] - 0.0277777612209320068), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
//delete probFormula;
probabilityOperatorFormula.reset();
//apFormula = new storm::property::prctl::Ap<double>("two");
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("two");
//eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(apFormula);
//probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, false);
//
probabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, eventuallyFormula);
//result = mc.checkNoBoundOperator(*probFormula);
//
result = mc.check(*probabilityOperatorFormula);
//ASSERT_LT(std::abs(result[0] - 0.0277777612209320068), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
//
//delete probFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("three");
//eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
//probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, true);
//
//result = mc.checkNoBoundOperator(*probFormula);
//
//ASSERT_LT(std::abs(result[0] - 0.0555555224418640136), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
//
//delete probFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("three");
//eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
//probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, false);
//
//result = mc.checkNoBoundOperator(*probFormula);
//
//ASSERT_LT(std::abs(result[0] - 0.0555555224418640136), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
//
//delete probFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("four");
//eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
//probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, true);
//
//result = mc.checkNoBoundOperator(*probFormula);
//
//ASSERT_LT(std::abs(result[0] - 0.083333283662796020508), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
//
//delete probFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("four");
//eventuallyFormula = new storm::property::prctl::Eventually<double>(apFormula);
//probFormula = new storm::property::prctl::ProbabilisticNoBoundOperator<double>(eventuallyFormula, false);
//
//result = mc.checkNoBoundOperator(*probFormula);
//
//ASSERT_LT(std::abs(result[0] - 0.083333283662796020508), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
//
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 0.0277777612209320068),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
//delete probFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("done");
//storm::property::prctl::ReachabilityReward<double>* reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
//storm::property::prctl::RewardNoBoundOperator<double>* rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, true);
//
//result = mc.checkNoBoundOperator(*rewardFormula);
probabilityOperatorFormula.reset();
// ---------------- test ap "three" ----------------
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("three");
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(apFormula);
probabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, eventuallyFormula);
result = mc.check(*probabilityOperatorFormula);
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 0.0555555224418640136),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
probabilityOperatorFormula.reset();
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("three");
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(apFormula);
probabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, eventuallyFormula);
result = mc.check(*probabilityOperatorFormula);
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 0.0555555224418640136),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
probabilityOperatorFormula.reset();
// ---------------- test ap "four" ----------------
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("four");
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(apFormula);
probabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, eventuallyFormula);
result = mc.check(*probabilityOperatorFormula);
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 0.083333283662796020508),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
probabilityOperatorFormula.reset();
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("four");
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(apFormula);
probabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, eventuallyFormula);
result = mc.check(*probabilityOperatorFormula);
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 0.083333283662796020508),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
probabilityOperatorFormula.reset();
// ---------------- test ap "done" ----------------
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("done");
auto reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(apFormula);
auto rewardFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Minimize, reachabilityRewardFormula);
result = mc.check(*rewardFormula);
#ifdef STORM_HAVE_CUDAFORSTORM
//ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.333329499),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#else
//ASSERT_LT(std::abs(result[0] - 7.33332904), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.33332904),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#endif
//delete rewardFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("done");
//reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
//rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, false);
//
//result = mc.checkNoBoundOperator(*rewardFormula);;
rewardFormula.reset();
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("done");
reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(apFormula);
rewardFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Maximize, reachabilityRewardFormula);
result = mc.check(*rewardFormula);
#ifdef STORM_HAVE_CUDAFORSTORM
//ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.333329499),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#else
//ASSERT_LT(std::abs(result[0] - 7.33333151), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.33333151),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#endif
//delete rewardFormula;
//std::shared_ptr<storm::models::Mdp<double>> stateRewardMdp = storm::parser::AutoParser::parseModel(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", "")->as<storm::models::Mdp<double>>();
//
//storm::modelchecker::prctl::TopologicalValueIterationMdpPrctlModelChecker<double> stateRewardModelChecker(*stateRewardMdp);
rewardFormula.reset();
// ------------- state rewards --------------
std::shared_ptr<storm::models::Mdp<double>> stateRewardMdp = storm::parser::AutoParser::parseModel(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", "")->as<storm::models::Mdp<double>>();
storm::modelchecker::prctl::TopologicalValueIterationMdpPrctlModelChecker<double> stateRewardModelChecker(*stateRewardMdp);
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("done");
reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(apFormula);
rewardFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Minimize, reachabilityRewardFormula);
result = stateRewardModelChecker.check(*rewardFormula);
//apFormula = new storm::property::prctl::Ap<double>("done");
//reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
//rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, true);
//
//result = stateRewardModelChecker.checkNoBoundOperator(*rewardFormula);
#ifdef STORM_HAVE_CUDAFORSTORM
//ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.333329499),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#else
//ASSERT_LT(std::abs(result[0] - 7.33332904), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.33332904),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#endif
//delete rewardFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("done");
//reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
//rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, false);
//
//result = stateRewardModelChecker.checkNoBoundOperator(*rewardFormula);
rewardFormula.reset();
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("done");
reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(apFormula);
rewardFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Maximize, reachabilityRewardFormula);
result = stateRewardModelChecker.check(*rewardFormula);
#ifdef STORM_HAVE_CUDAFORSTORM
//ASSERT_LT(std::abs(result[0] - 7.333329499), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.333329499),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#else
//ASSERT_LT(std::abs(result[0] - 7.33333151), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 7.33333151),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#endif
//delete rewardFormula;
//std::shared_ptr<storm::models::Mdp<double>> stateAndTransitionRewardMdp = storm::parser::AutoParser::parseModel(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")->as<storm::models::Mdp<double>>();
//
//storm::modelchecker::prctl::TopologicalValueIterationMdpPrctlModelChecker<double> stateAndTransitionRewardModelChecker(*stateAndTransitionRewardMdp);
//
//apFormula = new storm::property::prctl::Ap<double>("done");
//reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
//rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, true);
//
//result = stateAndTransitionRewardModelChecker.checkNoBoundOperator(*rewardFormula);
rewardFormula.reset();
// -------------------------------- state and transition reward ------------------------
std::shared_ptr<storm::models::Mdp<double>> stateAndTransitionRewardMdp = storm::parser::AutoParser::parseModel(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")->as<storm::models::Mdp<double>>();
storm::modelchecker::prctl::TopologicalValueIterationMdpPrctlModelChecker<double> stateAndTransitionRewardModelChecker(*stateAndTransitionRewardMdp);
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("done");
reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(apFormula);
rewardFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Minimize, reachabilityRewardFormula);
result = stateAndTransitionRewardModelChecker.check(*rewardFormula);
#ifdef STORM_HAVE_CUDAFORSTORM
//ASSERT_LT(std::abs(result[0] - 14.666658998), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 14.666658998),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#else
//ASSERT_LT(std::abs(result[0] - 14.6666581), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 14.6666581),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#endif
//delete rewardFormula;
//
//apFormula = new storm::property::prctl::Ap<double>("done");
//reachabilityRewardFormula = new storm::property::prctl::ReachabilityReward<double>(apFormula);
//rewardFormula = new storm::property::prctl::RewardNoBoundOperator<double>(reachabilityRewardFormula, false);
//
//result = stateAndTransitionRewardModelChecker.checkNoBoundOperator(*rewardFormula);
rewardFormula.reset();
apFormula = std::make_shared<storm::logic::AtomicLabelFormula>("done");
reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(apFormula);
rewardFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Maximize, reachabilityRewardFormula);
result = stateAndTransitionRewardModelChecker.check(*rewardFormula);
#ifdef STORM_HAVE_CUDAFORSTORM
//ASSERT_LT(std::abs(result[0] - 14.666658998), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 14.666658998),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#else
//ASSERT_LT(std::abs(result[0] - 14.666663), s->getOptionByLongName("precision").getArgument(0).getValueAsDouble());
ASSERT_LT(std::abs(result->asExplicitQuantitativeCheckResult<double>()[0] - 14.666663),
storm::settings::topologicalValueIterationEquationSolverSettings().getPrecision());
#endif
//delete rewardFormula;
rewardFormula.reset();
}
TEST(TopologicalValueIterationMdpPrctlModelCheckerTest, AsynchronousLeader) {

Loading…
Cancel
Save