NDEVR
API Documentation
optimization_algorithm_with_hessian.h
1#pragma once
2#include "optimization_algorithm.h"
3#include "solver.h"
4#include "optimizable_graph.h"
5#include "sparse_optimizer.h"
6namespace NDEVR
7{
8 class Solver;
9
13 template<class t_solver>
15 {
16 public:
17 t_solver solver;
20 {
21 // solver.setAlgorithm(&optimizer);
22 }
23
24 void clear()
25 {
26 solver.clear();
27 }
28
31 {
32 solver.optimizer().addVertex(v);
33 }
34
37 {
38 solver.optimizer().addEdge(e);
39 }
40
42 {
43 return solver.optimizer();
44 }
45
47 {
48 return solver.optimizer();
49 }
50
53 bool init(bool online = false)
54 {
55 bool useSchur = false;
56 for (OptimizableGraph::OGVertex* v : optimizer().activeVertices())
57 {
58 if (v->marginalized())
59 {
60 useSchur = true;
61 break;
62 }
63 }
64 if (useSchur)
65 {
66 if (solver.supportsSchur())
67 solver.setSchur(true);
68 }
69 else
70 {
71 if (solver.supportsSchur())
72 solver.setSchur(false);
73 }
74
75 bool initState = solver.init(online);
76 return initState;
77 }
78
83 {
84 return solver.buildStructure(false, scratch);
85 }
86
89 {
90 solver.buildSystem();
91 }
92
98 {
99 return solver.updateStructure(vset, edges);
100 }
101
102
103 };
104
105}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Abstract Edge class.
Definition hyper_graph.h:54
abstract Vertex, your types must derive from that one
Definition hyper_graph.h:28
A general case Vertex for optimization.
bool init(bool online=false)
Initializes the solver, detecting whether Schur complement should be used.
void updateLinearSystem()
Rebuilds the linear system (Hessian and gradient) from the current graph state.
void addVertex(HyperGraph::HGVertex &v)
Adds a vertex to the optimizer.
const SparseOptimizer & optimizer() const
Returns a const reference to the underlying sparse optimizer.
t_solver solver
The underlying solver instance.
bool buildLinearStructure(IndexScratch &scratch)
Builds the linear system structure.
bool updateStructure(const Buffer< HyperGraph::HGVertex * > &vset, const Set< HyperGraph::HGVertex * > &edges)
Updates the linear system structure after graph topology changes.
SparseOptimizer & optimizer()
Returns a mutable reference to the underlying sparse optimizer.
void addEdge(HyperGraph::HGEdge *e)
Adds an edge to the optimizer.
Generic interface for a non-linear solver operating on a graph.
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
Definition Set.h:59
Generic interface for a sparse solver operating on a graph which solves one iteration of the lineariz...
Definition solver.h:16
Sparse optimizer that manages active vertices and edges for graph-based optimization.
The primary namespace for the NDEVR SDK.
Scratch buffers for block index assignments during structure building.