gtsam  4.0.0
gtsam
DiscreteBayesNet.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 
18 #pragma once
19 
20 #include <vector>
21 #include <map>
22 #include <boost/shared_ptr.hpp>
25 
26 namespace gtsam {
27 
29  class GTSAM_EXPORT DiscreteBayesNet: public FactorGraph<DiscreteConditional>
30  {
31  public:
32 
34  typedef DiscreteBayesNet This;
36  typedef boost::shared_ptr<This> shared_ptr;
37  typedef boost::shared_ptr<ConditionalType> sharedConditional;
38 
41 
44 
46  template<typename ITERATOR>
47  DiscreteBayesNet(ITERATOR firstConditional, ITERATOR lastConditional) : Base(firstConditional, lastConditional) {}
48 
50  template<class CONTAINER>
51  explicit DiscreteBayesNet(const CONTAINER& conditionals) : Base(conditionals) {}
52 
54  template<class DERIVEDCONDITIONAL>
56 
58 
61 
63  bool equals(const This& bn, double tol = 1e-9) const;
64 
66 
69 
71  void add(const Signature& s);
72 
73 // /** Add a DiscreteCondtional in front, when listing parents first*/
74 // GTSAM_EXPORT void add_front(const Signature& s);
75 
76  //** evaluate for given Values */
77  double evaluate(const DiscreteConditional::Values & values) const;
78 
82  DiscreteFactor::sharedValues optimize() const;
83 
85  DiscreteFactor::sharedValues sample() const;
86 
88 
89  private:
91  friend class boost::serialization::access;
92  template<class ARCHIVE>
93  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
94  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
95  }
96  };
97 
98 // traits
99 template<> struct traits<DiscreteBayesNet> : public Testable<DiscreteBayesNet> {};
100 
101 } // \ namespace gtsam
102 
DiscreteBayesNet(const FactorGraph< DERIVEDCONDITIONAL > &graph)
Implicit copy/downcast constructor to override explicit template container constructor.
Definition: DiscreteBayesNet.h:55
DiscreteBayesNet()
Construct empty factor graph.
Definition: DiscreteBayesNet.h:43
DiscreteBayesNet(const CONTAINER &conditionals)
Construct from container of factors (shared_ptr or plain objects)
Definition: DiscreteBayesNet.h:51
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Optimize for triangulation.
Definition: triangulation.cpp:73
Discrete Conditional Density Derives from DecisionTreeFactor.
Definition: DiscreteConditional.h:33
Template to create a binary predicate.
Definition: Testable.h:110
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
An assignment from labels to value index (size_t).
Definition: Assignment.h:34
DiscreteBayesNet(ITERATOR firstConditional, ITERATOR lastConditional)
Construct from iterator over conditionals.
Definition: DiscreteBayesNet.h:47
Signature for a discrete conditional density, used to construct conditionals.
Definition: Signature.h:52
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: BayesTree.h:32
A Bayes net made from linear-Discrete densities.
Definition: DiscreteBayesNet.h:29
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Factor Graph Base Class.