Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DFTElement.cpp
Go to the documentation of this file.
2
3#include <set>
4
9
10namespace storm::dft {
11namespace storage {
12namespace elements {
13
14template<typename ValueType>
17 if (!this->mAllowDC) {
18 return false;
19 }
20
21 if (state.dontCare(mId)) {
22 return false;
23 }
24
25 // Check that no outgoing dependencies can be triggered anymore
26 // Notice that n-ary dependencies are supported via rewriting them during build-time
27 for (DFTDependencyPointer dependency : mOutgoingDependencies) {
28 assert(dependency->dependentEvents().size() == 1);
29 if (state.isOperational(dependency->dependentEvents()[0]->id()) && state.isOperational(dependency->triggerEvent()->id())) {
30 return false;
31 }
32 }
33
34 bool hasParentSpare = false;
35
36 // Check that no parent can fail anymore
37 for (DFTGatePointer const& parent : mParents) {
38 if (state.isOperational(parent->id())) {
39 return false;
40 }
41 if (parent->isSpareGate()) {
42 hasParentSpare = true;
43 }
44 }
45
46 if (!mRestrictions.empty() && state.isEventRelevantInRestriction(mId)) {
47 return false;
48 }
49
50 state.setDontCare(mId);
51 if (hasParentSpare) {
52 // Activate child for consistency in failed spares
53 state.activate(mId);
54 }
55 return true;
56}
57
58template<typename ValueType>
59void DFTElement<ValueType>::extendSpareModule(std::set<size_t>& elementsInModule) const {
60 for (auto const& parent : mParents) {
61 if (elementsInModule.count(parent->id()) == 0 && !parent->isSpareGate()) {
62 elementsInModule.insert(parent->id());
63 parent->extendSpareModule(elementsInModule);
64 }
65 }
66}
67
68template<typename ValueType>
69std::vector<size_t> DFTElement<ValueType>::independentUnit() const {
70 std::vector<size_t> res;
71 res.push_back(this->id());
72 // Extend for pdeps.
73 return res;
74}
75
76template<typename ValueType>
77void DFTElement<ValueType>::extendUnit(std::set<size_t>& unit) const {
78 unit.insert(mId);
79}
80
81template<typename ValueType>
82std::vector<size_t> DFTElement<ValueType>::independentSubDft(bool blockParents, bool sparesAsLeaves) const {
83 std::vector<size_t> res;
84 res.push_back(this->id());
85 return res;
86}
87
88template<typename ValueType>
89void DFTElement<ValueType>::extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t> const& parentsOfSubRoot, bool blockParents,
90 bool sparesAsLeaves) const {
91 if (elemsInSubtree.count(this->id()) > 0)
92 return;
93 if (std::find(parentsOfSubRoot.begin(), parentsOfSubRoot.end(), mId) != parentsOfSubRoot.end()) {
94 // This is a parent of the suspected root, thus it is not a subdft.
95 elemsInSubtree.clear();
96 return;
97 }
98 elemsInSubtree.insert(mId);
99 for (auto const& parent : mParents) {
100 if (blockParents && std::find(parentsOfSubRoot.begin(), parentsOfSubRoot.end(), parent->id()) != parentsOfSubRoot.end()) {
101 continue;
102 }
103 parent->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
104 if (elemsInSubtree.empty()) {
105 return;
106 }
107 }
108 for (auto const& dep : mOutgoingDependencies) {
109 dep->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
110 if (elemsInSubtree.empty()) {
111 return;
112 }
113 }
114
115 for (auto const& restr : mRestrictions) {
116 restr->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
117 if (elemsInSubtree.empty()) {
118 return;
119 }
120 }
121}
122
123// Explicitly instantiate the class.
124template class DFTElement<double>;
125template class DFTElement<RationalFunction>;
126
127} // namespace elements
128} // namespace storage
129} // namespace storm::dft
void activate(size_t repr)
Definition DFTState.cpp:385
bool isEventRelevantInRestriction(size_t id) const
Check whether the event is still relevant for any restriction.
Definition DFTState.cpp:493
bool dontCare(size_t id) const
Definition DFTState.cpp:177
bool isOperational(size_t id) const
Definition DFTState.cpp:152
Abstract base class for DFT elements.
Definition DFTElement.h:38
virtual void extendUnit(std::set< size_t > &unit) const
Helper to independent unit computation.
virtual bool checkDontCareAnymore(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const
virtual std::vector< size_t > independentUnit() const
Computes the independent unit of this element, that is, all elements which are direct or indirect suc...
virtual void extendSpareModule(std::set< size_t > &elementsInModule) const
virtual void extendSubDft(std::set< size_t > &elemsInSubtree, std::vector< size_t > const &parentsOfSubRoot, bool blockParents, bool sparesAsLeaves) const
Helper to the independent subtree computation.
virtual std::vector< size_t > independentSubDft(bool blockParents, bool sparesAsLeaves=false) const
Computes independent subtrees starting with this element (this), that is, all elements (x) which are ...