#include <NonlinearOptimizer.h>
Public Types | |
using | shared_ptr = boost::shared_ptr< const NonlinearOptimizer > |
Public Member Functions | |
Standard interface | |
virtual const Values & | optimize () |
const Values & | optimizeSafely () |
double | error () const |
return error in current optimizer state More... | |
size_t | iterations () const |
return number of iterations in current optimizer state More... | |
const Values & | values () const |
return values in current optimizer state More... | |
const NonlinearFactorGraph & | graph () const |
return the graph with nonlinear factors More... | |
Advanced interface | |
virtual | ~NonlinearOptimizer () |
virtual VectorValues | solve (const GaussianFactorGraph &gfg, const NonlinearOptimizerParams ¶ms) const |
virtual GaussianFactorGraph::shared_ptr | iterate ()=0 |
Protected Member Functions | |
virtual const NonlinearOptimizerParams & | _params () const =0 |
void | defaultOptimize () |
NonlinearOptimizer (const NonlinearFactorGraph &graph, std::unique_ptr< internal::NonlinearOptimizerState > state) | |
Protected Attributes | |
NonlinearFactorGraph | graph_ |
The graph with nonlinear factors. More... | |
std::unique_ptr< internal::NonlinearOptimizerState > | state_ |
PIMPL'd state. More... | |
This is the abstract interface for classes that can optimize for the maximum-likelihood estimate of a NonlinearFactorGraph.
To use a class derived from this interface, construct the class with a NonlinearFactorGraph and an initial Values variable assignment. Next, call the optimize() method which returns the optimized variable assignment.
Simple and compact example:
Example exposing more functionality and details:
Example of setting parameters before optimization:
This interface also exposes an iterate() method, which performs one iteration. The optimize() method simply calls iterate() multiple times, until the error changes less than a threshold. We expose iterate() so that you can easily control what happens between iterations, such as drawing or printing, moving points from behind the camera to in front, etc.
For more flexibility you may override virtual methods in your own derived class.
Definition at line 75 of file NonlinearOptimizer.h.
using gtsam::NonlinearOptimizer::shared_ptr = boost::shared_ptr<const NonlinearOptimizer> |
A shared pointer to this class
Definition at line 84 of file NonlinearOptimizer.h.
|
virtual |
Virtual destructor
Definition at line 49 of file NonlinearOptimizer.cpp.
|
protected |
Constructor for initial construction of base classes. Takes ownership of state.
Definition at line 44 of file NonlinearOptimizer.cpp.
|
protectedpure virtual |
|
protected |
A default implementation of the optimization loop, which calls iterate() until checkConvergence returns true.
Definition at line 65 of file NonlinearOptimizer.cpp.
double gtsam::NonlinearOptimizer::error | ( | ) | const |
return error in current optimizer state
Definition at line 52 of file NonlinearOptimizer.cpp.
|
inline |
return the graph with nonlinear factors
Definition at line 118 of file NonlinearOptimizer.h.
|
pure virtual |
Perform a single iteration, returning GaussianFactorGraph corresponding to the linearized factor graph.
Implemented in gtsam::DoglegOptimizer, gtsam::LevenbergMarquardtOptimizer, gtsam::GaussNewtonOptimizer, and gtsam::NonlinearConjugateGradientOptimizer.
size_t gtsam::NonlinearOptimizer::iterations | ( | ) | const |
return number of iterations in current optimizer state
Definition at line 56 of file NonlinearOptimizer.cpp.
|
inlinevirtual |
Optimize for the maximum-likelihood estimate, returning a the optimized variable assignments.
This function simply calls iterate() in a loop, checking for convergence with check_convergence(). For fine-grain control over the optimization process, you may call iterate() and check_convergence() yourself, and if needed modify the optimization state between iterations.
Reimplemented in gtsam::NonlinearConjugateGradientOptimizer.
Definition at line 98 of file NonlinearOptimizer.h.
const Values & gtsam::NonlinearOptimizer::optimizeSafely | ( | ) |
Optimize, but return empty result if any uncaught exception is thrown Intended for MATLAB. In C++, use above and catch exceptions. No message is printed: it is up to the caller to check the result
optimizer | a non-linear optimizer |
Definition at line 123 of file NonlinearOptimizer.cpp.
|
virtual |
Default function to do linear solve, i.e. optimize a GaussianFactorGraph
Reimplemented in IterativeLM.
Definition at line 135 of file NonlinearOptimizer.cpp.
const Values & gtsam::NonlinearOptimizer::values | ( | ) | const |
return values in current optimizer state
Definition at line 60 of file NonlinearOptimizer.cpp.
|
protected |
The graph with nonlinear factors.
Definition at line 78 of file NonlinearOptimizer.h.
|
protected |
PIMPL'd state.
Definition at line 80 of file NonlinearOptimizer.h.