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.

Dogleg vs Levenberg-Marquardt

Most examples in this series use LevenbergMarquardtOptimizer without asking whether it’s the best choice. GTSAM also ships DoglegOptimizer, a different trust-region strategy for nonlinear least squares. This notebook -- inspired by GitHub issue #452 -- empirically compares how often each optimizer actually finds the true optimum as the initial guess gets progressively worse.

The test problem is a small loop-closure graph with a known ground truth: two “rows” of two poses each, pinned by priors, connected by odometry within each row, and tied together diagonally by a single range measurement. That range factor makes the cost landscape trickier than a simple chain -- exactly the kind of case where trust-region strategy matters.

Open In Colab

GTSAM Copyright 2010-2026, Georgia Tech Research Corporation, Atlanta, Georgia 30332-0415 All Rights Reserved

Authors: Frank Dellaert, et al. (see THANKS for the full author list)

See LICENSE for the license information

1. Ground truth and factor graph

Four ground-truth poses, T11/T12 and T21/T22, form two parallel unit-length “rows”. Priors pin T11 and T21; BetweenFactors provide odometry within each row; a single RangeFactorPose2 between T12 and T22 (ground-truth distance 1.0) closes the loop diagonally. This graph -- and specifically that range factor -- is what makes the problem interesting: it’s non-convex enough that a bad initial guess can pull an optimizer toward the wrong local solution.

2. Monte Carlo comparison setup

For each noise level sigma in a fixed list, we run num_samples independent trials. Each trial perturbs every ground-truth pose by Gaussian noise of that magnitude (retract applies the noise as a manifold perturbation), then runs both DoglegOptimizer and LevenbergMarquardtOptimizer from the same noisy start. A run “succeeds” if the optimizer converges to (near) zero graph error -- i.e. back to the true global optimum, not stuck somewhere else.

The success probability at each sigma is estimated with a Bayesian Beta(0.5, 0.5) prior (Jeffreys’ prior), which gives a well-behaved uncertainty estimate even when the observed success rate is 0% or 100%.

sigma= 0.01:	DL success 99.95% +/- 0.07%, LM success 99.95% +/- 0.07%
sigma= 0.1:	DL success 99.95% +/- 0.07%, LM success 99.95% +/- 0.07%
sigma= 0.2:	DL success 99.95% +/- 0.07%, LM success 99.95% +/- 0.07%
sigma= 0.5:	DL success 99.25% +/- 0.27%, LM success 97.75% +/- 0.47%
sigma= 1:	DL success 79.87% +/- 1.27%, LM success 74.28% +/- 1.38%
sigma= 2:	DL success 58.39% +/- 1.56%, LM success 50.10% +/- 1.58%
sigma= 5:	DL success 62.49% +/- 1.53%, LM success 53.40% +/- 1.58%
sigma= 10:	DL success 61.69% +/- 1.54%, LM success 46.40% +/- 1.58%
sigma= 20:	DL success 66.68% +/- 1.49%, LM success 49.80% +/- 1.58%

3. Plot

The error bars show (\pm 1) posterior standard deviation around the estimated success probability at each noise level.

<Figure size 640x480 with 1 Axes>

This is a Monte Carlo experiment with no fixed random seed, so the exact numbers will differ every time this notebook runs -- but the qualitative pattern is the point: at small noise both optimizers succeed essentially every time, and as the initial guess gets worse, Dogleg’s trust-region approach tends to hold up at least as well as, and often better than, Levenberg-Marquardt on this particular loop-closure geometry.