24#include <boost/shared_ptr.hpp>
25#include <boost/make_shared.hpp>
36 public Conditional<DecisionTreeFactor, DiscreteConditional> {
48 typedef boost::shared_ptr<Values> sharedValues;
78 template<
typename ITERATOR>
79 static shared_ptr Combine(ITERATOR firstConditional,
80 ITERATOR lastConditional);
87 void print(
const std::string& s =
"Discrete Conditional: ",
88 const KeyFormatter& formatter = DefaultKeyFormatter)
const override;
99 const std::string& s =
"Discrete Conditional: ",
100 const KeyFormatter& formatter = DefaultKeyFormatter)
const {
122 size_t solve(
const Values& parentsValues)
const;
129 size_t sample(
const Values& parentsValues)
const;
136 void solveInPlace(
Values& parentsValues)
const;
139 void sampleInPlace(
Values& parentsValues)
const;
150template<
typename ITERATOR>
152 ITERATOR firstConditional, ITERATOR lastConditional) {
158 for (ITERATOR it = firstConditional; it != lastConditional;
161 DecisionTreeFactor::shared_ptr factor = c->toFactor();
162 product = (*factor) * product;
165 return boost::make_shared<DiscreteConditional>(
nrFrontals, product);
signatures for conditional densities
Base class for conditional densities.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
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
Template to create a binary predicate.
Definition: Testable.h:111
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
An assignment from labels to value index (size_t).
Definition: Assignment.h:34
const double & operator()(const Assignment< Key > &x) const
evaluate
Definition: DecisionTree-inl.h:619
A discrete probabilistic factor.
Definition: DecisionTreeFactor.h:38
Discrete Conditional Density Derives from DecisionTreeFactor.
Definition: DiscreteConditional.h:36
double operator()(const Values &values) const override
Evaluate, just look up in AlgebraicDecisonTree.
Definition: DiscreteConditional.h:105
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: DiscreteConditional.h:41
DecisionTreeFactor::shared_ptr toFactor() const
Convert to a factor.
Definition: DiscreteConditional.h:110
Assignment< Key > Values
A map from keys to values.
Definition: DiscreteConditional.h:47
Conditional< BaseFactor, This > BaseConditional
Typedef to our conditional base class.
Definition: DiscreteConditional.h:43
DiscreteConditional This
Typedef to this class.
Definition: DiscreteConditional.h:40
DecisionTreeFactor BaseFactor
Typedef to our factor base class.
Definition: DiscreteConditional.h:42
DiscreteConditional()
default constructor needed for serialization
Definition: DiscreteConditional.h:54
static shared_ptr Combine(ITERATOR firstConditional, ITERATOR lastConditional)
Combine several conditional into a single one.
Definition: DiscreteConditional.h:151
void printSignature(const std::string &s="Discrete Conditional: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
print index signature only
Definition: DiscreteConditional.h:98
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: DiscreteFactor.h:34
Signature for a discrete conditional density, used to construct conditionals.
Definition: Signature.h:52
TODO: Update comments.
Definition: Conditional.h:41
size_t nrFrontals() const
return the number of frontals
Definition: Conditional.h:85
Definition: Ordering.h:34
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:63