Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MTTFHelper.cpp
Go to the documentation of this file.
3
4namespace {
5
13void linspace(std::vector<double>& buffer, double start, double const stepsize) {
14 for (size_t i{0}; i < buffer.size(); ++i) {
15 buffer[i] = i * stepsize + start;
16 }
17}
18
19} // namespace
20
21namespace storm::dft {
22namespace utility {
23
24double MTTFHelperProceeding(storm::dft::DftEnvironment const& env, std::shared_ptr<storm::dft::storage::DFT<double>> const dft, double const stepsize,
25 double const precision) {
26 constexpr size_t chunksize{1001};
28
29 std::vector<double> timepoints{};
30 timepoints.resize(chunksize);
31 linspace(timepoints, 0.0, stepsize);
32 std::vector<double> probabilities{checker.getProbabilitiesAtTimepoints(timepoints)};
33
34 double delta{1.0};
35 double rval{0.0};
36
37 double y1{0.0}, y2{0.0}, y3{1.0 - probabilities[0]};
38 size_t i{1};
39 auto currentStepsize{stepsize};
40 while (std::abs(delta) > precision) {
41 if (i + 1 >= probabilities.size()) {
42 double const start{timepoints.back()};
43 // double stepsize
44 if (currentStepsize < 1e-3) {
45 currentStepsize *= 2;
46 }
47 linspace(timepoints, start, currentStepsize);
48 probabilities = checker.getProbabilitiesAtTimepoints(timepoints);
49 i = 1;
50 }
51
52 y1 = y3;
53 y2 = 1.0 - probabilities[i];
54 y3 = 1.0 - probabilities[i + 1];
55 i += 2;
56
57 delta = y1 + 4.0 * y2 + y3;
58 delta /= 3.0;
59 delta *= currentStepsize;
60 rval += delta;
61 }
62
63 return rval;
64}
65
66double MTTFHelperVariableChange(storm::dft::DftEnvironment const& env, std::shared_ptr<storm::dft::storage::DFT<double>> const dft, double const stepsize) {
67 constexpr size_t chunksize{1001};
69
70 std::vector<double> timepoints{};
71 timepoints.resize(static_cast<size_t>(1 / stepsize) - 1);
72 for (size_t i{0}; i < timepoints.size(); ++i) {
73 double x = (i + 1) * stepsize;
74 x = x / (1 - x);
75 timepoints[i] = x;
76 }
77
78 std::vector<double> probabilities{checker.getProbabilitiesAtTimepoints(timepoints, chunksize)};
79
80 double rval{0};
81 for (size_t i{0}; i < probabilities.size(); ++i) {
82 double x{(i + 1) * stepsize};
83 x = 1 / (1 - x);
84 x = x * x;
85 auto& p{probabilities[i]};
86 p = (1 - p) * x;
87
88 rval += p;
89 }
90 // remove the ends
91 rval -= (probabilities.front() + probabilities.back()) / 2;
92 // resize
93 rval *= stepsize;
94
95 return rval;
96}
97
98} // namespace utility
99} // namespace storm::dft
Environment for storm-dft.
std::vector< ValueType > getProbabilitiesAtTimepoints(std::vector< ValueType > const &timepoints, size_t chunksize=0)
Calculate the probability of failure for the given time points.
Represents a Dynamic Fault Tree.
Definition DFT.h:50
double MTTFHelperProceeding(storm::dft::DftEnvironment const &env, std::shared_ptr< storm::dft::storage::DFT< double > > const dft, double const stepsize, double const precision)
Tries to numerically approximate the mttf of the given dft by integrating 1 - cdf(dft) with Simpson's...
double MTTFHelperVariableChange(storm::dft::DftEnvironment const &env, std::shared_ptr< storm::dft::storage::DFT< double > > const dft, double const stepsize)
Tries to numerically approximate the mttf of the given dft by integrating 1 - cdf(dft) by changing th...