ISAM2Clique.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 // \callgraph
19 
20 #pragma once
21 
23 #include <gtsam/inference/Key.h>
27 #include <string>
28 
29 namespace gtsam {
30 
36 class GTSAM_EXPORT ISAM2Clique
37  : public BayesTreeCliqueBase<ISAM2Clique, GaussianFactorGraph> {
38  public:
39  typedef ISAM2Clique This;
41  typedef std::shared_ptr<This> shared_ptr;
42  typedef std::weak_ptr<This> weak_ptr;
45 
48 #ifdef USE_BROKEN_FAST_BACKSUBSTITUTE
49  mutable FastMap<Key, VectorValues::iterator> solnPointers_;
50 #endif
51 
53  ISAM2Clique() : Base() {}
54 
58  : Base(other),
59  cachedFactor_(other.cachedFactor_),
60  gradientContribution_(other.gradientContribution_) {}
61 
65  Base::operator=(other);
66  cachedFactor_ = other.cachedFactor_;
67  gradientContribution_ = other.gradientContribution_;
68  return *this;
69  }
70 
72  void setEliminationResult(
73  const FactorGraphType::EliminationResult& eliminationResult);
74 
76  Base::FactorType::shared_ptr& cachedFactor() { return cachedFactor_; }
77 
79  const Vector& gradientContribution() const { return gradientContribution_; }
80 
82  void addGradientAtZero(VectorValues* g) const;
83 
84  bool equals(const This& other, double tol = 1e-9) const;
85 
87  void print(const std::string& s = "",
88  const KeyFormatter& formatter = DefaultKeyFormatter) const override;
89 
90  void optimizeWildfire(const KeySet& replaced, double threshold,
91  KeySet* changed, VectorValues* delta,
92  size_t* count) const;
93 
94  bool optimizeWildfireNode(const KeySet& replaced, double threshold,
95  KeySet* changed, VectorValues* delta,
96  size_t* count) const;
97 
102  void nnz_internal(size_t* result) const;
103  size_t calculate_nnz() const;
104 
120  void findAll(const KeySet& markedMask, KeySet* keys) const;
121 
122  private:
127  bool isDirty(const KeySet& replaced, const KeySet& changed) const;
128 
133  void fastBackSubstitute(VectorValues* delta) const;
134 
135  /*
136  * Check whether the values changed above a threshold, or always true if the
137  * clique was replaced.
138  */
139  bool valuesChanged(const KeySet& replaced, const Vector& originalValues,
140  const VectorValues& delta, double threshold) const;
141 
143  void markFrontalsAsChanged(KeySet* changed) const;
144 
146  void restoreFromOriginals(const Vector& originalValues,
147  VectorValues* delta) const;
148 
149 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
150 
151  friend class boost::serialization::access;
152  template <class ARCHIVE>
153  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
154  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
155  ar& BOOST_SERIALIZATION_NVP(cachedFactor_);
156  ar& BOOST_SERIALIZATION_NVP(gradientContribution_);
157  }
158 #endif
159 }; // \struct ISAM2Clique
160 
172 size_t optimizeWildfire(const ISAM2Clique::shared_ptr& root, double threshold,
173  const KeySet& replaced, VectorValues* delta);
174 
176  double threshold, const KeySet& replaced,
178 
179 } // namespace gtsam
VectorValues
gtsam::ISAM2Clique::ISAM2Clique
ISAM2Clique()
Default constructor.
Definition: ISAM2Clique.h:53
GaussianFactorGraph.h
Linear Factor Graph where all factors are Gaussians.
GaussianConditional.h
Conditional Gaussian Base class.
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
gtsam::FastMap
Definition: FastMap.h:39
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
BayesTreeCliqueBase.h
Base class for cliques of a BayesTree.
gtsam::ISAM2Clique::Base
BayesTreeCliqueBase< This, GaussianFactorGraph > Base
Definition: ISAM2Clique.h:40
GaussianBayesNet.h
Chordal Bayes Net, the result of eliminating a factor graph.
gtsam::FastSet
Definition: FastSet.h:51
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
result
Values result
Definition: OdometryOptimize.cpp:8
gtsam::optimizeWildfire
size_t optimizeWildfire(const ISAM2Clique::shared_ptr &root, double threshold, const KeySet &keys, VectorValues *delta)
Definition: ISAM2Clique.cpp:226
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
Key.h
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
gtsam::BayesTreeCliqueBase::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: BayesTreeCliqueBase.h:55
gtsam::optimizeWildfireNonRecursive
size_t optimizeWildfireNonRecursive(const ISAM2Clique::shared_ptr &root, double threshold, const KeySet &keys, VectorValues *delta)
Definition: ISAM2Clique.cpp:260
gtsam.examples.PlanarManipulatorExample.delta
def delta(g0, g1)
Definition: PlanarManipulatorExample.py:45
gtsam::KeySet
FastSet< Key > KeySet
Definition: Key.h:96
gtsam::VectorValues
Definition: VectorValues.h:74
gtsam::BayesTreeCliqueBase
Definition: BayesTreeCliqueBase.h:49
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::ISAM2Clique::ISAM2Clique
ISAM2Clique(const ISAM2Clique &other)
Definition: ISAM2Clique.h:57
gtsam::ISAM2Clique::ConditionalType
GaussianConditional ConditionalType
Definition: ISAM2Clique.h:43
gtsam::GaussianConditional
Definition: GaussianConditional.h:40
gtsam::ISAM2Clique::cachedFactor_
Base::FactorType::shared_ptr cachedFactor_
Definition: ISAM2Clique.h:46
gtsam::ISAM2Clique::gradientContribution
const Vector & gradientContribution() const
Access the gradient contribution.
Definition: ISAM2Clique.h:79
gtsam::ISAM2Clique::This
ISAM2Clique This
Definition: ISAM2Clique.h:39
g
void g(const string &key, int i)
Definition: testBTree.cpp:41
gtsam::equals
Definition: Testable.h:112
gtsam::ISAM2Clique::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: ISAM2Clique.h:41
gtsam::ISAM2Clique::weak_ptr
std::weak_ptr< This > weak_ptr
Definition: ISAM2Clique.h:42
gtsam
traits
Definition: SFMdata.h:40
gtsam::ISAM2Clique::operator=
ISAM2Clique & operator=(const ISAM2Clique &other)
Definition: ISAM2Clique.h:64
gtsam::ISAM2Clique
Definition: ISAM2Clique.h:36
gtsam::ISAM2Clique::gradientContribution_
Vector gradientContribution_
Definition: ISAM2Clique.h:47
This
#define This
Definition: ActiveSetSolver-inl.h:27
gtsam::GaussianConditional::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianConditional.h:46
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::ISAM2Clique::cachedFactor
Base::FactorType::shared_ptr & cachedFactor()
Definition: ISAM2Clique.h:76
Base
Definition: test_virtual_functions.cpp:156
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::ISAM2Clique::sharedConditional
ConditionalType::shared_ptr sharedConditional
Definition: ISAM2Clique.h:44


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:33