Go to the documentation of this file.
29 using namespace gtsam;
31 int main(
int argc,
char** argv) {
33 const int nrNodes = 60;
38 const size_t nrStates = 7;
41 vector<DiscreteKey>
nodes;
42 for (
int i = 0;
i < nrNodes;
i++) {
54 const std::string edgePotential =
55 ".08 .9 .01 0 0 0 .01 "
56 ".03 .95 .01 0 0 0 .01 "
57 ".06 .06 .75 .05 .05 .02 .01 "
58 "0 0 0 .3 .6 .09 .01 "
59 "0 0 0 .02 .95 .02 .01 "
60 "0 0 0 .01 .01 .97 .01 "
64 for (
int i = 0;
i < nrNodes - 1;
i++)
67 cout <<
"Created Factor Graph with " << nrNodes <<
" variable nodes and "
68 <<
graph.
size() <<
" factors (Unary+Edge).";
72 auto optimalDecoding =
graph.optimize();
73 optimalDecoding.
print(
"\nMost Probable Explanation (optimalDecoding)\n");
80 cout <<
"\nComputing Node Marginals ..(BayesTree based)" << endl;
82 for (vector<DiscreteKey>::iterator it =
nodes.begin(); it !=
nodes.end();
88 cout <<
"Node#" << setw(4) << it->first <<
" : ";
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
A class for computing marginals in a DiscreteFactorGraph.
std::pair< Key, size_t > DiscreteKey
int main(int argc, char **argv)
IsDerived< DERIVEDFACTOR > add(std::shared_ptr< DERIVEDFACTOR > factor)
add is a synonym for push_back.
NonlinearFactorGraph graph
Marginals marginals(graph, result)
void print(const std::string &str="NonlinearFactorGraph: ", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:43:02