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;
71  Factors factors;
72  Children children;
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:
84  GTSAM_CONCEPT_TESTABLE_TYPE(FactorType)
85 
86  FastVector<sharedNode> roots_;
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 }
FastVector< sharedNode > roots_
Factors factors
factors associated with root
bool equals(const This &other, double tol=1e-9) const
const FastVector< sharedNode > & roots() const
Concept check for values that can be used in unit tests.
GRAPH FactorGraphType
The factor graph type.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
Definition: FastVector.h:34
#define GTSAM_CONCEPT_TESTABLE_TYPE(T)
Definition: Testable.h:177
Children children
sub-trees
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
const KeyFormatter & formatter
EliminationTree()
Protected default constructor.
GRAPH::Eliminate Eliminate
FastVector< sharedFactor > Factors
BayesNetType::ConditionalType ConditionalType
The type of conditionals.
Definition: pytypes.h:1403
EliminationTree< BAYESNET, GRAPH > This
This class.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void print(const std::string &str, const KeyFormatter &keyFormatter) const
std::shared_ptr< ConditionalType > sharedConditional
Shared pointer to a conditional.
Key key
key associated with root
const FastVector< sharedFactor > & remainingFactors() const
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
A thin wrapper around std::vector that uses a custom allocator.
traits
Definition: chartTesting.h:28
FastVector< sharedFactor > remainingFactors_
sharedFactor eliminate(const std::shared_ptr< BayesNetType > &output, const Eliminate &function, const FastVector< sharedFactor > &childrenFactors) const
BAYESNET BayesNetType
The BayesNet corresponding to FACTOR.
This & operator=(const This &other)
Annotation for function names.
Definition: attr.h:48
FastVector< std::shared_ptr< Node > > Children
const G double tol
Definition: Group.h:86
std::shared_ptr< This > shared_ptr
Shared pointer to this class.
GRAPH::FactorType FactorType
The type of factors.
std::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
std::shared_ptr< Node > sharedNode
Shared pointer to Node.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:12