25 using namespace gtsam;
30 DiscreteKey Cathy(1, nrStates), Heather(2, nrStates), Mark(3, nrStates),
41 graph.
add(Cathy & Heather,
"2 1 1 2");
42 graph.
add(Heather & Mark,
"2 1 1 2");
43 graph.
add(Mark & Allison,
"2 1 1 2");
55 actualCvector =
marginals.marginalProbabilities(Mark);
62 const int nrNodes = 10;
63 const size_t nrStates = 7;
66 vector<DiscreteKey>
key;
67 for (
int i = 0;
i < nrNodes;
i++) {
77 for (
int i = 1;
i < nrNodes;
i++)
80 const std::string edgePotential =
".08 .9 .01 0 0 0 .01 "
81 ".03 .95 .01 0 0 0 .01 "
82 ".06 .06 .75 .05 .05 .02 .01 "
83 "0 0 0 .3 .6 .09 .01 "
84 "0 0 0 .02 .95 .02 .01 "
85 "0 0 0 .01 .01 .97 .01 "
89 for (
int i = 0;
i < nrNodes - 1;
i++)
103 const int nrNodes = 5;
104 const size_t nrStates = 2;
107 vector<DiscreteKey>
key;
108 for (
int i = 0;
i < nrNodes;
i++) {
110 key.push_back(key_i);
122 Clique expected0(std::make_shared<DiscreteConditional>((
key[0] |
key[2],
key[4]) =
"2/1 2/1 2/1 2/1"));
123 Clique::shared_ptr actual0 = (*bayesTree)[0];
126 Clique expected1(std::make_shared<DiscreteConditional>((
key[1] |
key[3],
key[4]) =
"1/2 1/2 1/2 1/2"));
127 Clique::shared_ptr actual1 = (*bayesTree)[1];
136 EXPECT(
assert_equal(expectedM0, *std::dynamic_pointer_cast<DecisionTreeFactor>(actualM0),1
e-5));
141 EXPECT(
assert_equal(expectedM1, *std::dynamic_pointer_cast<DecisionTreeFactor>(actualM1),1
e-5));
147 const int nrNodes = 5;
148 const size_t nrStates = 2;
151 vector<DiscreteKey>
key;
152 for (
int i = 0;
i < nrNodes;
i++) {
154 key.push_back(key_i);
164 auto allPosbValues = DiscreteValues::CartesianProduct(
167 for (
size_t i = 0;
i < allPosbValues.size(); ++
i) {
170 for (
size_t j = 0;
j < 5;
j++)
180 for (
size_t j = 0;
j < 5;
j++) {
181 double sum =
T[
j] +
F[
j];
190 expectedM, *std::dynamic_pointer_cast<DecisionTreeFactor>(actualM)));