|
ADS-IDAC Engine 5.0.0
|
A fault tree: nodes keyed by name, plus a designated top event. More...
#include <fault_tree.hpp>
Public Member Functions | |
| void | addNode (Node node) |
| Adds a node at the end of the node list. More... | |
| bool | hasNode (const std::string &name) const |
| Tests whether a node of this name has been added. More... | |
| const Node & | node (const std::string &name) const |
| Looks a node up by name. More... | |
| const std::vector< Node > & | nodes () const |
| All nodes, basic events and gates, in the order they were added. More... | |
| std::size_t | size () const |
| Number of nodes (basic events plus gates). More... | |
| void | setTop (const std::string &name) |
| Designates the top event. More... | |
| const std::string & | top () const |
| Name of the top event. More... | |
| std::vector< std::string > | basicEventNames () const |
| void | setBasicEventProbability (const std::string &name, double probability) |
| void | validate () const |
Private Member Functions | |
| Node & | mutableNode (const std::string &name) |
| Non-const lookup. Throws FaultTreeError when the name is unknown. More... | |
Private Attributes | |
| std::vector< Node > | nodes_ |
| insertion order More... | |
| std::unordered_map< std::string, std::size_t > | index_ |
| name to position in nodes_ More... | |
| std::string | top_ |
| empty until setTop() More... | |
A fault tree: nodes keyed by name, plus a designated top event.
Nodes are stored in the order they are added, and that order is what nodes() and basicEventNames() report. addNode() and setTop() check only the name. All structural rules are checked by validate(), which the .fta reader and the Quantifier constructor both call.
Definition at line 78 of file fault_tree.hpp.
| void faulttree::FaultTree::addNode | ( | Node | node | ) |
Adds a node at the end of the node list.
The inputs named in node.children do not have to exist yet.
| node | Node to store. node.name must be non-empty. |
| FaultTreeError | if the name is empty or a node of that name already exists. |
Definition at line 23 of file fault_tree.cpp.
References index_, faulttree::Node::name, node(), and nodes_.
| std::vector< std::string > faulttree::FaultTree::basicEventNames | ( | ) | const |
Names of every basic event, in definition order (the order of the addNode() calls).
Definition at line 64 of file fault_tree.cpp.
References faulttree::Basic, faulttree::Node::name, node(), nodes_, and faulttree::Node::type.
Referenced by faulttree::Quantifier::basicEventNames().
| bool faulttree::FaultTree::hasNode | ( | const std::string & | name | ) | const |
Tests whether a node of this name has been added.
| name | Node name, compared exactly. |
Definition at line 32 of file fault_tree.cpp.
References index_.
Referenced by faulttree::Quantifier::isDefined(), setTop(), and validate().
|
private |
Non-const lookup. Throws FaultTreeError when the name is unknown.
Definition at line 44 of file fault_tree.cpp.
References index_, and nodes_.
Referenced by setBasicEventProbability().
| const Node & faulttree::FaultTree::node | ( | const std::string & | name | ) | const |
Looks a node up by name.
| name | Node name, compared exactly. |
| FaultTreeError | if no node of that name exists. |
Definition at line 36 of file fault_tree.cpp.
References index_, and nodes_.
Referenced by addNode(), basicEventNames(), and validate().
|
inline |
All nodes, basic events and gates, in the order they were added.
Definition at line 103 of file fault_tree.hpp.
References nodes_.
Referenced by faulttree::Quantifier::build().
| void faulttree::FaultTree::setBasicEventProbability | ( | const std::string & | name, |
| double | probability | ||
| ) |
Overrides a basic event's probability (the fixEvent operation the engine performs when a component failure is observed).
| name | Name of a basic event. |
| probability | New failure probability, in [0, 1]. |
| FaultTreeError | if the node is missing, is not a basic event, or the probability is outside [0, 1] (NaN is rejected too). |
Definition at line 72 of file fault_tree.cpp.
References faulttree::Basic, mutableNode(), faulttree::Node::probability, and faulttree::Node::type.
Referenced by faulttree::Quantifier::setBasicEventProbability().
| void faulttree::FaultTree::setTop | ( | const std::string & | name | ) |
Designates the top event.
| name | Name of a node that has already been added. |
| FaultTreeError | if no node of that name exists. |
Definition at line 52 of file fault_tree.cpp.
References hasNode(), and top_.
|
inline |
Number of nodes (basic events plus gates).
Definition at line 106 of file fault_tree.hpp.
References nodes_.
Referenced by faulttree::Quantifier::probabilityOf().
| const std::string & faulttree::FaultTree::top | ( | ) | const |
Name of the top event.
| FaultTreeError | if setTop() has not been called. |
Definition at line 59 of file fault_tree.cpp.
References top_.
Referenced by faulttree::Quantifier::topEventProbability().
| void faulttree::FaultTree::validate | ( | ) | const |
Structural check: every child resolves, no cycles, gates have the inputs their type requires, probabilities are in [0, 1], k is within range. Throws FaultTreeError describing the first problem found.
The checks, in order:
An event that feeds several gates is valid. Nodes that cannot be reached from the top event are not reported.
| FaultTreeError | for the first violated rule. |
Definition at line 88 of file fault_tree.cpp.
References faulttree::And, faulttree::Basic, faulttree::Node::children, hasNode(), index_, faulttree::Node::k, faulttree::KofN, faulttree::Node::name, node(), nodes_, faulttree::Not, faulttree::Or, faulttree::Node::probability, top_, and faulttree::Node::type.
Referenced by faulttree::Quantifier::Quantifier().
|
private |
name to position in nodes_
Definition at line 153 of file fault_tree.hpp.
Referenced by addNode(), hasNode(), mutableNode(), node(), and validate().
|
private |
insertion order
Definition at line 152 of file fault_tree.hpp.
Referenced by addNode(), basicEventNames(), mutableNode(), node(), nodes(), size(), and validate().
|
private |
empty until setTop()
Definition at line 154 of file fault_tree.hpp.
Referenced by setTop(), top(), and validate().