Storm 1.14.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
5#include "storm-dft/api/io.h"
10
11namespace {
12
13// Configurations for DFT approximation
14struct DftAnalysisConfig {
16 bool useSR;
17};
18
19class ApproxDepthConfig {
20 public:
21 typedef double ValueType;
22
23 static DftAnalysisConfig createConfig() {
24 return DftAnalysisConfig{storm::dft::builder::ApproximationHeuristic::DEPTH, false};
25 }
26};
27
28class ApproxProbabilityConfig {
29 public:
30 typedef double ValueType;
31
32 static DftAnalysisConfig createConfig() {
33 return DftAnalysisConfig{storm::dft::builder::ApproximationHeuristic::PROBABILITY, false};
34 }
35};
36
37class ApproxBoundDifferenceConfig {
38 public:
39 typedef double ValueType;
40
41 static DftAnalysisConfig createConfig() {
43 }
44};
45
46// General base class for testing of DFT approximation
47template<typename TestType>
48class DftApproximationTest : public ::testing::Test {
49 public:
50 typedef typename TestType::ValueType ValueType;
51
52 DftApproximationTest() : config(TestType::createConfig()) {}
53
54 DftApproximationTest const& getConfig() const {
55 return config;
56 }
57
58 std::pair<double, double> analyzeMTTF(std::string const& file, double errorBound) const {
59 std::shared_ptr<storm::dft::storage::DFT<double>> dft =
61 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft).first);
62 std::string property = "T=? [F \"failed\"]";
63 std::vector<std::shared_ptr<storm::logic::Formula const>> properties = storm::api::extractFormulasFromProperties(storm::api::parseProperties(property));
65 *dft, properties, config.useSR, false, storm::dft::utility::RelevantEvents(), false, errorBound, config.heuristic, false);
66 return boost::get<storm::dft::modelchecker::DFTModelChecker<double>::approximation_result>(results[0]);
67 }
68
69 std::pair<double, double> analyzeTimebound(std::string const& file, double timeBound, double errorBound) const {
70 std::shared_ptr<storm::dft::storage::DFT<double>> dft =
72 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft).first);
73 std::stringstream propertyStream;
74 propertyStream << "P=? [F<=" << timeBound << " \"failed\"]";
75 std::vector<std::shared_ptr<storm::logic::Formula const>> properties =
78 *dft, properties, config.useSR, false, storm::dft::utility::RelevantEvents(), false, errorBound, config.heuristic, false);
79 return boost::get<storm::dft::modelchecker::DFTModelChecker<double>::approximation_result>(results[0]);
80 }
81
82 private:
83 DftAnalysisConfig config;
84};
85
86typedef ::testing::Types<ApproxDepthConfig, ApproxProbabilityConfig, ApproxBoundDifferenceConfig> TestingTypes;
87
88TYPED_TEST_SUITE(DftApproximationTest, TestingTypes, );
89
90TYPED_TEST(DftApproximationTest, HecsMTTF) {
91 double errorBound = 2;
92 std::pair<double, double> approxResult = this->analyzeMTTF(STORM_TEST_RESOURCES_DIR "/dft/hecs_3_2_2_np.dft", errorBound);
93 EXPECT_LE(approxResult.first, 417.9436693);
94 EXPECT_GE(approxResult.second, 417.9436693);
95 EXPECT_LE(2 * (approxResult.second - approxResult.first) / (approxResult.first + approxResult.second), errorBound);
96 // Ensure results are not equal -> not exact values were computed
97 EXPECT_GE(approxResult.second - approxResult.first, errorBound * approxResult.first / 10);
98}
99
100TYPED_TEST(DftApproximationTest, HecsTimebound) {
101 // double errorBound = 0.01;
102 double errorBound = 0.1;
103 double timeBound = 100;
104 std::pair<double, double> approxResult = this->analyzeTimebound(STORM_TEST_RESOURCES_DIR "/dft/hecs_3_2_2_np.dft", timeBound, errorBound);
105 EXPECT_LE(approxResult.first, 0.0410018417);
106 EXPECT_GE(approxResult.second, 0.0410018417);
107 EXPECT_LE(approxResult.second - approxResult.first, errorBound);
108 // Ensure results are not equal -> not exact values were computed
109 EXPECT_GE(approxResult.second - approxResult.first, errorBound / 10);
110}
111
112} // 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)
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.
std::shared_ptr< storm::dft::storage::DFT< ValueType > > loadDFTGalileoFile(std::string const &file)
Load DFT from Galileo file.
Definition io.cpp:14
std::pair< bool, std::string > isWellFormed(storm::dft::storage::DFT< ValueType > const &dft, bool validForMarkovianAnalysis)
Check whether the DFT is well-formed.
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, bool allowModularisation, storm::dft::utility::RelevantEvents const &relevantEvents, bool allowDCForRelevant, double approximationError, storm::dft::builder::ApproximationHeuristic approximationHeuristic, bool eliminateChains, storm::transformer::EliminationLabelBehavior labelBehavior, bool printOutput)
Compute the exact or approximate analysis result of the given DFT according to the given properties.
Definition analysis.cpp:28
ApproximationHeuristic
Enum representing the heuristic used for deciding which states to expand.
TYPED_TEST(GraphTestAR, SymbolicProb01StochasticGameDieSmall)
Definition GraphTest.cpp:64
TYPED_TEST_SUITE(GraphTestAR, TestingTypes,)
::testing::Types< Cudd, Sylvan > TestingTypes
Definition GraphTest.cpp:61