gtsam 4.1.1
gtsam
IterativeSolver.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
19#pragma once
20
22#include <gtsam/base/Vector.h>
23
24#include <boost/tuple/tuple.hpp>
25#include <boost/shared_ptr.hpp>
26#include <boost/optional.hpp>
27
28#include <iosfwd>
29#include <string>
30#include <map>
31
32namespace gtsam {
33
34// Forward declarations
35struct KeyInfoEntry;
36class KeyInfo;
37class GaussianFactorGraph;
38class Values;
39class VectorValues;
40
45
46public:
47
48 typedef boost::shared_ptr<IterativeOptimizationParameters> shared_ptr;
49 enum Verbosity {
50 SILENT = 0, COMPLEXITY, ERROR
51 } verbosity_;
52
53public:
54
55 IterativeOptimizationParameters(Verbosity v = SILENT) :
56 verbosity_(v) {
57 }
58
60 }
61
62 /* utility */
63 inline Verbosity verbosity() const {
64 return verbosity_;
65 }
66 GTSAM_EXPORT std::string getVerbosity() const;
67 GTSAM_EXPORT void setVerbosity(const std::string &s);
68
69 /* matlab interface */
70 GTSAM_EXPORT void print() const;
71
72 /* virtual print function */
73 GTSAM_EXPORT virtual void print(std::ostream &os) const;
74
75 /* for serialization */
76 friend std::ostream& operator<<(std::ostream &os,
78
79 GTSAM_EXPORT static Verbosity verbosityTranslator(const std::string &s);
80 GTSAM_EXPORT static std::string verbosityTranslator(Verbosity v);
81};
82
87public:
88 typedef boost::shared_ptr<IterativeSolver> shared_ptr;
90 }
91 virtual ~IterativeSolver() {
92 }
93
94 /* interface to the nonlinear optimizer, without metadata, damping and initial estimate */
95 GTSAM_EXPORT VectorValues optimize(const GaussianFactorGraph &gfg,
96 boost::optional<const KeyInfo&> = boost::none,
97 boost::optional<const std::map<Key, Vector>&> lambda = boost::none);
98
99 /* interface to the nonlinear optimizer, without initial estimate */
100 GTSAM_EXPORT VectorValues optimize(const GaussianFactorGraph &gfg, const KeyInfo &keyInfo,
101 const std::map<Key, Vector> &lambda);
102
103 /* interface to the nonlinear optimizer that the subclasses have to implement */
104 virtual VectorValues optimize(const GaussianFactorGraph &gfg,
105 const KeyInfo &keyInfo, const std::map<Key, Vector> &lambda,
106 const VectorValues &initial) = 0;
107
108};
109
114struct GTSAM_EXPORT KeyInfoEntry {
115 size_t index, dim, start;
116 KeyInfoEntry() {
117 }
118 KeyInfoEntry(size_t idx, size_t d, Key start) :
119 index(idx), dim(d), start(start) {
120 }
121};
122
126class GTSAM_EXPORT KeyInfo: public std::map<Key, KeyInfoEntry> {
127
128public:
129
130 typedef std::map<Key, KeyInfoEntry> Base;
131
132protected:
133
134 Ordering ordering_;
135 size_t numCols_;
136
137 void initialize(const GaussianFactorGraph &fg);
138
139public:
140
143 numCols_(0) {
144 }
145
147 KeyInfo(const GaussianFactorGraph &fg);
148
150 KeyInfo(const GaussianFactorGraph &fg, const Ordering &ordering);
151
153 inline size_t numCols() const {
154 return numCols_;
155 }
156
158 inline const Ordering & ordering() const {
159 return ordering_;
160 }
161
163 std::vector<size_t> colSpec() const;
164
166 VectorValues x0() const;
167
169 Vector x0vector() const;
170
171};
172
173} // \ namespace gtsam
typedef and functions to augment Eigen's VectorXd
Variable ordering for the elimination algorithm.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Optimize for triangulation.
Definition: triangulation.cpp:73
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
Definition: Ordering.h:34
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition: GaussianFactorGraph.h:69
parameters for iterative linear solvers
Definition: IterativeSolver.h:44
Base class for Iterative Solvers like SubgraphSolver.
Definition: IterativeSolver.h:86
Handy data structure for iterative solvers key to (index, dimension, start)
Definition: IterativeSolver.h:114
Handy data structure for iterative solvers.
Definition: IterativeSolver.h:126
const Ordering & ordering() const
Return the ordering.
Definition: IterativeSolver.h:158
size_t numCols() const
Return the total number of columns (scalar variables = sum of dimensions)
Definition: IterativeSolver.h:153
KeyInfo()
Default Constructor.
Definition: IterativeSolver.h:142
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:74