Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DFTPand.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
16template<typename ValueType>
17class DFTPand : public DFTGate<ValueType> {
18 public:
26 DFTPand(size_t id, std::string const& name, bool inclusive, std::vector<std::shared_ptr<DFTElement<ValueType>>> const& children = {})
27 : DFTGate<ValueType>(id, name, children), inclusive(inclusive) {
28 // Intentionally left empty.
29 }
30
31 std::shared_ptr<DFTElement<ValueType>> clone() const override {
32 return std::shared_ptr<DFTElement<ValueType>>(new DFTPand<ValueType>(this->id(), this->name(), this->isInclusive(), {}));
33 }
34
38
39 std::string typestring() const override {
40 return this->isInclusive() ? "PAND (incl)" : "PAND (excl)";
41 }
42
47 bool isInclusive() const {
48 return inclusive;
49 }
50
52 STORM_LOG_ASSERT(isInclusive(), "Exclusive PAND not supported.");
53 if (state.isOperational(this->mId)) {
54 bool childOperationalBefore = false;
55 for (auto const& child : this->children()) {
56 if (!state.hasFailed(child->id())) {
57 childOperationalBefore = true;
58 } else if (childOperationalBefore && state.hasFailed(child->id())) {
59 // Child failed before sibling -> failsafe
60 this->failsafe(state, queues);
61 this->childrenDontCare(queues);
62 return;
63 }
64 }
65 if (!childOperationalBefore) {
66 // All children have failed
67 this->fail(state, queues);
68 }
69 }
70 }
71
73 STORM_LOG_ASSERT(isInclusive(), "Exclusive PAND not supported.");
74 STORM_LOG_ASSERT(this->hasFailsafeChild(state), "No failsafe child.");
75 if (state.isOperational(this->mId)) {
76 this->failsafe(state, queues);
77 this->childrenDontCare(queues);
78 }
79 }
80
81 protected:
83};
84
85} // namespace elements
86} // namespace storage
87} // namespace storm::dft
bool hasFailed(size_t id) const
Definition DFTState.cpp:155
bool isOperational(size_t id) const
Definition DFTState.cpp:150
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
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
Priority AND (PAND) gate.
Definition DFTPand.h:17
storm::dft::storage::elements::DFTElementType type() const override
Get type.
Definition DFTPand.h:35
std::string typestring() const override
Get type as string.
Definition DFTPand.h:39
DFTPand(size_t id, std::string const &name, bool inclusive, std::vector< std::shared_ptr< DFTElement< ValueType > > > const &children={})
Constructor.
Definition DFTPand.h:26
void checkFails(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Check failed status.
Definition DFTPand.h:51
bool isInclusive() const
Return whether the PAND is inclusive.
Definition DFTPand.h:47
void checkFailsafe(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Check failsafe status.
Definition DFTPand.h:72
std::shared_ptr< DFTElement< ValueType > > clone() const override
Create a shallow copy of the element.
Definition DFTPand.h:31
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
DFTElementType
Element types in a DFT.