25 using namespace gtsam;
27 int main(
int argc,
char** argv) {
34 DiscreteKey Cathy(1, nrStates), Heather(2, nrStates), Mark(3, nrStates),
41 graph.
add(Cathy,
"1 3");
42 graph.
add(Heather,
"9 1");
43 graph.
add(Mark,
"1 3");
44 graph.
add(Allison,
"9 1");
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 Cathy & Heather & Mark & Allison);
55 for (
size_t i = 0;
i < allPosbValues.size(); ++
i) {
57 double prodPot =
graph(values);
58 cout << values[Cathy.first] <<
" " << values[Heather.first] <<
" " 59 << values[Mark.first] <<
" " << values[Allison.first] <<
" :\t" 60 << prodPot <<
"\t" << prodPot / 3790 << endl;
67 optimalDecoding->print(
"\noptimalDecoding");
70 cout <<
"\nComputing Node Marginals .." << endl;
74 print(margProbs,
"Cathy's Node Marginal:");
77 print(margProbs,
"Heather's Node Marginal");
80 print(margProbs,
"Mark's Node Marginal");
83 print(margProbs,
"Allison's Node Marginal");
void print(const Matrix &A, const string &s, ostream &stream)
std::vector< Assignment< L > > cartesianProduct(const std::vector< std::pair< L, size_t > > &keys)
Get Cartesian product consisting all possible configurations.
void add(const DiscreteKey &j, SOURCE table)
Vector marginalProbabilities(const DiscreteKey &key) const
NonlinearFactorGraph graph
int main(int argc, char **argv)
std::pair< Key, size_t > DiscreteKey
A class for computing marginals in a DiscreteFactorGraph.
typedef and functions to augment Eigen's VectorXd
boost::shared_ptr< Values > sharedValues
boost::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
boost::shared_ptr< This > shared_ptr
Marginals marginals(graph, result)