gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NonlinearFactorGraph.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 
20 // \callgraph
21 
22 #pragma once
23 
24 #include <gtsam/geometry/Point2.h>
27 
28 namespace gtsam {
29 
30  // Forward declarations
31  class Values;
32  class Ordering;
33  class GaussianFactorGraph;
34  class SymbolicFactorGraph;
35 
40  struct GTSAM_EXPORT GraphvizFormatting {
41  enum Axis { X, Y, Z, NEGX, NEGY, NEGZ };
46  double scale;
50  std::map<size_t, Point2> factorPositions;
54  paperHorizontalAxis(Y), paperVerticalAxis(X),
55  figureWidthInches(5), figureHeightInches(5), scale(1),
56  mergeSimilarFactors(false), plotFactorPoints(true),
57  connectKeysToFactor(true) {}
58  };
59 
60 
69  class GTSAM_EXPORT NonlinearFactorGraph: public FactorGraph<NonlinearFactor> {
70 
71  public:
72 
74  typedef NonlinearFactorGraph This;
75  typedef boost::shared_ptr<This> shared_ptr;
76 
79 
81  template<typename ITERATOR>
82  NonlinearFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor) : Base(firstFactor, lastFactor) {}
83 
85  template<class CONTAINER>
86  explicit NonlinearFactorGraph(const CONTAINER& factors) : Base(factors) {}
87 
89  template<class DERIVEDFACTOR>
91 
93  void print(const std::string& str = "NonlinearFactorGraph: ", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
94 
96  bool equals(const NonlinearFactorGraph& other, double tol = 1e-9) const;
97 
99  void saveGraph(std::ostream& stm, const Values& values = Values(),
100  const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
101  const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
102 
104  FastSet<Key> keys() const;
105 
107  double error(const Values& c) const;
108 
110  double probPrime(const Values& c) const;
111 
115  boost::shared_ptr<SymbolicFactorGraph> symbolic() const;
116 
120  Ordering orderingCOLAMD() const;
121 
130  Ordering orderingCOLAMDConstrained(const FastMap<Key, int>& constraints) const;
131 
135  boost::shared_ptr<GaussianFactorGraph> linearize(const Values& linearizationPoint) const;
136 
140  NonlinearFactorGraph clone() const;
141 
151  NonlinearFactorGraph rekey(const std::map<Key,Key>& rekey_mapping) const;
152 
153  private:
154 
156  friend class boost::serialization::access;
157  template<class ARCHIVE>
158  void serialize(ARCHIVE & ar, const unsigned int version) {
159  ar & boost::serialization::make_nvp("NonlinearFactorGraph",
160  boost::serialization::base_object<Base>(*this));
161  }
162  };
163 
164 } // namespace
165 
Non-linear factor base classes.
Definition: FastMap.h:37
double figureWidthInches
The figure width on paper in inches.
Definition: NonlinearFactorGraph.h:44
Axis paperVerticalAxis
The world axis assigned to the vertical paper axis.
Definition: NonlinearFactorGraph.h:43
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: BayesTree.h:32
bool mergeSimilarFactors
Merge multiple factors that have the same connectivity.
Definition: NonlinearFactorGraph.h:47
NonlinearFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor)
Construct from iterator over factors.
Definition: NonlinearFactorGraph.h:82
NonlinearFactorGraph(const CONTAINER &factors)
Construct from container of factors (shared_ptr or plain objects)
Definition: NonlinearFactorGraph.h:86
double figureHeightInches
The figure height on paper in inches.
Definition: NonlinearFactorGraph.h:45
NonlinearFactorGraph()
Default constructor.
Definition: NonlinearFactorGraph.h:78
bool plotFactorPoints
Plots each factor as a dot between the variables.
Definition: NonlinearFactorGraph.h:48
double scale
Scale all positions to reduce / increase density.
Definition: NonlinearFactorGraph.h:46
2D Point
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:75
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
std::map< size_t, Point2 > factorPositions
(optional for each factor) Manually specify factor "dot" positions.
Definition: NonlinearFactorGraph.h:50
A non-linear factor graph is a graph of non-Gaussian, i.e.
Definition: NonlinearFactorGraph.h:69
Template to create a binary predicate.
Definition: Testable.h:102
bool connectKeysToFactor
Draw a line from each key within a factor to the dot of the factor.
Definition: NonlinearFactorGraph.h:49
NonlinearFactorGraph(const FactorGraph< DERIVEDFACTOR > &graph)
Implicit copy/downcast constructor to override explicit template container constructor.
Definition: NonlinearFactorGraph.h:90
Definition: Ordering.h:30
Axis paperHorizontalAxis
The world axis assigned to the horizontal paper axis.
Definition: NonlinearFactorGraph.h:42
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62
Formatting options when saving in GraphViz format using NonlinearFactorGraph::saveGraph.
Definition: NonlinearFactorGraph.h:40
Factor Graph Base Class.