25 #include <boost/foreach.hpp>
26 #include <boost/shared_ptr.hpp>
34 class DiscreteConditional;
46 typedef boost::shared_ptr<DecisionTreeFactor> shared_ptr;
60 template<
class SOURCE>
76 virtual void print(
const std::string& s =
"DecisionTreeFactor:\n",
77 const KeyFormatter& formatter = DefaultKeyFormatter)
const;
90 return apply(f, ADT::Ring::mul);
95 return apply(f, safe_div);
104 shared_ptr
sum(
size_t nrFrontals)
const {
105 return combine(nrFrontals, ADT::Ring::add);
110 return combine(keys, ADT::Ring::add);
114 shared_ptr
max(
size_t nrFrontals)
const {
135 shared_ptr combine(
size_t nrFrontals, ADT::Binary op)
const;
143 shared_ptr combine(
const Ordering& keys, ADT::Binary op)
const;
A base class for both DiscreteFactor and DiscreteConditional.
Definition: Potentials.h:31
virtual DecisionTreeFactor toDecisionTreeFactor() const
Convert into a decisiontree.
Definition: DecisionTreeFactor.h:99
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor...
Definition: DiscreteFactor.h:33
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:36
A discrete probabilistic factor.
Definition: DecisionTreeFactor.h:39
virtual double operator()(const Values &values) const
Value is just look up in AlgebraicDecisonTree.
Definition: DecisionTreeFactor.h:84
DecisionTreeFactor(const DiscreteKeys &keys, SOURCE table)
Constructor from Indices and (string or doubles)
Definition: DecisionTreeFactor.h:61
This is the base class for all factor types.
Definition: Factor.h:51
DecisionTreeFactor operator/(const DecisionTreeFactor &f) const
divide by factor f (safely)
Definition: DecisionTreeFactor.h:94
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
const double & operator()(const Assignment< Key > &x) const
evaluate
double max(const Vector &a)
Return the max element of a vector.
Definition: Vector.cpp:238
An assignment from labels to value index (size_t).
Definition: Assignment.h:35
shared_ptr max(size_t nrFrontals) const
Create new factor by maximizing over all values with the same separator values.
Definition: DecisionTreeFactor.h:114
Template to create a binary predicate.
Definition: Testable.h:102
DecisionTreeFactor operator*(const DecisionTreeFactor &f) const
multiply two factors
Definition: DecisionTreeFactor.h:89
shared_ptr sum(size_t nrFrontals) const
Create new factor by summing all values with the same separator values.
Definition: DecisionTreeFactor.h:104
DiscreteFactor Base
Typedef to base class.
Definition: DecisionTreeFactor.h:45
Discrete Conditional Density Derives from DecisionTreeFactor.
Definition: DiscreteConditional.h:33
Definition: Ordering.h:30
shared_ptr sum(const Ordering &keys) const
Create new factor by summing all values with the same separator values.
Definition: DecisionTreeFactor.h:109
DecisionTree< L, Y > apply(const DecisionTree< L, Y > &f, const typename DecisionTree< L, Y >::Unary &op)
free versions of apply
Definition: DecisionTree.h:216
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62