Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DftApproximationTest.cpp
Go to the documentation of this file.
1#include "storm-config.h"
2#include "test/storm_gtest.h"
3
6
7namespace {
8
9// Configurations for DFT approximation
10struct DftAnalysisConfig {
12 bool useSR;
13};
14
15class ApproxDepthConfig {
16 public:
17 typedef double ValueType;
18
19 static DftAnalysisConfig createConfig() {
20 return DftAnalysisConfig{storm::dft::builder::ApproximationHeuristic::DEPTH, false};
21 }
22};
23
24class ApproxProbabilityConfig {
25 public:
26 typedef double ValueType;
27
28 static DftAnalysisConfig createConfig() {
29 return DftAnalysisConfig{storm::dft::builder::ApproximationHeuristic::PROBABILITY, false};
30 }
31};
32
33class ApproxBoundDifferenceConfig {
34 public:
35 typedef double ValueType;
36
37 static DftAnalysisConfig createConfig() {
39 }
40};
41
42// General base class for testing of DFT approximation
43template<typename TestType>
44class DftApproximationTest : public ::testing::Test {
45 public:
46 typedef typename TestType::ValueType ValueType;
47
48 DftApproximationTest() : config(TestType::createConfig()) {}
49
50 DftApproximationTest const& getConfig() const {
51 return config;
52 }
53
54 std::pair<double, double> analyzeMTTF(std::string const& file, double errorBound) {
55 std::shared_ptr<storm::dft::storage::DFT<double>> dft =
57 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft).first);
58 std::string property = "T=? [F \"failed\"]";
59 std::vector<std::shared_ptr<storm::logic::Formula const>> properties = storm::api::extractFormulasFromProperties(storm::api::parseProperties(property));
61 *dft, properties, config.useSR, false, storm::dft::utility::RelevantEvents(), false, errorBound, config.heuristic, false);
62 return boost::get<storm::dft::modelchecker::DFTModelChecker<double>::approximation_result>(results[0]);
63 }
64
65 std::pair<double, double> analyzeTimebound(std::string const& file, double timeBound, double errorBound) {
66 std::shared_ptr<storm::dft::storage::DFT<double>> dft =
68 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft).first);
69 std::stringstream propertyStream;
70 propertyStream << "P=? [F<=" << timeBound << " \"failed\"]";
71 std::vector<std::shared_ptr<storm::logic::Formula const>> properties =
74 *dft, properties, config.useSR, false, storm::dft::utility::RelevantEvents(), false, errorBound, config.heuristic, false);
75 return boost::get<storm::dft::modelchecker::DFTModelChecker<double>::approximation_result>(results[0]);
76 }
77
78 private:
79 DftAnalysisConfig config;
80};
81
82typedef ::testing::Types<ApproxDepthConfig, ApproxProbabilityConfig, ApproxBoundDifferenceConfig> TestingTypes;
83
84TYPED_TEST_SUITE(DftApproximationTest, TestingTypes, );
85
86TYPED_TEST(DftApproximationTest, HecsMTTF) {
87 double errorBound = 2;
88 std::pair<double, double> approxResult = this->analyzeMTTF(STORM_TEST_RESOURCES_DIR "/dft/hecs_3_2_2_np.dft", errorBound);
89 EXPECT_LE(approxResult.first, 417.9436693);
90 EXPECT_GE(approxResult.second, 417.9436693);
91 EXPECT_LE(2 * (approxResult.second - approxResult.first) / (approxResult.first + approxResult.second), errorBound);
92 // Ensure results are not equal -> not exact values were computed
93 EXPECT_GE(approxResult.second - approxResult.first, errorBound * approxResult.first / 10);
94}
95
96TYPED_TEST(DftApproximationTest, HecsTimebound) {
97 // double errorBound = 0.01;
98 double errorBound = 0.1;
99 double timeBound = 100;
100 std::pair<double, double> approxResult = this->analyzeTimebound(STORM_TEST_RESOURCES_DIR "/dft/hecs_3_2_2_np.dft", timeBound, errorBound);
101 EXPECT_LE(approxResult.first, 0.0410018417);
102 EXPECT_GE(approxResult.second, 0.0410018417);
103 EXPECT_LE(approxResult.second - approxResult.first, errorBound);
104 // Ensure results are not equal -> not exact values were computed
105 EXPECT_GE(approxResult.second - approxResult.first, errorBound / 10);
106}
107
108} // namespace
std::vector< boost::variant< ValueType, approximation_result > > dft_results
std::vector< storm::jani::Property > parseProperties(storm::parser::FormulaParser &formulaParser, std::string const &inputString, boost::optional< std::set< std::string > > const &propertyFilter)
std::vector< std::shared_ptr< storm::logic::Formula const > > extractFormulasFromProperties(std::vector< storm::jani::Property > const &properties)
storm::dft::modelchecker::DFTModelChecker< ValueType >::dft_results analyzeDFT(storm::dft::storage::DFT< ValueType > const &dft, std::vector< std::shared_ptr< storm::logic::Formula const > > const &properties, bool symred=true, bool allowModularisation=true, storm::dft::utility::RelevantEvents const &relevantEvents={}, bool allowDCForRelevant=false, double approximationError=0.0, storm::dft::builder::ApproximationHeuristic approximationHeuristic=storm::dft::builder::ApproximationHeuristic::DEPTH, bool eliminateChains=false, storm::transformer::EliminationLabelBehavior labelBehavior=storm::transformer::EliminationLabelBehavior::KeepLabels, bool printOutput=false)
Compute the exact or approximate analysis result of the given DFT according to the given properties.
Definition storm-dft.h:181
std::shared_ptr< storm::dft::storage::DFT< ValueType > > prepareForMarkovAnalysis(storm::dft::storage::DFT< ValueType > const &dft)
Apply transformations to make DFT feasible for Markovian analysis.
Definition storm-dft.h:119
std::pair< bool, std::string > isWellFormed(storm::dft::storage::DFT< ValueType > const &dft, bool validForMarkovianAnalysis=true)
Check whether the DFT is well-formed.
Definition storm-dft.h:63
std::shared_ptr< storm::dft::storage::DFT< ValueType > > loadDFTGalileoFile(std::string const &file)
Load DFT from Galileo file.
Definition storm-dft.h:29
ApproximationHeuristic
Enum representing the heuristic used for deciding which states to expand.
TYPED_TEST(GraphTestAR, SymbolicProb01StochasticGameDieSmall)
Definition GraphTest.cpp:62
TYPED_TEST_SUITE(GraphTestAR, TestingTypes,)
::testing::Types< Cudd, Sylvan > TestingTypes
Definition GraphTest.cpp:59