PBerger
8 years ago
2 changed files with 428 additions and 0 deletions
-
285test/functional/modelchecker/GameBasedDtmcModelCheckerTest.cpp
-
143test/functional/modelchecker/GameBasedMdpModelCheckerTest.cpp
@ -0,0 +1,285 @@ |
|||
#include "gtest/gtest.h"
|
|||
#include "storm-config.h"
|
|||
|
|||
#include "src/parser/FormulaParser.h"
|
|||
#include "src/logic/Formulas.h"
|
|||
#include "src/utility/solver.h"
|
|||
#include "src/modelchecker/abstraction/GameBasedMdpModelChecker.h"
|
|||
#include "src/modelchecker/results/ExplicitQualitativeCheckResult.h"
|
|||
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
|
|||
#include "src/parser/PrismParser.h"
|
|||
#include "src/builder/DdPrismModelBuilder.h"
|
|||
#include "src/models/symbolic/StandardRewardModel.h"
|
|||
#include "src/models/symbolic/Dtmc.h"
|
|||
#include "src/settings/SettingsManager.h"
|
|||
|
|||
#include "src/settings/modules/NativeEquationSolverSettings.h"
|
|||
|
|||
#include "src/settings/modules/GeneralSettings.h"
|
|||
|
|||
TEST(GameBasedDtmcModelCheckerTest, Die_Cudd) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm"); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
|
|||
// Build the die model with its reward model.
|
|||
#ifdef WINDOWS
|
|||
storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#else
|
|||
typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#endif
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options); |
|||
EXPECT_EQ(13ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(20ul, model->getNumberOfTransitions()); |
|||
|
|||
ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>(); |
|||
auto checker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::CUDD, storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>>(program); |
|||
|
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"one\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0/6.0, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"two\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0/6.0, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"three\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0/6.0, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(GameBasedDtmcModelCheckerTest, Die_Sylvan) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/die.pm"); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
|
|||
// Build the die model with its reward model.
|
|||
#ifdef WINDOWS
|
|||
storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options; |
|||
#else
|
|||
typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options; |
|||
#endif
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program, options); |
|||
EXPECT_EQ(13ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(20ul, model->getNumberOfTransitions()); |
|||
|
|||
ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>(); |
|||
auto checker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::Sylvan, storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>>(program); |
|||
|
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"one\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0/6.0, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"two\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0/6.0, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"three\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0/6.0, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(GameBasedDtmcModelCheckerTest, Crowds_Cudd) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/crowds-5-5.pm"); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program); |
|||
EXPECT_EQ(8607ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(15113ul, model->getNumberOfTransitions()); |
|||
|
|||
ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>(); |
|||
auto checker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::CUDD, storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>>(program); |
|||
|
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observe0Greater1\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.33288236360191303, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeIGreater1\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.15222081144084315, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeOnlyTrueSender\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.3215392962289586, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(GameBasedDtmcModelCheckerTest, Crowds_Sylvan) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/crowds-5-5.pm"); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program); |
|||
EXPECT_EQ(8607ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(15113ul, model->getNumberOfTransitions()); |
|||
|
|||
ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>(); |
|||
auto checker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::Sylvan, storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>>(program); |
|||
|
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observe0Greater1\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
// FIXME: precision not optimal.
|
|||
EXPECT_NEAR(0.33288236360191303, quantitativeResult1[0], 10 * storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeIGreater1\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
// FIXME: precision not optimal.
|
|||
EXPECT_NEAR(0.15222081144084315, quantitativeResult2[0], 10 * storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F \"observeOnlyTrueSender\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
// FIXME: precision not optimal.
|
|||
EXPECT_NEAR(0.3215392962289586, quantitativeResult3[0], 10 * storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(GameBasedDtmcModelCheckerTest, SynchronousLeader_Cudd) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader-3-5.pm"); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
|
|||
// Build the die model with its reward model.
|
|||
#ifdef WINDOWS
|
|||
storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#else
|
|||
typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#endif
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options); |
|||
EXPECT_EQ(273ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(397ul, model->getNumberOfTransitions()); |
|||
|
|||
ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>(); |
|||
auto checker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::CUDD, storm::models::symbolic::Dtmc<storm::dd::DdType::CUDD>>>(program); |
|||
|
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"elected\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F<=20 \"elected\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::CUDD>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.99999989760000074, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(GameBasedDtmcModelCheckerTest, SynchronousLeader_Sylvan) { |
|||
storm::prism::Program program = storm::parser::PrismParser::parse(STORM_CPP_TESTS_BASE_PATH "/functional/builder/leader-3-5.pm"); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
|
|||
// Build the die model with its reward model.
|
|||
#ifdef WINDOWS
|
|||
storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options; |
|||
#else
|
|||
typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>::Options options; |
|||
#endif
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::Sylvan>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::Sylvan>().build(program, options); |
|||
EXPECT_EQ(273ul, model->getNumberOfStates()); |
|||
EXPECT_EQ(397ul, model->getNumberOfTransitions()); |
|||
|
|||
ASSERT_EQ(model->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>> dtmc = model->as<storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>(); |
|||
auto checker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::Sylvan, storm::models::symbolic::Dtmc<storm::dd::DdType::Sylvan>>>(program); |
|||
|
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("P=? [F \"elected\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("P=? [F<=20 \"elected\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = checker->check(task); |
|||
//result->filter(storm::modelchecker::SymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>(model->getReachableStates(), model->getInitialStates()));
|
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.99999989760000074, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
@ -0,0 +1,143 @@ |
|||
#include "gtest/gtest.h"
|
|||
#include "storm-config.h"
|
|||
|
|||
#include "src/parser/FormulaParser.h"
|
|||
#include "src/logic/Formulas.h"
|
|||
#include "src/models/sparse/StandardRewardModel.h"
|
|||
#include "src/models/sparse/Model.h"
|
|||
#include "src/modelchecker/abstraction/GameBasedMdpModelChecker.h"
|
|||
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
|
|||
#include "src/settings/SettingsManager.h"
|
|||
#include "src/settings/modules/GeneralSettings.h"
|
|||
#include "src/settings/modules/NativeEquationSolverSettings.h"
|
|||
|
|||
#include "src/parser/AutoParser.h"
|
|||
#include "src/parser/PrismParser.h"
|
|||
|
|||
#include "utility/storm.h"
|
|||
|
|||
TEST(GameBasedMdpModelCheckerTest, Dice_Cudd) { |
|||
std::string programFile = STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.nm"; |
|||
std::string formulaFile = STORM_CPP_BASE_PATH "/examples/mdp/two_dice/two_dice.prctl"; |
|||
|
|||
storm::prism::Program program = storm::parseProgram(programFile); |
|||
|
|||
// Build the die model
|
|||
#ifdef WINDOWS
|
|||
storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#else
|
|||
typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#endif
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options); |
|||
|
|||
ASSERT_EQ(model->getNumberOfStates(), 169ull); |
|||
ASSERT_EQ(model->getNumberOfTransitions(), 436ull); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>> mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>(); |
|||
auto mdpModelchecker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::CUDD, storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>>(program); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
|
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"two\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0277777612209320068, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"two\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0277777612209320068, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"three\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0555555224418640136, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"three\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult4 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0555555224418640136, quantitativeResult4[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"four\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult5 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.083333283662796020508, quantitativeResult5[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"four\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult6 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.083333283662796020508, quantitativeResult6[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
|||
|
|||
TEST(GameBasedMdpModelCheckerTest, AsynchronousLeader_Cudd) { |
|||
std::string programFile = STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader4.nm"; |
|||
std::string formulaFile = STORM_CPP_BASE_PATH "/examples/mdp/asynchronous_leader/leader.prctl"; |
|||
|
|||
storm::prism::Program program = storm::parseProgram(programFile); |
|||
// Build the die model
|
|||
#ifdef WINDOWS
|
|||
storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#else
|
|||
typename storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>::Options options; |
|||
#endif
|
|||
std::shared_ptr<storm::models::symbolic::Model<storm::dd::DdType::CUDD>> model = storm::builder::DdPrismModelBuilder<storm::dd::DdType::CUDD>().build(program, options); |
|||
|
|||
ASSERT_EQ(3172ull, model->getNumberOfStates()); |
|||
ASSERT_EQ(7144ull, model->getNumberOfTransitions()); |
|||
|
|||
std::shared_ptr<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>> mdp = model->as<storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>(); |
|||
auto mdpModelchecker = std::make_shared<storm::modelchecker::GameBasedMdpModelChecker<storm::dd::DdType::CUDD, storm::models::symbolic::Mdp<storm::dd::DdType::CUDD>>>(program); |
|||
|
|||
// A parser that we use for conveniently constructing the formulas.
|
|||
storm::parser::FormulaParser formulaParser; |
|||
std::shared_ptr<storm::logic::Formula const> formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F \"elected\"]"); |
|||
storm::modelchecker::CheckTask<storm::logic::Formula, double> task(*formula, true); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1, quantitativeResult1[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F \"elected\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1, quantitativeResult2[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmin=? [F<=25 \"elected\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0625, quantitativeResult3[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
|
|||
formula = formulaParser.parseSingleFormulaFromString("Pmax=? [F<=25 \"elected\"]"); |
|||
task = storm::modelchecker::CheckTask<storm::logic::Formula, double>(*formula, true); |
|||
|
|||
result = mdpModelchecker->check(task); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double>& quantitativeResult4 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0625, quantitativeResult4[0], storm::settings::getModule<storm::settings::modules::NativeEquationSolverSettings>().getPrecision()); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue