29 using namespace gtsam;
34 KeySet actual = simpleTestGraph1.keys();
41 KeySet actual = simpleTestGraph2.keys();
68 const auto [actualBayesNet, actualSfg] =
74 const auto [actualBayesNet2, actualSfg2] =
75 simpleTestGraph2.eliminatePartialSequential(
Ordering{0, 1});
94 SymbolicConditional::shared_ptr root =
95 std::make_shared<SymbolicConditional>(
96 SymbolicConditional::FromKeys(
KeyVector{4, 5, 1}, 2));
98 std::make_shared<SymbolicBayesTreeClique>(root));
100 const auto expectedFactorGraph =
104 const auto [actualBayesTree, actualFactorGraph] =
112 std::make_shared<SymbolicBayesTreeClique>(
113 std::make_shared<SymbolicConditional>(4, 1));
114 root2->children.push_back(std::make_shared<SymbolicBayesTreeClique>(
115 std::make_shared<SymbolicConditional>(5, 4)));
118 const auto [actualBayesTree2, actualFactorGraph2] =
119 simpleTestGraph2.eliminatePartialMultifrontal(
KeyVector{4, 5});
128 *simpleTestGraph2.marginalMultifrontalBayesNet(
Ordering{0, 1, 2, 3});
129 auto expectedBayesNet =
SymbolicBayesNet({0, 1, 2})({1, 2, 3})({2, 3})({3});
135 *simpleTestGraph2.marginalMultifrontalBayesNet(
KeyVector{0, 1, 2, 3});
137 auto expectedBayesNet =
SymbolicBayesNet({0, 1, 2})({2, 1, 3})({1, 3})({3});
142 const Ordering orderedVariables{0, 3},
143 marginalizedVariableOrdering{1, 2, 4, 5};
145 orderedVariables, marginalizedVariableOrdering);
152 const Ordering marginalizedVariableOrdering{2, 4, 5};
154 variables, marginalizedVariableOrdering);
162 auto expectedBayesTree =
163 *simpleTestGraph2.eliminatePartialMultifrontal(
Ordering{4, 5})
164 .second->eliminateMultifrontal(
Ordering{0, 1, 2, 3});
167 *simpleTestGraph2.marginalMultifrontalBayesTree(
Ordering{0, 1, 2, 3});
173 auto expectedBayesTree =
174 *simpleTestGraph2.eliminatePartialMultifrontal(
Ordering{4, 5})
175 .second->eliminateMultifrontal(Ordering::OrderingType::COLAMD);
178 *simpleTestGraph2.marginalMultifrontalBayesTree(
KeyVector{0, 1, 2, 3});
183 const Ordering orderedVariables{0, 3},
184 marginalizedVariableOrdering{1, 2, 4, 5};
185 auto expectedBayesTree =
187 .eliminatePartialMultifrontal(marginalizedVariableOrdering)
188 .second->eliminateMultifrontal(orderedVariables);
191 orderedVariables, marginalizedVariableOrdering);
197 const Ordering marginalizedVariableOrdering{2, 4, 5};
198 auto expectedBayesTree =
200 .eliminatePartialMultifrontal(marginalizedVariableOrdering)
201 .second->eliminateMultifrontal(Ordering::OrderingType::COLAMD);
205 variables, marginalizedVariableOrdering);
225 const Ordering order{0, 1, 2, 3, 4};
Provides additional testing facilities for common data structures.
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
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
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
FactorIndices add_factors(const CONTAINER &factors, bool useEmptySlots=false)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
static enum @1107 ordering
void insertRoot(const sharedClique &subtree)
bool assert_container_equality(const std::map< size_t, V2 > &expected, const std::map< size_t, V2 > &actual)
FastVector< FactorIndex > FactorIndices
Define collection types:
void push_factor(Key key)
#define EXPECT(condition)
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
std::shared_ptr< This > shared_ptr
TEST(SymbolicFactorGraph, keys1)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Marginals marginals(graph, result)