28 #include <type_traits> 31 using namespace gtsam;
86 NodeClique(Keys(
X(2))(
X(3)), 2,
90 Keys(
X(5))(
L(2))(
X(4)), 2,
91 Children(LeafClique(Keys(
L(3))(
X(4))(
X(5)), 1))))))(
92 LeafClique(Keys(
X(1))(
L(1))(
X(2)), 2))));
113 auto left = NodeClique(Keys(
_C_)(_A_), 1, {LeafClique(Keys(_D_)(
_C_), 1)});
114 auto right = NodeClique(Keys(_E_)(
_B_), 1, {LeafClique(Keys(_F_)(_E_), 1)});
124 SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_D_], bayesTree[_E_]};
127 SymbolicBayesTree::Cliques orphans;
128 bayesTree.removePath(bayesTree[_C_], &bn, &orphans);
133 bayesTree = bayesTreeOrig;
139 SymbolicBayesTree::Cliques expectedOrphans2{bayesTree[_F_], bayesTree[
_C_]};
142 SymbolicBayesTree::Cliques orphans2;
143 bayesTree.removePath(bayesTree[_E_], &bn2, &orphans2);
155 SymbolicBayesTree::Cliques orphans;
163 SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_T_],
174 SymbolicBayesTree::Cliques orphans;
175 bayesTree.
removePath(bayesTree[_T_], &bn, &orphans);
183 SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_X_]};
188 SymbolicBayesTree::Cliques& cliques) {
191 cliques.push_back(subtree);
193 for (SymbolicBayesTree::sharedClique& childClique : subtree->children) {
201 const Key _A_ = 6,
_B_ = 5,
_C_ = 4, _D_ = 3, _E_ = 2, _F_ = 1, _G_ = 0;
214 SymbolicBayesTree::sharedClique rootClique = bayesTree.
roots().front();
216 SymbolicBayesTree::Cliques allCliques;
219 for (SymbolicBayesTree::sharedClique& clique : allCliques) {
227 rootClique->deleteCachedShortcuts();
228 for (SymbolicBayesTree::sharedClique& clique : allCliques) {
229 bool notCleared = clique->cachedSeparatorMarginal().has_value();
230 CHECK(notCleared ==
false);
255 SymbolicBayesTree::Cliques orphans;
260 expected.
add(SymbolicConditional::FromKeys<KeyVector>(Keys(_E_)(
_L_)(
_B_), 3));
261 expected.
add(SymbolicConditional::FromKeys<KeyVector>(Keys(_S_)(
_B_)(
_L_), 1));
264 SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_T_], bayesTree[_X_]};
270 SymbolicBayesTree::Cliques orphans2;
271 bayesTree.removeTop(Keys(
_B_), &bn2, &orphans2);
275 SymbolicBayesTree::Cliques expectedOrphans2;
290 SymbolicBayesTree::Cliques orphans;
291 bayesTree.
removeTop(Keys(_T_), &bn, &orphans);
295 SymbolicConditional::FromKeys<KeyVector>(Keys(_E_)(
_L_)(
_B_), 3))(
296 SymbolicConditional::FromKeys<KeyVector>(Keys(_T_)(_E_)(
_L_), 1));
299 SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_X_]};
312 SymbolicBayesTree::Cliques orphans;
313 bayesTree.
removeTop(Keys(
L(5))(
X(4))(
X(2))(
X(3)), &bn, &orphans);
316 SymbolicConditional::FromKeys<KeyVector>(Keys(
X(4))(
L(5)), 2))(
331 SymbolicBayesTree::Cliques orphans;
332 bayesTree.
removeTop(Keys(
X(2))(
L(5))(
X(4))(
X(3)), &bn, &orphans);
335 SymbolicConditional::FromKeys<KeyVector>(Keys(
X(4))(
L(5)), 2))(
351 SymbolicBayesTree::Cliques orphans;
352 bayesTree.
removeTop(Keys(
X(10)), &bn, &orphans);
385 bayesNet.
saveGraph(
"/tmp/symbolicBayesNet.dot");
393 bayesTree.
saveGraph(
"/tmp/SymbolicBayesTree.dot");
483 sharedClique root1 = LeafClique(Keys(1), 1);
484 sharedClique root2 = LeafClique(Keys(2), 1);
524 bayesNet.saveGraph(
"/tmp/symbolicBayesNet.dot");
531 bayesTree.
saveGraph(
"/tmp/SymbolicBayesTree.dot");
569 sharedClique root = LeafClique(Keys(11)(12), 2);
572 root->children.push_back(LeafClique(Keys(9)(10)(11)(12), 2));
573 root->children.back()->parent_ = root;
575 root->children.push_back(LeafClique(Keys(7)(8)(11), 2));
576 root->children.back()->parent_ = root;
577 cur = root->children.back();
579 cur->children.push_back(LeafClique(Keys(5)(6)(7)(8), 2));
580 cur->children.back()->parent_ = cur;
581 cur = cur->children.back();
583 cur->children.push_back(LeafClique(Keys(3)(4)(6), 2));
584 cur->children.back()->parent_ = cur;
586 cur->children.push_back(LeafClique(Keys(1)(2)(5), 2));
587 cur->children.back()->parent_ = cur;
594 bt.
saveGraph(
"/tmp/SymbolicBayesTree.dot");
677 NodeClique(Keys(5)(1)(4), 1,
679 LeafClique(Keys(0)(1)(5), 1))))))));
685 #ifdef GTSAM_SUPPORT_NESTED_DISSECTION 690 #if defined(__APPLE__) 692 #elif defined(_WIN32) 703 #if defined(__APPLE__) 705 NodeClique(Keys(1)(0)(3), 3,
707 NodeClique(Keys(4)(0)(3), 1,
708 {LeafClique(Keys(5)(0)(4), 1)}))(
709 LeafClique(Keys(2)(1)(3), 1))));
710 #elif defined(_WIN32) 712 NodeClique(Keys(3)(5)(2), 3,
714 NodeClique(Keys(4)(3)(5), 1,
715 {LeafClique(Keys(0)(2)(5), 1)}))(
716 LeafClique(Keys(1)(0)(2), 1))));
719 NodeClique(Keys(2)(4)(1), 3,
721 NodeClique(Keys(0)(1)(4), 1,
722 {LeafClique(Keys(5)(0)(4), 1)}))(
723 LeafClique(Keys(3)(2)(4), 1))));
void removePath(sharedClique clique, BayesNetType *bn, Cliques *orphans)
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Provides additional testing facilities for common data structures.
void removeTop(const KeyVector &keys, BayesNetType *bn, Cliques *orphans)
std::decay_t< decltype(**declval< T >().begin())> PointedToType
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
static int runAllTests(TestResult &result)
std::shared_ptr< This > shared_ptr
ValuesVector< T > deref(const T &v)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Rot2 R(Rot2::fromAngle(0.1))
const GaussianFactorGraph factors
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
NonlinearFactorGraph graph
static enum @1107 ordering
void insertRoot(const sharedClique &subtree)
IsDerived< DERIVEDFACTOR > add(std::shared_ptr< DERIVEDFACTOR > factor)
add is a synonym for push_back.
void push_factor(Key key)
std::vector< PointedToType< T > > ValuesVector
void saveGraph(const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
output to file with graphviz format.
#define EXPECT(condition)
Array< int, Dynamic, 1 > v
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
bool assert_container_equal(const std::map< V1, V2 > &expected, const std::map< V1, V2 > &actual, double tol=1e-9)
Matrix< Scalar, Dynamic, Dynamic > C
#define EXPECT_LONGS_EQUAL(expected, actual)
void getAllCliques(const SymbolicBayesTree::sharedClique &subtree, SymbolicBayesTree::Cliques &cliques)
void saveGraph(const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
output to file with graphviz format.
std::shared_ptr< This > shared_ptr
const Roots & roots() const
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
std::shared_ptr< This > shared_ptr
TEST(SymbolicBayesTree, clear)
sharedBayesNet jointBayesNet(Key j1, Key j2, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const
sharedConditional marginalFactor(Key j, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const
std::uint64_t Key
Integer nonlinear key type.