Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DFTPor.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 DFTPor : public DFTGate<ValueType> {
18 public:
26 DFTPor(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 DFTPor<ValueType>(this->id(), this->name(), this->isInclusive(), {}));
33 }
34
38
39 std::string typestring() const override {
40 return this->isInclusive() ? "POR (incl)" : "POR (excl)";
41 }
42
47 bool isInclusive() const {
48 return inclusive;
49 }
50
52 STORM_LOG_ASSERT(isInclusive(), "Exclusive POR not supported.");
53 if (state.isOperational(this->mId)) {
54 auto childIter = this->children().begin();
55 if (state.hasFailed((*childIter)->id())) {
56 // First child has failed before others
57 this->fail(state, queues);
58 return;
59 }
60 // Iterate over other children
61 for (; childIter != this->children().end(); ++childIter) {
62 if (state.hasFailed((*childIter)->id())) {
63 // Child has failed before first child
64 this->failsafe(state, queues);
65 this->childrenDontCare(queues);
66 }
67 }
68 }
69 }
70
72 STORM_LOG_ASSERT(isInclusive(), "Exclusive POR not supported.");
73 // If first child is not failsafe, it could still fail.
74 if (state.isFailsafe(this->children().front()->id())) {
75 this->failsafe(state, queues);
76 this->childrenDontCare(queues);
77 }
78 }
79
80 protected:
82};
83
84} // namespace elements
85} // namespace storage
86} // 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
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 OR (POR) gate.
Definition DFTPor.h:17
std::string typestring() const override
Get type as string.
Definition DFTPor.h:39
storm::dft::storage::elements::DFTElementType type() const override
Get type.
Definition DFTPor.h:35
void checkFailsafe(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Check failsafe status.
Definition DFTPor.h:71
bool isInclusive() const
Return whether the PAND is inclusive.
Definition DFTPor.h:47
std::shared_ptr< DFTElement< ValueType > > clone() const override
Create a shallow copy of the element.
Definition DFTPor.h:31
DFTPor(size_t id, std::string const &name, bool inclusive, std::vector< std::shared_ptr< DFTElement< ValueType > > > const &children={})
Constructor.
Definition DFTPor.h:26
void checkFails(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const override
Check failed status.
Definition DFTPor.h:51
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
DFTElementType
Element types in a DFT.