gtsam
Loading...
Searching...
No Matches
SymbolicFactorGraph.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
18
19#pragma once
20
24#include <gtsam/base/types.h>
25
26namespace gtsam {
27
30 class SymbolicBayesNet;
34
35 /* ************************************************************************* */
37 {
46 static std::pair<std::shared_ptr<ConditionalType>, std::shared_ptr<FactorType> >
47 DefaultEliminate(const FactorGraphType& factors, const Ordering& keys) {
48 return EliminateSymbolic(factors, keys); }
49
51 const FactorGraphType& graph,
52 std::optional<std::reference_wrapper<const VariableIndex>> variableIndex) {
53 return Ordering::Colamd((*variableIndex).get());
54 }
55 };
56
57 /* ************************************************************************* */
61 class GTSAM_EXPORT SymbolicFactorGraph :
62 public FactorGraph<SymbolicFactor>,
63 public EliminateableFactorGraph<SymbolicFactorGraph>
64 {
65 public:
66
70 typedef std::shared_ptr<This> shared_ptr;
71
74
77
79 template<typename ITERATOR>
80 SymbolicFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor) : Base(firstFactor, lastFactor) {}
81
83 template<class CONTAINER>
84 explicit SymbolicFactorGraph(const CONTAINER& factors) : Base(factors) {}
85
87 template<class DERIVEDFACTOR>
89
95 std::initializer_list<std::shared_ptr<SymbolicFactor>> sharedFactors)
96 : Base(sharedFactors) {}
97
102
113
115
118
119 bool equals(const This& fg, double tol = 1e-9) const;
120
122 void print(
123 const std::string& s = "SymbolicFactorGraph",
124 const KeyFormatter& formatter = DefaultKeyFormatter) const override {
125 Base::print(s, formatter);
126 }
127
129
132
134 void push_factor(Key key);
135
137 void push_factor(Key key1, Key key2);
138
140 void push_factor(Key key1, Key key2, Key key3);
141
143 void push_factor(Key key1, Key key2, Key key3, Key key4);
144
146
147 private:
148#if GTSAM_ENABLE_BOOST_SERIALIZATION
150 friend class boost::serialization::access;
151 template<class ARCHIVE>
152 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
153 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
154 }
155#endif
156 };
157
159template<>
160struct traits<SymbolicFactorGraph> : public Testable<SymbolicFactorGraph> {
161};
162
163} //\ namespace gtsam
Typedefs for easier changing of types.
Factor Graph Base Class.
Variable elimination algorithms for factor graphs.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
std::pair< std::shared_ptr< SymbolicConditional >, std::shared_ptr< SymbolicFactor > > EliminateSymbolic(const SymbolicFactorGraph &factors, const Ordering &keys)
Dense elimination function for symbolic factors.
Definition SymbolicFactor.cpp:35
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Template to create a binary predicate.
Definition Testable.h:112
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
virtual void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
FactorGraph()
Definition FactorGraph.h:103
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Definition FactorGraph.h:153
Traits class for eliminateable factor graphs, specifies the types that result from elimination,...
Definition EliminateableFactorGraph.h:38
EliminateableFactorGraph is a base class for factor graphs that contains elimination algorithms.
Definition EliminateableFactorGraph.h:59
Definition Ordering.h:33
static Ordering Colamd(const FACTOR_GRAPH &graph)
Compute a fill-reducing ordering using COLAMD from a factor graph (see details for note on performanc...
Definition Ordering.h:93
A SymbolicBayesNet is a Bayes Net of purely symbolic conditionals.
Definition SymbolicBayesNet.h:32
A Bayes tree that represents the connectivity between variables but is not associated with any probab...
Definition SymbolicBayesTree.h:50
SymbolicConditional is a conditional with keys but no probability data, produced by symbolic eliminat...
Definition SymbolicConditional.h:38
Definition SymbolicEliminationTree.h:29
SymbolicFactor represents a symbolic factor that specifies graph topology but is not associated with ...
Definition SymbolicFactor.h:38
SymbolicFactor FactorType
Type of factors in factor graph.
Definition SymbolicFactorGraph.h:38
SymbolicFactorGraph FactorGraphType
Type of the factor graph (e.g. GaussianFactorGraph).
Definition SymbolicFactorGraph.h:39
static Ordering DefaultOrderingFunc(const FactorGraphType &graph, std::optional< std::reference_wrapper< const VariableIndex > > variableIndex)
The default ordering generation function.
Definition SymbolicFactorGraph.h:50
SymbolicEliminationTree EliminationTreeType
Type of elimination tree.
Definition SymbolicFactorGraph.h:42
static std::pair< std::shared_ptr< ConditionalType >, std::shared_ptr< FactorType > > DefaultEliminate(const FactorGraphType &factors, const Ordering &keys)
The default dense elimination function.
Definition SymbolicFactorGraph.h:47
SymbolicBayesNet BayesNetType
Type of Bayes net from sequential elimination.
Definition SymbolicFactorGraph.h:41
SymbolicJunctionTree JunctionTreeType
Type of Junction tree.
Definition SymbolicFactorGraph.h:44
SymbolicBayesTree BayesTreeType
Type of Bayes tree.
Definition SymbolicFactorGraph.h:43
SymbolicConditional ConditionalType
Type of conditionals from elimination.
Definition SymbolicFactorGraph.h:40
Symbolic Factor Graph.
Definition SymbolicFactorGraph.h:64
SymbolicFactorGraph(SymbolicFactor &&c)
Construct from a single factor.
Definition SymbolicFactorGraph.h:99
SymbolicFactorGraph & operator()(SymbolicFactor &&c)
Add a single factor and return a reference.
Definition SymbolicFactorGraph.h:109
SymbolicFactorGraph()
Construct empty factor graph.
Definition SymbolicFactorGraph.h:76
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition SymbolicFactorGraph.h:70
SymbolicFactorGraph(const FactorGraph< DERIVEDFACTOR > &graph)
Implicit copy/downcast constructor to override explicit template container constructor.
Definition SymbolicFactorGraph.h:88
void print(const std::string &s="SymbolicFactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition SymbolicFactorGraph.h:122
SymbolicFactorGraph(std::initializer_list< std::shared_ptr< SymbolicFactor > > sharedFactors)
Constructor that takes an initializer list of shared pointers.
Definition SymbolicFactorGraph.h:94
EliminateableFactorGraph< This > BaseEliminateable
Typedef to base elimination class.
Definition SymbolicFactorGraph.h:69
SymbolicFactorGraph This
Typedef to this class.
Definition SymbolicFactorGraph.h:67
SymbolicFactorGraph(ITERATOR firstFactor, ITERATOR lastFactor)
Construct from iterator over factors.
Definition SymbolicFactorGraph.h:80
FactorGraph< SymbolicFactor > Base
Typedef to base factor graph type.
Definition SymbolicFactorGraph.h:68
SymbolicFactorGraph(const CONTAINER &factors)
Construct from container of factors (shared_ptr or plain objects).
Definition SymbolicFactorGraph.h:84
A EliminatableClusterTree, i.e., a set of variable clusters with factors, arranged in a tree,...
Definition SymbolicJunctionTree.h:51