g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
core
solver.h
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// * Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// * Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#ifndef G2O_SOLVER_H
28
#define G2O_SOLVER_H
29
30
#include <cstddef>
31
32
#include "
g2o_core_api.h
"
33
#include "
hyper_graph.h
"
34
#include "
sparse_block_matrix.h
"
35
36
namespace
g2o
{
37
38
class
SparseOptimizer
;
39
44
class
G2O_CORE_API
Solver
{
45
public
:
46
Solver
();
47
virtual
~Solver
();
48
49
public
:
53
virtual
bool
init
(
SparseOptimizer
*
optimizer
,
bool
online =
false
) = 0;
54
58
virtual
bool
buildStructure
(
bool
zeroBlocks =
false
) = 0;
62
virtual
bool
updateStructure
(
const
std::vector<HyperGraph::Vertex*>& vset,
63
const
HyperGraph::EdgeSet
& edges) = 0;
67
virtual
bool
buildSystem
() = 0;
68
72
virtual
bool
solve
() = 0;
73
78
virtual
bool
computeMarginals
(
79
SparseBlockMatrix<MatrixX>
& spinv,
80
const
std::vector<std::pair<int, int> >& blockIndices) = 0;
81
90
virtual
bool
setLambda
(
double
lambda,
bool
backup =
false
) = 0;
91
95
virtual
void
restoreDiagonal
() = 0;
96
98
double
*
x
() {
return
_x
; }
99
const
double
*
x
()
const
{
return
_x
; }
101
double
*
b
() {
return
_b
; }
102
const
double
*
b
()
const
{
return
_b
; }
103
105
size_t
vectorSize
()
const
{
return
_xSize
; }
106
108
SparseOptimizer
*
optimizer
()
const
{
return
_optimizer
; }
109
void
setOptimizer(
SparseOptimizer
* optimizer);
110
112
bool
levenberg
()
const
{
return
_isLevenberg
; }
113
void
setLevenberg(
bool
levenberg);
114
120
virtual
bool
supportsSchur
() {
return
false
; }
121
123
virtual
bool
schur
() = 0;
124
virtual
void
setSchur
(
bool
s) = 0;
125
126
size_t
additionalVectorSpace
()
const
{
return
_additionalVectorSpace
; }
127
void
setAdditionalVectorSpace(
size_t
s);
128
132
virtual
void
setWriteDebug
(
bool
) = 0;
133
virtual
bool
writeDebug
()
const
= 0;
134
136
virtual
bool
saveHessian
(
const
std::string&
/*fileName*/
)
const
= 0;
137
138
protected
:
139
SparseOptimizer
*
_optimizer
;
140
double
*
_x
;
141
double
*
_b
;
142
size_t
_xSize
,
_maxXSize
;
143
bool
_isLevenberg
;
145
size_t
_additionalVectorSpace
;
146
147
void
resizeVector
(
size_t
sx);
148
149
private
:
150
// Disable the copy constructor and assignment operator
151
Solver
(
const
Solver
&) {}
152
Solver
&
operator=
(
const
Solver
&) {
return
*
this
; }
153
};
154
}
// namespace g2o
155
156
#endif
g2o::HyperGraph::EdgeSet
std::set< Edge * > EdgeSet
Definition
hyper_graph.h:141
g2o::Solver::updateStructure
virtual bool updateStructure(const std::vector< HyperGraph::Vertex * > &vset, const HyperGraph::EdgeSet &edges)=0
g2o::Solver::Solver
Solver(const Solver &)
Definition
solver.h:151
g2o::Solver::b
double * b()
return b, the right hand side of the system
Definition
solver.h:101
g2o::Solver::writeDebug
virtual bool writeDebug() const =0
g2o::Solver::computeMarginals
virtual bool computeMarginals(SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices)=0
g2o::Solver::saveHessian
virtual bool saveHessian(const std::string &) const =0
write the hessian to disk using the specified file name
g2o::Solver::_maxXSize
size_t _maxXSize
Definition
solver.h:142
g2o::Solver::setSchur
virtual void setSchur(bool s)=0
g2o::Solver::supportsSchur
virtual bool supportsSchur()
Definition
solver.h:120
g2o::Solver::restoreDiagonal
virtual void restoreDiagonal()=0
g2o::Solver::b
const double * b() const
Definition
solver.h:102
g2o::Solver::_b
double * _b
Definition
solver.h:141
g2o::Solver::init
virtual bool init(SparseOptimizer *optimizer, bool online=false)=0
g2o::Solver::_additionalVectorSpace
size_t _additionalVectorSpace
Definition
solver.h:145
g2o::Solver::buildStructure
virtual bool buildStructure(bool zeroBlocks=false)=0
g2o::Solver::vectorSize
size_t vectorSize() const
return the size of the solution vector (x) and b
Definition
solver.h:105
g2o::Solver::x
double * x()
return x, the solution vector
Definition
solver.h:98
g2o::Solver::_isLevenberg
bool _isLevenberg
Definition
solver.h:143
g2o::Solver::setLambda
virtual bool setLambda(double lambda, bool backup=false)=0
g2o::Solver::_x
double * _x
Definition
solver.h:140
g2o::Solver::solve
virtual bool solve()=0
g2o::Solver::operator=
Solver & operator=(const Solver &)
Definition
solver.h:152
g2o::Solver::levenberg
bool levenberg() const
the system is Levenberg-Marquardt
Definition
solver.h:112
g2o::Solver::_xSize
size_t _xSize
Definition
solver.h:142
g2o::Solver::buildSystem
virtual bool buildSystem()=0
g2o::Solver::additionalVectorSpace
size_t additionalVectorSpace() const
Definition
solver.h:126
g2o::Solver::schur
virtual bool schur()=0
should the solver perform the schur complement or not
g2o::Solver::resizeVector
void resizeVector(size_t sx)
Definition
solver.cpp:50
g2o::Solver::setWriteDebug
virtual void setWriteDebug(bool)=0
g2o::Solver::x
const double * x() const
Definition
solver.h:99
g2o::Solver::Solver
Solver()
Definition
solver.cpp:36
g2o::Solver::optimizer
SparseOptimizer * optimizer() const
the optimizer (graph) on which the solver works
Definition
solver.h:108
g2o::Solver::_optimizer
SparseOptimizer * _optimizer
Definition
solver.h:139
g2o::SparseBlockMatrix
Sparse matrix which uses blocks.
Definition
sparse_block_matrix.h:64
g2o::SparseOptimizer
Definition
sparse_optimizer.h:42
g2o_core_api.h
G2O_CORE_API
#define G2O_CORE_API
Definition
g2o_core_api.h:29
hyper_graph.h
g2o
Definition
dl_wrapper.cpp:55
sparse_block_matrix.h
Generated on
for g2o by
1.17.0