g2o
Public Member Functions | Public Attributes | List of all members
g2o::Star Struct Reference

#include <star.h>

Collaboration diagram for g2o::Star:
Collaboration graph
[legend]

Public Member Functions

 Star (int level, SparseOptimizer *optimizer)
 
bool labelStarEdges (int iterations, EdgeLabeler *labeler)
 
int level () const
 returns the level of the lower edges in the star More...
 
SparseOptimizeroptimizer ()
 returns the optimizer More...
 
HyperGraph::EdgeSetlowLevelEdges ()
 low level edge set More...
 
HyperGraph::EdgeSetstarEdges ()
 high level edge set More...
 
HyperGraph::EdgeSetstarFrontierEdges ()
 edges in the high level that lead to some node owned by a different star More...
 
HyperGraph::VertexSetgauge ()
 set of nodes to keep fixed in the optimization More...
 
HyperGraph::VertexSetlowLevelVertices ()
 set of all vertices in the low level More...
 

Public Attributes

int _level
 level of the star More...
 
SparseOptimizer_optimizer
 optimizer More...
 
HyperGraph::EdgeSet _lowLevelEdges
 edges in the lower level More...
 
HyperGraph::EdgeSet _starEdges
 edges in the star More...
 
HyperGraph::EdgeSet _starFrontierEdges
 edges in the star that lead to some other star More...
 
HyperGraph::VertexSet _gauge
 vertices that are fixed (center of the star) More...
 
HyperGraph::VertexSet _lowLevelVertices
 vertices that are fixed (center of the star) More...
 

Detailed Description

Class that represents a subgraph in the hierarchical optimization. The subgraph is consisting of

Additionally, a star provides a function to compute the parameters for each of the edges in the higher level, based on the actual configuration of the state variables. It does so by using an EdgeLabeler class.

Definition at line 26 of file star.h.

Constructor & Destructor Documentation

g2o::Star::Star ( int  level,
SparseOptimizer optimizer 
)

constructs a star at level l in the graph of the sparse optimizer passed as argument

Parameters
levelthe (higher) level of the star
optimizerthe optimizer

Definition at line 7 of file star.cpp.

SparseOptimizer * optimizer()
returns the optimizer
Definition: star.h:41
int level() const
returns the level of the lower edges in the star
Definition: star.h:39
SparseOptimizer * _optimizer
optimizer
Definition: star.h:56
int _level
level of the star
Definition: star.h:54

Member Function Documentation

HyperGraph::VertexSet& g2o::Star::gauge ( )
inline

set of nodes to keep fixed in the optimization

Definition at line 49 of file star.h.

References _gauge.

Referenced by g2o::computeBorder(), g2o::computeSimpleStars(), and main().

49 {return _gauge;}
HyperGraph::VertexSet _gauge
vertices that are fixed (center of the star)
Definition: star.h:64
bool g2o::Star::labelStarEdges ( int  iterations,
EdgeLabeler labeler 
)

labels the edges in the star by first optimizing the low level edges, then by calling the labelEdge of the labeler.

Parameters
iterationsthe number of iterations of the optimizer
labelerthe labeler

Definition at line 9 of file star.cpp.

References _gauge, _lowLevelEdges, _optimizer, _starEdges, g2o::SparseOptimizer::activeVertices(), g2o::OptimizationAlgorithmWithHessian::buildLinearStructure(), g2o::SparseOptimizer::computeActiveErrors(), g2o::SparseOptimizer::computeInitialGuess(), g2o::OptimizableGraph::Vertex::hessianIndex(), g2o::HyperGraph::Vertex::id(), g2o::SparseOptimizer::indexMapping(), g2o::OptimizationAlgorithm::init(), g2o::SparseOptimizer::initializeOptimization(), g2o::EdgeLabeler::labelEdges(), g2o::SparseOptimizer::optimize(), optimizer(), g2o::OptimizableGraph::Vertex::pop(), g2o::OptimizableGraph::Vertex::push(), g2o::OptimizableGraph::Vertex::setFixed(), g2o::SparseOptimizer::solver(), g2o::OptimizationAlgorithmWithHessian::updateLinearSystem(), and g2o::HyperGraph::Edge::vertices().

Referenced by g2o::assignHierarchicalEdges(), and g2o::computeSimpleStars().

9  {
10  // mark all vertices in the lowLevelEdges as floating
11  bool ok=true;
12  std::set<OptimizableGraph::Vertex*> vset;
13  for (HyperGraph::EdgeSet::iterator it=_lowLevelEdges.begin(); it!=_lowLevelEdges.end(); it++){
14  HyperGraph::Edge* e=*it;
15  for (size_t i=0; i<e->vertices().size(); i++){
17  v->setFixed(false);
18  vset.insert(v);
19  }
20  }
21  for (std::set<OptimizableGraph::Vertex*>::iterator it=vset.begin(); it!=vset.end(); it++){
22  OptimizableGraph::Vertex* v = *it;
23  v->push();
24  }
25 
26  // fix all vertices in the gauge
27  //cerr << "fixing gauge: ";
28  for (HyperGraph::VertexSet::iterator it = _gauge.begin(); it!=_gauge.end(); it++){
30  //cerr << v->id() << " ";
31  v->setFixed(true);
32  }
33  //cerr << endl;
34  if (iterations>0){
37  int result=_optimizer->optimize(iterations);
38  if (result<1){
39  cerr << "Vertices num: " << _optimizer->activeVertices().size() << "ids: ";
40  for (size_t i=0; i<_optimizer->indexMapping().size(); i++){
41  cerr << _optimizer->indexMapping()[i]->id() << " " ;
42  }
43  cerr << endl;
44  cerr << "!!! optimization failure" << endl;
45  cerr << "star size=" << _lowLevelEdges.size() << endl;
46  cerr << "gauge: ";
47  for (HyperGraph::VertexSet::iterator it=_gauge.begin(); it!=_gauge.end(); it++){
49  cerr << "[" << v->id() << " " << v->hessianIndex() << "] ";
50  }
51  cerr << endl;
52  ok=false;
53  }
54  } else {
56  // cerr << "guess" << endl;
57  //optimizer()->computeInitialGuess();
58  // cerr << "solver init" << endl;
59  optimizer()->solver()->init();
60  // cerr << "structure" << endl;
61  OptimizationAlgorithmWithHessian* solverWithHessian = dynamic_cast<OptimizationAlgorithmWithHessian*> (optimizer()->solver());
62  if (!solverWithHessian->buildLinearStructure())
63  cerr << "FATAL: failure while building linear structure" << endl;
64  // cerr << "errors" << endl;
66  // cerr << "system" << endl;
67  solverWithHessian->updateLinearSystem();
68  }
69 
70  std::set<OptimizableGraph::Edge*> star;
71  for(HyperGraph::EdgeSet::iterator it=_starEdges.begin(); it!=_starEdges.end(); it++){
72  star.insert((OptimizableGraph::Edge*)*it);
73  }
74  if (ok) {
75  int result = labeler->labelEdges(star);
76  if (result < 0)
77  ok=false;
78  }
79  // release all vertices in the gauge
80  for (std::set<OptimizableGraph::Vertex*>::iterator it=vset.begin(); it!=vset.end(); it++){
81  OptimizableGraph::Vertex* v = *it;
82  v->pop();
83  }
84  for (HyperGraph::VertexSet::iterator it=_gauge.begin(); it!=_gauge.end(); it++){
86  v->setFixed(false);
87  }
88 
89  return ok;
90  }
virtual void computeInitialGuess()
SparseOptimizer * optimizer()
returns the optimizer
Definition: star.h:41
HyperGraph::EdgeSet _lowLevelEdges
edges in the lower level
Definition: star.h:58
int optimize(int iterations, bool online=false)
virtual bool init(bool online=false)=0
OptimizationAlgorithm * solver()
HyperGraph::EdgeSet _starEdges
edges in the star
Definition: star.h:60
class G2O_CORE_API Vertex
class G2O_CORE_API Edge
const VertexContainer & indexMapping() const
the index mapping of the vertices
HyperGraph::VertexSet _gauge
vertices that are fixed (center of the star)
Definition: star.h:64
const VertexContainer & activeVertices() const
the vertices active in the current optimization
SparseOptimizer * _optimizer
optimizer
Definition: star.h:56
virtual bool initializeOptimization(HyperGraph::EdgeSet &eset)
class G2O_CORE_API Edge
Definition: hyper_graph.h:79
int g2o::Star::level ( ) const
inline

returns the level of the lower edges in the star

Definition at line 39 of file star.h.

References _level.

39 { return _level; };
int _level
level of the star
Definition: star.h:54
HyperGraph::EdgeSet& g2o::Star::lowLevelEdges ( )
inline

low level edge set

Definition at line 43 of file star.h.

References _lowLevelEdges.

Referenced by g2o::assignHierarchicalEdges(), g2o::computeSimpleStars(), and g2o::constructEdgeStarMap().

43 {return _lowLevelEdges;}
HyperGraph::EdgeSet _lowLevelEdges
edges in the lower level
Definition: star.h:58
HyperGraph::VertexSet& g2o::Star::lowLevelVertices ( )
inline

set of all vertices in the low level

Definition at line 51 of file star.h.

References _lowLevelVertices.

Referenced by g2o::assignHierarchicalEdges().

51 {return _lowLevelVertices;}
HyperGraph::VertexSet _lowLevelVertices
vertices that are fixed (center of the star)
Definition: star.h:66
SparseOptimizer* g2o::Star::optimizer ( )
inline

returns the optimizer

Definition at line 41 of file star.h.

References _optimizer.

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

41 { return _optimizer;}
SparseOptimizer * _optimizer
optimizer
Definition: star.h:56
HyperGraph::EdgeSet& g2o::Star::starEdges ( )
inline

high level edge set

Definition at line 45 of file star.h.

References _starEdges.

Referenced by g2o::constructEdgeStarMap().

45 {return _starEdges;}
HyperGraph::EdgeSet _starEdges
edges in the star
Definition: star.h:60
HyperGraph::EdgeSet& g2o::Star::starFrontierEdges ( )
inline

edges in the high level that lead to some node owned by a different star

Definition at line 47 of file star.h.

References _starFrontierEdges.

Referenced by g2o::computeBorder(), and main().

47 {return _starFrontierEdges;}
HyperGraph::EdgeSet _starFrontierEdges
edges in the star that lead to some other star
Definition: star.h:62

Member Data Documentation

HyperGraph::VertexSet g2o::Star::_gauge

vertices that are fixed (center of the star)

Definition at line 64 of file star.h.

Referenced by g2o::assignHierarchicalEdges(), g2o::computeSimpleStars(), gauge(), labelStarEdges(), and g2o::BackBoneTreeAction::perform().

int g2o::Star::_level

level of the star

Definition at line 54 of file star.h.

Referenced by level().

HyperGraph::EdgeSet g2o::Star::_lowLevelEdges
HyperGraph::VertexSet g2o::Star::_lowLevelVertices

vertices that are fixed (center of the star)

Definition at line 66 of file star.h.

Referenced by g2o::BackBoneTreeAction::addToMap(), g2o::assignHierarchicalEdges(), g2o::computeSimpleStars(), g2o::BackBoneTreeAction::fillStar(), and lowLevelVertices().

SparseOptimizer* g2o::Star::_optimizer

optimizer

Definition at line 56 of file star.h.

Referenced by labelStarEdges(), and optimizer().

HyperGraph::EdgeSet g2o::Star::_starEdges

edges in the star

Definition at line 60 of file star.h.

Referenced by g2o::assignHierarchicalEdges(), g2o::computeBorder(), g2o::computeSimpleStars(), labelStarEdges(), main(), and starEdges().

HyperGraph::EdgeSet g2o::Star::_starFrontierEdges

edges in the star that lead to some other star

Definition at line 62 of file star.h.

Referenced by starFrontierEdges().


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