Build etree and jtree

release/4.3a0
Frank Dellaert 2025-01-27 14:01:31 -05:00
parent d8ed60aead
commit 9800e110aa
1 changed files with 18 additions and 0 deletions

View File

@ -18,6 +18,8 @@
#include <CppUnitLite/TestHarness.h>
#include <gtsam/base/Testable.h>
#include <gtsam/discrete/DiscreteEliminationTree.h>
#include <gtsam/discrete/DiscreteJunctionTree.h>
#include <gtsam/discrete/DiscreteSearch.h>
#include "AsiaExample.h"
@ -28,13 +30,29 @@ using namespace gtsam;
namespace asia {
using namespace asia_example;
static const DiscreteBayesNet bayesNet = createAsiaExample();
// Create factor graph and optimize with max-product for MPE
static const DiscreteFactorGraph factorGraph(bayesNet);
static const DiscreteValues mpe = factorGraph.optimize();
// Create junction tree
static const Ordering ordering{D, X, B, E, L, T, S, A};
static const DiscreteEliminationTree etree(factorGraph, ordering);
static const DiscreteJunctionTree junctionTree(etree);
// Create Bayes tree
static const DiscreteBayesTree bayesTree =
*factorGraph.eliminateMultifrontal(ordering);
} // namespace asia
/* ************************************************************************* */
TEST(DiscreteBayesNet, AsiaFactorGraphKBest) {
GTSAM_PRINT(asia::etree);
GTSAM_PRINT(asia::junctionTree);
DiscreteSearch search(asia::factorGraph);
}
/* ************************************************************************* */
TEST(DiscreteBayesNet, EmptyKBest) {
DiscreteBayesNet net; // no factors