NDEVR
API Documentation
SparseOptimizer

Sparse optimizer that manages active vertices and edges for graph-based optimization. More...

Inheritance diagram for SparseOptimizer:
[legend]
Collaboration diagram for SparseOptimizer:
[legend]

Public Types

enum  
 Action types for optimization callbacks.
Public Types inherited from OptimizableGraph
enum  ActionType { AT_PREITERATION , AT_POSTITERATION , AT_NUM_ELEMENTS }
 Types of actions that can be registered for optimization callbacks. More...
typedef Buffer< OptimizableGraph::OGEdge * > EdgeContainer
 vector container for edges
typedef Buffer< OptimizableGraph::OGVertex * > VertexContainer
 vector container for vertices

Public Member Functions

g_type activeChi2 () const
 Returns the total chi-squared error of all active edges.
const EdgeContaineractiveEdges () const
 the edges active in the current optimization
g_type activeRobustChi2 () const
 Returns the total robustified chi-squared error of all active edges.
const VertexContaineractiveVertices () const
 the vertices active in the current optimization
bool buildIndexMapping (SparseOptimizer::VertexContainer &vlist)
 Builds the index mapping from active vertices to Hessian positions.
void clear () final override
 Clears all internal structures and the base graph.
void clearIndexMapping ()
 Clears the index mapping, resetting all vertex Hessian indices to -1.
void computeActiveErrors ()
 computes the error vectors of all edges in the activeSet, and caches them
void discardTop () final override
 discard the last backup of the estimate for all variables by removing it from the stack
OptimizableGraph::OGEdge *const * findActiveEdge (const OptimizableGraph::OGEdge *e) const
 Finds an active edge by pointer using binary search.
OGVertex *const * findActiveVertex (const OGVertex *v) const
 Finds an active vertex by pointer using binary search.
OGVertexfindGauge ()
 Finds a gauge vertex (first vertex with maximum dimension) for fixing.
bool * forceStopFlag () const
 Returns the external force-stop flag pointer.
bool gaugeFreedom ()
 Returns true if the graph has gauge freedom (no fixed vertex of maximum dimension).
const VertexContainerindexMapping () const
 the index mapping of the vertices
bool initializeOptimization (int level=0)
 Initializes the structures for optimizing a portion of the graph specified by a subset of vertices.
bool initializeOptimization (Set< HyperGraph::HGVertex * > &eset)
 Initializes optimization from a specific edge set.
bool isReadyToUpdate () const
 Returns true if the index mapping has been built and the optimizer is ready.
void linearizeSystem ()
 Linearizes the system by computing the Jacobians for the nodes and edges in the graph.
void pop () final override
 pop (restore) the estimate of all variables from the stack
void pop (Set< HyperGraph::HGVertex * > &vlist) final override
 pop (restore) the estimate a subset of the variables from the stack
void push () final override
 Remove a vertex.
void push (Set< HyperGraph::HGVertex * > &vlist) final override
 push the estimate of a subset of the variables onto a stack
void setForceStopFlag (bool *flag)
 sets a variable checked at every iteration to force a user stop.
bool terminate ()
 if external stop flag is given, return its state. False otherwise
void update (const g_type *update)
 update the estimate of the active vertices
Public Member Functions inherited from OptimizableGraph
 OptimizableGraph ()
 empty constructor
virtual bool addEdge (HyperGraph::HGEdge *e_) final override
 adds a new edge.
virtual bool addVertex (HyperGraph::HGVertex &v) final override
 adds a new vertex.
g_type chi2 () const
 returns the chi2 of the current configuration
Set< sint04dimensions () const
 iterates over all vertices and returns a set of all the vertex dimensions in the graph
bool isSolverSuitable (const OptimizationAlgorithmProperty &solverProperty, const Set< sint04 > &vertDims_=Set< int >()) const
 test whether a solver is suitable for optimizing this graph.
JacobianWorkspacejacobianWorkspace ()
 verify that all the information of the edges are semi positive definite, i.e., all Eigenvalues are >= 0.
const JacobianWorkspacejacobianWorkspace () const
 Returns a const reference to the Jacobian workspace.
sint04 maxDimension () const
 return the maximum dimension of all vertices in the graph
virtual void setFixed (Set< HyperGraph::HGVertex * > &vset, bool fixed)
 fixes/releases a set of vertices
Public Member Functions inherited from HyperGraph
 HyperGraph ()
 constructs an empty hyper graph
virtual ~HyperGraph ()
 destroys the hyper-graph and all the vertices of the graph
Buffer< HGEdge * > & edges ()
const Buffer< HGEdge * > & edges () const
HGVertexvertex (int id)
 returns a vertex id in the hyper-graph, or 0 if the vertex id is not present
const HGVertexvertex (int id) const
 returns a vertex id in the hyper-graph, or 0 if the vertex id is not present
Dictionary< int, HGVertex * > & vertices ()
const Dictionary< int, HGVertex * > & vertices () const

Protected Member Functions

void sortVectorContainers ()
 Sorts active vertices and edges by their ID comparators for deterministic ordering.

Protected Attributes

EdgeContainer _activeEdges
 Active edges, sorted by EdgeIDCompare.
VertexContainer _activeVertices
 Active vertices, sorted by VertexIDCompare.
bool * _forceStopFlag
 External flag to force stopping the optimization.
VertexContainer _ivMap
 Index-to-vertex mapping for the Hessian.
Protected Attributes inherited from OptimizableGraph
JacobianWorkspace _jacobianWorkspace
 Workspace for computing Jacobians.
int _nextEdgeId = 0
 Counter for assigning internal edge IDs.
Protected Attributes inherited from HyperGraph
Buffer< HGEdge * > _edges
 Collection of all edges in the graph.
Dictionary< int, HGVertex * > _vertices
 Map from vertex id to vertex pointer.

Detailed Description

Sparse optimizer that manages active vertices and edges for graph-based optimization.

Definition at line 13 of file sparse_optimizer.h.

Member Function Documentation

◆ buildIndexMapping()

bool SparseOptimizer::buildIndexMapping ( SparseOptimizer::VertexContainer & vlist)
inline

Builds the index mapping from active vertices to Hessian positions.

Parameters
[in]vlistThe vertex container to build the mapping from.
Returns
True on success, false if the list is empty.

Definition at line 176 of file sparse_optimizer.h.

References _ivMap, OptimizableGraph::OGVertex::fixed(), OptimizableGraph::OGVertex::marginalized(), and OptimizableGraph::OGVertex::setHessianIndex().

Referenced by initializeOptimization(), and initializeOptimization().

◆ findActiveEdge()

OptimizableGraph::OGEdge *const * SparseOptimizer::findActiveEdge ( const OptimizableGraph::OGEdge * e) const
inline

Finds an active edge by pointer using binary search.

Parameters
[in]eThe edge to find.
Returns
Pointer to the found element, or end() if not found.

Definition at line 336 of file sparse_optimizer.h.

References _activeEdges.

◆ findActiveVertex()

OGVertex *const * SparseOptimizer::findActiveVertex ( const OGVertex * v) const
inline

Finds an active vertex by pointer using binary search.

Parameters
[in]vThe vertex to find.
Returns
Pointer to the found element, or end() if not found.

Definition at line 323 of file sparse_optimizer.h.

References _activeVertices.

◆ initializeOptimization() [1/2]

bool SparseOptimizer::initializeOptimization ( int level = 0)
inline

Initializes the structures for optimizing a portion of the graph specified by a subset of vertices.

Before calling it be sure to invoke marginalized() and fixed() to the vertices you want to include in the schur complement or to set as fixed during the optimization.

Parameters
vsetthe subgraph to be optimized.
levelis the level (in multilevel optimization)
Returns
false if somethings goes wrong

Initializes optimization structures from all graph vertices at the given level.

Parameters
[in]levelThe multi-level optimization level (-1 for all levels).
Returns
True on success.

Definition at line 221 of file sparse_optimizer.h.

References _activeEdges, _activeVertices, OptimizableGraph::_jacobianWorkspace, OptimizableGraph::OGEdge::allVerticesFixed(), buildIndexMapping(), cast(), clearIndexMapping(), HyperGraph::edges(), HyperGraph::HGVertex::edges(), HyperGraph::HGVertex::id(), Set< t_value >::size(), sortVectorContainers(), HyperGraph::HGEdge::vertex(), HyperGraph::HGEdge::vertexCount(), and HyperGraph::vertices().

◆ initializeOptimization() [2/2]

bool SparseOptimizer::initializeOptimization ( Set< HyperGraph::HGVertex * > & eset)
inline

Initializes optimization from a specific edge set.

Parameters
[in]esetThe set of edges to optimize.
Returns
True on success.

Definition at line 280 of file sparse_optimizer.h.

References _activeEdges, _activeVertices, OptimizableGraph::_jacobianWorkspace, buildIndexMapping(), cast(), clearIndexMapping(), Set< t_value >::size(), sortVectorContainers(), HyperGraph::HGEdge::vertex(), and HyperGraph::HGEdge::vertexCount().

◆ push()

void SparseOptimizer::push ( )
inlinefinaloverridevirtual

Remove a vertex.

If the vertex is contained in the currently active set of vertices, then the internal temporary structures are cleaned, e.g., the index mapping is erased. In case you need the index mapping for manipulating the graph, you have to store it in your own copy.

Reimplemented from OptimizableGraph.

Definition at line 413 of file sparse_optimizer.h.

References _activeVertices, and push().

Referenced by push().

◆ setForceStopFlag()

void SparseOptimizer::setForceStopFlag ( bool * flag)
inline

sets a variable checked at every iteration to force a user stop.

The iteration exits when the variable is true;

Definition at line 390 of file sparse_optimizer.h.

References _forceStopFlag.

◆ update()

void SparseOptimizer::update ( const g_type * update)
inline

update the estimate of the active vertices

Parameters
updatethe g_type vector containing the stacked elements of the increments on the vertices.

Definition at line 61 of file sparse_optimizer.h.

References _ivMap, OptimizableGraph::OGVertex::dimension(), OptimizableGraph::OGVertex::oplus(), and update().

Referenced by OptimizationAlgorithmGaussNewton< t_type >::solve(), OptimizationAlgorithmLevenberg< t_type >::solve(), and update().


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