gtsam  4.0.0
gtsam
ISAM-inst.h
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>
27  void ISAM<BAYESTREE>::update_internal(const FactorGraphType& newFactors, Cliques& orphans, const Eliminate& function)
28  {
29  // Remove the contaminated part of the Bayes tree
30  BayesNetType bn;
31  if (!this->empty()) {
32  const KeySet newFactorKeys = newFactors.keys();
33  this->removeTop(std::vector<Key>(newFactorKeys.begin(), newFactorKeys.end()), bn, orphans);
34  }
35 
36  // Add the removed top and the new factors
37  FactorGraphType factors;
38  factors += bn;
39  factors += newFactors;
40 
41  // Add the orphaned subtrees
42  for(const sharedClique& orphan: orphans)
43  factors += boost::make_shared<BayesTreeOrphanWrapper<Clique> >(orphan);
44 
45  // eliminate into a Bayes net
46  const VariableIndex varIndex(factors);
47  const KeySet newFactorKeys = newFactors.keys();
48  const Ordering constrainedOrdering =
49  Ordering::ColamdConstrainedLast(varIndex, std::vector<Key>(newFactorKeys.begin(), newFactorKeys.end()));
50  Base bayesTree = *factors.eliminateMultifrontal(constrainedOrdering, function, varIndex);
51  this->roots_.insert(this->roots_.end(), bayesTree.roots().begin(), bayesTree.roots().end());
52  this->nodes_.insert(bayesTree.nodes().begin(), bayesTree.nodes().end());
53  }
54 
55  /* ************************************************************************* */
56  template<class BAYESTREE>
57  void ISAM<BAYESTREE>::update(const FactorGraphType& newFactors, const Eliminate& function)
58  {
59  Cliques orphans;
60  this->update_internal(newFactors, orphans, function);
61  }
62 
63 }
void update(const FactorGraphType &newFactors, const Eliminate &function=EliminationTraitsType::DefaultEliminate)
update the Bayes tree with a set of new factors, typically derived from measurements ...
Definition: ISAM-inst.h:57
static Ordering ColamdConstrainedLast(const FactorGraph< FACTOR > &graph, const std::vector< Key > &constrainLast, bool forceOrder=false)
Compute a fill-reducing ordering using constrained COLAMD from a factor graph (see details for note o...
Definition: Ordering.h:100
void update_internal(const FactorGraphType &newFactors, Cliques &orphans, const Eliminate &function=EliminationTraitsType::DefaultEliminate)
update_internal provides access to list of orphans for drawing purposes
Definition: ISAM-inst.h:27
Incremental update functionality (iSAM) for BayesTree.
The VariableIndex class computes and stores the block column structure of a factor graph...
Definition: VariableIndex.h:42
Definition: Ordering.h:33
Global functions in a separate testing namespace.
Definition: chartTesting.h:28