|
g2o
|
Implementation of the Levenberg Algorithm. More...
#include <optimization_algorithm_levenberg.h>


Public Member Functions | |
| OptimizationAlgorithmLevenberg (std::unique_ptr< Solver > solver) | |
| virtual | ~OptimizationAlgorithmLevenberg () |
| virtual SolverResult | solve (int iteration, bool online=false) |
| virtual void | printVerbose (std::ostream &os) const |
| double | currentLambda () const |
| return the currently used damping factor | |
| void | setMaxTrialsAfterFailure (int max_trials) |
| int | maxTrialsAfterFailure () const |
| get the number of inner iterations for Levenberg-Marquardt | |
| double | userLambdaInit () |
| void | setUserLambdaInit (double lambda) |
| int | levenbergIteration () |
| return the number of levenberg iterations performed in the last round | |
Public Member Functions inherited from g2o::OptimizationAlgorithmWithHessian | |
| OptimizationAlgorithmWithHessian (Solver &solver) | |
| virtual | ~OptimizationAlgorithmWithHessian () |
| virtual bool | init (bool online=false) |
| virtual bool | computeMarginals (SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices) |
| virtual bool | buildLinearStructure () |
| virtual void | updateLinearSystem () |
| virtual bool | updateStructure (const std::vector< HyperGraph::Vertex * > &vset, const HyperGraph::EdgeSet &edges) |
| Solver & | solver () |
| return the underlying solver used to solve the linear system | |
| virtual void | setWriteDebug (bool writeDebug) |
| virtual bool | writeDebug () const |
Public Member Functions inherited from g2o::OptimizationAlgorithm | |
| OptimizationAlgorithm () | |
| virtual | ~OptimizationAlgorithm () |
| const SparseOptimizer * | optimizer () const |
| return the optimizer operating on | |
| SparseOptimizer * | optimizer () |
| void | setOptimizer (SparseOptimizer *optimizer) |
| const PropertyMap & | properties () const |
| return the properties of the solver | |
| bool | updatePropertiesFromString (const std::string &propString) |
| void | printProperties (std::ostream &os) const |
Protected Member Functions | |
| double | computeLambdaInit () const |
| double | computeScale () const |
Protected Attributes | |
| Property< int > * | _maxTrialsAfterFailure |
| Property< double > * | _userLambdaInit |
| double | _currentLambda |
| double | _tau |
| double | _goodStepLowerScale |
| double | _goodStepUpperScale |
| double | _ni |
| int | _levenbergIterations |
Protected Attributes inherited from g2o::OptimizationAlgorithmWithHessian | |
| Solver & | _solver |
| Property< bool > * | _writeDebug |
Protected Attributes inherited from g2o::OptimizationAlgorithm | |
| SparseOptimizer * | _optimizer |
| the optimizer the solver is working on | |
| PropertyMap | _properties |
Private Attributes | |
| std::unique_ptr< Solver > | m_solver |
Implementation of the Levenberg Algorithm.
Definition at line 40 of file optimization_algorithm_levenberg.h.
|
explicit |
construct the Levenberg algorithm, which will use the given Solver for solving the linearized system.
Definition at line 41 of file optimization_algorithm_levenberg.cpp.
References _maxTrialsAfterFailure, g2o::OptimizationAlgorithm::_properties, _userLambdaInit, and g2o::PropertyMap::makeProperty().
|
virtual |
Definition at line 57 of file optimization_algorithm_levenberg.cpp.
|
protected |
helper for Levenberg, this function computes the initial damping factor, if the user did not specify an own value, see setUserLambdaInit()
Definition at line 154 of file optimization_algorithm_levenberg.cpp.
References g2o::OptimizationAlgorithm::_optimizer, _tau, _userLambdaInit, g2o::OptimizableGraph::Vertex::dimension(), g2o::OptimizableGraph::Vertex::hessian(), g2o::SparseOptimizer::indexMapping(), and g2o::Property< T >::value().
Referenced by solve().
|
protected |
Definition at line 168 of file optimization_algorithm_levenberg.cpp.
References _currentLambda, g2o::OptimizationAlgorithmWithHessian::_solver, g2o::Solver::b(), g2o::Solver::vectorSize(), and g2o::Solver::x().
Referenced by solve().
|
inline |
return the currently used damping factor
Definition at line 55 of file optimization_algorithm_levenberg.h.
|
inline |
return the number of levenberg iterations performed in the last round
Definition at line 72 of file optimization_algorithm_levenberg.h.
|
inline |
get the number of inner iterations for Levenberg-Marquardt
Definition at line 62 of file optimization_algorithm_levenberg.h.
|
virtual |
called by the optimizer if verbose. re-implement, if you want to print something
Reimplemented from g2o::OptimizationAlgorithm.
Definition at line 185 of file optimization_algorithm_levenberg.cpp.
References _currentLambda, _levenbergIterations, g2o::OptimizationAlgorithmWithHessian::_solver, and g2o::Solver::schur().
| void g2o::OptimizationAlgorithmLevenberg::setMaxTrialsAfterFailure | ( | int | max_trials | ) |
the number of internal iteration if an update step increases chi^2 within Levenberg-Marquardt
Definition at line 177 of file optimization_algorithm_levenberg.cpp.
References _maxTrialsAfterFailure, and g2o::Property< T >::setValue().
| void g2o::OptimizationAlgorithmLevenberg::setUserLambdaInit | ( | double | lambda | ) |
specify the initial lambda used for the first iteraion, if not given the SparseOptimizer tries to compute a suitable value
Definition at line 181 of file optimization_algorithm_levenberg.cpp.
References _userLambdaInit, and g2o::Property< T >::setValue().
|
virtual |
Solve one iteration. The SparseOptimizer running on-top will call this for the given number of iterations.
| iteration | indicates the current iteration |
Implements g2o::OptimizationAlgorithm.
Definition at line 59 of file optimization_algorithm_levenberg.cpp.
References __PRETTY_FUNCTION__, _currentLambda, _goodStepLowerScale, _goodStepUpperScale, _levenbergIterations, _maxTrialsAfterFailure, _ni, g2o::OptimizationAlgorithm::_optimizer, g2o::OptimizationAlgorithmWithHessian::_solver, g2o::SparseOptimizer::activeRobustChi2(), g2o::Solver::buildStructure(), g2o::Solver::buildSystem(), g2o::SparseOptimizer::computeActiveErrors(), computeLambdaInit(), computeScale(), g2o::cst(), g2o::SparseOptimizer::discardTop(), g2o_isfinite, G2O_WARN, g2o::get_monotonic_time(), g2o::G2OBatchStatistics::globalStats(), g2o::G2OBatchStatistics::levenbergIterations, OK, g2o::Solver::optimizer(), g2o::SparseOptimizer::pop(), g2o::SparseOptimizer::push(), g2o::Solver::restoreDiagonal(), g2o::Solver::setLambda(), g2o::Solver::solve(), Terminate, g2o::SparseOptimizer::terminate(), g2o::G2OBatchStatistics::timeLinearSolution, g2o::G2OBatchStatistics::timeQuadraticForm, g2o::G2OBatchStatistics::timeResiduals, g2o::G2OBatchStatistics::timeUpdate, g2o::SparseOptimizer::update(), g2o::Property< T >::value(), and g2o::Solver::x().
|
inline |
return the lambda set by the user, if < 0 the SparseOptimizer will compute the initial lambda
Definition at line 66 of file optimization_algorithm_levenberg.h.
|
protected |
Definition at line 78 of file optimization_algorithm_levenberg.h.
Referenced by computeScale(), printVerbose(), and solve().
|
protected |
lower bound for lambda decrease if a good LM step
Definition at line 80 of file optimization_algorithm_levenberg.h.
Referenced by solve().
|
protected |
upper bound for lambda decrease if a good LM step
Definition at line 82 of file optimization_algorithm_levenberg.h.
Referenced by solve().
|
protected |
the number of levenberg iterations performed to accept the last step
Definition at line 85 of file optimization_algorithm_levenberg.h.
Referenced by printVerbose(), and solve().
|
protected |
Definition at line 76 of file optimization_algorithm_levenberg.h.
Referenced by OptimizationAlgorithmLevenberg(), setMaxTrialsAfterFailure(), and solve().
|
protected |
Definition at line 84 of file optimization_algorithm_levenberg.h.
Referenced by solve().
|
protected |
Definition at line 79 of file optimization_algorithm_levenberg.h.
Referenced by computeLambdaInit().
|
protected |
Definition at line 77 of file optimization_algorithm_levenberg.h.
Referenced by computeLambdaInit(), OptimizationAlgorithmLevenberg(), and setUserLambdaInit().
|
private |
Definition at line 96 of file optimization_algorithm_levenberg.h.