gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DiscreteFactor.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 #include <gtsam/inference/Factor.h>
23 
24 namespace gtsam {
25 
26 class DecisionTreeFactor;
27 class DiscreteConditional;
28 
33 class GTSAM_EXPORT DiscreteFactor: public Factor {
34 
35 public:
36 
37  // typedefs needed to play nice with gtsam
38  typedef DiscreteFactor This;
39  typedef boost::shared_ptr<DiscreteFactor> shared_ptr;
40  typedef Factor Base;
41 
53  typedef boost::shared_ptr<Values> sharedValues;
54 
55 public:
56 
59 
62 
65  template<typename CONTAINER>
66  DiscreteFactor(const CONTAINER& keys) : Base(keys) {}
67 
69  virtual ~DiscreteFactor() {
70  }
71 
75 
76  // equals
77  virtual bool equals(const DiscreteFactor& lf, double tol = 1e-9) const = 0;
78 
79  // print
80  virtual void print(const std::string& s = "DiscreteFactor\n",
81  const KeyFormatter& formatter = DefaultKeyFormatter) const {
82  Factor::print(s, formatter);
83  }
84 
86  virtual bool empty() const { return size() == 0; }
87 
91 
93  virtual double operator()(const Values&) const = 0;
94 
96  virtual DecisionTreeFactor operator*(const DecisionTreeFactor&) const = 0;
97 
98  virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
99 
101 };
102 // DiscreteFactor
103 
104 }// namespace gtsam
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor...
Definition: DiscreteFactor.h:33
Assignment< Key > Values
A map from keys to values TODO: Do we need this? Should we just use gtsam::Values? We just need another special DiscreteValue to represent labels, However, all other Lie's operators are undefined in this class.
Definition: DiscreteFactor.h:52
A discrete probabilistic factor.
Definition: DecisionTreeFactor.h:39
DiscreteFactor This
This class.
Definition: DiscreteFactor.h:38
Factor Base
Our base class.
Definition: DiscreteFactor.h:40
This is the base class for all factor types.
Definition: Factor.h:51
void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition: Factor.cpp:30
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:249
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:75
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
An assignment from labels to value index (size_t).
Definition: Assignment.h:35
The base class for all factors.
virtual ~DiscreteFactor()
Virtual destructor.
Definition: DiscreteFactor.h:69
Template to create a binary predicate.
Definition: Testable.h:102
DiscreteFactor(const CONTAINER &keys)
Construct from container of keys.
Definition: DiscreteFactor.h:66
virtual bool empty() const
Test whether the factor is empty.
Definition: DiscreteFactor.h:86
DiscreteFactor()
Default constructor creates empty factor.
Definition: DiscreteFactor.h:61
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62
An assignment from labels to a discrete value index (size_t)
boost::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
Definition: DiscreteFactor.h:39