Separated split() from the SubgraphSolver because it won't compile in other projects, rearranged headers to remove redundancy and fix template problems
parent
2abd5ee4aa
commit
4962c8ed38
|
|
@ -37,9 +37,9 @@ check_PROGRAMS += tests/testKalmanFilter
|
||||||
|
|
||||||
# Iterative Methods
|
# Iterative Methods
|
||||||
headers += iterative-inl.h
|
headers += iterative-inl.h
|
||||||
sources += iterative.cpp SubgraphPreconditioner.cpp
|
sources += iterative.cpp SubgraphPreconditioner.cpp SubgraphSolver.cpp
|
||||||
headers += IterativeSolver.h IterativeOptimizationParameters.h
|
headers += IterativeSolver.h IterativeOptimizationParameters.h
|
||||||
headers += SubgraphSolver.h SubgraphSolver-inl.h
|
headers += SubgraphSolver-inl.h
|
||||||
|
|
||||||
# Timing tests
|
# Timing tests
|
||||||
noinst_PROGRAMS = tests/timeGaussianFactor tests/timeFactorOverhead tests/timeSLAMlike
|
noinst_PROGRAMS = tests/timeGaussianFactor tests/timeFactorOverhead tests/timeSLAMlike
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
|
|
||||||
#include <gtsam/linear/SubgraphSolver.h>
|
#include <gtsam/linear/SubgraphSolver.h>
|
||||||
#include <gtsam/linear/GaussianFactor.h>
|
|
||||||
#include <gtsam/linear/GaussianFactorGraph.h>
|
|
||||||
#include <gtsam/linear/GaussianBayesNet.h>
|
|
||||||
#include <gtsam/linear/JacobianFactor.h>
|
|
||||||
#include <gtsam/nonlinear/Key.h>
|
|
||||||
#include <gtsam/linear/iterative-inl.h>
|
#include <gtsam/linear/iterative-inl.h>
|
||||||
#include <gtsam/inference/EliminationTree-inl.h>
|
#include <gtsam/inference/EliminationTree-inl.h>
|
||||||
|
|
||||||
|
|
@ -29,39 +21,6 @@ using namespace std;
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/* split the gaussian factor graph Ab into Ab1 and Ab2 according to the map */
|
|
||||||
bool split(const std::map<Index, Index> &M,
|
|
||||||
const GaussianFactorGraph &Ab,
|
|
||||||
GaussianFactorGraph &Ab1,
|
|
||||||
GaussianFactorGraph &Ab2) {
|
|
||||||
|
|
||||||
Ab1 = GaussianFactorGraph();
|
|
||||||
Ab2 = GaussianFactorGraph();
|
|
||||||
|
|
||||||
for ( size_t i = 0 ; i < Ab.size() ; ++i ) {
|
|
||||||
|
|
||||||
boost::shared_ptr<GaussianFactor> factor = Ab[i] ;
|
|
||||||
|
|
||||||
if (factor->keys().size() > 2)
|
|
||||||
throw(invalid_argument("split: only support factors with at most two keys"));
|
|
||||||
if (factor->keys().size() == 1) {
|
|
||||||
Ab1.push_back(factor);
|
|
||||||
Ab2.push_back(factor);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Index key1 = factor->keys()[0];
|
|
||||||
Index key2 = factor->keys()[1];
|
|
||||||
|
|
||||||
if ((M.find(key1) != M.end() && M.find(key1)->second == key2) ||
|
|
||||||
(M.find(key2) != M.end() && M.find(key2)->second == key1))
|
|
||||||
Ab1.push_back(factor);
|
|
||||||
else
|
|
||||||
Ab2.push_back(factor);
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class GRAPH, class LINEAR, class VALUES>
|
template<class GRAPH, class LINEAR, class VALUES>
|
||||||
void SubgraphSolver<GRAPH,LINEAR,VALUES>::replaceFactors(const typename LINEAR::shared_ptr &graph) {
|
void SubgraphSolver<GRAPH,LINEAR,VALUES>::replaceFactors(const typename LINEAR::shared_ptr &graph) {
|
||||||
|
|
||||||
|
|
@ -120,12 +79,4 @@ void SubgraphSolver<GRAPH,LINEAR,VALUES>::initialize(const GRAPH& G, const VALUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // \namespace gtsam
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include <gtsam/linear/SubgraphSolver.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace gtsam {
|
||||||
|
|
||||||
|
/* split the gaussian factor graph Ab into Ab1 and Ab2 according to the map */
|
||||||
|
bool split(const std::map<Index, Index> &M,
|
||||||
|
const GaussianFactorGraph &Ab,
|
||||||
|
GaussianFactorGraph &Ab1,
|
||||||
|
GaussianFactorGraph &Ab2) {
|
||||||
|
|
||||||
|
Ab1 = GaussianFactorGraph();
|
||||||
|
Ab2 = GaussianFactorGraph();
|
||||||
|
|
||||||
|
for ( size_t i = 0 ; i < Ab.size() ; ++i ) {
|
||||||
|
|
||||||
|
boost::shared_ptr<GaussianFactor> factor = Ab[i] ;
|
||||||
|
|
||||||
|
if (factor->keys().size() > 2)
|
||||||
|
throw(invalid_argument("split: only support factors with at most two keys"));
|
||||||
|
if (factor->keys().size() == 1) {
|
||||||
|
Ab1.push_back(factor);
|
||||||
|
Ab2.push_back(factor);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Index key1 = factor->keys()[0];
|
||||||
|
Index key2 = factor->keys()[1];
|
||||||
|
|
||||||
|
if ((M.find(key1) != M.end() && M.find(key1)->second == key2) ||
|
||||||
|
(M.find(key2) != M.end() && M.find(key2)->second == key1))
|
||||||
|
Ab1.push_back(factor);
|
||||||
|
else
|
||||||
|
Ab2.push_back(factor);
|
||||||
|
}
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // \namespace gtsam
|
||||||
|
|
@ -11,12 +11,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
|
#include <gtsam/linear/GaussianFactorGraph.h>
|
||||||
#include <gtsam/linear/IterativeSolver.h>
|
#include <gtsam/linear/IterativeSolver.h>
|
||||||
#include <gtsam/linear/SubgraphPreconditioner.h>
|
#include <gtsam/linear/SubgraphPreconditioner.h>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
/* split the gaussian factor graph Ab into Ab1 and Ab2 according to the map */
|
||||||
|
bool split(const std::map<Index, Index> &M,
|
||||||
|
const GaussianFactorGraph &Ab,
|
||||||
|
GaussianFactorGraph &Ab1,
|
||||||
|
GaussianFactorGraph &Ab2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A nonlinear system solver using subgraph preconditioning conjugate gradient
|
* A nonlinear system solver using subgraph preconditioning conjugate gradient
|
||||||
* Concept NonLinearSolver<G,T,L> implements
|
* Concept NonLinearSolver<G,T,L> implements
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,10 @@
|
||||||
|
|
||||||
#include <gtsam/linear/GaussianSequentialSolver.h>
|
#include <gtsam/linear/GaussianSequentialSolver.h>
|
||||||
#include <gtsam/linear/GaussianMultifrontalSolver.h>
|
#include <gtsam/linear/GaussianMultifrontalSolver.h>
|
||||||
|
#include <gtsam/nonlinear/NonlinearOptimization.h>
|
||||||
|
|
||||||
#include <gtsam/linear/SubgraphSolver-inl.h>
|
#include <gtsam/linear/SubgraphSolver-inl.h>
|
||||||
#include <gtsam/nonlinear/NonlinearOptimizer-inl.h>
|
#include <gtsam/nonlinear/NonlinearOptimizer-inl.h>
|
||||||
#include <gtsam/nonlinear/NonlinearOptimization.h>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <boost/serialization/nvp.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue