g2o
Public Member Functions | Protected Attributes | List of all members
g2o::OptimizationAlgorithmWithHessian Class Reference

Base for solvers operating on the approximated Hessian, e.g., Gauss-Newton, Levenberg. More...

#include <optimization_algorithm_with_hessian.h>

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

Public Member Functions

 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 ()
 
virtual SolverResult solve (int iteration, bool online=false)=0
 
virtual void printVerbose (std::ostream &os) const
 
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
 

Protected Attributes

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

Base for solvers operating on the approximated Hessian, e.g., Gauss-Newton, Levenberg.

Definition at line 40 of file optimization_algorithm_with_hessian.h.

Constructor & Destructor Documentation

g2o::OptimizationAlgorithmWithHessian::OptimizationAlgorithmWithHessian ( Solver solver)
explicit

Definition at line 38 of file optimization_algorithm_with_hessian.cpp.

References g2o::OptimizationAlgorithm::_properties, _writeDebug, and g2o::PropertyMap::makeProperty().

38  :
41  {
42  _writeDebug = _properties.makeProperty<Property<bool> >("writeDebug", true);
43  }
Solver * solver()
return the underlying solver used to solve the linear system
PropertyMap _properties
the properties of your solver, use this to store the parameters of your solver
P * makeProperty(const std::string &name_, const typename P::ValueType &v)
Definition: property.h:119
g2o::OptimizationAlgorithmWithHessian::~OptimizationAlgorithmWithHessian ( )
virtual

Definition at line 45 of file optimization_algorithm_with_hessian.cpp.

References _solver.

Member Function Documentation

bool g2o::OptimizationAlgorithmWithHessian::buildLinearStructure ( )
virtual

Definition at line 80 of file optimization_algorithm_with_hessian.cpp.

References _solver, and g2o::Solver::buildStructure().

Referenced by g2o::computeSimpleStars(), and g2o::Star::labelStarEdges().

81  {
82  return _solver ? _solver->buildStructure() : false;
83  }
virtual bool buildStructure(bool zeroBlocks=false)=0
bool g2o::OptimizationAlgorithmWithHessian::computeMarginals ( SparseBlockMatrix< MatrixXD > &  spinv,
const std::vector< std::pair< int, int > > &  blockIndices 
)
virtual

computes the block diagonal elements of the pattern specified in the input and stores them in given SparseBlockMatrix. If your solver does not support computing the marginals, return false.

Implements g2o::OptimizationAlgorithm.

Definition at line 75 of file optimization_algorithm_with_hessian.cpp.

References _solver, and g2o::Solver::computeMarginals().

76  {
77  return _solver ? _solver->computeMarginals(spinv, blockIndices) : false;
78  }
virtual bool computeMarginals(SparseBlockMatrix< MatrixXD > &spinv, const std::vector< std::pair< int, int > > &blockIndices)=0
bool g2o::OptimizationAlgorithmWithHessian::init ( bool  online = false)
virtual

initialize the solver, called once before the first call to solve()

Implements g2o::OptimizationAlgorithm.

Definition at line 50 of file optimization_algorithm_with_hessian.cpp.

References g2o::OptimizationAlgorithm::_optimizer, _solver, _writeDebug, g2o::SparseOptimizer::activeVertices(), g2o::Solver::init(), g2o::OptimizableGraph::Vertex::marginalized(), g2o::Solver::setSchur(), g2o::Solver::setWriteDebug(), g2o::Solver::supportsSchur(), and g2o::Property< T >::value().

51  {
52  assert(_optimizer && "_optimizer not set");
53  assert(_solver && "Solver not set");
55  bool useSchur=false;
56  for (OptimizableGraph::VertexContainer::const_iterator it=_optimizer->activeVertices().begin(); it!=_optimizer->activeVertices().end(); ++it) {
58  if (v->marginalized()){
59  useSchur=true;
60  break;
61  }
62  }
63  if (useSchur){
64  if (_solver->supportsSchur())
65  _solver->setSchur(true);
66  } else {
67  if (_solver->supportsSchur())
68  _solver->setSchur(false);
69  }
70 
71  bool initState = _solver->init(_optimizer, online);
72  return initState;
73  }
class G2O_CORE_API Vertex
virtual bool supportsSchur()
Definition: solver.h:117
SparseOptimizer * _optimizer
the optimizer the solver is working on
const VertexContainer & activeVertices() const
the vertices active in the current optimization
const T & value() const
Definition: property.h:57
virtual void setWriteDebug(bool)=0
virtual bool init(SparseOptimizer *optimizer, bool online=false)=0
virtual void setSchur(bool s)=0
void g2o::OptimizationAlgorithmWithHessian::setWriteDebug ( bool  writeDebug)
virtual

write debug output of the Hessian if system is not positive definite

Definition at line 96 of file optimization_algorithm_with_hessian.cpp.

References _writeDebug, and g2o::Property< T >::setValue().

Solver* g2o::OptimizationAlgorithmWithHessian::solver ( )
inline

return the underlying solver used to solve the linear system

Definition at line 57 of file optimization_algorithm_with_hessian.h.

Referenced by g2o::SparseOptimizerIncremental::initSolver().

void g2o::OptimizationAlgorithmWithHessian::updateLinearSystem ( )
virtual
bool g2o::OptimizationAlgorithmWithHessian::updateStructure ( const std::vector< HyperGraph::Vertex * > &  vset,
const HyperGraph::EdgeSet edges 
)
virtual

update the structures for online processing

Implements g2o::OptimizationAlgorithm.

Definition at line 91 of file optimization_algorithm_with_hessian.cpp.

References _solver, and g2o::Solver::updateStructure().

92  {
93  return _solver ? _solver->updateStructure(vset, edges) : false;
94  }
virtual bool updateStructure(const std::vector< HyperGraph::Vertex * > &vset, const HyperGraph::EdgeSet &edges)=0
virtual bool g2o::OptimizationAlgorithmWithHessian::writeDebug ( ) const
inlinevirtual

Definition at line 63 of file optimization_algorithm_with_hessian.h.

63 { return _writeDebug->value();}
const T & value() const
Definition: property.h:57

Member Data Documentation

Solver* g2o::OptimizationAlgorithmWithHessian::_solver
protected
Property<bool>* g2o::OptimizationAlgorithmWithHessian::_writeDebug
protected

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