← Documentation
ADS-IDAC Engine 5.0.0
bncore::JunctionTreeCompiler Class Reference

Builds a junction tree from a Bayesian network graph. More...

#include <compiler.hpp>

Static Public Member Functions

static std::unique_ptr< JunctionTree > compile (const Graph &graph, const std::string &heuristic="min_fill")
 Compiles a junction tree. More...
 

Static Private Member Functions

static std::vector< std::vector< NodeId > > moralize (const Graph &graph)
 Moral graph as adjacency lists indexed by NodeId, each sorted ascending. More...
 

Detailed Description

Builds a junction tree from a Bayesian network graph.

Definition at line 18 of file compiler.hpp.

Member Function Documentation

◆ compile()

std::unique_ptr< JunctionTree > bncore::JunctionTreeCompiler::compile ( const Graph &  graph,
const std::string &  heuristic = "min_fill" 
)
static

Compiles a junction tree.

The steps are:

  1. Moralize the graph: drop edge directions and connect every pair of parents of a common child.
  2. Triangulate by greedy elimination. At each step the variable whose elimination clique (the variable plus its remaining neighbors) has the smallest product of state counts is eliminated. Ties go to the fewest fill edges, then to the smallest clique. Each step scans every remaining variable and every pair of its neighbors.
  3. Keep the maximal elimination cliques, each with its scope sorted by NodeId.
  4. Join cliques that share variables with a maximum weight spanning tree (Kruskal), where the weight of an edge is the number of shared variables. Cliques with nothing in common are not joined, so a graph with unconnected parts gives a forest.
  5. Fill every clique's base potential with 1.0 and assign each variable's CPT to the first clique that contains the variable and its parents.
Parameters
graphNetwork to compile. The returned tree keeps a pointer to it, so it must outlive the tree.
heuristicName of an elimination heuristic. The argument is not read: the ordering of step 2 is always used.
Returns
The compiled tree, owned by the caller.

Definition at line 53 of file compiler.cpp.

References bncore::Graph::get_parents(), bncore::Graph::get_variable(), moralize(), bncore::Graph::num_variables(), and bncore::VariableMetadata::states.

Referenced by faulttree::Quantifier::build(), and HumanFailureEventsBBN::NetworkInitiation().

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

◆ moralize()

std::vector< std::vector< NodeId > > bncore::JunctionTreeCompiler::moralize ( const Graph &  graph)
staticprivate

Moral graph as adjacency lists indexed by NodeId, each sorted ascending.

Definition at line 18 of file compiler.cpp.

References bncore::Graph::get_children(), bncore::Graph::get_parents(), and bncore::Graph::num_variables().

Referenced by compile().

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

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