26 template<
class DERIVED,
class FACTORGRAPH>
30 conditional_ = eliminationResult.first;
34 template<
class DERIVED,
class FACTORGRAPH>
36 const DERIVED&
other,
double tol)
const
38 return (!conditional_ && !
other.conditional())
39 || conditional_->equals(*
other.conditional(),
tol);
43 template<
class DERIVED,
class FACTORGRAPH>
47 KeySet p_F_S_parents(this->conditional()->beginParents(), this->conditional()->endParents());
48 KeySet indicesB(
B->conditional()->begin(),
B->conditional()->end());
50 std::set_difference(p_F_S_parents.begin(), p_F_S_parents.end(),
51 indicesB.begin(), indicesB.end(), back_inserter(S_setminus_B));
56 template<
class DERIVED,
class FACTORGRAPH>
60 gttic(shortcut_indices);
62 KeySet indicesB(
B->conditional()->begin(),
B->conditional()->end());
63 KeyVector S_setminus_B = separator_setminus_B(
B);
66 std::set_intersection(S_setminus_B.begin(), S_setminus_B.end(),
67 allKeys.begin(), allKeys.end(), back_inserter(keep));
69 std::set_intersection(indicesB.begin(), indicesB.end(),
70 allKeys.begin(), allKeys.end(), back_inserter(keep));
75 template<
class DERIVED,
class FACTORGRAPH>
79 conditional_->print(
s, keyFormatter);
83 template<
class DERIVED,
class FACTORGRAPH>
87 size += child->treeSize();
92 template<
class DERIVED,
class FACTORGRAPH>
95 std::lock_guard<std::mutex> marginalLock(cachedSeparatorMarginalMutex_);
96 if (!cachedSeparatorMarginal_)
99 size_t subtree_count = 1;
101 subtree_count += child->numCachedSeparatorMarginals();
103 return subtree_count;
111 template<
class DERIVED,
class FACTORGRAPH>
115 gttic(BayesTreeCliqueBase_shortcut);
118 KeyVector S_setminus_B = separator_setminus_B(
B);
119 if (!parent_.expired() && !S_setminus_B.empty())
123 gttoc(BayesTreeCliqueBase_shortcut);
125 gttic(BayesTreeCliqueBase_shortcut);
132 std::shared_ptr<FactorGraphType> p_S_B = p_Cp_B.
marginal(keep,
function);
133 return *p_S_B->eliminatePartialSequential(S_setminus_B,
function).first;
145 template <
class DERIVED,
class FACTORGRAPH>
149 std::lock_guard<std::mutex> marginalLock(cachedSeparatorMarginalMutex_);
150 gttic(BayesTreeCliqueBase_separatorMarginal);
152 if (!cachedSeparatorMarginal_) {
153 gttic(BayesTreeCliqueBase_separatorMarginal_cachemiss);
156 if (parent_.expired() ) {
159 cachedSeparatorMarginal_ =
empty;
162 gttoc(BayesTreeCliqueBase_separatorMarginal_cachemiss);
163 gttoc(BayesTreeCliqueBase_separatorMarginal);
170 gttic(BayesTreeCliqueBase_separatorMarginal);
171 gttic(BayesTreeCliqueBase_separatorMarginal_cachemiss);
177 KeyVector indicesS(this->conditional()->beginParents(),
178 this->conditional()->endParents());
179 auto separatorMarginal =
181 cachedSeparatorMarginal_ = *separatorMarginal;
186 return *cachedSeparatorMarginal_;
193 template <
class DERIVED,
class FACTORGRAPH>
197 gttic(BayesTreeCliqueBase_marginal2);
201 p_C.
push_back(std::shared_ptr<FactorType>(this->conditional_));
206 template<
class DERIVED,
class FACTORGRAPH>
213 std::lock_guard<std::mutex> marginalLock(cachedSeparatorMarginalMutex_);
214 if (cachedSeparatorMarginal_) {
216 child->deleteCachedShortcuts();
220 cachedSeparatorMarginal_ = {};