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