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