MROB
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mrob::Optimizer Class Referenceabstract

#include <optimizer.hpp>

Inheritance diagram for mrob::Optimizer:
Inheritance graph
[legend]

Public Types

enum  optimMethod { NEWTON_RAPHSON =0, LEVENBERG_MARQUARDT_SPHER, LEVENBERG_MARQUARDT_ELLIP }
 

Public Member Functions

 Optimizer (matData_t solutionTolerance=1e-4, matData_t lambda=1e-5)
 
uint_t solve (optimMethod method, uint_t max_iters=1e2, double lambda=1e-5)
 
virtual matData_t calculate_error ()=0
 
virtual void calculate_gradient_hessian ()=0
 
virtual void update_state ()=0
 
virtual void bookkeep_state ()=0
 
virtual void update_state_from_bookkeep ()=0
 

Protected Member Functions

uint_t optimize_newton_raphson ()
 
virtual uint_t optimize_newton_raphson_one_iteration (bool useLambda=false)=0
 
uint_t optimize_levenberg_marquardt ()
 
virtual matData_t calculate_model_fidelity (matData_t diff_error)=0
 

Protected Attributes

optimMethod optimization_method_ {}
 
matData_t solutionTolerance_
 
uint_t max_iters_
 
MatX1 gradient_
 
MatX1 dx_
 
matData_t lambda_
 

Detailed Description

The class optimizer provides a level of abstraction for solving second order optimization problems of the form:

min C(x)

The current methods implemented are:

given the following requirements:

Member Enumeration Documentation

◆ optimMethod

This enums optimization methods available:

  • NR: Newton-Raphson (Gauss_newtow is a variant with approximations in the Hessian)
  • LM_S: Levenberg Marquardt: Spherical
  • LM_E: Levenberg Marquardt: Eliptical

Member Function Documentation

◆ bookkeep_state()

virtual void mrob::Optimizer::bookkeep_state ( )
pure virtual

For Levenberg-Marquard This function bookkeeps the current state values This is in case the optimization step does not improve

Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.

◆ calculate_error()

virtual matData_t mrob::Optimizer::calculate_error ( )
pure virtual

General abstract functions to implement: Calculate error calculates the current error function

Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.

◆ calculate_gradient_hessian()

virtual void mrob::Optimizer::calculate_gradient_hessian ( )
pure virtual

Gradient calculates the gradient and Hessian This function may be called after calculate_error() or not (some cases of LM). For a general purpose it is required that this function is either: 1) self-contained. No assumptions made and recalculated (redundantly) residuals 2) Most of the times will be called after calculate_error. No recalculations are requires except inside the update_bookkeep_state which will have invalid residuals and need update (less prefered option)

Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.

◆ calculate_model_fidelity()

virtual matData_t mrob::Optimizer::calculate_model_fidelity ( matData_t  diff_error)
protectedpure virtual

calculate_model_fidely returns the difference between the quadratized model and the current error, as required for the LM algorithm.

This is a an abstrct class since the hessian matrix might be different for the sparse and the dense case

Implemented in mrob::OptimizerDense.

◆ optimize_levenberg_marquardt()

uint_t Optimizer::optimize_levenberg_marquardt ( )
protected

Levenberg-Marquardt method, inside will distinguish between elliptic and spherical

Input useLambda (default false) builds the NR problem with lambda factor on the diagonal H' = H + lambda * D. where D depends on which LM has been selected (TODO better)

◆ optimize_newton_raphson()

uint_t Optimizer::optimize_newton_raphson ( )
protected

Optimizes according to the Newton-Raphson algorithm (second order method).

Input useLambda (default false) builds the NR problem with lambda factor on the diagonal H' = H + lambda * D. where D depends on which LM has been selected (TODO better)

◆ optimize_newton_raphson_one_iteration()

virtual uint_t mrob::Optimizer::optimize_newton_raphson_one_iteration ( bool  useLambda = false)
protectedpure virtual

One iteration of the RN method

Implemented in mrob::OptimizerDense.

◆ solve()

uint_t Optimizer::solve ( optimMethod  method,
uint_t  max_iters = 1e2,
double  lambda = 1e-5 
)

Optimization call. Input: optmization method from {NR=0, LM_S, LM_E}

  • max_iterations
  • lambda: initial value of lambda for LM methods output: number of iterations

◆ update_state()

virtual void mrob::Optimizer::update_state ( )
pure virtual

Updates the current solution

Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.

◆ update_state_from_bookkeep()

virtual void mrob::Optimizer::update_state_from_bookkeep ( )
pure virtual

For Levenberg-Marquard Undoes an incorrect update

Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.


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