Classes | Public Types | Public Member Functions | Static Private Member Functions | List of all members
gtsam::AlgebraicDecisionTree< L > Class Template Reference

#include <AlgebraicDecisionTree.h>

Inheritance diagram for gtsam::AlgebraicDecisionTree< L >:
Inheritance graph
[legend]

Classes

struct  Ring
 

Public Types

using Base = DecisionTree< L, double >
 
- Public Types inherited from gtsam::DecisionTree< L, double >
using Binary = std::function< double(const double &, const double &)>
 
using CompareFunc = std::function< bool(const double &, const double &)>
 
using LabelC = std::pair< L, size_t >
 
using LabelFormatter = std::function< std::string(L)>
 
using NodePtr = typename Node::Ptr
 
using Unary = std::function< double(const double &)>
 
using UnaryAssignment = std::function< double(const Assignment< L > &, const double &)>
 
using ValueFormatter = std::function< std::string(double)>
 

Public Member Functions

 AlgebraicDecisionTree (double leaf=1.0)
 
 AlgebraicDecisionTree (const Base &add)
 
 AlgebraicDecisionTree (const L &label, double y1, double y2)
 
 AlgebraicDecisionTree (const typename Base::LabelC &labelC, double y1, double y2)
 
 AlgebraicDecisionTree (const std::vector< typename Base::LabelC > &labelCs, const std::vector< double > &ys)
 
 AlgebraicDecisionTree (const std::vector< typename Base::LabelC > &labelCs, const std::string &table)
 
template<typename Iterator >
 AlgebraicDecisionTree (Iterator begin, Iterator end, const L &label)
 
template<typename M >
 AlgebraicDecisionTree (const AlgebraicDecisionTree< M > &other, const std::map< M, L > &map)
 
bool equals (const AlgebraicDecisionTree &other, double tol=1e-9) const
 Equality method customized to value type double. More...
 
AlgebraicDecisionTree operator* (const AlgebraicDecisionTree &g) const
 
AlgebraicDecisionTree operator+ (const AlgebraicDecisionTree &g) const
 
AlgebraicDecisionTree operator/ (const AlgebraicDecisionTree &g) const
 
void print (const std::string &s="", const typename Base::LabelFormatter &labelFormatter=&DefaultFormatter) const
 print method customized to value type double. More...
 
AlgebraicDecisionTree sum (const L &label, size_t cardinality) const
 
AlgebraicDecisionTree sum (const typename Base::LabelC &labelC) const
 
- Public Member Functions inherited from gtsam::DecisionTree< L, double >
 DecisionTree ()
 
 DecisionTree (const double &y)
 
 DecisionTree (const L &label, const double &y1, const double &y2)
 Create tree with 2 assignments y1, y2, splitting on variable label More...
 
 DecisionTree (const LabelC &label, const double &y1, const double &y2)
 
 DecisionTree (const std::vector< LabelC > &labelCs, const std::vector< double > &ys)
 
 DecisionTree (const std::vector< LabelC > &labelCs, const std::string &table)
 
 DecisionTree (Iterator begin, Iterator end, const L &label)
 
 DecisionTree (const L &label, const DecisionTree &f0, const DecisionTree &f1)
 
 DecisionTree (const DecisionTree< L, X > &other, Func Y_of_X)
 Convert from a different value type. More...
 
 DecisionTree (const DecisionTree< M, X > &other, const std::map< M, L > &map, Func Y_of_X)
 Convert from a different value type X to value type Y, also transate labels via map from type M to L. More...
 
 DecisionTree (const NodePtr &root)
 
NodePtr compose (Iterator begin, Iterator end, const L &label) const
 
void print (const std::string &s, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter) const
 GTSAM-style print. More...
 
bool equals (const DecisionTree &other, const CompareFunc &compare=&DefaultCompare) const
 
virtual ~DecisionTree ()=default
 Make virtual. More...
 
bool empty () const
 Check if tree is empty. More...
 
bool operator== (const DecisionTree &q) const
 
const double & operator() (const Assignment< L > &x) const
 
void visit (Func f) const
 Visit all leaves in depth-first fashion. More...
 
void visitLeaf (Func f) const
 Visit all leaves in depth-first fashion. More...
 
void visitWith (Func f) const
 Visit all leaves in depth-first fashion. More...
 
size_t nrLeaves () const
 Return the number of leaves in the tree. More...
 
X fold (Func f, X x0) const
 Fold a binary function over the tree, returning accumulator. More...
 
std::set< Llabels () const
 
DecisionTree apply (const Unary &op) const
 
DecisionTree apply (const UnaryAssignment &op) const
 Apply Unary operation "op" to f while also providing the corresponding assignment. More...
 
DecisionTree apply (const DecisionTree &g, const Binary &op) const
 
DecisionTree choose (const L &label, size_t index) const
 
DecisionTree combine (const L &label, size_t cardinality, const Binary &op) const
 
DecisionTree combine (const LabelC &labelC, const Binary &op) const
 
void dot (std::ostream &os, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const
 
void dot (const std::string &name, const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const
 
std::string dot (const LabelFormatter &labelFormatter, const ValueFormatter &valueFormatter, bool showZero=true) const
 

Static Private Member Functions

static std::string DefaultFormatter (const L &x)
 Default method used by labelFormatter or valueFormatter when printing. More...
 

Additional Inherited Members

- Public Attributes inherited from gtsam::DecisionTree< L, double >
NodePtr root_
 A DecisionTree just contains the root. TODO(dellaert): make protected. More...
 
- Protected Member Functions inherited from gtsam::DecisionTree< L, double >
NodePtr convertFrom (const typename DecisionTree< M, X >::NodePtr &f, std::function< L(const M &)> L_of_M, std::function< double(const X &)> Y_of_X) const
 Convert from a DecisionTree<M, X> to DecisionTree<L, Y>. More...
 
NodePtr create (It begin, It end, ValueIt beginY, ValueIt endY) const
 
- Static Protected Member Functions inherited from gtsam::DecisionTree< L, double >
static bool DefaultCompare (const double &a, const double &b)
 Default method for comparison of two objects of type Y. More...
 

Detailed Description

template<typename L>
class gtsam::AlgebraicDecisionTree< L >

Algebraic Decision Trees fix the range to double Just has some nice constructors and some syntactic sugar TODO: consider eliminating this class altogether?

Definition at line 39 of file AlgebraicDecisionTree.h.

Member Typedef Documentation

◆ Base

template<typename L>
using gtsam::AlgebraicDecisionTree< L >::Base = DecisionTree<L, double>

Definition at line 54 of file AlgebraicDecisionTree.h.

Constructor & Destructor Documentation

◆ AlgebraicDecisionTree() [1/8]

template<typename L>
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( double  leaf = 1.0)
inline

Definition at line 75 of file AlgebraicDecisionTree.h.

◆ AlgebraicDecisionTree() [2/8]

template<typename L>
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( const Base add)
inline

Definition at line 78 of file AlgebraicDecisionTree.h.

◆ AlgebraicDecisionTree() [3/8]

template<typename L>
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( const L label,
double  y1,
double  y2 
)
inline

Create a new leaf function splitting on a variable

Definition at line 81 of file AlgebraicDecisionTree.h.

◆ AlgebraicDecisionTree() [4/8]

template<typename L>
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( const typename Base::LabelC labelC,
double  y1,
double  y2 
)
inline

Create a new leaf function splitting on a variable

Definition at line 85 of file AlgebraicDecisionTree.h.

◆ AlgebraicDecisionTree() [5/8]

template<typename L>
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( const std::vector< typename Base::LabelC > &  labelCs,
const std::vector< double > &  ys 
)
inline

Create from keys and vector table

Definition at line 91 of file AlgebraicDecisionTree.h.

◆ AlgebraicDecisionTree() [6/8]

template<typename L>
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( const std::vector< typename Base::LabelC > &  labelCs,
const std::string &  table 
)
inline

Create from keys and string table

Definition at line 99 of file AlgebraicDecisionTree.h.

◆ AlgebraicDecisionTree() [7/8]

template<typename L>
template<typename Iterator >
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( Iterator  begin,
Iterator  end,
const L label 
)
inline

Create a new function splitting on a variable

Definition at line 114 of file AlgebraicDecisionTree.h.

◆ AlgebraicDecisionTree() [8/8]

template<typename L>
template<typename M >
gtsam::AlgebraicDecisionTree< L >::AlgebraicDecisionTree ( const AlgebraicDecisionTree< M > &  other,
const std::map< M, L > &  map 
)
inline

Convert labels from type M to type L.

Parameters
otherThe AlgebraicDecisionTree with label type M to convert.
mapMap from label type M to label type L.

Definition at line 126 of file AlgebraicDecisionTree.h.

Member Function Documentation

◆ DefaultFormatter()

template<typename L>
static std::string gtsam::AlgebraicDecisionTree< L >::DefaultFormatter ( const L x)
inlinestaticprivate

Default method used by labelFormatter or valueFormatter when printing.

Parameters
xThe value passed to format.
Returns
std::string

Definition at line 47 of file AlgebraicDecisionTree.h.

◆ equals()

template<typename L>
bool gtsam::AlgebraicDecisionTree< L >::equals ( const AlgebraicDecisionTree< L > &  other,
double  tol = 1e-9 
) const
inline

Equality method customized to value type double.

Definition at line 174 of file AlgebraicDecisionTree.h.

◆ operator*()

template<typename L>
AlgebraicDecisionTree gtsam::AlgebraicDecisionTree< L >::operator* ( const AlgebraicDecisionTree< L > &  g) const
inline

product

Definition at line 142 of file AlgebraicDecisionTree.h.

◆ operator+()

template<typename L>
AlgebraicDecisionTree gtsam::AlgebraicDecisionTree< L >::operator+ ( const AlgebraicDecisionTree< L > &  g) const
inline

sum

Definition at line 137 of file AlgebraicDecisionTree.h.

◆ operator/()

template<typename L>
AlgebraicDecisionTree gtsam::AlgebraicDecisionTree< L >::operator/ ( const AlgebraicDecisionTree< L > &  g) const
inline

division

Definition at line 147 of file AlgebraicDecisionTree.h.

◆ print()

template<typename L>
void gtsam::AlgebraicDecisionTree< L >::print ( const std::string &  s = "",
const typename Base::LabelFormatter labelFormatter = &DefaultFormatter 
) const
inline

print method customized to value type double.

Definition at line 162 of file AlgebraicDecisionTree.h.

◆ sum() [1/2]

template<typename L>
AlgebraicDecisionTree gtsam::AlgebraicDecisionTree< L >::sum ( const L label,
size_t  cardinality 
) const
inline

sum out variable

Definition at line 152 of file AlgebraicDecisionTree.h.

◆ sum() [2/2]

template<typename L>
AlgebraicDecisionTree gtsam::AlgebraicDecisionTree< L >::sum ( const typename Base::LabelC labelC) const
inline

sum out variable

Definition at line 157 of file AlgebraicDecisionTree.h.


The documentation for this class was generated from the following file:


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:46:15