gtsam
4.0.0
gtsam
|
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.
Public Member Functions | |
Standard interface | |
virtual const Values & | optimize () |
Optimize for the maximum-likelihood estimate, returning a the optimized variable assignments. More... | |
const Values & | optimizeSafely () |
Optimize, but return empty result if any uncaught exception is thrown Intended for MATLAB. More... | |
double | error () const |
return error | |
size_t | iterations () const |
return number of iterations | |
const Values & | values () const |
return values | |
Advanced interface | |
virtual | ~NonlinearOptimizer () |
Virtual destructor. | |
virtual VectorValues | solve (const GaussianFactorGraph &gfg, const NonlinearOptimizerParams ¶ms) const |
Default function to do linear solve, i.e. More... | |
virtual GaussianFactorGraph::shared_ptr | iterate ()=0 |
Perform a single iteration, returning GaussianFactorGraph corresponding to the linearized factor graph. | |
Public Types | |
typedef boost::shared_ptr< const NonlinearOptimizer > | shared_ptr |
A shared pointer to this class. | |
Protected Member Functions | |
void | defaultOptimize () |
A default implementation of the optimization loop, which calls iterate() until checkConvergence returns true. | |
virtual const NonlinearOptimizerParams & | _params () const =0 |
NonlinearOptimizer (const NonlinearFactorGraph &graph, std::unique_ptr< internal::NonlinearOptimizerState > state) | |
Constructor for initial construction of base classes. More... | |
Protected Attributes | |
NonlinearFactorGraph | graph_ |
The graph with nonlinear factors. | |
std::unique_ptr< internal::NonlinearOptimizerState > | state_ |
PIMPL'd state. | |
|
protected |
Constructor for initial construction of base classes.
Takes ownership of state.
|
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.
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 |
|
virtual |
Default function to do linear solve, i.e.
optimize a GaussianFactorGraph