From 6f19ffd96673edfac3f5faa227de6c8e0d225230 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 1 Jan 2025 15:10:53 -0500 Subject: [PATCH] fixed maxProduct --- gtsam/hybrid/HybridBayesNet.cpp | 3 +-- gtsam/hybrid/tests/testHybridGaussianFactorGraph.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gtsam/hybrid/HybridBayesNet.cpp b/gtsam/hybrid/HybridBayesNet.cpp index 66e4011dc..aa2e0fc24 100644 --- a/gtsam/hybrid/HybridBayesNet.cpp +++ b/gtsam/hybrid/HybridBayesNet.cpp @@ -131,6 +131,7 @@ DiscreteValues HybridBayesNet::discreteMaxProduct( for (TableFactor::SparseIt it(sparseTable); it; ++it) { if (it.value() > maxValue) { maxIdx = it.index(); + maxValue = it.value(); } } @@ -210,8 +211,6 @@ AlgebraicDecisionTree HybridBayesNet::errorTree( // Iterate over each conditional. for (auto &&conditional : *this) { - conditional->print(); - conditional->errorTree(continuousValues).print("errorTre", DefaultKeyFormatter); result = result + conditional->errorTree(continuousValues); } diff --git a/gtsam/hybrid/tests/testHybridGaussianFactorGraph.cpp b/gtsam/hybrid/tests/testHybridGaussianFactorGraph.cpp index 1942e9234..32a425474 100644 --- a/gtsam/hybrid/tests/testHybridGaussianFactorGraph.cpp +++ b/gtsam/hybrid/tests/testHybridGaussianFactorGraph.cpp @@ -650,7 +650,7 @@ TEST(HybridGaussianFactorGraph, EliminateTiny1) { mode, std::vector{conditional0, conditional1}); // Add prior on mode. - expectedBayesNet.emplace_shared(mode, "74/26"); + expectedBayesNet.emplace_shared(mode, "74/26"); // Test elimination const auto posterior = fg.eliminateSequential(); @@ -700,11 +700,12 @@ TEST(HybridGaussianFactorGraph, EliminateTiny1Swapped) { m1, std::vector{conditional0, conditional1}); // Add prior on m1. - expectedBayesNet.emplace_shared(m1, "1/1"); + expectedBayesNet.emplace_shared( + m1, "0.188638/0.811362"); // Test elimination const auto posterior = fg.eliminateSequential(); - // EXPECT(assert_equal(expectedBayesNet, *posterior, 0.01)); + EXPECT(assert_equal(expectedBayesNet, *posterior, 0.01)); EXPECT(ratioTest(bn, measurements, *posterior)); @@ -736,7 +737,7 @@ TEST(HybridGaussianFactorGraph, EliminateTiny2) { mode, std::vector{conditional0, conditional1}); // Add prior on mode. - expectedBayesNet.emplace_shared(mode, "23/77"); + expectedBayesNet.emplace_shared(mode, "23/77"); // Test elimination const auto posterior = fg.eliminateSequential();