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 #include <string>
26 namespace gtsam {
27 
28 class DecisionTreeFactor;
29 class DiscreteConditional;
30 class HybridValues;
31 
38 class GTSAM_EXPORT DiscreteFactor: public Factor {
39 
40 public:
41 
42  // typedefs needed to play nice with gtsam
43  typedef DiscreteFactor This;
44  typedef std::shared_ptr<DiscreteFactor> shared_ptr;
45  typedef Factor Base;
46 
48 
49 public:
50 
53 
56 
59  template<typename CONTAINER>
60  DiscreteFactor(const CONTAINER& keys) : Base(keys) {}
61 
65 
67  virtual bool equals(const DiscreteFactor& lf, double tol = 1e-9) const = 0;
68 
70  void print(
71  const std::string& s = "DiscreteFactor\n",
72  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
74  }
75 
79 
81  virtual double operator()(const DiscreteValues&) const = 0;
82 
84  double error(const DiscreteValues& values) const;
85 
90  double error(const HybridValues& c) const override;
91 
93  virtual DecisionTreeFactor operator*(const DecisionTreeFactor&) const = 0;
94 
95  virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
96 
100 
103 
111  virtual std::string markdown(
112  const KeyFormatter& keyFormatter = DefaultKeyFormatter,
113  const Names& names = {}) const = 0;
114 
122  virtual std::string html(
123  const KeyFormatter& keyFormatter = DefaultKeyFormatter,
124  const Names& names = {}) const = 0;
125 
127 };
128 // DiscreteFactor
129 
130 // traits
131 template<> struct traits<DiscreteFactor> : public Testable<DiscreteFactor> {};
132 
133 
150 std::vector<double> expNormalize(const std::vector<double> &logProbs);
151 
152 
153 }// namespace gtsam
void print(const std::string &s="DiscreteFactor\, const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Concept check for values that can be used in unit tests.
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
leaf::MyValues values
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:52
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
const KeyFormatter & formatter
DiscreteFactor This
This class.
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
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
std::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
DiscreteValues::Names Names
Translation table from values to strings.
traits
Definition: chartTesting.h:28
Factor Base
Our base class.
std::vector< double > expNormalize(const std::vector< double > &logProbs)
Normalize a set of log probabilities.
DiscreteFactor(const CONTAINER &keys)
static double error
Definition: testRot3.cpp:37
const G double tol
Definition: Group.h:86
const KeyVector keys
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
std::map< Key, std::vector< std::string > > Names
Translation table from values to strings.
The base class for all factors.


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:10