← Documentation
ADS-IDAC Engine 5.0.0
faulttree::Quantifier Class Reference

Exact fault tree quantifier backed by a BNCore junction tree. More...

#include <quantifier.hpp>

Collaboration diagram for faulttree::Quantifier:
[legend]

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Quantifier() [1/2]

faulttree::Quantifier::Quantifier ( const FaultTree &  tree)
explicit

Compiles the tree. Throws FaultTreeError if the model is invalid or a gate exceeds kMaxGateInputs.

Parameters
treeModel to quantify. It is copied and checked with FaultTree::validate().
Exceptions
FaultTreeErrorif 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().

Here is the call graph for this function:

◆ ~Quantifier()

faulttree::Quantifier::~Quantifier ( )
default

◆ Quantifier() [2/2]

faulttree::Quantifier::Quantifier ( const Quantifier &  )
delete

Member Function Documentation

◆ basicEventNames()

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_.

Here is the call graph for this function:

◆ build()

void faulttree::Quantifier::build ( )
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDefined()

bool faulttree::Quantifier::isDefined ( const std::string &  name) const

True when the tree defines a node of this name.

Parameters
nameNode name, compared exactly.

Definition at line 131 of file quantifier.cpp.

References faulttree::FaultTree::hasNode(), and tree_.

Here is the call graph for this function:

◆ operator=()

Quantifier & faulttree::Quantifier::operator= ( const Quantifier &  )
delete

◆ probabilityOf()

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.

Parameters
nameName of a basic event or gate.
Returns
Marginal probability of the Failed state.
Exceptions
FaultTreeErrorif 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBasicEventProbability()

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.

Parameters
nameName of a basic event.
probabilityNew failure probability, in [0, 1].
Exceptions
FaultTreeErrorif 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_.

Here is the call graph for this function:

◆ topEventProbability()

double faulttree::Quantifier::topEventProbability ( ) const

P(top event = Failed).

Returns
Probability in [0, 1] that the top event of the tree fails.

Definition at line 112 of file quantifier.cpp.

References probabilityOf(), faulttree::FaultTree::top(), and tree_.

Here is the call graph for this function:

Member Data Documentation

◆ engine_

std::unique_ptr<bncore::BatchExecutionEngine> faulttree::Quantifier::engine_
private

refers to junction_tree_

Definition at line 113 of file quantifier.hpp.

Referenced by build(), probabilityOf(), and setBasicEventProbability().

◆ graph_

std::unique_ptr<bncore::Graph> faulttree::Quantifier::graph_
private

one binary variable per node

Definition at line 111 of file quantifier.hpp.

Referenced by build(), and setBasicEventProbability().

◆ junction_tree_

std::unique_ptr<bncore::JunctionTree> faulttree::Quantifier::junction_tree_
private

points at graph_

Definition at line 112 of file quantifier.hpp.

Referenced by build().

◆ tree_

FaultTree faulttree::Quantifier::tree_
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().

◆ var_of_node_

std::unordered_map<std::string, std::size_t> faulttree::Quantifier::var_of_node_
private

node name to BNCore variable id

Definition at line 114 of file quantifier.hpp.

Referenced by build(), probabilityOf(), and setBasicEventProbability().


The documentation for this class was generated from the following files: