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 <boost/shared_ptr.hpp>
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 boost::shared_ptr<This> shared_ptr;
56 
57  public:
58  typedef GRAPH FactorGraphType;
59  typedef typename GRAPH::FactorType FactorType;
60  typedef typename boost::shared_ptr<FactorType> sharedFactor;
61  typedef BAYESNET BayesNetType;
63  typedef typename boost::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 boost::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 boost::shared_ptr<Node> sharedNode;
81 
82  protected:
84  GTSAM_CONCEPT_TESTABLE_TYPE(FactorType);
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:
123 
129  std::pair<boost::shared_ptr<BayesNetType>, boost::shared_ptr<FactorGraphType> >
130  eliminate(Eliminate function) const;
131 
135 
137  void print(const std::string& name = "EliminationTree: ",
139 
140  protected:
142  bool equals(const This& other, double tol = 1e-9) const;
143 
145 
146  public:
149 
151  const FastVector<sharedNode>& roots() const { return roots_; }
152 
155 
157  void swap(This& other);
158 
159  protected:
162 
163  private:
165  friend class ::EliminationTreeTester;
166  };
167 
168 }
FastVector< sharedNode > roots_
Factors factors
factors associated with root
boost::shared_ptr< ConditionalType > sharedConditional
Shared pointer to a conditional.
Concept check for values that can be used in unit tests.
GRAPH FactorGraphType
The factor graph type.
void print(const std::string &str, const KeyFormatter &keyFormatter) const
bool equals(const This &other, double tol=1e-9) const
sharedFactor eliminate(const boost::shared_ptr< BayesNetType > &output, const Eliminate &function, const FastVector< sharedFactor > &childrenFactors) const
Children children
sub-trees
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
const KeyFormatter & formatter
boost::shared_ptr< This > shared_ptr
Shared pointer to this class.
boost::shared_ptr< Node > sharedNode
Shared pointer to Node.
EliminationTree()
Protected default constructor.
GRAPH::Eliminate Eliminate
const FastVector< sharedFactor > & remainingFactors() const
FastVector< sharedFactor > Factors
BayesNetType::ConditionalType ConditionalType
The type of conditionals.
boost::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
Definition: pytypes.h:928
EliminationTree(const This &other)
EliminationTree< BAYESNET, GRAPH > This
This class.
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
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const FastVector< sharedNode > & roots() const
Key key
key associated with root
A thin wrapper around std::vector that uses a custom allocator.
traits
Definition: chartTesting.h:28
FastVector< sharedFactor > remainingFactors_
GTSAM_CONCEPT_TESTABLE_TYPE(FactorType)
BAYESNET BayesNetType
The BayesNet corresponding to FACTOR.
This & operator=(const This &other)
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
Definition: FastVector.h:34
Annotation for function names.
Definition: attr.h:36
const G double tol
Definition: Group.h:83
GRAPH::FactorType FactorType
The type of factors.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
FastVector< boost::shared_ptr< Node > > Children


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:01