SubgraphSolver.cpp
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 
21 
27 
28 using namespace std;
29 
30 namespace gtsam {
31 
32 /**************************************************************************************************/
33 // Just taking system [A|b]
34 SubgraphSolver::SubgraphSolver(const GaussianFactorGraph &Ab,
35  const Parameters &parameters, const Ordering& ordering) :
36  parameters_(parameters) {
37  const auto [Ab1, Ab2] = splitGraph(Ab);
38  if (parameters_.verbosity())
39  cout << "Split A into (A1) " << Ab1.size() << " and (A2) " << Ab2.size()
40  << " factors" << endl;
41 
42  auto Rc1 = *Ab1.eliminateSequential(ordering, EliminateQR);
43  auto xbar = Rc1.optimize();
44  pc_ = std::make_shared<SubgraphPreconditioner>(Ab2, Rc1, xbar);
45 }
46 
47 /**************************************************************************************************/
48 // Taking eliminated tree [R1|c] and constraint graph [A2|b2]
50  const GaussianFactorGraph &Ab2,
51  const Parameters &parameters)
52  : parameters_(parameters) {
53  auto xbar = Rc1.optimize();
54  pc_ = std::make_shared<SubgraphPreconditioner>(Ab2, Rc1, xbar);
55 }
56 
57 /**************************************************************************************************/
58 // Taking subgraphs [A1|b1] and [A2|b2]
59 // delegate up
61  const GaussianFactorGraph &Ab2,
62  const Parameters &parameters,
63  const Ordering &ordering)
64  : SubgraphSolver(*Ab1.eliminateSequential(ordering, EliminateQR), Ab2,
65  parameters) {}
66 
67 /**************************************************************************************************/
70  Errors>(*pc_, pc_->zero(), parameters_);
71  return pc_->x(ybar);
72 }
73 
75  const KeyInfo &keyInfo, const map<Key, Vector> &lambda,
76  const VectorValues &initial) {
77  return VectorValues();
78 }
79 /**************************************************************************************************/
80 pair<GaussianFactorGraph, GaussianFactorGraph> //
82 
83  /* identify the subgraph structure */
85  auto subgraph = builder(factorGraph);
86 
87  /* build factor subgraph */
88  return splitFactorGraph(factorGraph, subgraph);
89 }
90 
91 /****************************************************************************/
92 
93 } // \namespace gtsam
GaussianFactorGraph.h
Linear Factor Graph where all factors are Gaussians.
gtsam::SubgraphSolver::SubgraphSolver
SubgraphSolver(const GaussianFactorGraph &A, const Parameters &parameters, const Ordering &ordering)
Definition: SubgraphSolver.cpp:34
SubgraphSolver.h
Subgraph Solver from IROS 2010.
gtsam::SubgraphSolverParameters::builderParams
SubgraphBuilderParameters builderParams
Definition: SubgraphSolver.h:37
gtsam::SubgraphPreconditioner
Definition: SubgraphPreconditioner.h:54
gtsam::IterativeOptimizationParameters::verbosity
Verbosity verbosity() const
Definition: IterativeSolver.h:61
GaussianBayesNet.h
Chordal Bayes Net, the result of eliminating a factor graph.
gtsam::SubgraphSolver::splitGraph
std::pair< GaussianFactorGraph, GaussianFactorGraph > splitGraph(const GaussianFactorGraph &gfg)
Split graph using Kruskal algorithm, treating binary factors as edges.
Definition: SubgraphSolver.cpp:81
gtsam::SubgraphSolver::pc_
std::shared_ptr< SubgraphPreconditioner > pc_
preconditioner object
Definition: SubgraphSolver.h:82
gtsam::KeyInfo
Definition: IterativeSolver.h:127
gtsam::GaussianFactorGraph
Definition: GaussianFactorGraph.h:73
gtsam::conjugateGradients
V conjugateGradients(const S &Ab, V x, const ConjugateGradientParameters &parameters, bool steepest)
Definition: iterative-inl.h:126
gtsam::VectorValues
Definition: VectorValues.h:74
gtsam::splitFactorGraph
std::pair< GaussianFactorGraph, GaussianFactorGraph > splitFactorGraph(const GaussianFactorGraph &factorGraph, const Subgraph &subgraph)
Definition: SubgraphBuilder.cpp:420
parameters
static ConjugateGradientParameters parameters
Definition: testIterative.cpp:33
gtsam::GaussianBayesNet::optimize
VectorValues optimize() const
Definition: GaussianBayesNet.cpp:44
iterative-inl.h
Iterative methods, template implementation.
gtsam::SubgraphBuilder
Definition: SubgraphBuilder.h:153
gtsam::SubgraphSolver::optimize
VectorValues optimize() const
Optimize from zero.
Definition: SubgraphSolver.cpp:68
gtsam::FastList< Vector >
lambda
static double lambda[]
Definition: jv.c:524
ordering
static enum @1096 ordering
gtsam::SubgraphSolverParameters
Definition: SubgraphSolver.h:35
gtsam
traits
Definition: SFMdata.h:40
gtsam::SubgraphSolver::parameters_
Parameters parameters_
Definition: SubgraphSolver.h:81
std
Definition: BFloat16.h:88
SubgraphPreconditioner.h
exampleQR::Ab
Matrix Ab
Definition: testNoiseModel.cpp:207
SubgraphBuilder.h
initial
Definition: testScenarioRunner.cpp:148
gtsam::SubgraphSolver
Definition: SubgraphSolver.h:76
gtsam::Ordering
Definition: inference/Ordering.h:33
gtsam::GaussianBayesNet
Definition: GaussianBayesNet.h:35
gtsam::EliminateQR
std::pair< GaussianConditional::shared_ptr, JacobianFactor::shared_ptr > EliminateQR(const GaussianFactorGraph &factors, const Ordering &keys)
Definition: JacobianFactor.cpp:778


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