gtsam  4.1.0
gtsam
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 #include <gtsam/base/Testable.h>
24 
25 namespace gtsam {
26 
27 class DecisionTreeFactor;
28 class DiscreteConditional;
29 
34 class GTSAM_EXPORT DiscreteFactor: public Factor {
35 
36 public:
37 
38  // typedefs needed to play nice with gtsam
39  typedef DiscreteFactor This;
40  typedef boost::shared_ptr<DiscreteFactor> shared_ptr;
41  typedef Factor Base;
42 
54  typedef boost::shared_ptr<Values> sharedValues;
55 
56 public:
57 
60 
63 
66  template<typename CONTAINER>
67  DiscreteFactor(const CONTAINER& keys) : Base(keys) {}
68 
70  virtual ~DiscreteFactor() {
71  }
72 
76 
77  // equals
78  virtual bool equals(const DiscreteFactor& lf, double tol = 1e-9) const = 0;
79 
80  // print
81  virtual void print(const std::string& s = "DiscreteFactor\n",
82  const KeyFormatter& formatter = DefaultKeyFormatter) const {
83  Factor::print(s, formatter);
84  }
85 
87  virtual bool empty() const { return size() == 0; }
88 
92 
94  virtual double operator()(const Values&) const = 0;
95 
97  virtual DecisionTreeFactor operator*(const DecisionTreeFactor&) const = 0;
98 
99  virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
100 
102 };
103 // DiscreteFactor
104 
105 // traits
106 template<> struct traits<DiscreteFactor> : public Testable<DiscreteFactor> {};
107 template<> struct traits<DiscreteFactor::Values> : public Testable<DiscreteFactor::Values> {};
108 
109 }// namespace gtsam
gtsam::Factor::print
void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition: Factor.cpp:29
Testable.h
Concept check for values that can be used in unit tests.
gtsam::equals
Template to create a binary predicate.
Definition: Testable.h:110
gtsam::DecisionTreeFactor
A discrete probabilistic factor.
Definition: DecisionTreeFactor.h:38
gtsam::DiscreteFactor::DiscreteFactor
DiscreteFactor()
Default constructor creates empty factor.
Definition: DiscreteFactor.h:62
gtsam::Assignment
An assignment from labels to value index (size_t).
Definition: Assignment.h:34
Assignment.h
An assignment from labels to a discrete value index (size_t)
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::DiscreteFactor
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: DiscreteFactor.h:34
gtsam::DiscreteFactor::operator*
virtual DecisionTreeFactor operator*(const DecisionTreeFactor &) const =0
Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor.
gtsam::DiscreteFactor::empty
virtual bool empty() const
Test whether the factor is empty.
Definition: DiscreteFactor.h:87
gtsam::DiscreteFactor::operator()
virtual double operator()(const Values &) const =0
Find value for given assignment of values to variables.
gtsam
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
gtsam::DiscreteFactor::~DiscreteFactor
virtual ~DiscreteFactor()
Virtual destructor.
Definition: DiscreteFactor.h:70
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
gtsam::DiscreteFactor::This
DiscreteFactor This
This class.
Definition: DiscreteFactor.h:39
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
Factor.h
The base class for all factors.
gtsam::KeyFormatter
boost::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
gtsam::Factor
This is the base class for all factor types.
Definition: Factor.h:55
gtsam::DiscreteFactor::Base
Factor Base
Our base class.
Definition: DiscreteFactor.h:41
gtsam::DiscreteFactor::DiscreteFactor
DiscreteFactor(const CONTAINER &keys)
Construct from container of keys.
Definition: DiscreteFactor.h:67
gtsam::Values
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:71
gtsam::DiscreteFactor::Values
Assignment< Key > Values
A map from keys to values TODO: Do we need this? Should we just use gtsam::Values?...
Definition: DiscreteFactor.h:53
gtsam::DiscreteFactor::shared_ptr
boost::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
Definition: DiscreteFactor.h:40