g2o
Loading...
Searching...
No Matches
g2o::Solver Class Referenceabstract

Generic interface for a sparse solver operating on a graph which solves one iteration of the linearized objective function. More...

#include <solver.h>

Inheritance diagram for g2o::Solver:
Collaboration diagram for g2o::Solver:

Public Member Functions

 Solver ()
virtual ~Solver ()
virtual bool init (SparseOptimizer *optimizer, bool online=false)=0
virtual bool buildStructure (bool zeroBlocks=false)=0
virtual bool updateStructure (const std::vector< HyperGraph::Vertex * > &vset, const HyperGraph::EdgeSet &edges)=0
virtual bool buildSystem ()=0
virtual bool solve ()=0
virtual bool computeMarginals (SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices)=0
virtual bool setLambda (double lambda, bool backup=false)=0
virtual void restoreDiagonal ()=0
double * x ()
 return x, the solution vector
const double * x () const
double * b ()
 return b, the right hand side of the system
const double * b () const
size_t vectorSize () const
 return the size of the solution vector (x) and b
SparseOptimizer * optimizer () const
 the optimizer (graph) on which the solver works
void setOptimizer (SparseOptimizer *optimizer)
bool levenberg () const
 the system is Levenberg-Marquardt
void setLevenberg (bool levenberg)
virtual bool supportsSchur ()
virtual bool schur ()=0
 should the solver perform the schur complement or not
virtual void setSchur (bool s)=0
size_t additionalVectorSpace () const
void setAdditionalVectorSpace (size_t s)
virtual void setWriteDebug (bool)=0
virtual bool writeDebug () const =0
virtual bool saveHessian (const std::string &) const =0
 write the hessian to disk using the specified file name

Protected Member Functions

void resizeVector (size_t sx)

Protected Attributes

SparseOptimizer * _optimizer
double * _x
double * _b
size_t _xSize
size_t _maxXSize
bool _isLevenberg
size_t _additionalVectorSpace

Private Member Functions

 Solver (const Solver &)
Solver & operator= (const Solver &)

Detailed Description

Generic interface for a sparse solver operating on a graph which solves one iteration of the linearized objective function.

Definition at line 44 of file solver.h.

Constructor & Destructor Documentation

◆ Solver() [1/2]

g2o::Solver::Solver ( )

Definition at line 36 of file solver.cpp.

References _additionalVectorSpace, _b, _isLevenberg, _maxXSize, _optimizer, _x, and _xSize.

Referenced by operator=(), and Solver().

◆ ~Solver()

g2o::Solver::~Solver ( )
virtual

Definition at line 45 of file solver.cpp.

References _b, _x, and g2o::free_aligned().

◆ Solver() [2/2]

g2o::Solver::Solver ( const Solver & )
inlineprivate

Definition at line 151 of file solver.h.

References Solver().

Member Function Documentation

◆ additionalVectorSpace()

size_t g2o::Solver::additionalVectorSpace ( ) const
inline

Definition at line 126 of file solver.h.

References _additionalVectorSpace.

◆ b() [1/2]

double * g2o::Solver::b ( )
inline

return b, the right hand side of the system

Definition at line 101 of file solver.h.

References _b.

Referenced by g2o::BlockSolver< Traits >::restoreDiagonal(), and g2o::BlockSolver< Traits >::setLambda().

◆ b() [2/2]

const double * g2o::Solver::b ( ) const
inline

Definition at line 102 of file solver.h.

References _b.

◆ buildStructure()

virtual bool g2o::Solver::buildStructure ( bool zeroBlocks = false)
pure virtual

build the structure of the system

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ buildSystem()

virtual bool g2o::Solver::buildSystem ( )
pure virtual

build the current system

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ computeMarginals()

virtual bool g2o::Solver::computeMarginals ( SparseBlockMatrix< MatrixX > & spinv,
const std::vector< std::pair< int, int > > & blockIndices )
pure virtual

computes the block diagonal elements of the pattern specified in the input and stores them in given SparseBlockMatrix

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ init()

virtual bool g2o::Solver::init ( SparseOptimizer * optimizer,
bool online = false )
pure virtual

initialize the solver, called once before the first iteration

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

References optimizer().

◆ levenberg()

bool g2o::Solver::levenberg ( ) const
inline

the system is Levenberg-Marquardt

Definition at line 112 of file solver.h.

References _isLevenberg.

Referenced by setLevenberg().

◆ operator=()

Solver & g2o::Solver::operator= ( const Solver & )
inlineprivate

Definition at line 152 of file solver.h.

References Solver().

◆ optimizer()

SparseOptimizer * g2o::Solver::optimizer ( ) const
inline

the optimizer (graph) on which the solver works

Definition at line 108 of file solver.h.

References _optimizer.

Referenced by g2o::BlockSolver< Traits >::init(), init(), and setOptimizer().

◆ resizeVector()

void g2o::Solver::resizeVector ( size_t sx)
protected

◆ restoreDiagonal()

virtual void g2o::Solver::restoreDiagonal ( )
pure virtual

restore a previously made backup of the diagonal

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ saveHessian()

virtual bool g2o::Solver::saveHessian ( const std::string & ) const
pure virtual

write the hessian to disk using the specified file name

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ schur()

virtual bool g2o::Solver::schur ( )
pure virtual

should the solver perform the schur complement or not

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ setAdditionalVectorSpace()

void g2o::Solver::setAdditionalVectorSpace ( size_t s)

Definition at line 82 of file solver.cpp.

References _additionalVectorSpace.

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

◆ setLambda()

virtual bool g2o::Solver::setLambda ( double lambda,
bool backup = false )
pure virtual

update the system while performing Levenberg, i.e., modifying the diagonal components of A by doing += lambda along the main diagonal of the Matrix. Note that this function may be called with a positive and a negative lambda. The latter is used to undo a former modification. If backup is true, then the solver should store a backup of the diagonal, which can be restored by restoreDiagonal()

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ setLevenberg()

void g2o::Solver::setLevenberg ( bool levenberg)

Definition at line 80 of file solver.cpp.

References _isLevenberg, and levenberg().

◆ setOptimizer()

void g2o::Solver::setOptimizer ( SparseOptimizer * optimizer)

Definition at line 76 of file solver.cpp.

References _optimizer, and optimizer().

◆ setSchur()

virtual void g2o::Solver::setSchur ( bool s)
pure virtual

◆ setWriteDebug()

virtual void g2o::Solver::setWriteDebug ( bool )
pure virtual

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

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ solve()

virtual bool g2o::Solver::solve ( )
pure virtual

◆ supportsSchur()

virtual bool g2o::Solver::supportsSchur ( )
inlinevirtual

does this solver support the Schur complement for solving a system consisting of poses and landmarks. Re-implement in a derived solver, if your solver supports it.

Reimplemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

Definition at line 120 of file solver.h.

◆ updateStructure()

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

update the structures for online processing

Implemented in g2o::BlockSolver< Traits >, and g2o::BlockSolver< BlockSolverTraits< p, l > >.

◆ vectorSize()

size_t g2o::Solver::vectorSize ( ) const
inline

return the size of the solution vector (x) and b

Definition at line 105 of file solver.h.

References _xSize.

◆ writeDebug()

virtual bool g2o::Solver::writeDebug ( ) const
pure virtual

◆ x() [1/2]

double * g2o::Solver::x ( )
inline

return x, the solution vector

Definition at line 98 of file solver.h.

References _x.

◆ x() [2/2]

const double * g2o::Solver::x ( ) const
inline

Definition at line 99 of file solver.h.

References _x.

Member Data Documentation

◆ _additionalVectorSpace

size_t g2o::Solver::_additionalVectorSpace
protected

Definition at line 145 of file solver.h.

Referenced by additionalVectorSpace(), resizeVector(), setAdditionalVectorSpace(), and Solver().

◆ _b

double* g2o::Solver::_b
protected

◆ _isLevenberg

bool g2o::Solver::_isLevenberg
protected

the system we gonna solve is a Levenberg-Marquardt system

Definition at line 143 of file solver.h.

Referenced by levenberg(), setLevenberg(), and Solver().

◆ _maxXSize

size_t g2o::Solver::_maxXSize
protected

Definition at line 142 of file solver.h.

Referenced by resizeVector(), and Solver().

◆ _optimizer

◆ _x

double* g2o::Solver::_x
protected

Definition at line 140 of file solver.h.

Referenced by resizeVector(), g2o::BlockSolver< Traits >::solve(), Solver(), x(), x(), and ~Solver().

◆ _xSize

size_t g2o::Solver::_xSize
protected

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