g2o
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
g2o::OptimizationAlgorithmGaussNewton Class Reference

Implementation of the Gauss Newton Algorithm. More...

#include <optimization_algorithm_gauss_newton.h>

Inheritance diagram for g2o::OptimizationAlgorithmGaussNewton:
Inheritance graph
[legend]
Collaboration diagram for g2o::OptimizationAlgorithmGaussNewton:
Collaboration graph
[legend]

Public Member Functions

 OptimizationAlgorithmGaussNewton (std::unique_ptr< Solver > solver)
 
virtual ~OptimizationAlgorithmGaussNewton ()
 
virtual SolverResult solve (int iteration, bool online=false)
 
virtual void printVerbose (std::ostream &os) const
 
- 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)
 
Solversolver ()
 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 SparseOptimizeroptimizer () const
 return the optimizer operating on
 
SparseOptimizeroptimizer ()
 
void setOptimizer (SparseOptimizer *optimizer)
 
const PropertyMapproperties () const
 return the properties of the solver
 
bool updatePropertiesFromString (const std::string &propString)
 
void printProperties (std::ostream &os) const
 

Private Attributes

std::unique_ptr< Solverm_solver
 

Additional Inherited Members

- 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
 

Detailed Description

Implementation of the Gauss Newton Algorithm.

Definition at line 40 of file optimization_algorithm_gauss_newton.h.

Constructor & Destructor Documentation

◆ OptimizationAlgorithmGaussNewton()

g2o::OptimizationAlgorithmGaussNewton::OptimizationAlgorithmGaussNewton ( std::unique_ptr< Solver solver)
explicit

construct the Gauss Newton algorithm, which use the given Solver for solving the linearized system.

Definition at line 43 of file optimization_algorithm_gauss_newton.cpp.

46 m_solver{std::move(solver)} {}
Solver & solver()
return the underlying solver used to solve the linear system

◆ ~OptimizationAlgorithmGaussNewton()

g2o::OptimizationAlgorithmGaussNewton::~OptimizationAlgorithmGaussNewton ( )
virtual

Definition at line 48 of file optimization_algorithm_gauss_newton.cpp.

48{}

Member Function Documentation

◆ printVerbose()

void g2o::OptimizationAlgorithmGaussNewton::printVerbose ( std::ostream &  os) const
virtual

called by the optimizer if verbose. re-implement, if you want to print something

Reimplemented from g2o::OptimizationAlgorithm.

Definition at line 97 of file optimization_algorithm_gauss_newton.cpp.

97 {
98 os << "\t schur= " << _solver.schur();
99}
virtual bool schur()=0
should the solver perform the schur complement or not

References g2o::OptimizationAlgorithmWithHessian::_solver, and g2o::Solver::schur().

◆ solve()

OptimizationAlgorithm::SolverResult g2o::OptimizationAlgorithmGaussNewton::solve ( int  iteration,
bool  online = false 
)
virtual

Solve one iteration. The SparseOptimizer running on-top will call this for the given number of iterations.

Parameters
iterationindicates the current iteration

Implements g2o::OptimizationAlgorithm.

Reimplemented in g2o::SolverSLAM2DLinear.

Definition at line 50 of file optimization_algorithm_gauss_newton.cpp.

51 {
52 assert(_solver.optimizer() == _optimizer &&
53 "underlying linear solver operates on different graph");
54 bool ok = true;
55
56 // here so that correct component for max-mixtures can be computed before the
57 // build structure
58 double t = get_monotonic_time();
60 G2OBatchStatistics* globalStats = G2OBatchStatistics::globalStats();
61 if (globalStats) {
62 globalStats->timeResiduals = get_monotonic_time() - t;
63 }
64
65 if (iteration == 0 &&
66 !online) { // built up the CCS structure, here due to easy time measure
68 if (!ok) {
69 G2O_WARN("{}: Failure while building CCS structure", __PRETTY_FUNCTION__);
70 return OptimizationAlgorithm::Fail;
71 }
72 }
73
76 if (globalStats) {
77 globalStats->timeQuadraticForm = get_monotonic_time() - t;
79 }
80
81 ok = _solver.solve();
82 if (globalStats) {
83 globalStats->timeLinearSolution = get_monotonic_time() - t;
85 }
86
88 if (globalStats) {
89 globalStats->timeUpdate = get_monotonic_time() - t;
90 }
91 if (ok)
92 return OK;
93 else
94 return Fail;
95}
SparseOptimizer * _optimizer
the optimizer the solver is working on
virtual bool buildStructure(bool zeroBlocks=false)=0
double * x()
return x, the solution vector
Definition solver.h:98
virtual bool solve()=0
virtual bool buildSystem()=0
SparseOptimizer * optimizer() const
the optimizer (graph) on which the solver works
Definition solver.h:108
void update(const double *update)
#define G2O_WARN(...)
Definition logger.h:88
#define __PRETTY_FUNCTION__
Definition macros.h:90
double get_monotonic_time()
Definition timeutil.cpp:43
static G2OBatchStatistics * globalStats()
Definition batch_stats.h:77

References __PRETTY_FUNCTION__, g2o::OptimizationAlgorithm::_optimizer, g2o::OptimizationAlgorithmWithHessian::_solver, g2o::Solver::buildStructure(), g2o::Solver::buildSystem(), g2o::SparseOptimizer::computeActiveErrors(), G2O_WARN, g2o::get_monotonic_time(), g2o::G2OBatchStatistics::globalStats(), OK, g2o::Solver::optimizer(), g2o::Solver::solve(), g2o::G2OBatchStatistics::timeLinearSolution, g2o::G2OBatchStatistics::timeQuadraticForm, g2o::G2OBatchStatistics::timeResiduals, g2o::G2OBatchStatistics::timeUpdate, g2o::SparseOptimizer::update(), and g2o::Solver::x().

Referenced by g2o::SolverSLAM2DLinear::solve().

Member Data Documentation

◆ m_solver

std::unique_ptr<Solver> g2o::OptimizationAlgorithmGaussNewton::m_solver
private

Definition at line 55 of file optimization_algorithm_gauss_newton.h.


The documentation for this class was generated from the following files: