24 #include <boost/optional.hpp> 31 template<
class CLIQUE>
class BayesTree;
47 template<
class DERIVED,
class FACTORGRAPH>
52 typedef DERIVED DerivedType;
54 typedef boost::shared_ptr<This> shared_ptr;
55 typedef boost::weak_ptr<This> weak_ptr;
56 typedef boost::shared_ptr<DerivedType> derived_ptr;
57 typedef boost::weak_ptr<DerivedType> derived_weak_ptr;
60 typedef FACTORGRAPH FactorGraphType;
61 typedef typename EliminationTraitsType::BayesNetType BayesNetType;
62 typedef typename BayesNetType::ConditionalType ConditionalType;
63 typedef boost::shared_ptr<ConditionalType> sharedConditional;
64 typedef typename FactorGraphType::FactorType FactorType;
65 typedef typename FactorGraphType::Eliminate Eliminate;
84 sharedConditional conditional_;
85 derived_weak_ptr parent_;
86 FastVector<derived_ptr> children;
98 bool equals(
const DERIVED& other,
double tol = 1e-9)
const;
101 void print(
const std::string& s =
"",
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
108 const sharedConditional&
conditional()
const {
return conditional_; }
111 inline bool isRoot()
const {
return parent_.expired(); }
120 derived_ptr
parent()
const {
return parent_.lock(); }
130 BayesNetType
shortcut(
const derived_ptr& root, Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
133 FactorGraphType
separatorMarginal(Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
136 FactorGraphType
marginal2(Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
144 const boost::optional<FactorGraphType>& cachedSeparatorMarginal()
const {
147 friend class BayesTree<DerivedType>;
165 friend class boost::serialization::access;
166 template<
class ARCHIVE>
167 void serialize(ARCHIVE & ar,
const unsigned int ) {
168 ar & BOOST_SERIALIZATION_NVP(conditional_);
169 ar & BOOST_SERIALIZATION_NVP(parent_);
170 ar & BOOST_SERIALIZATION_NVP(children);
FactorGraphType marginal2(Eliminate function=EliminationTraitsType::DefaultEliminate) const
return the marginal P(C) of the clique, using marginal caching
Definition: BayesTreeCliqueBase-inst.h:188
BayesTreeCliqueBase(const sharedConditional &conditional)
Construct from a conditional, leaving parent and child pointers uninitialized.
Definition: BayesTreeCliqueBase.h:76
A thin wrapper around std::vector that uses a custom allocator.
int problemSize() const
Problem size (used for parallel traversal)
Definition: BayesTreeCliqueBase.h:123
bool isRoot() const
is this the root of a Bayes tree ?
Definition: BayesTreeCliqueBase.h:111
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
Variable ordering for the elimination algorithm.
This is the base class for BayesTree cliques.
Definition: BayesTreeCliqueBase.h:48
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
BayesTreeCliqueBase()
Default constructor.
Definition: BayesTreeCliqueBase.h:73
derived_ptr parent() const
return a shared_ptr to the parent clique
Definition: BayesTreeCliqueBase.h:120
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:56
size_t numCachedSeparatorMarginals() const
Collect number of cliques with cached separator marginals.
Definition: BayesTreeCliqueBase-inst.h:92
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
void deleteCachedShortcuts()
This deletes the cached shortcuts of all cliques (subtree) below this clique.
Definition: BayesTreeCliqueBase-inst.h:200
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
bool equals(const DERIVED &other, double tol=1e-9) const
check equality
Definition: BayesTreeCliqueBase-inst.h:34
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print this node
Definition: BayesTreeCliqueBase-inst.h:75
void deleteCachedShortcutsNonRecursive()
Non-recursive delete cached shortcuts and marginals - internal only.
Definition: BayesTreeCliqueBase.h:160
KeyVector separator_setminus_B(const derived_ptr &B) const
Calculate set for shortcut calculations.
Definition: BayesTreeCliqueBase-inst.h:44
const sharedConditional & conditional() const
Access the conditional.
Definition: BayesTreeCliqueBase.h:108
KeyVector 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
Traits class for eliminateable factor graphs, specifies the types that result from elimination,...
Definition: BayesTreeCliqueBase.h:32
void setEliminationResult(const typename FactorGraphType::EliminationResult &eliminationResult)
Fill the elimination result produced during elimination.
Definition: BayesTreeCliqueBase-inst.h:26
boost::optional< FactorGraphType > cachedSeparatorMarginal_
This stores the Cached separator margnal P(S)
Definition: BayesTreeCliqueBase.h:81
FactorGraphType separatorMarginal(Eliminate function=EliminationTraitsType::DefaultEliminate) const
return the marginal P(S) on the separator
Definition: BayesTreeCliqueBase-inst.h:145
Typedefs for easier changing of types.
size_t treeSize() const
The size of subtree rooted at this clique, i.e., nr of Cliques.
Definition: BayesTreeCliqueBase-inst.h:83