26 #include <gtsam/base/ConcurrentMap.h> 40 double avgConditionalSize;
41 std::size_t maxConditionalSize;
42 double avgSeparatorSize;
43 std::size_t maxSeparatorSize;
44 void print(
const std::string& s =
"")
const ;
65 template<
class CLIQUE>
70 typedef std::shared_ptr<This> shared_ptr;
77 typedef typename CLIQUE::ConditionalType ConditionalType;
78 typedef std::shared_ptr<ConditionalType> sharedConditional;
79 typedef typename CLIQUE::BayesNetType BayesNetType;
80 typedef std::shared_ptr<BayesNetType> sharedBayesNet;
81 typedef typename CLIQUE::FactorType FactorType;
82 typedef std::shared_ptr<FactorType> sharedFactor;
83 typedef typename CLIQUE::FactorGraphType FactorGraphType;
84 typedef std::shared_ptr<FactorGraphType> sharedFactorGraph;
85 typedef typename FactorGraphType::Eliminate Eliminate;
86 typedef typename CLIQUE::EliminationTraitsType EliminationTraitsType;
120 This& operator=(
const This& other);
126 bool equals(
const This& other,
double tol = 1e-9)
const;
130 void print(
const std::string& s =
"",
131 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
142 return nodes_.empty();
146 const Nodes&
nodes()
const {
return nodes_; }
152 const Roots&
roots()
const {
return roots_; }
156 typename Nodes::const_iterator c = nodes_.find(j);
157 if(c == nodes_.end())
158 throw std::out_of_range(
"Requested the BayesTree clique for a key that is not in the BayesTree");
167 size_t numCachedSeparatorMarginals()
const;
174 sharedConditional marginalFactor(
Key j,
const Eliminate&
function = EliminationTraitsType::DefaultEliminate)
const;
180 sharedFactorGraph joint(
Key j1,
Key j2,
const Eliminate&
function = EliminationTraitsType::DefaultEliminate)
const;
186 sharedBayesNet jointBayesNet(
Key j1,
Key j2,
const Eliminate&
function = EliminationTraitsType::DefaultEliminate)
const;
192 void dot(std::ostream& os,
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
196 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
199 void saveGraph(
const std::string& filename,
200 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
210 template<
class CONTAINER>
211 Key findParentClique(
const CONTAINER& parents)
const;
217 void deleteCachedShortcuts();
223 void removePath(sharedClique clique, BayesNetType* bn, Cliques* orphans);
229 void removeTop(
const KeyVector& keys, BayesNetType* bn, Cliques* orphans);
233 Cliques removeSubtree(
const sharedClique& subtree);
238 void insertRoot(
const sharedClique& subtree);
241 void addClique(
const sharedClique& clique,
const sharedClique& parent_clique = sharedClique());
249 void dot(std::ostream &s, sharedClique clique,
const KeyFormatter& keyFormatter,
250 int parentnum = 0)
const;
256 void removeClique(sharedClique clique);
259 void fillNodesIndex(
const sharedClique& subtree);
265 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 267 friend class boost::serialization::access;
268 template<
class ARCHIVE>
269 void serialize(ARCHIVE & ar,
const unsigned int ) {
270 ar & BOOST_SERIALIZATION_NVP(nodes_);
271 ar & BOOST_SERIALIZATION_NVP(roots_);
280 template <
class CLIQUE,
typename =
void>
283 typedef CLIQUE CliqueType;
284 typedef typename CLIQUE::ConditionalType Base;
286 std::shared_ptr<CliqueType> clique;
300 this->keys_.assign(clique->conditional()->beginParents(),
301 clique->conditional()->endParents());
305 const std::string& s =
"",
306 const KeyFormatter& formatter = DefaultKeyFormatter)
const override {
307 clique->print(s +
"stored clique", formatter);
sharedClique sharedNode
Synonym for sharedClique (TODO: remove)
Definition: BayesTree.h:76
A thin wrapper around std::list that uses boost's fast_pool_allocator.
double dot(const V1 &a, const V2 &b)
Definition: Vector.h:195
Nodes nodes_
Definition: BayesTree.h:100
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
const Nodes & nodes() const
Definition: BayesTree.h:146
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
Definition: FastVector.h:34
Definition: BayesTree.h:34
Clique Node
Synonym for Clique (TODO: remove)
Definition: BayesTree.h:75
Definition: BayesTree.h:281
std::shared_ptr< Clique > sharedClique
Shared pointer to a clique.
Definition: BayesTree.h:74
sharedClique operator[](Key j) const
Definition: BayesTree.h:149
Definition: BayesTree.h:66
Definition: Testable.h:112
Definition: BayesTree.h:35
BayesTreeOrphanWrapper(const std::shared_ptr< CliqueType > &clique)
Construct a new Bayes Tree Orphan Wrapper object.
Definition: BayesTree.h:298
CLIQUE Clique
The clique type, normally BayesTreeClique.
Definition: BayesTree.h:73
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
ConcurrentMap< Key, sharedClique > Nodes
Definition: BayesTree.h:92
BayesTree()
Definition: BayesTree.h:109
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
Definition: FastList.h:43
A thin wrapper around std::vector that uses a custom allocator.
Definition: chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
const sharedClique & clique(Key j) const
Definition: BayesTree.h:155
bool empty() const
Definition: BayesTree.h:141
const Roots & roots() const
Definition: BayesTree.h:152
Roots roots_
Definition: BayesTree.h:103
FastList< sharedClique > Cliques
Definition: BayesTree.h:89
FastVector< sharedClique > Roots
Definition: BayesTree.h:95
Definition: BayesTree.h:48
Definition: BayesTree.h:39
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102