EliminationTree.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 #pragma once
19 
20 #include <utility>
21 #include <memory>
22 
23 #include <gtsam/base/Testable.h>
24 #include <gtsam/base/FastVector.h>
25 
26 class EliminationTreeTester; // for unit tests, see testEliminationTree
27 
28 namespace gtsam {
29 
30  class VariableIndex;
31  class Ordering;
32 
50  template<class BAYESNET, class GRAPH>
52  {
53  protected:
55  typedef std::shared_ptr<This> shared_ptr;
56 
57  public:
58  typedef GRAPH FactorGraphType;
59  typedef typename GRAPH::FactorType FactorType;
60  typedef typename std::shared_ptr<FactorType> sharedFactor;
61  typedef BAYESNET BayesNetType;
63  typedef typename std::shared_ptr<ConditionalType> sharedConditional;
64  typedef typename GRAPH::Eliminate Eliminate;
65 
66  struct Node {
69 
70  Key key;
73 
74  sharedFactor eliminate(const std::shared_ptr<BayesNetType>& output,
75  const Eliminate& function, const FastVector<sharedFactor>& childrenFactors) const;
76 
77  void print(const std::string& str, const KeyFormatter& keyFormatter) const;
78  };
79 
80  typedef std::shared_ptr<Node> sharedNode;
81 
82  protected:
85 
88 
91 
100  EliminationTree(const FactorGraphType& factorGraph,
101  const VariableIndex& structure, const Ordering& order);
102 
108  EliminationTree(const FactorGraphType& factorGraph, const Ordering& order);
109 
112  EliminationTree(const This& other) { *this = other; }
113 
116  This& operator=(const This& other);
117 
119 
120  public:
121  ~EliminationTree();
124 
130  std::pair<std::shared_ptr<BayesNetType>, std::shared_ptr<FactorGraphType> >
131  eliminate(Eliminate function) const;
132 
136 
138  void print(const std::string& name = "EliminationTree: ",
140 
141  protected:
143  bool equals(const This& other, double tol = 1e-9) const;
144 
146 
147  public:
150 
152  const FastVector<sharedNode>& roots() const { return roots_; }
153 
156 
158  void swap(This& other);
159 
160  protected:
163 
164  private:
166  friend class ::EliminationTreeTester;
167  };
168 
169 }
gtsam::EliminationTree::Node::factors
Factors factors
factors associated with root
Definition: EliminationTree.h:71
gtsam::EliminationTree::Node::Children
FastVector< std::shared_ptr< Node > > Children
Definition: EliminationTree.h:68
gtsam::EliminationTree::Node::Factors
FastVector< sharedFactor > Factors
Definition: EliminationTree.h:67
name
Annotation for function names.
Definition: attr.h:51
gtsam::EliminationTree::roots_
FastVector< sharedNode > roots_
Definition: EliminationTree.h:86
gtsam::EliminationTree::This
EliminationTree< BAYESNET, GRAPH > This
This class.
Definition: EliminationTree.h:54
gtsam::EliminationTree::Eliminate
GRAPH::Eliminate Eliminate
Definition: EliminationTree.h:64
FastVector.h
A thin wrapper around std::vector that uses a custom allocator.
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::EliminationTree::remainingFactors_
FastVector< sharedFactor > remainingFactors_
Definition: EliminationTree.h:87
Testable.h
Concept check for values that can be used in unit tests.
EliminationTreeTester
Definition: testSymbolicEliminationTree.cpp:36
gtsam::FastVector
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
Definition: FastVector.h:34
gtsam::EliminationTree::~EliminationTree
~EliminationTree()
Definition: EliminationTree-inst.h:192
gtsam::EliminationTree::sharedConditional
std::shared_ptr< ConditionalType > sharedConditional
Shared pointer to a conditional.
Definition: EliminationTree.h:63
gtsam::EliminationTree::swap
void swap(This &other)
Definition: EliminationTree-inst.h:320
gtsam::EliminationTree::print
void print(const std::string &name="EliminationTree: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
Definition: EliminationTree-inst.h:244
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
gtsam::EliminationTree::ConditionalType
BayesNetType::ConditionalType ConditionalType
The type of conditionals.
Definition: EliminationTree.h:62
gtsam::EliminationTree::BayesNetType
BAYESNET BayesNetType
The BayesNet corresponding to FACTOR.
Definition: EliminationTree.h:61
gtsam::EliminationTree
Definition: EliminationTree.h:51
gtsam::EliminationTree::Node
Definition: EliminationTree.h:66
gtsam::EliminationTree::Node::children
Children children
sub-trees
Definition: EliminationTree.h:72
gtsam::EliminationTree::Node::eliminate
sharedFactor eliminate(const std::shared_ptr< BayesNetType > &output, const Eliminate &function, const FastVector< sharedFactor > &childrenFactors) const
Definition: EliminationTree-inst.h:35
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::EliminationTree::roots
const FastVector< sharedNode > & roots() const
Definition: EliminationTree.h:152
gtsam::GaussianFactorGraph
Definition: GaussianFactorGraph.h:73
gtsam::EliminationTree::shared_ptr
std::shared_ptr< This > shared_ptr
Shared pointer to this class.
Definition: EliminationTree.h:55
gtsam::KeyFormatter
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
gtsam::EliminationTree::Node::key
Key key
key associated with root
Definition: EliminationTree.h:70
gtsam::EliminationTree::EliminationTree
EliminationTree()
Protected default constructor.
Definition: EliminationTree.h:162
gtsam::GaussianConditional
Definition: GaussianConditional.h:40
gtsam::EliminationTree::eliminate
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminate(Eliminate function) const
Definition: EliminationTree-inst.h:224
gtsam::EliminationTree::FactorType
GRAPH::FactorType FactorType
The type of factors.
Definition: EliminationTree.h:59
gtsam::VariableIndex
Definition: VariableIndex.h:41
gtsam::EliminationTree::sharedNode
std::shared_ptr< Node > sharedNode
Shared pointer to Node.
Definition: EliminationTree.h:80
str
Definition: pytypes.h:1524
gtsam::EliminationTree::FactorGraphType
GRAPH FactorGraphType
The factor graph type.
Definition: EliminationTree.h:58
gtsam
traits
Definition: chartTesting.h:28
gtsam::EliminationTree::Node::print
void print(const std::string &str, const KeyFormatter &keyFormatter) const
Definition: EliminationTree-inst.h:62
GTSAM_CONCEPT_TESTABLE_TYPE
#define GTSAM_CONCEPT_TESTABLE_TYPE(T)
Definition: Testable.h:177
gtsam::EliminationTree::operator=
This & operator=(const This &other)
Definition: EliminationTree-inst.h:172
gtsam::EliminationTree::sharedFactor
std::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
Definition: EliminationTree.h:60
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::EliminationTree::equals
bool equals(const This &other, double tol=1e-9) const
Definition: EliminationTree-inst.h:251
gtsam::Ordering
Definition: inference/Ordering.h:33
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::EliminationTree::remainingFactors
const FastVector< sharedFactor > & remainingFactors() const
Definition: EliminationTree.h:155


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:02:18