25 using namespace gtsam;
27 int main(
int argc,
char** argv) {
34 DiscreteKey Cathy(1, nrStates), Heather(2, nrStates), Mark(3, nrStates),
47 graph.
add(Cathy & Heather,
"2 1 1 2");
48 graph.
add(Heather & Mark,
"2 1 1 2");
49 graph.
add(Mark & Allison,
"2 1 1 2");
52 cout <<
"\nUGM distribution:" << endl;
54 DiscreteValues::CartesianProduct(Cathy & Heather & Mark & Allison);
55 for (
size_t i = 0;
i < allPosbValues.size(); ++
i) {
58 cout <<
values[Cathy.first] <<
" " <<
values[Heather.first] <<
" "
59 <<
values[Mark.first] <<
" " <<
values[Allison.first] <<
" :\t"
60 << prodPot <<
"\t" << prodPot / 3790 << endl;
65 auto optimalDecoding =
graph.optimize();
69 cout <<
"\nComputing Node Marginals .." << endl;
73 print(margProbs,
"Cathy's Node Marginal:");
75 margProbs =
marginals.marginalProbabilities(Heather);
76 print(margProbs,
"Heather's Node Marginal");
78 margProbs =
marginals.marginalProbabilities(Mark);
79 print(margProbs,
"Mark's Node Marginal");
81 margProbs =
marginals.marginalProbabilities(Allison);
82 print(margProbs,
"Allison's Node Marginal");