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 
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> >
173  EliminateSymbolic(const SymbolicFactorGraph& factors, const Ordering& keys);
174 
176  template<>
177  struct traits<SymbolicFactor> : public Testable<SymbolicFactor> {
178  };
179 
180 } //\ namespace gtsam
181 
gtsam::SymbolicFactor::ConditionalType
SymbolicConditional ConditionalType
Definition: SymbolicFactor.h:44
gtsam::SymbolicFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: SymbolicFactor.h:47
Eigen::internal::print
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
Definition: NEON/PacketMath.h:3115
gtsam::SymbolicFactor::Base
Factor Base
Definition: SymbolicFactor.h:43
gtsam::HybridValues
Definition: HybridValues.h:37
gtsam::SymbolicFactor::printKeys
void printKeys(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print only keys
Definition: SymbolicFactor.h:100
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Testable.h
Concept check for values that can be used in unit tests.
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3, Key j4)
Definition: SymbolicFactor.h:68
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
gtsam::SymbolicFactor::FromKeysShared
static SymbolicFactor::shared_ptr FromKeysShared(const CONTAINER &keys)
Definition: SymbolicFactor.h:134
simple_graph::factors
const GaussianFactorGraph factors
Definition: testJacobianFactor.cpp:213
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3)
Definition: SymbolicFactor.h:64
gtsam::SymbolicFactor::FromIteratorsShared
static SymbolicFactor::shared_ptr FromIteratorsShared(KEYITERATOR beginKey, KEYITERATOR endKey)
Definition: SymbolicFactor.h:118
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
gtsam::SymbolicFactor::clone
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Definition: SymbolicFactor.h:83
gtsam::Factor
Definition: Factor.h:70
HybridValues
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
result
Values result
Definition: OdometryOptimize.cpp:8
Factor.h
The base class for all factors.
gtsam::SymbolicFactor::This
SymbolicFactor This
Definition: SymbolicFactor.h:42
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
Key.h
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2)
Definition: SymbolicFactor.h:60
gtsam::SymbolicFactor::print
void print(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition: SymbolicFactor.h:93
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
gtsam::KeyFormatter
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::SymbolicFactor::SymbolicFactor
SymbolicFactor(const Factor &factor)
Definition: SymbolicFactor.h:80
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6)
Definition: SymbolicFactor.h:76
gtsam::equals
Definition: Testable.h:112
gtsam::SymbolicConditional
Definition: SymbolicConditional.h:36
gtsam
traits
Definition: SFMdata.h:40
gtsam::Testable
Definition: Testable.h:152
error
static double error
Definition: testRot3.cpp:37
gtsam::traits
Definition: Group.h:36
gtsam::SymbolicFactor
Definition: SymbolicFactor.h:38
gtsam::SymbolicFactor::FromIterators
static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey)
Definition: SymbolicFactor.h:112
gtsam::SymbolicFactor::FromKeys
static SymbolicFactor FromKeys(const CONTAINER &keys)
Definition: SymbolicFactor.h:127
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor()
Definition: SymbolicFactor.h:53
This
#define This
Definition: ActiveSetSolver-inl.h:27
gtsam::tol
const G double tol
Definition: Group.h:79
Base
Definition: test_virtual_functions.cpp:156
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j)
Definition: SymbolicFactor.h:56
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::SymbolicFactor::SymbolicFactor
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5)
Definition: SymbolicFactor.h:72
gtsam::Ordering
Definition: inference/Ordering.h:33
j1
double j1(double x)
Definition: j1.c:174
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::EliminateSymbolic
std::pair< std::shared_ptr< SymbolicConditional >, std::shared_ptr< SymbolicFactor > > EliminateSymbolic(const SymbolicFactorGraph &factors, const Ordering &keys)
Definition: SymbolicFactor.cpp:36


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:05:21