/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ #pragma once #include #include #include #include #include namespace gtsam { /** * A nonlinear system solver using subgraph preconditioning conjugate gradient * Concept NonLinearSolver implements * linearize: G * T -> L * solve : L -> VectorValues */ template class SubgraphSolver : public IterativeSolver { private: typedef typename VALUES::Key Key; typedef typename GRAPH::Pose Pose; typedef typename GRAPH::Constraint Constraint; typedef boost::shared_ptr shared_ptr ; typedef boost::shared_ptr shared_ordering ; typedef boost::shared_ptr shared_graph ; typedef boost::shared_ptr shared_linear ; typedef boost::shared_ptr shared_values ; typedef boost::shared_ptr shared_preconditioner ; typedef std::map mapPairIndex ; /* the ordering derived from the spanning tree */ shared_ordering ordering_; /* the indice of two vertices in the gaussian factor graph */ mapPairIndex pairs_; /* preconditioner */ shared_preconditioner pc_; public: SubgraphSolver(const LINEAR &GFG) { throw std::runtime_error("SubgraphSolver: gaussian factor graph initialization not supported"); } SubgraphSolver(const SubgraphSolver& solver) : IterativeSolver(solver), ordering_(solver.ordering_), pairs_(solver.pairs_), pc_(solver.pc_){} SubgraphSolver(shared_ordering ordering, mapPairIndex pairs, shared_preconditioner pc, sharedParameters parameters = boost::make_shared()) : IterativeSolver(parameters), ordering_(ordering), pairs_(pairs), pc_(pc) {} SubgraphSolver(const GRAPH& G, const VALUES& theta0):IterativeSolver(){ initialize(G,theta0); } shared_ptr update(const LINEAR &graph) const ; VectorValues::shared_ptr optimize() const ; shared_ordering ordering() const { return ordering_; } protected: void initialize(const GRAPH& G, const VALUES& theta0); private: SubgraphSolver():IterativeSolver(){} }; } // nsamespace gtsam