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.

GncParams

GncParams<PARAMS> configures graduated non-convexity (GNC), a robust optimization strategy that gradually changes a surrogate loss. Python exposes GncGaussNewtonParams and GncLMParams for Gauss–Newton and Levenberg–Marquardt inner optimizers.

Open In Colab
import gtsam
import numpy as np
from gtsam.symbol_shorthand import L, V, X

GncGaussNewtonParams

Construct with defaults or pass a configured GaussNewtonParams object. The base optimizer controls each weighted least-squares solve; GNC-specific fields control the robust loss schedule and convergence.

gauss_newton = gtsam.GaussNewtonParams()
gauss_newton.setMaxIterations(50)
gnc_gn = gtsam.GncGaussNewtonParams(gauss_newton)
gnc_gn.setLossType(gtsam.GncLossType.TLS)
gnc_gn.setMaxIterations(30)
gnc_gn.setRelativeCostTol(1e-5)
gnc_gn.setWeightsTol(1e-4)
print("inner iterations:", gnc_gn.baseOptimizerParams.getMaxIterations())

GncLMParams

The LM specialization has the same GNC controls but carries LevenbergMarquardtParams as baseOptimizerParams. This is often a safer default for strongly nonlinear problems.

lm = gtsam.LevenbergMarquardtParams.CeresDefaults()
lm.setlambdaInitial(1e-3)
gnc_lm = gtsam.GncLMParams(lm)
gnc_lm.setLossType(gtsam.GncLossType.GM)
gnc_lm.setScheduler(gtsam.GncScheduler.SuperLinear)
gnc_lm.setLambdaStep(1.4)
print("initial LM lambda:", gnc_lm.baseOptimizerParams.getlambdaInitial())

Inliers, outliers, and stopping criteria

setKnownInliers() and setKnownOutliers() lock selected factor indices. setAllowNonNoiseModelFactors() controls whether factors without noise models are accepted. setVerbosityGNC() exposes the continuation schedule, weights, or values when diagnosing convergence. Use these parameter objects with GncGaussNewtonOptimizer or GncLMOptimizer.

Source

GncParams.h

AI assistance caveat

AI was used to help draft this documentation, and inaccuracies could be present.