g2o
|
Implementation of the Levenberg Algorithm. More...
#include <optimization_algorithm_levenberg.h>
Public Member Functions | |
OptimizationAlgorithmLevenberg (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 More... | |
void | setMaxTrialsAfterFailure (int max_trials) |
the number of internal iteration if an update step increases chi^2 within Levenberg-Marquardt More... | |
int | maxTrialsAfterFailure () const |
get the number of inner iterations for Levenberg-Marquardt More... | |
double | userLambdaInit () |
return the lambda set by the user, if < 0 the SparseOptimizer will compute the initial lambda More... | |
void | setUserLambdaInit (double lambda) |
specify the initial lambda used for the first iteraion, if not given the SparseOptimizer tries to compute a suitable value More... | |
int | levenbergIteration () |
return the number of levenberg iterations performed in the last round More... | |
Public Member Functions inherited from g2o::OptimizationAlgorithmWithHessian | |
OptimizationAlgorithmWithHessian (Solver *solver) | |
virtual | ~OptimizationAlgorithmWithHessian () |
virtual bool | init (bool online=false) |
virtual bool | computeMarginals (SparseBlockMatrix< MatrixXD > &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 More... | |
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 More... | |
SparseOptimizer * | optimizer () |
void | setOptimizer (SparseOptimizer *optimizer) |
const PropertyMap & | properties () const |
return the properties of the solver More... | |
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 |
lower bound for lambda decrease if a good LM step More... | |
double | _goodStepUpperScale |
upper bound for lambda decrease if a good LM step More... | |
double | _ni |
int | _levenbergIterations |
the numer of levenberg iterations performed to accept the last step More... | |
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 More... | |
PropertyMap | _properties |
the properties of your solver, use this to store the parameters of your solver More... | |
Implementation of the Levenberg Algorithm.
Definition at line 38 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 40 of file optimization_algorithm_levenberg.cpp.
References _currentLambda, _goodStepLowerScale, _goodStepUpperScale, _levenbergIterations, _maxTrialsAfterFailure, _ni, g2o::OptimizationAlgorithm::_properties, _tau, _userLambdaInit, and g2o::PropertyMap::makeProperty().
|
virtual |
Definition at line 53 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 149 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 165 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 53 of file optimization_algorithm_levenberg.h.
|
inline |
return the number of levenberg iterations performed in the last round
Definition at line 67 of file optimization_algorithm_levenberg.h.
|
inline |
get the number of inner iterations for Levenberg-Marquardt
Definition at line 59 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 184 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 174 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 179 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 57 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::SparseOptimizer::discardTop(), g2o_isfinite, 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::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 62 of file optimization_algorithm_levenberg.h.
|
protected |
Definition at line 73 of file optimization_algorithm_levenberg.h.
Referenced by computeScale(), OptimizationAlgorithmLevenberg(), printVerbose(), and solve().
|
protected |
lower bound for lambda decrease if a good LM step
Definition at line 75 of file optimization_algorithm_levenberg.h.
Referenced by OptimizationAlgorithmLevenberg(), and solve().
|
protected |
upper bound for lambda decrease if a good LM step
Definition at line 76 of file optimization_algorithm_levenberg.h.
Referenced by OptimizationAlgorithmLevenberg(), and solve().
|
protected |
the numer of levenberg iterations performed to accept the last step
Definition at line 78 of file optimization_algorithm_levenberg.h.
Referenced by OptimizationAlgorithmLevenberg(), printVerbose(), and solve().
|
protected |
Definition at line 71 of file optimization_algorithm_levenberg.h.
Referenced by OptimizationAlgorithmLevenberg(), setMaxTrialsAfterFailure(), and solve().
|
protected |
Definition at line 77 of file optimization_algorithm_levenberg.h.
Referenced by OptimizationAlgorithmLevenberg(), and solve().
|
protected |
Definition at line 74 of file optimization_algorithm_levenberg.h.
Referenced by computeLambdaInit(), and OptimizationAlgorithmLevenberg().
|
protected |
Definition at line 72 of file optimization_algorithm_levenberg.h.
Referenced by computeLambdaInit(), OptimizationAlgorithmLevenberg(), and setUserLambdaInit().