FactorGraph is a Julia package for constructing factor graphs and running belief propagation algorithms.
Gaussian models can use scalar or vector variables, linear Gaussian factors, belief propagation in moment, canonical, and min-sum form.
Discrete finite-state models are represented with variables over finite state spaces and factor tables, with iterative sum-product inference for marginals and min-sum inference for MAP estimates.
The Gaussian and discrete APIs share support for sequential, flooding, and residual schedules, damping, exact forward-backward inference on tree-structured graphs, dynamic graph updates, and inspection helpers for graphs, messages, marginals, and estimates.
Install FactorGraph from the Julia package manager:
pkg> add FactorGraphThen load it in Julia:
using FactorGraphusing FactorGraph
variables = [
GaussianVariable(:x1, 1),
GaussianVariable(:x2, 1),
]
factors = [
GaussianFactor(:x1, 1.0, 1.0, 0.1; label = "prior_x1"),
GaussianFactor(:x2, 2.0, 1.0, 0.1; label = "prior_x2"),
GaussianFactor(:x1, :x2, -1.0, [1.0 -1.0], 0.2; label = "link"),
]
graph = factorGraph(variables, factors)
inference = moment(graph)
gbp!(graph, inference; iterations = 30)
marginalMean(graph, inference, :x1)
marginalCovariance(graph, inference, :x1)- Gaussian factor graphs with moment, canonical, and min-sum inference
- Discrete finite-state factor graphs with sum-product and min-sum inference
- Sequential, flooding, and residual message schedules
- Exact forward-backward inference on tree-structured graphs
- Dynamic graph updates with stale-inference checks
- Freezing, damping, diagnostics, WLS validation, and graph visualization
The full documentation is available at mcosovic.github.io/FactorGraph.jl/stable.
It includes:
- Gaussian and discrete model guides
- Iterative and tree-structured inference
- Domain examples and graph visualization
- Dynamic graph updates and validation helpers
- API references and release notes
FactorGraph is released under the MIT License.