Loading...
Searching...
No Matches
DiscreteFactor.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/discrete/DiscreteValues.h>
#include <gtsam/inference/Factor.h>
#include <gtsam/base/Testable.h>
#include <string>
namespace gtsam {
class DecisionTreeFactor;
class DiscreteConditional;
class HybridValues;
class GTSAM_EXPORT DiscreteFactor: public Factor {
public:
// typedefs needed to play nice with gtsam
typedef DiscreteFactor This;
typedef boost::shared_ptr<DiscreteFactor> shared_ptr;
typedef Factor Base;
using Values = DiscreteValues;
public:
DiscreteFactor() {}
template<typename CONTAINER>
DiscreteFactor(const CONTAINER& keys) : Base(keys) {}
virtual ~DiscreteFactor() {
}
virtual bool equals(const DiscreteFactor& lf, double tol = 1e-9) const = 0;
void print(
const std::string& s = "DiscreteFactor\n",
const KeyFormatter& formatter = DefaultKeyFormatter) const override {
Base::print(s, formatter);
}
virtual double operator()(const DiscreteValues&) const = 0;
double error(const DiscreteValues& values) const;
double error(const HybridValues& c) const override;
virtual DecisionTreeFactor operator*(const DecisionTreeFactor&) const = 0;
virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
using Names = DiscreteValues::Names;
virtual std::string markdown(
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const Names& names = {}) const = 0;
virtual std::string html(
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const Names& names = {}) const = 0;
};
// DiscreteFactor
// traits
template<> struct traits<DiscreteFactor> : public Testable<DiscreteFactor> {};
std::vector<double> expNormalize(const std::vector<double> &logProbs);
}// namespace gtsam
Testable.h
Concept check for values that can be used in unit tests.
DiscreteValues.h
Factor.h
The base class for all factors.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::KeyFormatter
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
gtsam::expNormalize
std::vector< double > expNormalize(const std::vector< double > &logProbs)
Normalize a set of log probabilities.
Definition DiscreteFactor.cpp:42
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::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::DecisionTreeFactor
A discrete probabilistic factor.
Definition DecisionTreeFactor.h:45
gtsam::DiscreteConditional
Discrete Conditional Density Derives from DecisionTreeFactor.
Definition DiscreteConditional.h:40
gtsam::DiscreteFactor
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition DiscreteFactor.h:38
gtsam::DiscreteFactor::html
virtual std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const =0
Render as html table.
gtsam::DiscreteFactor::Base
Factor Base
Our base class.
Definition DiscreteFactor.h:45
gtsam::DiscreteFactor::print
void print(const std::string &s="DiscreteFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition DiscreteFactor.h:74
gtsam::DiscreteFactor::Values
DiscreteValues Values
backwards compatibility
Definition DiscreteFactor.h:47
gtsam::DiscreteFactor::shared_ptr
boost::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
Definition DiscreteFactor.h:44
gtsam::DiscreteFactor::~DiscreteFactor
virtual ~DiscreteFactor()
Virtual destructor.
Definition DiscreteFactor.h:63
gtsam::DiscreteFactor::Names
DiscreteValues::Names Names
Translation table from values to strings.
Definition DiscreteFactor.h:106
gtsam::DiscreteFactor::equals
virtual bool equals(const DiscreteFactor &lf, double tol=1e-9) const =0
equals
gtsam::DiscreteFactor::This
DiscreteFactor This
This class.
Definition DiscreteFactor.h:43
gtsam::DiscreteFactor::error
double error(const DiscreteValues &values) const
Error is just -log(value).
Definition DiscreteFactor.cpp:32
gtsam::DiscreteFactor::operator*
virtual DecisionTreeFactor operator*(const DecisionTreeFactor &) const =0
Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor.
gtsam::DiscreteFactor::operator()
virtual double operator()(const DiscreteValues &) const =0
Find value for given assignment of values to variables.
gtsam::DiscreteFactor::markdown
virtual std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const =0
Render as markdown table.
gtsam::DiscreteFactor::DiscreteFactor
DiscreteFactor(const CONTAINER &keys)
Construct from container of keys.
Definition DiscreteFactor.h:60
gtsam::DiscreteFactor::DiscreteFactor
DiscreteFactor()
Default constructor creates empty factor.
Definition DiscreteFactor.h:55
gtsam::DiscreteValues
A map from keys to values.
Definition DiscreteValues.h:34
gtsam::DiscreteValues::Names
std::map< Key, std::vector< std::string > > Names
Translation table from values to strings.
Definition DiscreteValues.h:95
gtsam::HybridValues
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
gtsam::Factor::keys
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:140
gtsam::Factor::Factor
Factor()
Default constructor for I/O.
Definition Factor.h:91
gtsam::Factor::print
virtual void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition Factor.cpp:29
HybridValues
the error.