Browse Source
Started to improve performance of sparse CTMC model checker.
Started to improve performance of sparse CTMC model checker.
Former-commit-id: 1d014412ec
tempestpy_adaptions
dehnert
10 years ago
20 changed files with 316 additions and 42 deletions
-
44src/modelchecker/csl/SparseCtmcCslModelChecker.cpp
-
3src/modelchecker/csl/SparseCtmcCslModelChecker.h
-
8src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp
-
4src/settings/modules/GeneralSettings.cpp
-
7src/settings/modules/GeneralSettings.h
-
2src/solver/GmmxxLinearEquationSolver.cpp
-
2src/solver/GmmxxLinearEquationSolver.h
-
2src/solver/GmmxxNondeterministicLinearEquationSolver.cpp
-
2src/solver/LinearEquationSolver.h
-
2src/solver/NativeLinearEquationSolver.cpp
-
2src/solver/NativeLinearEquationSolver.h
-
5src/solver/TopologicalNondeterministicLinearEquationSolver.cpp
-
1src/utility/cli.h
-
5src/utility/solver.cpp
-
2src/utility/solver.h
-
6test/performance/modelchecker/GmmxxDtmcPrctModelCheckerTest.cpp
-
159test/performance/modelchecker/GmmxxMdpPrctlModelCheckerTest.cpp
-
84test/performance/modelchecker/NativeDtmcPrctlModelCheckerTest.cpp
-
6test/performance/modelchecker/NativeMdpPrctlModelCheckerTest.cpp
-
12test/performance/modelchecker/TopologicalValueIterationMdpPrctlModelCheckerTest.cpp
@ -0,0 +1,159 @@ |
|||
#include "gtest/gtest.h"
|
|||
#include "storm-config.h"
|
|||
|
|||
#include "src/settings/SettingsManager.h"
|
|||
#include "src/modelchecker/prctl/SparseMdpPrctlModelChecker.h"
|
|||
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
|
|||
#include "src/utility/solver.h"
|
|||
#include "src/parser/AutoParser.h"
|
|||
|
|||
TEST(GmxxMdpPrctlModelCheckerTest, AsynchronousLeader) { |
|||
std::shared_ptr<storm::models::sparse::Model<double>> abstractModel = 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"); |
|||
|
|||
ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Mdp); |
|||
|
|||
std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = abstractModel->as<storm::models::sparse::Mdp<double>>(); |
|||
|
|||
ASSERT_EQ(2095783ull, mdp->getNumberOfStates()); |
|||
ASSERT_EQ(7714385ull, mdp->getNumberOfTransitions()); |
|||
|
|||
storm::modelchecker::SparseMdpPrctlModelChecker<double> checker(*mdp, std::unique_ptr<storm::utility::solver::NondeterministicLinearEquationSolverFactory<double>>(new storm::utility::solver::GmmxxNondeterministicLinearEquationSolverFactory<double>())); |
|||
|
|||
auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected"); |
|||
auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula); |
|||
auto minProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, eventuallyFormula); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*minProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0, quantitativeResult1[0], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
auto maxProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, eventuallyFormula); |
|||
|
|||
result = checker.check(*maxProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0, quantitativeResult2[0], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected"); |
|||
auto trueFormula = std::make_shared<storm::logic::BooleanLiteralFormula>(true); |
|||
auto boundedUntilFormula = std::make_shared<storm::logic::BoundedUntilFormula>(trueFormula, labelFormula, 25); |
|||
minProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, boundedUntilFormula); |
|||
|
|||
result = checker.check(*minProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0, quantitativeResult3[0], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
maxProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, boundedUntilFormula); |
|||
|
|||
result = checker.check(*maxProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult4 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0, quantitativeResult4[0], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected"); |
|||
auto reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(labelFormula); |
|||
auto minRewardOperatorFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Minimize, reachabilityRewardFormula); |
|||
|
|||
result = checker.check(*minRewardOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult5 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(6.172433512, quantitativeResult5[0], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
auto maxRewardOperatorFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Maximize, reachabilityRewardFormula); |
|||
|
|||
result = checker.check(*maxRewardOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult6 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(6.1724344, quantitativeResult6[0], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
} |
|||
|
|||
TEST(GmxxMdpPrctlModelCheckerTest, Consensus) { |
|||
std::shared_ptr<storm::models::sparse::Model<double>> abstractModel = 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", ""); |
|||
|
|||
ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Mdp); |
|||
|
|||
std::shared_ptr<storm::models::sparse::Mdp<double>> mdp = abstractModel->as<storm::models::sparse::Mdp<double>>(); |
|||
|
|||
ASSERT_EQ(63616ull, mdp->getNumberOfStates()); |
|||
ASSERT_EQ(213472ull, mdp->getNumberOfTransitions()); |
|||
|
|||
storm::modelchecker::SparseMdpPrctlModelChecker<double> checker(*mdp, std::unique_ptr<storm::utility::solver::NondeterministicLinearEquationSolverFactory<double>>(new storm::utility::solver::GmmxxNondeterministicLinearEquationSolverFactory<double>())); |
|||
|
|||
auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("finished"); |
|||
auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula); |
|||
auto minProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, eventuallyFormula); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*minProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0, quantitativeResult1[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("finished"); |
|||
auto labelFormula2 = std::make_shared<storm::logic::AtomicLabelFormula>("all_coins_equal_0"); |
|||
auto andFormula = std::make_shared<storm::logic::BinaryBooleanStateFormula>(storm::logic::BinaryBooleanStateFormula::OperatorType::And, labelFormula, labelFormula2); |
|||
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(andFormula); |
|||
minProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, eventuallyFormula); |
|||
|
|||
result = checker.check(*minProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.4374282832, quantitativeResult2[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("finished"); |
|||
labelFormula2 = std::make_shared<storm::logic::AtomicLabelFormula>("all_coins_equal_1"); |
|||
andFormula = std::make_shared<storm::logic::BinaryBooleanStateFormula>(storm::logic::BinaryBooleanStateFormula::OperatorType::And, labelFormula, labelFormula2); |
|||
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(andFormula); |
|||
auto maxProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, eventuallyFormula); |
|||
|
|||
result = checker.check(*maxProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.5293286369, quantitativeResult3[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("finished"); |
|||
labelFormula2 = std::make_shared<storm::logic::AtomicLabelFormula>("agree"); |
|||
auto notFormula = std::make_shared<storm::logic::UnaryBooleanStateFormula>(storm::logic::UnaryBooleanStateFormula::OperatorType::Not, labelFormula2); |
|||
andFormula = std::make_shared<storm::logic::BinaryBooleanStateFormula>(storm::logic::BinaryBooleanStateFormula::OperatorType::And, labelFormula, notFormula); |
|||
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(andFormula); |
|||
maxProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, eventuallyFormula); |
|||
|
|||
result = checker.check(*maxProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult4 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.10414097, quantitativeResult4[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("finished"); |
|||
auto trueFormula = std::make_shared<storm::logic::BooleanLiteralFormula>(true); |
|||
auto boundedUntilFormula = std::make_shared<storm::logic::BoundedUntilFormula>(trueFormula, labelFormula, 50); |
|||
minProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Minimize, boundedUntilFormula); |
|||
|
|||
result = checker.check(*minProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult5 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0, quantitativeResult5[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
maxProbabilityOperatorFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(storm::logic::OptimalityType::Maximize, boundedUntilFormula); |
|||
|
|||
result = checker.check(*maxProbabilityOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult6 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.0, quantitativeResult6[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("finished"); |
|||
auto reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(labelFormula); |
|||
auto minRewardOperatorFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Minimize, reachabilityRewardFormula); |
|||
|
|||
result = checker.check(*minRewardOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult7 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1725.593313, quantitativeResult7[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
|
|||
auto maxRewardOperatorFormula = std::make_shared<storm::logic::RewardOperatorFormula>(storm::logic::OptimalityType::Maximize, reachabilityRewardFormula); |
|||
|
|||
result = checker.check(*maxRewardOperatorFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult8 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(2183.142422, quantitativeResult8[31168], storm::settings::nativeEquationSolverSettings().getPrecision()); |
|||
} |
@ -0,0 +1,84 @@ |
|||
#include "gtest/gtest.h"
|
|||
#include "storm-config.h"
|
|||
#include "src/settings/SettingsManager.h"
|
|||
#include "src/settings/SettingMemento.h"
|
|||
#include "src/modelchecker/prctl/SparseDtmcPrctlModelChecker.h"
|
|||
#include "src/modelchecker/results/ExplicitQuantitativeCheckResult.h"
|
|||
#include "src/utility/solver.h"
|
|||
#include "src/parser/AutoParser.h"
|
|||
|
|||
TEST(NativeDtmcPrctlModelCheckerTest, Crowds) { |
|||
std::shared_ptr<storm::models::sparse::Model<double>> abstractModel = storm::parser::AutoParser::parseModel(STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.tra", STORM_CPP_BASE_PATH "/examples/dtmc/crowds/crowds20_5.lab", "", ""); |
|||
|
|||
ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>(); |
|||
|
|||
ASSERT_EQ(2036647ull, dtmc->getNumberOfStates()); |
|||
ASSERT_EQ(7362293ull, dtmc->getNumberOfTransitions()); |
|||
|
|||
storm::modelchecker::SparseDtmcPrctlModelChecker<double> checker(*dtmc, std::unique_ptr<storm::utility::solver::LinearEquationSolverFactory<double>>(new storm::utility::solver::NativeLinearEquationSolverFactory<double>())); |
|||
|
|||
auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("observe0Greater1"); |
|||
auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*eventuallyFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.22968140721646868, quantitativeResult1[0], storm::settings::gmmxxEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("observeIGreater1"); |
|||
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula); |
|||
|
|||
result = checker.check(*eventuallyFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.05073232193, quantitativeResult2[0], storm::settings::gmmxxEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("observeOnlyTrueSender"); |
|||
eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula); |
|||
|
|||
result = checker.check(*eventuallyFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.22742305378217331, quantitativeResult3[0], storm::settings::gmmxxEquationSolverSettings().getPrecision()); |
|||
} |
|||
|
|||
|
|||
TEST(NativeDtmcPrctlModelCheckerTest, SynchronousLeader) { |
|||
std::shared_ptr<storm::models::sparse::Model<double>> abstractModel = storm::parser::AutoParser::parseModel(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"); |
|||
|
|||
ASSERT_EQ(abstractModel->getType(), storm::models::ModelType::Dtmc); |
|||
|
|||
std::shared_ptr<storm::models::sparse::Dtmc<double>> dtmc = abstractModel->as<storm::models::sparse::Dtmc<double>>(); |
|||
|
|||
ASSERT_EQ(1312334ull, dtmc->getNumberOfStates()); |
|||
ASSERT_EQ(1574477ull, dtmc->getNumberOfTransitions()); |
|||
|
|||
storm::modelchecker::SparseDtmcPrctlModelChecker<double> checker(*dtmc, std::unique_ptr<storm::utility::solver::LinearEquationSolverFactory<double>>(new storm::utility::solver::NativeLinearEquationSolverFactory<double>())); |
|||
|
|||
auto labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected"); |
|||
auto eventuallyFormula = std::make_shared<storm::logic::EventuallyFormula>(labelFormula); |
|||
|
|||
std::unique_ptr<storm::modelchecker::CheckResult> result = checker.check(*eventuallyFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult1 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0, quantitativeResult1[0], storm::settings::gmmxxEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected"); |
|||
auto trueFormula = std::make_shared<storm::logic::BooleanLiteralFormula>(true); |
|||
auto boundedUntilFormula = std::make_shared<storm::logic::BoundedUntilFormula>(trueFormula, labelFormula, 20); |
|||
|
|||
result = checker.check(*boundedUntilFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult2 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(0.9993949793, quantitativeResult2[0], storm::settings::gmmxxEquationSolverSettings().getPrecision()); |
|||
|
|||
labelFormula = std::make_shared<storm::logic::AtomicLabelFormula>("elected"); |
|||
auto reachabilityRewardFormula = std::make_shared<storm::logic::ReachabilityRewardFormula>(labelFormula); |
|||
|
|||
result = checker.check(*reachabilityRewardFormula); |
|||
storm::modelchecker::ExplicitQuantitativeCheckResult<double> quantitativeResult3 = result->asExplicitQuantitativeCheckResult<double>(); |
|||
|
|||
EXPECT_NEAR(1.0252174454896057, quantitativeResult3[0], storm::settings::gmmxxEquationSolverSettings().getPrecision()); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue