Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DFTVot.h
Go to the documentation of this file.
1#pragma once
2
3#include "DFTGate.h"
4
5namespace storm::dft {
6namespace storage {
7namespace elements {
8
13template<typename ValueType>
14class DFTVot : public DFTGate<ValueType> {
15 public:
23 DFTVot(size_t id, std::string const& name, unsigned threshold, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {})
24 : DFTGate<ValueType>(id, name, children), mThreshold(threshold) {
25 STORM_LOG_ASSERT(mThreshold > 1, "Should use OR gate instead of VOT1");
26 // k=n cannot be checked as children might be added later
27 }
28
29 std::shared_ptr<DFTElement<ValueType>> clone() const override {
30 return std::shared_ptr<DFTElement<ValueType>>(new DFTVot<ValueType>(this->id(), this->name(), this->threshold(), {}));
31 }
32
36
37 bool isStaticElement() const override {
38 return true;
39 }
40
45 unsigned threshold() const {
46 return mThreshold;
47 }
48
49 std::string typestring() const override {
50 return storm::dft::storage::elements::toString(this->type()) + " (" + std::to_string(mThreshold) + ")";
51 }
52
54 if (state.isOperational(this->mId)) {
55 unsigned nrFailedChildren = 0;
56 for (auto const& child : this->children()) {
57 if (state.hasFailed(child->id())) {
58 ++nrFailedChildren;
59 if (nrFailedChildren >= mThreshold) {
60 this->fail(state, queues);
61 return;
62 }
63 }
64 }
65 }
66 }
67
69 STORM_LOG_ASSERT(this->hasFailsafeChild(state), "No failsafe child.");
70 if (state.isOperational(this->mId)) {
71 unsigned nrFailsafeChildren = 0;
72 for (auto const& child : this->children()) {
73 if (state.isFailsafe(child->id())) {
74 ++nrFailsafeChildren;
75 if (nrFailsafeChildren > this->nrChildren() - mThreshold) {
76 this->failsafe(state, queues);
77 this->childrenDontCare(queues);
78 return;
79 }
80 }
81 }
82 }
83 }
84
85 bool isTypeEqualTo(DFTElement<ValueType> const& other) const override {
87 return false;
88 }
89 auto& otherVOT = static_cast<DFTVot<ValueType> const&>(other);
90 return this->threshold() == otherVOT.threshold();
91 }
92
93 private:
94 unsigned mThreshold;
95};
96
97} // namespace elements
98} // namespace storage
99} // namespace storm::dft
bool hasFailed(size_t id) const
Definition DFTState.cpp:155
bool isOperational(size_t id) const
Definition DFTState.cpp:150
bool isFailsafe(size_t id) const
Definition DFTState.cpp:165
bool hasFailsafeChild(storm::dft::storage::DFTState< ValueType > &state) const
Check whether it has a failsafe child.
DFTElementVector const & children() const
Get children.
Definition DFTChildren.h:45
size_t nrChildren() const override
Get number of children.
Definition DFTChildren.h:49
Abstract base class for DFT elements.
Definition DFTElement.h:39
virtual size_t id() const
Get id.
Definition DFTElement.h:73
virtual std::string const & name() const
Get name.
Definition DFTElement.h:89
Abstract base class for gates.
Definition DFTGate.h:13
void failsafe(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Definition DFTGate.h:72
void childrenDontCare(storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const
Propagate Don't Care to children.
Definition DFTGate.h:86
void fail(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Definition DFTGate.h:59
VOT gate with threshold k.
Definition DFTVot.h:14
DFTVot(size_t id, std::string const &name, unsigned threshold, std::vector< std::shared_ptr< DFTElement< ValueType > > > const &children={})
Constructor.
Definition DFTVot.h:23
bool isTypeEqualTo(DFTElement< ValueType > const &other) const override
Check whether two elements have the same type.
Definition DFTVot.h:85
void checkFails(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Check failed status.
Definition DFTVot.h:53
storm::dft::storage::elements::DFTElementType type() const override
Get type.
Definition DFTVot.h:33
void checkFailsafe(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Check failsafe status.
Definition DFTVot.h:68
std::shared_ptr< DFTElement< ValueType > > clone() const override
Create a shallow copy of the element.
Definition DFTVot.h:29
bool isStaticElement() const override
Check whether the element is static, ie a BE or a static gate (AND, OR, VOT).
Definition DFTVot.h:37
unsigned threshold() const
Get the threshold k.
Definition DFTVot.h:45
std::string typestring() const override
Get type as string.
Definition DFTVot.h:49
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
DFTElementType
Element types in a DFT.
std::string toString(DFTElementType const &type)