|
ADS-IDAC Engine 5.0.0
|
Exact fault tree quantifier backed by a BNCore junction tree. More...
#include <quantifier.hpp>
Public Member Functions | |
| Quantifier (const FaultTree &tree) | |
| ~Quantifier () | |
| Quantifier (const Quantifier &)=delete | |
| Quantifier & | operator= (const Quantifier &)=delete |
| double | topEventProbability () const |
| double | probabilityOf (const std::string &name) const |
| void | setBasicEventProbability (const std::string &name, double probability) |
| std::vector< std::string > | basicEventNames () const |
| Names of the basic events, in definition order. More... | |
| bool | isDefined (const std::string &name) const |
Private Member Functions | |
| void | build () |
Private Attributes | |
| FaultTree | tree_ |
| validated private copy of the model More... | |
| std::unique_ptr< bncore::Graph > | graph_ |
| one binary variable per node More... | |
| std::unique_ptr< bncore::JunctionTree > | junction_tree_ |
| points at graph_ More... | |
| std::unique_ptr< bncore::BatchExecutionEngine > | engine_ |
| refers to junction_tree_ More... | |
| std::unordered_map< std::string, std::size_t > | var_of_node_ |
| node name to BNCore variable id More... | |
Exact fault tree quantifier backed by a BNCore junction tree.
Construction copies the tree, validates it, and builds the network: one binary BNCore variable per node (state 0 "Failed", state 1 "Working"), one edge from each input to the gate it feeds, the prior {p, 1-p} for each basic event, and a deterministic conditional table for each gate. The junction tree is compiled once, and queries run on a single-threaded bncore::BatchExecutionEngine with no evidence.
The quantifier works on its own copy of the tree, so later changes to the caller's FaultTree have no effect on it. It is not copyable.
Definition at line 57 of file quantifier.hpp.
|
explicit |
Compiles the tree. Throws FaultTreeError if the model is invalid or a gate exceeds kMaxGateInputs.
| tree | Model to quantify. It is copied and checked with FaultTree::validate(). |
| FaultTreeError | if validation fails or a gate has more than kMaxGateInputs inputs. |
Definition at line 34 of file quantifier.cpp.
References build(), tree_, and faulttree::FaultTree::validate().
|
default |
|
delete |
| std::vector< std::string > faulttree::Quantifier::basicEventNames | ( | ) | const |
Names of the basic events, in definition order.
Definition at line 127 of file quantifier.cpp.
References faulttree::FaultTree::basicEventNames(), and tree_.
|
private |
Builds graph_, the conditional tables, junction_tree_ and engine_ from tree_.
Definition at line 41 of file quantifier.cpp.
References faulttree::Basic, bncore::JunctionTreeCompiler::compile(), engine_, graph_, junction_tree_, faulttree::kMaxGateInputs, faulttree::FaultTree::nodes(), tree_, and var_of_node_.
Referenced by Quantifier().
| bool faulttree::Quantifier::isDefined | ( | const std::string & | name | ) | const |
True when the tree defines a node of this name.
| name | Node name, compared exactly. |
Definition at line 131 of file quantifier.cpp.
References faulttree::FaultTree::hasNode(), and tree_.
|
delete |
| double faulttree::Quantifier::probabilityOf | ( | const std::string & | name | ) | const |
P(node = Failed) for any node in the tree.
Each call runs one evaluation of the inference engine. The call is const for the quantifier but reuses the engine's cached workspace, so concurrent queries on one Quantifier are not synchronized.
| name | Name of a basic event or gate. |
| FaultTreeError | if the tree has no node of that name. |
Definition at line 99 of file quantifier.cpp.
References engine_, faulttree::FaultTree::size(), tree_, and var_of_node_.
Referenced by topEventProbability().
| void faulttree::Quantifier::setBasicEventProbability | ( | const std::string & | name, |
| double | probability | ||
| ) |
Re-quantifies a basic event. This is the fixEvent operation: when a component is observed failed, its basic event is pinned to 1.0 and the tree is re-evaluated.
The stored tree and the variable's prior are updated in place and the engine's cached workspace is dropped, so the next query rebuilds its potentials from the new value. The junction tree is not recompiled.
| name | Name of a basic event. |
| probability | New failure probability, in [0, 1]. |
| FaultTreeError | if the node is missing, is a gate, or the probability is outside [0, 1]. Nothing is changed in that case. |
Definition at line 116 of file quantifier.cpp.
References engine_, graph_, faulttree::FaultTree::setBasicEventProbability(), tree_, and var_of_node_.
| double faulttree::Quantifier::topEventProbability | ( | ) | const |
P(top event = Failed).
Definition at line 112 of file quantifier.cpp.
References probabilityOf(), faulttree::FaultTree::top(), and tree_.
|
private |
refers to junction_tree_
Definition at line 113 of file quantifier.hpp.
Referenced by build(), probabilityOf(), and setBasicEventProbability().
|
private |
one binary variable per node
Definition at line 111 of file quantifier.hpp.
Referenced by build(), and setBasicEventProbability().
|
private |
|
private |
validated private copy of the model
Definition at line 110 of file quantifier.hpp.
Referenced by basicEventNames(), build(), isDefined(), probabilityOf(), Quantifier(), setBasicEventProbability(), and topEventProbability().
|
private |
node name to BNCore variable id
Definition at line 114 of file quantifier.hpp.
Referenced by build(), probabilityOf(), and setBasicEventProbability().