This header configures iSAM2’s nonlinear update strategy. ISAM2Params holds global incremental settings and one of three wrapped inner-step configurations: Gauss–Newton, Dogleg, or Dogleg line search.
import gtsam
import numpy as np
from gtsam.symbol_shorthand import L, V, XISAM2GaussNewtonParams¶
Gauss–Newton uses wildfire thresholding to skip small back-substitution updates. Lower thresholds do more work but approximate the full update more closely.
gauss_newton = gtsam.ISAM2GaussNewtonParams(0.001)
gauss_newton.setWildfireThreshold(5e-4)
print("wildfire threshold:", gauss_newton.getWildfireThreshold())ISAM2DoglegParams¶
Dogleg adds a trust-region radius and an adaptation mode. setInitialDelta(), setAdaptationMode(), and setVerbose() tune that local nonlinear step.
dogleg = gtsam.ISAM2DoglegParams()
dogleg.setInitialDelta(1.0)
dogleg.setAdaptationMode("SEARCH_EACH_ITERATION")
dogleg.setWildfireThreshold(1e-4)
print("initial delta:", dogleg.getInitialDelta())ISAM2DoglegLineSearchParams¶
The line-search variant bounds the trust-region radius and controls step size and sufficient decrease. It is useful when the standard adaptation rule is too coarse.
line_search = gtsam.ISAM2DoglegLineSearchParams()
line_search.setMinDelta(1e-4)
line_search.setMaxDelta(10.0)
line_search.setStepSize(0.5)
line_search.setSufficientDecreaseCoeff(1e-4)
print("delta interval:", line_search.getMinDelta(), line_search.getMaxDelta())ISAM2Params¶
The main object selects one optimization configuration and controls relinearization, factorization, caching, detailed results, and factor-slot reuse. Relinearization threshold and skip are the most important accuracy/performance controls.
params = gtsam.ISAM2Params()
params.setOptimizationParams(gauss_newton)
params.setRelinearizeThreshold(0.05)
params.relinearizeSkip = 1
params.enableDetailedResults = True
params.evaluateNonlinearError = True
params.setFactorization("CHOLESKY")
print("factorization:", params.getFactorization())