This API walkthrough introduces the wrapped classes GaussNewtonParams, GaussNewtonOptimizer declared by GaussNewtonOptimizer.h and demonstrates their principal Python operations.
import gtsam
import numpy as np
from gtsam.symbol_shorthand import L, XOverview¶
The GaussNewtonOptimizer class in GTSAM is designed to optimize nonlinear factor graphs using the Gauss-Newton algorithm. This class is particularly suited for problems where the cost function can be approximated well by a quadratic function near the minimum. The Gauss-Newton method is an iterative optimization technique that updates the solution by linearizing the nonlinear system at each iteration.
The Gauss-Newton algorithm is based on the idea of linearizing the nonlinear residuals around the current estimate . The update step is derived from solving the normal equations:
where is the Jacobian of the residuals with respect to the variables. The solution is used to update the estimate:
This process is repeated iteratively until convergence.
Key features:
Iterative Optimization: The optimizer refines the solution iteratively by linearizing the nonlinear system around the current estimate.
Convergence Control: It provides mechanisms to control the convergence through parameters such as maximum iterations and relative error tolerance.
Integration with GTSAM: Seamlessly integrates with GTSAM’s factor graph framework, allowing it to be used with various types of factors and variables.
Key Methods¶
Please see the base class NonlinearOptimizer.
Parameters¶
The Gauss-Newton optimizer uses the standard optimization parameters inherited from NonlinearOptimizerParams, which include:
Maximum iterations
Relative and absolute error thresholds
Error function verbosity
Linear solver type
Usage Considerations¶
Initial Guess: The quality of the initial guess can significantly affect the convergence and performance of the Gauss-Newton optimizer.
Non-convexity: Since the method relies on linear approximations, it may struggle with highly non-convex problems or those with poor initial estimates.
Performance: The Gauss-Newton method is generally faster than other nonlinear optimization methods like Levenberg-Marquardt for problems that are well-approximated by a quadratic model near the solution.
Files¶
Wrapped class API¶
The header also exposes the following wrapped classes. This executable listing makes their constructors, properties, and methods visible in the installed build: GaussNewtonParams.
def public_api(qualified_name):
value = gtsam
for component in qualified_name.split('.'):
value = getattr(value, component, None)
if value is None:
return []
return [name for name in dir(value) if not name.startswith('_')]
print('\nGaussNewtonParams')
print(public_api('GaussNewtonParams'))