Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DFTState.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
6
10
11namespace storm::dft {
12namespace storage {
13
14// Forward declarations
15namespace elements {
16
17template<typename ValueType>
18class DFTBE;
19template<typename ValueType>
20class DFTDependency;
21template<typename ValueType>
22class DFTElement;
23
24} // namespace elements
25
26template<typename ValueType>
27class DFT;
29
30template<typename ValueType>
31class DFTState {
32 friend struct std::hash<DFTState>;
33
34 private:
35 // Status is bitvector where each element has two bits with the meaning according to DFTElementState
37 size_t mId;
39 std::vector<size_t> mUsedRepresentants;
40 size_t indexRelevant;
41 bool mPseudoState;
42 bool mValid = true;
43 bool mTransient = false;
44 const DFT<ValueType>& mDft;
45 const DFTStateGenerationInfo& mStateGenerationInfo;
46
47 public:
55 DFTState(DFT<ValueType> const& dft, DFTStateGenerationInfo const& stateGenerationInfo, size_t id);
56
65 DFTState(storm::storage::BitVector const& status, DFT<ValueType> const& dft, DFTStateGenerationInfo const& stateGenerationInfo, size_t id);
66
70 void construct();
71
72 std::shared_ptr<DFTState<ValueType>> copy() const;
73
74 DFTElementState getElementState(size_t id) const;
75
76 static DFTElementState getElementState(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id);
77
79
80 static DFTDependencyState getDependencyState(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id);
81
82 size_t getId() const;
83
84 void setId(size_t id);
85
86 bool isOperational(size_t id) const;
87
88 bool hasFailed(size_t id) const;
89
90 static bool hasFailed(storm::storage::BitVector const& state, size_t indexId);
91
92 bool isFailsafe(size_t id) const;
93
94 static bool isFailsafe(storm::storage::BitVector const& state, size_t indexId);
95
96 bool dontCare(size_t id) const;
97
98 bool dependencyTriggered(size_t id) const;
99
100 bool dependencySuccessful(size_t id) const;
101
102 bool dependencyUnsuccessful(size_t id) const;
103
104 void setFailed(size_t id);
105
106 void setFailsafe(size_t id);
107
108 void setDontCare(size_t id);
109
110 void setDependencySuccessful(size_t id);
111
112 void setDependencyUnsuccessful(size_t id);
113
114 void setDependencyDontCare(size_t id);
115
116 void beNoLongerFailable(size_t id);
117
118 void activate(size_t repr);
119
120 bool isActive(size_t id) const;
121
123 mValid = false;
124 }
125
126 bool isInvalid() const {
127 return !mValid;
128 }
129
131 mTransient = true;
132 }
133
134 bool isTransient() const {
135 return mTransient;
136 }
137
138 bool isPseudoState() const {
139 return mPseudoState;
140 }
141
143 return mStatus;
144 }
145
147 return failableElements;
148 }
149
156 uint_fast64_t uses(size_t id) const;
157
167 static uint_fast64_t usesIndex(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id);
168
174 uint_fast64_t extractUses(size_t from) const;
175
181 bool isUsed(size_t child) const;
182
188 void setUses(size_t spareId, size_t child);
189
194 void finalizeUses(size_t spareId);
195
205 bool claimNew(size_t spareId, size_t currentlyUses, std::vector<std::shared_ptr<storm::dft::storage::elements::DFTElement<ValueType>>> const& children);
206
214 ValueType getFailableBERate(size_t index) const;
215
223 ValueType getBERate(size_t id) const;
224
230 bool updateFailableDependencies(size_t id);
231
237 bool updateFailableInRestrictions(size_t id);
238
243 void updateDontCareDependencies(size_t id);
244
250 void letBEFail(std::shared_ptr<storm::dft::storage::elements::DFTBE<ValueType> const> be);
251
258 void letDependencyTrigger(std::shared_ptr<storm::dft::storage::elements::DFTDependency<ValueType> const> dependency, bool successful = true);
259
264 bool orderBySymmetry();
265
271 bool isEventDisabledViaRestriction(size_t id) const;
272
278 bool isEventRelevantInRestriction(size_t id) const;
279
285
286 friend bool operator==(DFTState const& a, DFTState const& b) {
287 return a.mStatus == b.mStatus;
288 }
289
290 private:
291 void propagateActivation(size_t representativeId);
292
293 int getElementStateInt(size_t id) const;
294
295 static int getElementStateInt(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id);
296};
297
298} // namespace storage
299} // namespace storm::dft
300
301namespace std {
302template<typename ValueType>
303struct hash<storm::dft::storage::DFTState<ValueType>> {
304 size_t operator()(storm::dft::storage::DFTState<ValueType> const& s) const {
305 return hash<storm::storage::BitVector>()(s.mStatus);
306 }
307};
308} // namespace std
Represents a Dynamic Fault Tree.
Definition DFT.h:52
void letBEFail(std::shared_ptr< storm::dft::storage::elements::DFTBE< ValueType > const > be)
Sets the next BE as failed.
Definition DFTState.cpp:357
void setDependencyDontCare(size_t id)
Definition DFTState.cpp:227
bool dependencyUnsuccessful(size_t id) const
Definition DFTState.cpp:189
friend bool operator==(DFTState const &a, DFTState const &b)
Definition DFTState.h:286
std::shared_ptr< DFTState< ValueType > > copy() const
Definition DFTState.cpp:104
ValueType getBERate(size_t id) const
Get the current failure rate of the given BE.
Definition DFTState.cpp:342
bool claimNew(size_t spareId, size_t currentlyUses, std::vector< std::shared_ptr< storm::dft::storage::elements::DFTElement< ValueType > > > const &children)
Claim a new spare child for the given spare gate.
Definition DFTState.cpp:530
void beNoLongerFailable(size_t id)
Definition DFTState.cpp:232
void activate(size_t repr)
Definition DFTState.cpp:383
DFTDependencyState getDependencyState(size_t id) const
Definition DFTState.cpp:119
void letDependencyTrigger(std::shared_ptr< storm::dft::storage::elements::DFTDependency< ValueType > const > dependency, bool successful=true)
Trigger the dependency and set it as successful/unsuccessful.
Definition DFTState.cpp:371
storm::dft::storage::FailableElements & getFailableElements()
Definition DFTState.h:146
bool hasFailed(size_t id) const
Definition DFTState.cpp:155
uint_fast64_t uses(size_t id) const
This method returns the id of the used child for a spare.
Definition DFTState.cpp:431
bool isUsed(size_t child) const
Checks whether an element is currently used.
Definition DFTState.cpp:452
bool isActive(size_t id) const
Definition DFTState.cpp:389
bool hasOperationalRelevantEvent()
Check whether at least one relevant event is still operational.
Definition DFTState.cpp:514
bool updateFailableDependencies(size_t id)
Sets all failable BEs due to dependencies from newly failed element.
Definition DFTState.cpp:238
ValueType getFailableBERate(size_t index) const
Get the failure rate of the currently failable BE on the given index.
bool dependencySuccessful(size_t id) const
Definition DFTState.cpp:185
bool isEventRelevantInRestriction(size_t id) const
Check whether the event is still relevant for any restriction.
Definition DFTState.cpp:491
void finalizeUses(size_t spareId)
Sets the use for the spare to a default value to gain consistent states after failures.
Definition DFTState.cpp:463
bool orderBySymmetry()
Order the state in decreasing order using the symmetries.
Definition DFTState.cpp:553
uint_fast64_t extractUses(size_t from) const
This method is commonly used to get the usage information for spares.
Definition DFTState.cpp:446
bool dontCare(size_t id) const
Definition DFTState.cpp:175
bool isOperational(size_t id) const
Definition DFTState.cpp:150
bool updateFailableInRestrictions(size_t id)
Sets all failable BEs due to restrictions from newly failed element.
Definition DFTState.cpp:265
bool isEventDisabledViaRestriction(size_t id) const
Check whether the event cannot fail at the moment due to a restriction.
Definition DFTState.cpp:469
void setDependencyUnsuccessful(size_t id)
Definition DFTState.cpp:220
DFTElementState getElementState(size_t id) const
Definition DFTState.cpp:109
storm::storage::BitVector const & status() const
Definition DFTState.h:142
void updateDontCareDependencies(size_t id)
Sets all dependencies dont care whose dependent event is the newly failed BE.
Definition DFTState.cpp:329
void setUses(size_t spareId, size_t child)
Sets for the spare which child is now used.
Definition DFTState.cpp:457
bool isFailsafe(size_t id) const
Definition DFTState.cpp:165
bool dependencyTriggered(size_t id) const
Definition DFTState.cpp:180
void construct()
Construct concrete state from pseudo state by using the underlying bitvector.
Definition DFTState.cpp:49
void setDependencySuccessful(size_t id)
Definition DFTState.cpp:213
static uint_fast64_t usesIndex(storm::storage::BitVector const &state, DFTStateGenerationInfo const &stateGenerationInfo, size_t id)
Returns the index of the used child for a spare gate.
Definition DFTState.cpp:441
Handling of currently failable elements (BEs) either due to their own failure or because of dependenc...
Abstract base class for basic events (BEs) in DFTs.
Definition DFTBE.h:14
Dependency gate with probability p.
Abstract base class for DFT elements.
Definition DFTElement.h:39
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
LabParser.cpp.
Definition cli.cpp:18