ISAM-inst.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/ISAM.h>
22 
23 namespace gtsam {
24 
25 /* ************************************************************************* */
26 template<class BAYESTREE>
28  Cliques* orphans, const Eliminate& function) {
29  // Remove the contaminated part of the Bayes tree
30  BayesNetType bn;
31  const KeySet newFactorKeys = newFactors.keys();
32  if (!this->empty()) {
33  KeyVector keyVector(newFactorKeys.begin(), newFactorKeys.end());
34  this->removeTop(keyVector, &bn, orphans);
35  }
36 
37  // Add the removed top and the new factors
39  factors.push_back(bn);
40  factors.push_back(newFactors);
41 
42  // Add the orphaned subtrees
43  for (const sharedClique& orphan : *orphans)
44  factors.template emplace_shared<BayesTreeOrphanWrapper<Clique> >(orphan);
45 
46  // Get an ordering where the new keys are eliminated last
47  const VariableIndex index(factors);
49  KeyVector(newFactorKeys.begin(), newFactorKeys.end()));
50 
51  // eliminate all factors (top, added, orphans) into a new Bayes tree
52  auto bayesTree = factors.eliminateMultifrontal(ordering, function, std::cref(index));
53 
54  // Re-add into Bayes tree data structures
55  this->roots_.insert(this->roots_.end(), bayesTree->roots().begin(),
56  bayesTree->roots().end());
57  this->nodes_.insert(bayesTree->nodes().begin(), bayesTree->nodes().end());
58 }
59 
60 /* ************************************************************************* */
61 template<class BAYESTREE>
63  const Eliminate& function) {
64  Cliques orphans;
65  this->updateInternal(newFactors, &orphans, function);
66 }
67 
68 }
gtsam::Ordering::ColamdConstrainedLast
static Ordering ColamdConstrainedLast(const FACTOR_GRAPH &graph, const KeyVector &constrainLast, bool forceOrder=false)
Definition: inference/Ordering.h:112
gtsam::BayesTree< HybridBayesTreeClique >::FactorGraphType
HybridBayesTreeClique ::FactorGraphType FactorGraphType
Definition: BayesTree.h:83
gtsam::BayesTree< HybridBayesTreeClique >::Eliminate
FactorGraphType::Eliminate Eliminate
Definition: BayesTree.h:85
simple_graph::factors
const GaussianFactorGraph factors
Definition: testJacobianFactor.cpp:213
ISAM.h
Incremental update functionality (iSAM) for BayesTree.
gtsam::FastSet< Key >
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
gtsam::EliminateableFactorGraph::eliminateMultifrontal
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Definition: EliminateableFactorGraph-inst.h:89
gtsam::BayesTree< HybridBayesTreeClique >::BayesNetType
HybridBayesTreeClique ::BayesNetType BayesNetType
Definition: BayesTree.h:79
gtsam::FastList
Definition: FastList.h:43
gtsam::VariableIndex
Definition: VariableIndex.h:41
ordering
static enum @1096 ordering
empty
Definition: test_copy_move.cpp:19
gtsam
traits
Definition: SFMdata.h:40
gtsam::ISAM::updateInternal
void updateInternal(const FactorGraphType &newFactors, Cliques *orphans, const Eliminate &function=EliminationTraitsType::DefaultEliminate)
Definition: ISAM-inst.h:27
gtsam::FactorGraph::push_back
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
Definition: FactorGraph.h:147
gtsam::BayesTree< HybridBayesTreeClique >::sharedClique
std::shared_ptr< Clique > sharedClique
Shared pointer to a clique.
Definition: BayesTree.h:74
VariableIndex.h
gtsam::ISAM::update
void update(const FactorGraphType &newFactors, const Eliminate &function=EliminationTraitsType::DefaultEliminate)
Definition: ISAM-inst.h:62
gtsam::Ordering
Definition: inference/Ordering.h:33


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