Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

HybridGaussianFactorGraph

Open In Colab

HybridGaussianFactorGraph is a specialized HybridFactorGraph designed to represent linearized hybrid systems or systems that are inherently Conditional Linear Gaussian (CLG). It primarily contains:

  • gtsam.GaussianFactor (or derived types like JacobianFactor, HessianFactor)

  • gtsam.DiscreteFactor (or derived types like DecisionTreeFactor, TableFactor)

  • gtsam.HybridGaussianFactor (including HybridGaussianConditional)

This graph type is typically the result of linearizing a HybridNonlinearFactorGraph. It supports specialized elimination methods (eliminateSequential, eliminateMultifrontal via EliminateableFactorGraph base) that correctly handle the mix of discrete and continuous variables, producing a HybridBayesNet or HybridBayesTree.

Initialization and Adding Factors


Hybrid Gaussian Factor Graph: 
size: 3
Factor 0
GaussianFactor:

  A[x0] = [
	-1
]
  b = [ 0 ]
  Noise model: unit (1) 

Factor 1
DiscreteFactor:
 f[ (d0,2), ]
 Choice(d0) 
 0 Leaf  0.7
 1 Leaf  0.3

Factor 2
HybridGaussianFactor:
Hybrid [x1; d1]{
 Choice(d1) 
 0 Leaf :
  A[x1] = [
	1
]
  b = [ 0 ]
  Noise model: unit (1) 
scalar: 0

 1 Leaf :
  A[x1] = [
	1
]
  b = [ 2 ]
isotropic dim=1 sigma=0.5
scalar: 0

}

Loading...

Key Inspection and Choosing a Gaussian Subgraph

Besides the standard keys(), discreteKeys(), etc., you can choose a specific GaussianFactorGraph corresponding to a discrete assignment.


Discrete Keys: d0d1
Continuous Keys: x0x1

Chosen GaussianFactorGraph for D0=0, D1=1:

size: 2
factor 0: 
  A[x0] = [
	-1
]
  b = [ 0 ]
  Noise model: unit (1) 
factor 1: 
  A[x1] = [
	1
]
  b = [ 2 ]
isotropic dim=1 sigma=0.5
Loading...

Computing Errors (error, errorTree, probPrime, discretePosterior)

Several methods exist to evaluate the graph under different assumptions.


Total Hybrid Error (Gaussian+Discrete): 0.38167494393873247

Error Tree (Gaussian factor errors):
ErrorTree
 Choice(d1) 
ErrorTree
 0 Choice(d0) 
ErrorTree
 0 0 Leaf 2.5666749
ErrorTree
 0 1 Leaf 3.4139728
ErrorTree
 1 Choice(d0) 
ErrorTree
 1 0 Leaf 0.38167494
ErrorTree
 1 1 Leaf 1.2289728

Probability Prime (unnormalized density): 0.6827169384198328

Discrete Posterior Tree P(M | X=x):
ErrorTree
 Choice(d1) 
ErrorTree
 0 Choice(d0) 
ErrorTree
 0 0 Leaf 0.070773923
ErrorTree
 0 1 Leaf 0.030331681
ErrorTree
 1 Choice(d0) 
ErrorTree
 1 0 Leaf 0.62922608
ErrorTree
 1 1 Leaf 0.26966832

Elimination (eliminateSequential, eliminateMultifrontal)

Elimination methods handle the hybrid nature, producing HybridBayesNet or HybridBayesTree. Discrete keys are typically eliminated after continuous keys by default using HybridOrdering.


Default Hybrid Ordering: Position 0: x0, x1, d0, d1


Resulting HybridBayesNet:
Loading...

Resulting HybridBayesTree:
Loading...