Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DftExplorationHeuristic.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
8
9namespace storm::dft {
10namespace builder {
11
16
20template<typename ValueType>
22 public:
23 explicit DFTExplorationHeuristic(size_t id) : id(id), expand(false) {
24 // Intentionally left empty
25 }
26
27 virtual ~DFTExplorationHeuristic() = default;
28
29 virtual bool updateHeuristicValues(DFTExplorationHeuristic const& predecessor, ValueType rate, ValueType exitRate) = 0;
30
31 virtual void setBounds(ValueType /*lowerBound*/, ValueType /*upperBound*/) {
32 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Should be handled by specialized heuristic.");
33 }
34
35 void markExpand() {
36 expand = true;
37 }
38
39 size_t getId() const {
40 return id;
41 }
42
43 bool isExpand() const {
44 return expand;
45 }
46
47 virtual size_t getDepth() const {
48 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Should be handled by specialized heuristic.");
49 }
50
51 virtual ValueType getProbability() const {
52 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Should be handled by specialized heuristic.");
53 }
54
55 virtual ValueType getLowerBound() const {
56 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Should be handled by specialized heuristic.");
57 }
58
59 virtual ValueType getUpperBound() const {
60 STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Should be handled by specialized heuristic.");
61 }
62
63 virtual double getPriority() const = 0;
64
65 virtual bool isSkip(double approximationThreshold) const {
66 return !this->isExpand() && this->getPriority() < approximationThreshold;
67 }
68
69 virtual bool operator<(DFTExplorationHeuristic<ValueType> const& other) const {
70 return this->getPriority() < other.getPriority();
71 }
72
73 protected:
74 size_t id;
75 bool expand;
76};
77
78template<typename ValueType>
80 public:
82
84 : DFTExplorationHeuristic<ValueType>(id), depth(predecessor.getDepth() + 1) {}
85
86 bool updateHeuristicValues(DFTExplorationHeuristic<ValueType> const& predecessor, ValueType, ValueType) override {
87 if (predecessor.getDepth() + 1 < this->depth) {
88 this->depth = predecessor.getDepth() + 1;
89 return true;
90 }
91 return false;
92 }
93
94 size_t getDepth() const override {
95 return depth;
96 }
97
98 double getPriority() const override {
99 return this->depth;
100 }
101
102 bool isSkip(double approximationThreshold) const override {
103 return !this->expand && this->getPriority() > approximationThreshold;
104 }
105
106 bool operator<(DFTExplorationHeuristic<ValueType> const& other) const override {
107 return this->getPriority() > other.getPriority();
108 }
109
110 protected:
111 size_t depth;
112};
113
114template<typename ValueType>
116 public:
117 DFTExplorationHeuristicProbability(size_t id) : DFTExplorationHeuristic<ValueType>(id), probability(storm::utility::one<ValueType>()) {}
118
119 DFTExplorationHeuristicProbability(size_t id, DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate)
120 : DFTExplorationHeuristic<ValueType>(id), probability(storm::utility::zero<ValueType>()) {
121 this->updateHeuristicValues(predecessor, rate, exitRate);
122 }
123
124 bool updateHeuristicValues(DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate) override {
125 STORM_LOG_ASSERT(!storm::utility::isZero<ValueType>(exitRate), "Exit rate is 0");
126 probability += predecessor.getProbability() * rate / exitRate;
127 return true;
128 }
129
130 ValueType getProbability() const override {
131 return probability;
132 }
133
134 double getPriority() const override;
135
136 protected:
137 ValueType probability;
138};
139
140template<typename ValueType>
142 public:
144 : DFTExplorationHeuristicProbability<ValueType>(id), lowerBound(storm::utility::zero<ValueType>()), upperBound(storm::utility::infinity<ValueType>()) {}
145
146 DFTExplorationHeuristicBoundDifference(size_t id, DFTExplorationHeuristic<ValueType> const& predecessor, ValueType rate, ValueType exitRate)
147 : DFTExplorationHeuristicProbability<ValueType>(id, predecessor, rate, exitRate),
148 lowerBound(storm::utility::zero<ValueType>()),
149 upperBound(storm::utility::infinity<ValueType>()) {}
150
151 void setBounds(ValueType lowerBound, ValueType upperBound) override {
152 this->lowerBound = lowerBound;
153 this->upperBound = upperBound;
154 }
155
156 ValueType getLowerBound() const override {
157 return lowerBound;
158 }
159
160 ValueType getUpperBound() const override {
161 return upperBound;
162 }
163
164 double getPriority() const override;
165
166 protected:
167 ValueType lowerBound;
168 ValueType upperBound;
169};
170
171} // namespace builder
172} // namespace storm::dft
DFTExplorationHeuristicBoundDifference(size_t id, DFTExplorationHeuristic< ValueType > const &predecessor, ValueType rate, ValueType exitRate)
void setBounds(ValueType lowerBound, ValueType upperBound) override
DFTExplorationHeuristicDepth(size_t id, DFTExplorationHeuristic< ValueType > const &predecessor)
bool operator<(DFTExplorationHeuristic< ValueType > const &other) const override
bool updateHeuristicValues(DFTExplorationHeuristic< ValueType > const &predecessor, ValueType, ValueType) override
bool isSkip(double approximationThreshold) const override
General super class for approximation heuristics.
virtual bool isSkip(double approximationThreshold) const
virtual bool operator<(DFTExplorationHeuristic< ValueType > const &other) const
virtual bool updateHeuristicValues(DFTExplorationHeuristic const &predecessor, ValueType rate, ValueType exitRate)=0
DFTExplorationHeuristicProbability(size_t id, DFTExplorationHeuristic< ValueType > const &predecessor, ValueType rate, ValueType exitRate)
bool updateHeuristicValues(DFTExplorationHeuristic< ValueType > const &predecessor, ValueType rate, ValueType exitRate) override
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
ApproximationHeuristic
Enum representing the heuristic used for deciding which states to expand.
LabParser.cpp.
Definition cli.cpp:18