gtsam  4.1.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>
26 
27 namespace gtsam {
28 
30  class GTSAM_EXPORT DiscreteBayesNet: public BayesNet<DiscreteConditional>
31  {
32  public:
33 
35  typedef DiscreteBayesNet This;
37  typedef boost::shared_ptr<This> shared_ptr;
38  typedef boost::shared_ptr<ConditionalType> sharedConditional;
39 
42 
45 
47  template<typename ITERATOR>
48  DiscreteBayesNet(ITERATOR firstConditional, ITERATOR lastConditional) : Base(firstConditional, lastConditional) {}
49 
51  template<class CONTAINER>
52  explicit DiscreteBayesNet(const CONTAINER& conditionals) : Base(conditionals) {}
53 
55  template<class DERIVEDCONDITIONAL>
57 
59 
62 
64  bool equals(const This& bn, double tol = 1e-9) const;
65 
67 
70 
72  void add(const Signature& s);
73 
74 // /** Add a DiscreteCondtional in front, when listing parents first*/
75 // GTSAM_EXPORT void add_front(const Signature& s);
76 
77  //** evaluate for given Values */
78  double evaluate(const DiscreteConditional::Values & values) const;
79 
83  DiscreteFactor::sharedValues optimize() const;
84 
86  DiscreteFactor::sharedValues sample() const;
87 
89 
90  private:
92  friend class boost::serialization::access;
93  template<class ARCHIVE>
94  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
95  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
96  }
97  };
98 
99 // traits
100 template<> struct traits<DiscreteBayesNet> : public Testable<DiscreteBayesNet> {};
101 
102 } // \ namespace gtsam
103 
BayesNet.h
Bayes network.
gtsam::equals
Template to create a binary predicate.
Definition: Testable.h:110
gtsam::optimize
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Optimize for triangulation.
Definition: triangulation.cpp:73
gtsam::DiscreteBayesNet::DiscreteBayesNet
DiscreteBayesNet()
Construct empty factor graph.
Definition: DiscreteBayesNet.h:44
gtsam::Assignment
An assignment from labels to value index (size_t).
Definition: Assignment.h:34
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
gtsam::DiscreteBayesNet
A Bayes net made from linear-Discrete densities.
Definition: DiscreteBayesNet.h:31
gtsam::Signature
Signature for a discrete conditional density, used to construct conditionals.
Definition: Signature.h:52
gtsam::serialize
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:100
FactorGraph.h
Factor Graph Base Class.
gtsam
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
gtsam::DiscreteBayesNet::DiscreteBayesNet
DiscreteBayesNet(const FactorGraph< DERIVEDCONDITIONAL > &graph)
Implicit copy/downcast constructor to override explicit template container constructor.
Definition: DiscreteBayesNet.h:56
gtsam::DiscreteConditional
Discrete Conditional Density Derives from DecisionTreeFactor.
Definition: DiscreteConditional.h:36
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
gtsam::DiscreteBayesNet::DiscreteBayesNet
DiscreteBayesNet(const CONTAINER &conditionals)
Construct from container of factors (shared_ptr or plain objects)
Definition: DiscreteBayesNet.h:52
gtsam::FactorGraph< DiscreteConditional >
DiscreteConditional.h
gtsam::BayesNet
A BayesNet is a tree of conditionals, stored in elimination order.
Definition: BayesNet.h:34
gtsam::DiscreteBayesNet::DiscreteBayesNet
DiscreteBayesNet(ITERATOR firstConditional, ITERATOR lastConditional)
Construct from iterator over conditionals.
Definition: DiscreteBayesNet.h:48