gtsam 4.2.0
gtsam
Loading...
Searching...
No Matches
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
23#include <gtsam/base/Testable.h>
24
25#include <string>
26namespace gtsam {
27
28class DecisionTreeFactor;
29class DiscreteConditional;
30class HybridValues;
31
38class GTSAM_EXPORT DiscreteFactor: public Factor {
39
40public:
41
42 // typedefs needed to play nice with gtsam
44 typedef boost::shared_ptr<DiscreteFactor> shared_ptr;
45 typedef Factor Base;
46
48
49public:
50
53
56
59 template<typename CONTAINER>
60 DiscreteFactor(const CONTAINER& keys) : Base(keys) {}
61
63 virtual ~DiscreteFactor() {
64 }
65
69
71 virtual bool equals(const DiscreteFactor& lf, double tol = 1e-9) const = 0;
72
74 void print(
75 const std::string& s = "DiscreteFactor\n",
76 const KeyFormatter& formatter = DefaultKeyFormatter) const override {
77 Base::print(s, formatter);
78 }
79
83
85 virtual double operator()(const DiscreteValues&) const = 0;
86
88 double error(const DiscreteValues& values) const;
89
94 double error(const HybridValues& c) const override;
95
98
99 virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
100
104
107
115 virtual std::string markdown(
116 const KeyFormatter& keyFormatter = DefaultKeyFormatter,
117 const Names& names = {}) const = 0;
118
126 virtual std::string html(
127 const KeyFormatter& keyFormatter = DefaultKeyFormatter,
128 const Names& names = {}) const = 0;
129
131};
132// DiscreteFactor
133
134// traits
135template<> struct traits<DiscreteFactor> : public Testable<DiscreteFactor> {};
136
137
154std::vector<double> expNormalize(const std::vector<double> &logProbs);
155
156
157}// namespace gtsam
Concept check for values that can be used in unit tests.
The base class for all factors.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
std::vector< double > expNormalize(const std::vector< double > &logProbs)
Normalize a set of log probabilities.
Definition DiscreteFactor.cpp:42
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
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 helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
A discrete probabilistic factor.
Definition DecisionTreeFactor.h:45
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition DiscreteFactor.h:38
virtual std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const =0
Render as html table.
Factor Base
Our base class.
Definition DiscreteFactor.h:45
void print(const std::string &s="DiscreteFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition DiscreteFactor.h:74
boost::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
Definition DiscreteFactor.h:44
virtual ~DiscreteFactor()
Virtual destructor.
Definition DiscreteFactor.h:63
DiscreteValues::Names Names
Translation table from values to strings.
Definition DiscreteFactor.h:106
virtual bool equals(const DiscreteFactor &lf, double tol=1e-9) const =0
equals
DiscreteFactor This
This class.
Definition DiscreteFactor.h:43
virtual DecisionTreeFactor operator*(const DecisionTreeFactor &) const =0
Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor.
virtual double operator()(const DiscreteValues &) const =0
Find value for given assignment of values to variables.
virtual std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const =0
Render as markdown table.
DiscreteFactor(const CONTAINER &keys)
Construct from container of keys.
Definition DiscreteFactor.h:60
DiscreteFactor()
Default constructor creates empty factor.
Definition DiscreteFactor.h:55
A map from keys to values.
Definition DiscreteValues.h:34
std::map< Key, std::vector< std::string > > Names
Translation table from values to strings.
Definition DiscreteValues.h:95
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
Definition Factor.h:68
the error.