NDEVR
API Documentation
OptimizationAlgorithmLevenberg< t_type >

Implementation of the Levenberg-Marquardt optimization algorithm. More...

Inheritance diagram for OptimizationAlgorithmLevenberg< t_type >:
[legend]
Collaboration diagram for OptimizationAlgorithmLevenberg< t_type >:
[legend]

Public Member Functions

 OptimizationAlgorithmLevenberg ()
 construct the Levenberg algorithm, which will use the given Solver for solving the linearized system.
void clear ()
 Resets all Levenberg-Marquardt state to initial values.
g_type currentLambda () const
 return the currently used damping factor
int levenbergIteration ()
 return the number of levenberg iterations performed in the last round
void optimize (uint04 iterations, bool online, IndexScratch &scratch)
 Runs Levenberg-Marquardt optimization for the given number of iterations.
void setUserLambdaInit (g_type lambda)
 Sets a user-specified initial damping factor.
OptimizationAlgorithm::SolverResult solve (int iteration, bool online, IndexScratch &scratch)
 Performs a single Levenberg-Marquardt iteration with adaptive damping.
Public Member Functions inherited from OptimizationAlgorithmWithHessian< t_type >
 OptimizationAlgorithmWithHessian ()
 Default constructor.
void addEdge (HyperGraph::HGEdge *e)
 Adds an edge to the optimizer.
void addVertex (HyperGraph::HGVertex &v)
 Adds a vertex to the optimizer.
bool buildLinearStructure (IndexScratch &scratch)
 Builds the linear system structure.
void clear ()
 Clears the solver state.
bool init (bool online=false)
 Initializes the solver, detecting whether Schur complement should be used.
SparseOptimizeroptimizer ()
 Returns a mutable reference to the underlying sparse optimizer.
void updateLinearSystem ()
 Rebuilds the linear system (Hessian and gradient) from the current graph state.
bool updateStructure (const Buffer< HyperGraph::HGVertex * > &vset, const Set< HyperGraph::HGVertex * > &edges)
 Updates the linear system structure after graph topology changes.

Protected Member Functions

g_type computeLambdaInit () const
 helper for Levenberg, this function computes the initial damping factor, if the user did not specify an own value, see setUserLambdaInit()
g_type computeScale () const
 Computes the predicted reduction scale for the trust-region ratio.

Protected Attributes

g_type _currentLambda
 Current damping factor.
g_type _goodStepLowerScale
 Lower bound for lambda decrease if a good LM step.
g_type _goodStepUpperScale
 Upper bound for lambda decrease if a good LM step.
g_type _lambdaInit = 0.0
 User-specified initial lambda (0 = auto-compute).
int _levenbergIterations
 The number of Levenberg iterations performed to accept the last step.
int _nBad
 Counter for consecutive bad (non-improving) iterations.
g_type _ni
 Multiplicative increase factor for lambda on bad steps.
g_type _tau
 Scaling factor for initial lambda computation.

Additional Inherited Members

Public Types inherited from OptimizationAlgorithm
enum  SolverResult { Terminate =2 , OK =1 , Fail =-1 }
 Result codes returned by the solver after each iteration. More...
Public Attributes inherited from OptimizationAlgorithmWithHessian< t_type >
t_type solver
 The underlying solver instance.

Detailed Description

template<class t_type>
class OptimizationAlgorithmLevenberg< t_type >

Implementation of the Levenberg-Marquardt optimization algorithm.

Template Parameters
t_typeThe block solver type.

Definition at line 10 of file optimization_algorithm_levenberg.h.

Member Function Documentation

◆ computeScale()

template<class t_type>
g_type OptimizationAlgorithmLevenberg< t_type >::computeScale ( ) const
inlineprotected

Computes the predicted reduction scale for the trust-region ratio.

Returns
The computed scale factor.

Definition at line 200 of file optimization_algorithm_levenberg.h.

References _currentLambda, and OptimizationAlgorithmWithHessian< t_solver >::solver.

Referenced by solve().

◆ optimize()

template<class t_type>
void OptimizationAlgorithmLevenberg< t_type >::optimize ( uint04 iterations,
bool online,
IndexScratch & scratch )
inline

Runs Levenberg-Marquardt optimization for the given number of iterations.

Parameters
[in]iterationsMaximum number of iterations.
[in]onlineWhether this is an online (incremental) optimization.
[in]scratchScratch buffers for pose and landmark indices.

Definition at line 138 of file optimization_algorithm_levenberg.h.

References OptimizationAlgorithmWithHessian< t_solver >::init(), OptimizationAlgorithm::OK, OptimizationAlgorithmWithHessian< t_solver >::optimizer(), and solve().

◆ setUserLambdaInit()

template<class t_type>
void OptimizationAlgorithmLevenberg< t_type >::setUserLambdaInit ( g_type lambda)
inline

Sets a user-specified initial damping factor.

Parameters
[in]lambdaThe initial lambda value. If > 0, overrides the automatic computation.

Definition at line 160 of file optimization_algorithm_levenberg.h.

References _lambdaInit.

◆ solve()

template<class t_type>
OptimizationAlgorithm::SolverResult OptimizationAlgorithmLevenberg< t_type >::solve ( int iteration,
bool online,
IndexScratch & scratch )
inline

Performs a single Levenberg-Marquardt iteration with adaptive damping.

Parameters
[in]iterationCurrent iteration index.
[in]onlineWhether this is an online step.
[in]scratchScratch buffers for pose and landmark indices.
Returns
The solver result (OK, Fail, or Terminate).

Definition at line 46 of file optimization_algorithm_levenberg.h.

References _currentLambda, _goodStepLowerScale, _goodStepUpperScale, _levenbergIterations, _nBad, _ni, SparseOptimizer::activeRobustChi2(), SparseOptimizer::computeActiveErrors(), computeLambdaInit(), computeScale(), OptimizationAlgorithm::Fail, getMax(), getMin(), gs_epsilon, OptimizationAlgorithm::OK, OptimizationAlgorithmWithHessian< t_solver >::optimizer(), OptimizationAlgorithmWithHessian< t_solver >::solver, OptimizationAlgorithm::Terminate, and SparseOptimizer::update().

Referenced by optimize().


The documentation for this class was generated from the following file: