g2o
Public Member Functions | 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 (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< 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)
 
Solversolver ()
 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 SparseOptimizeroptimizer () const
 return the optimizer operating on More...
 
SparseOptimizeroptimizer ()
 
void setOptimizer (SparseOptimizer *optimizer)
 
const PropertyMapproperties () const
 return the properties of the solver More...
 
bool updatePropertiesFromString (const std::string &propString)
 
void printProperties (std::ostream &os) const
 

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 More...
 
PropertyMap _properties
 the properties of your solver, use this to store the parameters of your solver More...
 

Detailed Description

Implementation of the Gauss Newton Algorithm.

Definition at line 38 of file optimization_algorithm_gauss_newton.h.

Constructor & Destructor Documentation

g2o::OptimizationAlgorithmGaussNewton::OptimizationAlgorithmGaussNewton ( Solver solver)
explicit

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

Definition at line 41 of file optimization_algorithm_gauss_newton.cpp.

41  :
43  {
44  }
Solver * solver()
return the underlying solver used to solve the linear system
g2o::OptimizationAlgorithmGaussNewton::~OptimizationAlgorithmGaussNewton ( )
virtual

Definition at line 46 of file optimization_algorithm_gauss_newton.cpp.

47  {
48  }

Member Function Documentation

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 95 of file optimization_algorithm_gauss_newton.cpp.

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

96  {
97  os
98  << "\t schur= " << _solver->schur();
99  }
virtual bool schur()=0
should the solver perform the schur complement or not
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.

References __PRETTY_FUNCTION__, g2o::OptimizationAlgorithm::_optimizer, g2o::OptimizationAlgorithmWithHessian::_solver, g2o::Solver::buildStructure(), g2o::Solver::buildSystem(), g2o::SparseOptimizer::computeActiveErrors(), 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, and g2o::Solver::x().

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

51  {
52  assert(_optimizer && "_optimizer not set");
53  assert(_solver->optimizer() == _optimizer && "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 build structure
57  double t=get_monotonic_time();
59  G2OBatchStatistics* globalStats = G2OBatchStatistics::globalStats();
60  if (globalStats) {
61  globalStats->timeResiduals = get_monotonic_time()-t;
62  }
63 
64  if (iteration == 0 && !online) { // built up the CCS structure, here due to easy time measure
65  ok = _solver->buildStructure();
66  if (! ok) {
67  cerr << __PRETTY_FUNCTION__ << ": Failure while building CCS structure" << endl;
68  return OptimizationAlgorithm::Fail;
69  }
70  }
71 
74  if (globalStats) {
75  globalStats->timeQuadraticForm = get_monotonic_time()-t;
77  }
78 
79  ok = _solver->solve();
80  if (globalStats) {
81  globalStats->timeLinearSolution = get_monotonic_time()-t;
83  }
84 
85  _optimizer->update(_solver->x());
86  if (globalStats) {
87  globalStats->timeUpdate = get_monotonic_time()-t;
88  }
89  if (ok)
90  return OK;
91  else
92  return Fail;
93  }
double get_monotonic_time()
Definition: timeutil.cpp:113
#define __PRETTY_FUNCTION__
Definition: macros.h:89
SparseOptimizer * _optimizer
the optimizer the solver is working on
static G2OBatchStatistics * globalStats()
Definition: batch_stats.h:73
SparseOptimizer * optimizer() const
the optimizer (graph) on which the solver works
Definition: solver.h:106
virtual bool solve()=0
double * x()
return x, the solution vector
Definition: solver.h:96
virtual bool buildSystem()=0
virtual bool buildStructure(bool zeroBlocks=false)=0

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