20 #include <boost/optional.hpp> 27 template<
class CLIQUE>
class BayesTree;
43 template<
class DERIVED,
class FACTORGRAPH>
48 typedef DERIVED DerivedType;
50 typedef boost::shared_ptr<This> shared_ptr;
51 typedef boost::weak_ptr<This> weak_ptr;
52 typedef boost::shared_ptr<DerivedType> derived_ptr;
53 typedef boost::weak_ptr<DerivedType> derived_weak_ptr;
56 typedef FACTORGRAPH FactorGraphType;
57 typedef typename EliminationTraitsType::BayesNetType BayesNetType;
58 typedef typename BayesNetType::ConditionalType ConditionalType;
59 typedef boost::shared_ptr<ConditionalType> sharedConditional;
60 typedef typename FactorGraphType::FactorType FactorType;
61 typedef typename FactorGraphType::Eliminate Eliminate;
80 sharedConditional conditional_;
81 derived_weak_ptr parent_;
94 bool equals(
const DERIVED& other,
double tol = 1e-9)
const;
97 void print(
const std::string& s =
"",
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
104 const sharedConditional&
conditional()
const {
return conditional_; }
107 inline bool isRoot()
const {
return parent_.expired(); }
116 derived_ptr
parent()
const {
return parent_.lock(); }
126 BayesNetType
shortcut(
const derived_ptr& root, Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
129 FactorGraphType
separatorMarginal(Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
132 FactorGraphType
marginal2(Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
140 const boost::optional<FactorGraphType>& cachedSeparatorMarginal()
const {
161 friend class boost::serialization::access;
162 template<
class ARCHIVE>
163 void serialize(ARCHIVE & ar,
const unsigned int ) {
164 ar & BOOST_SERIALIZATION_NVP(conditional_);
165 ar & BOOST_SERIALIZATION_NVP(parent_);
166 ar & BOOST_SERIALIZATION_NVP(children);
void deleteCachedShortcuts()
This deletes the cached shortcuts of all cliques (subtree) below this clique.
Definition: BayesTreeCliqueBase-inst.h:200
FastVector< Key > shortcut_indices(const derived_ptr &B, const FactorGraphType &p_Cp_B) const
Determine variable indices to keep in recursive separator shortcut calculation The factor graph p_Cp_...
Definition: BayesTreeCliqueBase-inst.h:56
FactorGraphType separatorMarginal(Eliminate function=EliminationTraitsType::DefaultEliminate) const
return the marginal P(S) on the separator
Definition: BayesTreeCliqueBase-inst.h:145
std::pair< boost::shared_ptr< ConditionalType >, boost::shared_ptr< _FactorType > > EliminationResult
The pair of conditional and remaining factor produced by a single dense elimination step on a subgrap...
Definition: EliminateableFactorGraph.h:86
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print this node
Definition: BayesTreeCliqueBase-inst.h:75
size_t treeSize() const
The size of subtree rooted at this clique, i.e., nr of Cliques.
Definition: BayesTreeCliqueBase-inst.h:83
BayesNetType shortcut(const derived_ptr &root, Eliminate function=EliminationTraitsType::DefaultEliminate) const
return the conditional P(S|Root) on the separator given the root
Definition: BayesTreeCliqueBase-inst.h:111
Typedefs for easier changing of types.
BayesTreeCliqueBase()
Default constructor.
Definition: BayesTreeCliqueBase.h:69
Definition: BayesTree.h:64
Traits class for eliminateable factor graphs, specifies the types that result from elimination...
Definition: BayesTreeCliqueBase.h:28
const sharedConditional & conditional() const
Access the conditional.
Definition: BayesTreeCliqueBase.h:104
size_t numCachedSeparatorMarginals() const
Collect number of cliques with cached separator marginals.
Definition: BayesTreeCliqueBase-inst.h:92
derived_ptr parent() const
return a shared_ptr to the parent clique
Definition: BayesTreeCliqueBase.h:116
boost::optional< FactorGraphType > cachedSeparatorMarginal_
This stores the Cached separator margnal P(S)
Definition: BayesTreeCliqueBase.h:77
BayesTreeCliqueBase(const sharedConditional &conditional)
Construct from a conditional, leaving parent and child pointers uninitialized.
Definition: BayesTreeCliqueBase.h:72
bool equals(const DERIVED &other, double tol=1e-9) const
check equality
Definition: BayesTreeCliqueBase-inst.h:34
void setEliminationResult(const typename FactorGraphType::EliminationResult &eliminationResult)
Fill the elimination result produced during elimination.
Definition: BayesTreeCliqueBase-inst.h:26
void deleteCachedShortcutsNonRecursive()
Non-recursive delete cached shortcuts and marginals - internal only.
Definition: BayesTreeCliqueBase.h:156
A thin wrapper around std::vector that uses boost's pool_allocator.
int problemSize() const
Problem size (used for parallel traversal)
Definition: BayesTreeCliqueBase.h:119
FastVector< Key > separator_setminus_B(const derived_ptr &B) const
Calculate set for shortcut calculations.
Definition: BayesTreeCliqueBase-inst.h:44
This is the base class for BayesTree cliques.
Definition: BayesTreeCliqueBase.h:44
bool isRoot() const
is this the root of a Bayes tree ?
Definition: BayesTreeCliqueBase.h:107
FactorGraphType marginal2(Eliminate function=EliminationTraitsType::DefaultEliminate) const
return the marginal P(C) of the clique, using marginal caching
Definition: BayesTreeCliqueBase-inst.h:188
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33