g2o
Loading...
Searching...
No Matches
optimization_algorithm_with_hessian.cpp
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
28
29#include <cassert>
30#include <iostream>
31
32#include "optimizable_graph.h"
33#include "solver.h"
34#include "sparse_optimizer.h"
35using namespace std;
36
37namespace g2o {
38
44
46
48 assert(_optimizer && "_optimizer not set");
50 bool useSchur = false;
51 for (OptimizableGraph::VertexContainer::const_iterator it =
52 _optimizer->activeVertices().begin();
53 it != _optimizer->activeVertices().end(); ++it) {
55 if (v->marginalized()) {
56 useSchur = true;
57 break;
58 }
59 }
60 if (useSchur) {
62 } else {
64 }
65
66 bool initState = _solver.init(_optimizer, online);
67 return initState;
68}
69
72 const std::vector<std::pair<int, int> >& blockIndices) {
73 return _solver.computeMarginals(spinv, blockIndices);
74}
75
79
83
85 const std::vector<HyperGraph::Vertex*>& vset,
86 const HyperGraph::EdgeSet& edges) {
87 return _solver.updateStructure(vset, edges);
88}
89
93
94} // namespace g2o
std::set< Edge * > EdgeSet
A general case Vertex for optimization.
bool marginalized() const
true => this node is marginalized out during the optimization
virtual bool updateStructure(const std::vector< HyperGraph::Vertex * > &vset, const HyperGraph::EdgeSet &edges)
virtual bool computeMarginals(SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices)
Generic interface for a non-linear solver operating on a graph.
SparseOptimizer * _optimizer
the optimizer the solver is working on
P * makeProperty(const std::string &name_, const typename P::ValueType &v)
Definition property.h:116
void setValue(const T &v)
Definition property.h:58
const T & value() const
Definition property.h:59
Generic interface for a sparse solver operating on a graph which solves one iteration of the lineariz...
Definition solver.h:44
virtual bool updateStructure(const std::vector< HyperGraph::Vertex * > &vset, const HyperGraph::EdgeSet &edges)=0
virtual bool computeMarginals(SparseBlockMatrix< MatrixX > &spinv, const std::vector< std::pair< int, int > > &blockIndices)=0
virtual void setSchur(bool s)=0
virtual bool supportsSchur()
Definition solver.h:120
virtual bool init(SparseOptimizer *optimizer, bool online=false)=0
virtual bool buildStructure(bool zeroBlocks=false)=0
virtual bool buildSystem()=0
virtual void setWriteDebug(bool)=0
Sparse matrix which uses blocks.
const VertexContainer & activeVertices() const
the vertices active in the current optimization
Definition jet.h:876