Potentials.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 
18 #pragma once
19 
22 #include <gtsam/inference/Key.h>
23 
24 #include <boost/shared_ptr.hpp>
25 #include <set>
26 
27 namespace gtsam {
28 
32  class Potentials: public AlgebraicDecisionTree<Key> {
33 
34  public:
35 
37 
38  protected:
39 
41  std::map<Key,size_t> cardinalities_;
42 
44  Potentials(const ADT& potentials) :
45  ADT(potentials) {
46  }
47 
48  // Safe division for probabilities
49  GTSAM_EXPORT static double safe_div(const double& a, const double& b);
50 
51 // // Apply either a permutation or a reduction
52 // template<class P>
53 // void remapIndices(const P& remapping);
54 
55  public:
56 
58  GTSAM_EXPORT Potentials();
59 
61  GTSAM_EXPORT Potentials(const DiscreteKeys& keys, const ADT& decisionTree);
62 
64  template<class SOURCE>
65  Potentials(const DiscreteKeys& keys, SOURCE table) :
66  ADT(keys, table), cardinalities_(keys.cardinalities()) {
67  }
68 
69  // Testable
70  GTSAM_EXPORT bool equals(const Potentials& other, double tol = 1e-9) const;
71  GTSAM_EXPORT void print(const std::string& s = "Potentials: ",
73 
74  size_t cardinality(Key j) const { return cardinalities_.at(j);}
75 
76 // /**
77 // * @brief Permutes the keys in Potentials
78 // *
79 // * This permutes the Indices and performs necessary re-ordering of ADD.
80 // * This is virtual so that derived types e.g. DecisionTreeFactor can
81 // * re-implement it.
82 // */
83 // GTSAM_EXPORT virtual void permuteWithInverse(const Permutation& inversePermutation);
84 //
85 // /**
86 // * Apply a reduction, which is a remapping of variable indices.
87 // */
88 // GTSAM_EXPORT virtual void reduceWithInverse(const internal::Reduction& inverseReduction);
89 
90  }; // Potentials
91 
92 // traits
93 template<> struct traits<Potentials> : public Testable<Potentials> {};
94 template<> struct traits<Potentials::ADT> : public Testable<Potentials::ADT> {};
95 
96 
97 } // namespace gtsam
AlgebraicDecisionTree< Key > ADT
Definition: Potentials.h:36
Potentials(const ADT &potentials)
Definition: Potentials.h:44
AlgebraicDecisionTree< Key > ADT
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
Algebraic Decision Trees.
Potentials(const DiscreteKeys &keys, SOURCE table)
Definition: Potentials.h:65
const KeyFormatter & formatter
Array33i a
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_EXPORT bool equals(const Potentials &other, double tol=1e-9) const
Definition: Potentials.cpp:52
Array< double, 1, 3 > e(1./3., 0.5, 2.)
size_t cardinality(Key j) const
Definition: Potentials.h:74
RealScalar s
const G & b
Definition: Group.h:83
traits
Definition: chartTesting.h:28
specialized key for discrete variables
static GTSAM_EXPORT double safe_div(const double &a, const double &b)
Definition: Potentials.cpp:34
ArrayXXf table(10, 4)
GTSAM_EXPORT void print(const std::string &s="Potentials: ", const KeyFormatter &formatter=DefaultKeyFormatter) const
Definition: Potentials.cpp:57
std::map< Key, size_t > cardinalities_
Cardinality for each key, used in combine.
Definition: Potentials.h:41
const G double tol
Definition: Group.h:83
const KeyVector keys
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
std::ptrdiff_t j
GTSAM_EXPORT Potentials()
Definition: Potentials.cpp:44
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:37


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:43:28