24 #include <boost/optional.hpp> 32 template<
class CLIQUE>
class BayesTree;
48 template<
class DERIVED,
class FACTORGRAPH>
119 bool equals(
const DERIVED& other,
double tol = 1
e-9)
const;
132 inline bool isRoot()
const {
return parent_.expired(); }
141 derived_ptr
parent()
const {
return parent_.lock(); }
151 BayesNetType
shortcut(
const derived_ptr&
root, Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
154 FactorGraphType
separatorMarginal(Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
157 FactorGraphType
marginal2(Eliminate
function = EliminationTraitsType::DefaultEliminate)
const;
166 std::lock_guard<std::mutex> marginalLock(cachedSeparatorMarginalMutex_);
184 std::lock_guard<std::mutex> marginalLock(cachedSeparatorMarginalMutex_);
185 cachedSeparatorMarginal_ = boost::none;
191 friend class boost::serialization::access;
192 template<
class ARCHIVE>
194 if(!parent_.lock()) {
197 ar & BOOST_SERIALIZATION_NVP(is_root);
198 ar & BOOST_SERIALIZATION_NVP(conditional_);
200 ar & BOOST_SERIALIZATION_NVP(parent_);
202 ar & BOOST_SERIALIZATION_NVP(children);
FACTORGRAPH FactorGraphType
Typedefs for easier changing of types.
std::mutex cachedSeparatorMarginalMutex_
KeyVector shortcut_indices(const derived_ptr &B, const FactorGraphType &p_Cp_B) const
FactorGraphType::Eliminate Eliminate
void deleteCachedShortcutsNonRecursive()
BayesTreeCliqueBase(const BayesTreeCliqueBase &c)
size_t numCachedSeparatorMarginals() const
EliminationTraitsType::BayesNetType BayesNetType
BayesNetType shortcut(const derived_ptr &root, Eliminate function=EliminationTraitsType::DefaultEliminate) const
const boost::optional< FactorGraphType > & cachedSeparatorMarginal() const
BayesTreeCliqueBase(const sharedConditional &conditional)
const mpreal root(const mpreal &x, unsigned long int k, mp_rnd_t r=mpreal::get_default_rnd())
boost::shared_ptr< ConditionalType > sharedConditional
static const KeyFormatter DefaultKeyFormatter
boost::shared_ptr< This > shared_ptr
void setEliminationResult(const typename FactorGraphType::EliminationResult &eliminationResult)
boost::optional< FactorGraphType > cachedSeparatorMarginal_
This stores the Cached separator marginal P(S)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
FactorGraphType marginal2(Eliminate function=EliminationTraitsType::DefaultEliminate) const
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
derived_ptr parent() const
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
void serialize(ARCHIVE &ar, const unsigned int)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
boost::weak_ptr< DerivedType > derived_weak_ptr
FastVector< derived_ptr > children
EliminationTraits< FACTORGRAPH > EliminationTraitsType
boost::shared_ptr< DerivedType > derived_ptr
A thin wrapper around std::vector that uses a custom allocator.
void deleteCachedShortcuts()
bool equals(const DERIVED &other, double tol=1e-9) const
sharedConditional conditional_
KeyVector separator_setminus_B(const derived_ptr &B) const
Calculate set for shortcut calculations.
FactorGraphType separatorMarginal(Eliminate function=EliminationTraitsType::DefaultEliminate) const
boost::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
The function type that does a single dense elimination step on a subgraph.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
BayesTreeCliqueBase & operator=(const BayesTreeCliqueBase &c)
BayesTreeCliqueBase< DERIVED, FACTORGRAPH > This
std::pair< boost::shared_ptr< ConditionalType >, boost::shared_ptr< _FactorType > > EliminationResult
boost::weak_ptr< This > weak_ptr
const sharedConditional & conditional() const
BayesNetType::ConditionalType ConditionalType
FactorGraphType::FactorType FactorType