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.

HybridFactor

Open In Colab

HybridFactor is the abstract base class for all factors involved in hybrid inference problems within GTSAM. It extends the standard gtsam.Factor interface to accommodate factors that may involve both discrete and continuous variables.

Key features:

Basic Interface

All hybrid factors provide methods to access their continuous and discrete keys and check their category.

Is Discrete? False
Is Continuous? False
Is Hybrid? True
Number of Continuous Keys: 1
Continuous Keys: [8646911284551352320]
Discrete Keys: 
d0 2

All Keys (Factor base): [8646911284551352320, 7205759403792793600]

Hybrid Factor Example (HybridGaussianFactor):
Hybrid [x0; d0]{
 Choice(d0) 
 0 Leaf :
  A[x0] = [
	1
]
  b = [ 0 ]
  Noise model: unit (1) 
scalar: 0

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

}

Virtual Methods (errorTree, restrict)

Derived classes implement methods to handle the interaction between discrete and continuous parts.

  • errorTree(VectorValues): Calculates the error for the continuous part, returning an AlgebraicDecisionTree keyed by the discrete variables.

  • restrict(DiscreteValues): Creates a new factor (typically continuous-only) by fixing the discrete variables to a specific assignment.


Error Tree (AlgebraicDecisionTree):
ErrorTree
 Leaf 0.125

Restricted Factor (Assignment D0=0):
Continuous [x0]{
 Leaf :
  A[x0] = [
	1
]
  b = [ 0 ]
  Noise model: unit (1) 
scalar: 0

}

Restricted Factor (Assignment D0=1):
Continuous [x0]{
 Leaf :
  A[x0] = [
	1
]
  b = [ 1 ]
  Noise model: unit (1) 
scalar: 0

}