gtsam 4.2.0
gtsam
Loading...
Searching...
No Matches
BayesNet.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3* GTSAM Copyright 2010, Georgia Tech Research Corporation,
4* Atlanta, Georgia 30332-0415
5* All Rights Reserved
6* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8* See LICENSE for the license information
9
10* -------------------------------------------------------------------------- */
11
19#pragma once
20
22
23#include <boost/shared_ptr.hpp>
24#include <string>
25
26namespace gtsam {
27
28class HybridValues;
29
34template <class CONDITIONAL>
35class BayesNet : public FactorGraph<CONDITIONAL> {
36 private:
38
39 public:
40 typedef typename boost::shared_ptr<CONDITIONAL>
42
43 protected:
46
49
51 template <typename ITERATOR>
52 BayesNet(ITERATOR firstConditional, ITERATOR lastConditional)
53 : Base(firstConditional, lastConditional) {}
54
60 BayesNet(std::initializer_list<sharedConditional> conditionals)
61 : Base(conditionals) {}
62
64
65 public:
68
70 void print(
71 const std::string& s = "BayesNet",
72 const KeyFormatter& formatter = DefaultKeyFormatter) const override;
73
77
79 void dot(std::ostream& os,
80 const KeyFormatter& keyFormatter = DefaultKeyFormatter,
81 const DotWriter& writer = DotWriter()) const;
82
84 std::string dot(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
85 const DotWriter& writer = DotWriter()) const;
86
88 void saveGraph(const std::string& filename,
89 const KeyFormatter& keyFormatter = DefaultKeyFormatter,
90 const DotWriter& writer = DotWriter()) const;
91
95
96 // Expose HybridValues version of logProbability.
97 double logProbability(const HybridValues& x) const;
98
99 // Expose HybridValues version of evaluate.
100 double evaluate(const HybridValues& c) const;
101
103};
104
105} // namespace gtsam
106
107#include <gtsam/inference/BayesNet-inst.h>
Factor Graph Base Class.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
A BayesNet is a tree of conditionals, stored in elimination order.
Definition BayesNet.h:35
BayesNet(std::initializer_list< sharedConditional > conditionals)
Constructor that takes an initializer list of shared pointers.
Definition BayesNet.h:60
void print(const std::string &s="BayesNet", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print out graph
Definition BayesNet-inst.h:32
void dot(std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
Output to graphviz format, stream version.
Definition BayesNet-inst.h:46
boost::shared_ptr< CONDITIONAL > sharedConditional
A shared pointer to a conditional.
Definition BayesNet.h:41
BayesNet(ITERATOR firstConditional, ITERATOR lastConditional)
Construct from iterator over conditionals.
Definition BayesNet.h:52
void saveGraph(const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
output to file with graphviz format.
Definition BayesNet-inst.h:83
BayesNet()
Default constructor as an empty BayesNet.
Definition BayesNet.h:48
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition FactorGraph.h:97
DotWriter is a helper class for writing graphviz .dot files.
Definition DotWriter.h:35
the error.