SymbolicFactor.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 
20 #include <gtsam/inference/Factor.h>
21 #include <gtsam/inference/Key.h>
22 #include <gtsam/base/Testable.h>
23 
24 #include <memory>
25 
26 #include <utility>
27 
28 namespace gtsam {
29 
30  // Forward declarations
31  class SymbolicConditional;
32  class HybridValues;
33  class Ordering;
34 
38  class GTSAM_EXPORT SymbolicFactor : public Factor {
39 
40  public:
41 
43  typedef Factor Base;
45 
47  typedef std::shared_ptr<This> shared_ptr;
48 
51 
54 
56  explicit SymbolicFactor(Key j) :
57  Base(KeyVector{j}) {}
58 
61  Base(KeyVector{j1, j2}) {}
62 
64  SymbolicFactor(Key j1, Key j2, Key j3) :
65  Base(KeyVector{j1, j2, j3}) {}
66 
68  SymbolicFactor(Key j1, Key j2, Key j3, Key j4) :
69  Base(KeyVector{j1, j2, j3, j4}) {}
70 
72  SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5) :
73  Base(KeyVector{j1, j2, j3, j4, j5}) {}
74 
76  SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6) :
77  Base(KeyVector{j1, j2, j3, j4, j5, j6}) {}
78 
80  explicit SymbolicFactor(const Factor& factor) : Base(factor.keys()) {}
81 
83  SymbolicFactor::shared_ptr clone() const { return std::make_shared<This>(*this); }
84 
86 
89 
90  bool equals(const This& other, double tol = 1e-9) const;
91 
93  void print(
94  const std::string& s = "SymbolicFactor",
95  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
97  }
98 
100  void printKeys(
101  const std::string& s = "SymbolicFactor",
102  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
103  Base::printKeys(s, formatter);
104  }
105 
109 
111  template<typename KEYITERATOR>
112  static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey) {
113  return SymbolicFactor(Base::FromIterators(beginKey, endKey));
114  }
115 
117  template<typename KEYITERATOR>
118  static SymbolicFactor::shared_ptr FromIteratorsShared(KEYITERATOR beginKey, KEYITERATOR endKey) {
119  SymbolicFactor::shared_ptr result = std::make_shared<SymbolicFactor>();
120  result->keys_.assign(beginKey, endKey);
121  return result;
122  }
123 
126  template<class CONTAINER>
127  static SymbolicFactor FromKeys(const CONTAINER& keys) {
128  return SymbolicFactor(Base::FromKeys(keys));
129  }
130 
133  template<class CONTAINER>
134  static SymbolicFactor::shared_ptr FromKeysShared(const CONTAINER& keys) {
135  return FromIteratorsShared(keys.begin(), keys.end());
136  }
137 
139 
142 
144  double error(const HybridValues& c) const override;
145 
148  std::pair<std::shared_ptr<SymbolicConditional>, std::shared_ptr<SymbolicFactor> >
149  eliminate(const Ordering& keys) const;
150 
152 
153  private:
154 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
155 
156  friend class boost::serialization::access;
157  template<class ARCHIVE>
158  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
159  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
160  }
161 #endif
162  }; // IndexFactor
163 
164  // Forward declarations
165  class SymbolicFactorGraph;
166  class Ordering;
167 
172  GTSAM_EXPORT std::pair<std::shared_ptr<SymbolicConditional>, std::shared_ptr<SymbolicFactor> >
174 
176  template<>
177  struct traits<SymbolicFactor> : public Testable<SymbolicFactor> {
178  };
179 
180 } //\ namespace gtsam
181 
void printKeys(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print only keys
SymbolicFactor(Key j1, Key j2, Key j3, Key j4)
Concept check for values that can be used in unit tests.
std::string serialize(const T &input)
serializes to a string
SymbolicConditional ConditionalType
std::shared_ptr< This > shared_ptr
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
const GaussianFactorGraph factors
static SymbolicFactor::shared_ptr FromKeysShared(const CONTAINER &keys)
SymbolicFactor(Key j1, Key j2, Key j3)
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
void print(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
SymbolicFactor(Key j1, Key j2)
static SymbolicFactor::shared_ptr FromIteratorsShared(KEYITERATOR beginKey, KEYITERATOR endKey)
const KeyFormatter & formatter
SymbolicFactor This
std::pair< std::shared_ptr< SymbolicConditional >, std::shared_ptr< SymbolicFactor > > EliminateSymbolic(const SymbolicFactorGraph &factors, const Ordering &keys)
Values result
SymbolicFactor(const Factor &factor)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
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
traits
Definition: chartTesting.h:28
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6)
static SymbolicFactor FromKeys(const CONTAINER &keys)
static double error
Definition: testRot3.cpp:37
const G double tol
Definition: Group.h:86
static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey)
const KeyVector keys
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
std::ptrdiff_t j
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5)
The base class for all factors.


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:36:34