38 using namespace gtsam;
127 auto discreteConditional_m0 = bayesTree[
M(0)]->conditional()->asDiscrete();
149 const auto [expectedHybridBayesTree, expectedRemainingGraph] =
151 .BaseEliminateable::eliminatePartialMultifrontal(
ordering);
154 auto x0_conditional = dynamic_pointer_cast<HybridGaussianConditional>(
155 bayesTree[
X(0)]->conditional()->inner());
156 auto expected_x0_conditional =
157 dynamic_pointer_cast<HybridGaussianConditional>(
158 (*expectedHybridBayesTree)[
X(0)]->conditional()->inner());
162 auto x1_conditional = dynamic_pointer_cast<HybridGaussianConditional>(
163 bayesTree[
X(1)]->conditional()->inner());
164 auto expected_x1_conditional =
165 dynamic_pointer_cast<HybridGaussianConditional>(
166 (*expectedHybridBayesTree)[
X(1)]->conditional()->inner());
170 auto x2_conditional = dynamic_pointer_cast<HybridGaussianConditional>(
171 bayesTree[
X(2)]->conditional()->inner());
172 auto expected_x2_conditional =
173 dynamic_pointer_cast<HybridGaussianConditional>(
174 (*expectedHybridBayesTree)[
X(2)]->conditional()->inner());
181 expectedRemainingGraph->eliminateMultifrontal(discreteOrdering);
184 auto discrete = bayesTree[
M(1)]->conditional()->asDiscrete();
192 auto expectedConditional = (*discreteBayesTree)[
M(1)]->conditional();
193 auto actualConditional = bayesTree[
M(1)]->conditional();
206 for (
size_t i = 0;
i < 3;
i++) {
212 for (
size_t i = 0;
i < 4;
i++) {
219 for (
size_t j = 0;
j < 4;
j++) {
224 const auto [unPrunedHybridBayesTree, unPrunedRemainingGraph] =
226 .BaseEliminateable::eliminatePartialMultifrontal(
ordering);
228 size_t maxNrLeaves = 5;
232 bayesTree.
prune(maxNrLeaves);
268 auto discreteConditional_m0 = *dynamic_pointer_cast<DiscreteConditional>(
269 bayesTree[
M(0)]->conditional()->inner());
273 auto count = [](
const double &
value,
int count) {
274 return value > 0 ? count + 1 : count;
281 auto &unPrunedLastDensity = *dynamic_pointer_cast<HybridGaussianConditional>(
282 unPrunedHybridBayesTree->clique(
X(3))->conditional()->inner());
283 auto &lastDensity = *dynamic_pointer_cast<HybridGaussianConditional>(
284 bayesTree[
X(3)]->conditional()->inner());
286 std::vector<std::pair<DiscreteValues, double>> assignments =
287 discreteConditional_m0.enumerate();
289 for (
auto &&av : assignments) {
291 const double value = av.second;
294 EXPECT(lastDensity(assignment) ==
nullptr);
296 CHECK(lastDensity(assignment));
298 *lastDensity(assignment)));
313 for (
size_t i = 0;
i < 3;
i++) {
319 for (
size_t i = 0;
i < 4;
i++) {
327 size_t maxComponents = 5;
329 incrementalHybrid.
prune(maxComponents);
336 2, bayesTree[
X(0)]->conditional()->asHybrid()->nrComponents());
338 3, bayesTree[
X(1)]->conditional()->asHybrid()->nrComponents());
340 5, bayesTree[
X(2)]->conditional()->asHybrid()->nrComponents());
342 5, bayesTree[
X(3)]->conditional()->asHybrid()->nrComponents());
353 incrementalHybrid.
prune(maxComponents);
354 bayesTree = incrementalHybrid.
bayesTree();
360 5, bayesTree[
X(3)]->conditional()->asHybrid()->nrComponents());
362 5, bayesTree[
X(4)]->conditional()->asHybrid()->nrComponents());
379 auto priorNoise = noiseModel::Diagonal::Sigmas(
384 auto poseNoise = noiseModel::Isotropic::Sigma(3, 0.1);
411 auto noise_model = noiseModel::Isotropic::Sigma(3, 1.0);
412 auto still = std::make_shared<PlanarMotionModel>(
W(0),
W(1),
Pose2(0, 0, 0),
414 moving = std::make_shared<PlanarMotionModel>(
W(0),
W(1),
odometry,
416 std::vector<NoiseModelFactor::shared_ptr>
components{moving, still};
449 still = std::make_shared<PlanarMotionModel>(
W(1),
W(2),
Pose2(0, 0, 0),
489 still = std::make_shared<PlanarMotionModel>(
W(2),
W(3),
Pose2(0, 0, 0),
523 auto discreteTree = bayesTree[
M(3)]->conditional()->asDiscrete();
532 expected_assignment[
M(1)] = 1;
533 expected_assignment[
M(2)] = 1;
534 expected_assignment[
M(3)] = 1;
540 auto lastConditional = bayesTree[
X(3)]->conditional()->asHybrid();