|
MROB
|
#include <optimizer.hpp>

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_ |
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:
Newton-Raphson (NR), this is a second order method: x' = x - (Hessian)^-1 * Gradient
Note that Gauss-Newton is an instance of this, but approximating the Hessian by J'*J
given the following requirements:
This enums optimization methods available:
|
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.
|
pure virtual |
General abstract functions to implement: Calculate error calculates the current error function
Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.
|
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.
|
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.
|
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)
|
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)
|
protectedpure virtual |
One iteration of the RN method
Implemented in mrob::OptimizerDense.
| 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}
|
pure virtual |
Updates the current solution
Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.
|
pure virtual |
For Levenberg-Marquard Undoes an incorrect update
Implemented in mrob::PlaneRegistration, and mrob::FGraphSolveDense.
1.8.13