33 using namespace gtsam;
61 return {std::make_shared<JacobianFactor>(
key, I_3x3,
Z_3x1),
62 std::make_shared<JacobianFactor>(
key, I_3x3, Vector3::Ones())};
68 HybridGaussianFactorGraphEliminateFullMultifrontalSimple) {
128 Ordering::ColamdConstrainedLast(hfg, {
M(0),
M(1),
M(2),
M(3)});
180 std::vector<int> naturalX(
N);
181 std::iota(naturalX.begin(), naturalX.end(), 1);
182 std::vector<Key> ordX;
183 std::transform(naturalX.begin(), naturalX.end(), std::back_inserter(ordX),
184 [](
int x) { return X(x); });
187 std::copy(ndX.begin(), ndX.end(), std::back_inserter(
ordering));
190 std::vector<int> naturalC(
N - 1);
191 std::iota(naturalC.begin(), naturalC.end(), 1);
192 std::vector<Key> ordC;
193 std::transform(naturalC.begin(), naturalC.end(), std::back_inserter(ordC),
194 [](
int x) { return M(x); });
197 std::copy(ndC.begin(), ndC.end(), std::back_inserter(
ordering));
200 const auto [hbt, remaining] = hfg->eliminatePartialMultifrontal(
ordering);
227 std::vector<int> naturalX(
N);
228 std::iota(naturalX.begin(), naturalX.end(), 1);
229 std::vector<Key> ordX;
230 std::transform(naturalX.begin(), naturalX.end(), std::back_inserter(ordX),
231 [](
int x) { return X(x); });
234 std::copy(ndX.begin(), ndX.end(), std::back_inserter(
ordering));
237 std::vector<int> naturalC(
N - 1);
238 std::iota(naturalC.begin(), naturalC.end(), 1);
239 std::vector<Key> ordC;
240 std::transform(naturalC.begin(), naturalC.end(), std::back_inserter(ordC),
241 [](
int x) { return M(x); });
245 std::copy(ndC.begin(), ndC.end(), std::back_inserter(
ordering));
248 const auto [hbt, remaining] = hfg->eliminatePartialMultifrontal(
ordering);
255 factorGraph.
push_back(new_fg->at(new_fg->size() - 2));
256 factorGraph.
push_back(new_fg->at(new_fg->size() - 1));
269 for (
int t = 1;
t <=
N;
t++) {
276 std::iota(naturalX.begin(), naturalX.end(), 1);
278 for (
size_t i = 1;
i <=
N;
i++) {
279 ordX.emplace_back(
X(
i));
280 ordX.emplace_back(
Y(
i));
283 for (
size_t i = 1;
i <=
N - 1;
i++) {
284 ordX.emplace_back(
M(
i));
286 for (
size_t i = 1;
i <=
N - 1;
i++) {
287 ordX.emplace_back(
D(
i));
313 for (
size_t i = 1;
i <=
N;
i++) {
314 ordering_partial.emplace_back(
X(
i));
315 ordering_partial.emplace_back(
Y(
i));
317 const auto [hbn, remaining] =
318 hfg->eliminatePartialSequential(ordering_partial);
340 s.linearizedFactorGraph().eliminateMultifrontal();
344 expectedValues.
insert(
X(0), -0.999904 * Vector1::Ones());
345 expectedValues.
insert(
X(1), -0.99029 * Vector1::Ones());
346 expectedValues.
insert(
X(2), -1.00971 * Vector1::Ones());
347 expectedValues.
insert(
X(3), -1.0001 * Vector1::Ones());
357 for (
size_t i = 0;
i <
N - 1;
i++) {
360 for (
size_t i = 0;
i <
N;
i++) {
363 for (
size_t i = 0;
i <
N - 1;
i++) {
390 assignment[
M(0)] = 1;
391 assignment[
M(1)] = 1;
392 assignment[
M(2)] = 1;
400 expected_delta.
insert(make_pair(
X(0), -Vector1::Ones()));
401 expected_delta.
insert(make_pair(
X(1), -Vector1::Ones()));
402 expected_delta.
insert(make_pair(
X(2), -Vector1::Ones()));
403 expected_delta.
insert(make_pair(
X(3), -Vector1::Ones()));
410 for (
size_t k = 0; k <
s.K; k++)
ordering.push_back(
X(k));
412 const auto [hybridBayesNet, remainingFactorGraph] =
413 s.linearizedFactorGraph().eliminatePartialSequential(
ordering);
443 for (
size_t k = 0; k <
s.K; k++)
ordering.push_back(
X(k));
445 const auto [hybridBayesNet, remainingFactorGraph] =
446 s.linearizedFactorGraph().eliminatePartialSequential(
ordering);
452 vector<double> probs = {0.012519475, 0.041280228, 0.075018647, 0.081663656,
453 0.037152205, 0.12248971, 0.07349729, 0.08};
457 VectorValues expectedValues = hybridBayesNet->optimize(expectedMPE);
482 assignment[
M(0)] = 1;
483 assignment[
M(1)] = 1;
484 assignment[
M(2)] = 1;
491 auto bayesTree =
s.linearizedFactorGraph().eliminateMultifrontal(
ordering);
493 auto expected_gbt = bayesTree->choose(assignment);