Skip to main content

Module junction_tree

Module junction_tree 

Source
Expand description

Junction-tree (clique-tree) exact inference for discrete pairwise/higher-order Markov Random Fields.

Implements the Lauritzen-Spiegelhalter / Hugin algorithm:

  1. Moralise the factor graph — connect every pair of variables that co-occur in the scope of some factor (this also marries co-parents).
  2. Triangulate the moral graph by eliminating variables in a heuristic order (min-fill, breaking ties by min-degree). The set of a variable together with its still-living neighbours at elimination time is a candidate clique.
  3. Collect the maximal cliques (drop any candidate that is a subset of another).
  4. Build a clique tree as a maximum-weight spanning tree over the cliques, where the weight of an edge between two cliques is the size of their separator (their shared variables). Maximising separator sizes guarantees the running-intersection property.
  5. Assign each input factor to a clique that contains its scope and multiply it into that clique’s potential.
  6. Calibrate with a Hugin-style two-pass schedule (collect to a root, then distribute from the root) so that every clique holds the joint marginal over its variables (up to a global scale equal to the partition function Z).

All potentials are stored in the log domain (ln-potentials, row-major over the clique’s joint configuration in increasing variable order) so that the message passing never under/overflows. A configuration value of -inf represents a zero-probability entry.

Structs§

Clique
A clique of the junction tree.
JunctionTree
A calibrated (or calibratable) junction tree for exact inference.
JunctionTreeConfig
Configuration for a junction tree: number of variables and their cardinalities.