Loading...
Searching...
No Matches
IterativeSolver.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/inference/Ordering.h>
#include <gtsam/base/Vector.h>
#include <boost/tuple/tuple.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
#include <iosfwd>
#include <string>
#include <map>
namespace gtsam {
// Forward declarations
struct KeyInfoEntry;
class KeyInfo;
class GaussianFactorGraph;
class Values;
class VectorValues;
class IterativeOptimizationParameters {
public:
typedef boost::shared_ptr<IterativeOptimizationParameters> shared_ptr;
enum Verbosity {
SILENT = 0, COMPLEXITY, ERROR
} verbosity_;
public:
IterativeOptimizationParameters(Verbosity v = SILENT) :
verbosity_(v) {
}
virtual ~IterativeOptimizationParameters() {
}
/* utility */
inline Verbosity verbosity() const {
return verbosity_;
}
GTSAM_EXPORT std::string getVerbosity() const;
GTSAM_EXPORT void setVerbosity(const std::string &s);
/* matlab interface */
GTSAM_EXPORT void print() const;
/* virtual print function */
GTSAM_EXPORT virtual void print(std::ostream &os) const;
/* for serialization */
friend std::ostream& operator<<(std::ostream &os,
const IterativeOptimizationParameters &p);
GTSAM_EXPORT static Verbosity verbosityTranslator(const std::string &s);
GTSAM_EXPORT static std::string verbosityTranslator(Verbosity v);
};
class IterativeSolver {
public:
typedef boost::shared_ptr<IterativeSolver> shared_ptr;
IterativeSolver() {
}
virtual ~IterativeSolver() {
}
/* interface to the nonlinear optimizer, without metadata, damping and initial estimate */
GTSAM_EXPORT VectorValues optimize(const GaussianFactorGraph &gfg,
boost::optional<const KeyInfo&> = boost::none,
boost::optional<const std::map<Key, Vector>&> lambda = boost::none);
/* interface to the nonlinear optimizer, without initial estimate */
GTSAM_EXPORT VectorValues optimize(const GaussianFactorGraph &gfg, const KeyInfo &keyInfo,
const std::map<Key, Vector> &lambda);
/* interface to the nonlinear optimizer that the subclasses have to implement */
virtual VectorValues optimize(const GaussianFactorGraph &gfg,
const KeyInfo &keyInfo, const std::map<Key, Vector> &lambda,
const VectorValues &initial) = 0;
};
struct GTSAM_EXPORT KeyInfoEntry {
size_t index, dim, start;
KeyInfoEntry() {
}
KeyInfoEntry(size_t idx, size_t d, Key start) :
index(idx), dim(d), start(start) {
}
};
class GTSAM_EXPORT KeyInfo: public std::map<Key, KeyInfoEntry> {
public:
typedef std::map<Key, KeyInfoEntry> Base;
protected:
Ordering ordering_;
size_t numCols_;
void initialize(const GaussianFactorGraph &fg);
public:
KeyInfo() :
numCols_(0) {
}
KeyInfo(const GaussianFactorGraph &fg);
KeyInfo(const GaussianFactorGraph &fg, const Ordering &ordering);
inline size_t numCols() const {
return numCols_;
}
inline const Ordering & ordering() const {
return ordering_;
}
std::vector<size_t> colSpec() const;
VectorValues x0() const;
Vector x0vector() const;
};
} // \ namespace gtsam
Vector.h
typedef and functions to augment Eigen's VectorXd
Ordering.h
Variable ordering for the elimination algorithm.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
gtsam::Ordering
Definition Ordering.h:34
gtsam::GaussianFactorGraph
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition GaussianFactorGraph.h:75
gtsam::KeyInfoEntry
Handy data structure for iterative solvers key to (index, dimension, start).
Definition IterativeSolver.h:114
gtsam::KeyInfo
Handy data structure for iterative solvers.
Definition IterativeSolver.h:126
gtsam::KeyInfo::ordering
const Ordering & ordering() const
Return the ordering.
Definition IterativeSolver.h:158
gtsam::KeyInfo::numCols
size_t numCols() const
Return the total number of columns (scalar variables = sum of dimensions).
Definition IterativeSolver.h:153
gtsam::KeyInfo::KeyInfo
KeyInfo()
Default Constructor.
Definition IterativeSolver.h:142
gtsam::VectorValues
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74
gtsam::Values
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65