templating on params is still problematic
parent
398c01375e
commit
75bd3dc52c
|
|
@ -28,6 +28,8 @@ class GaussNewtonOptimizer;
|
||||||
* NonlinearOptimizationParams.
|
* NonlinearOptimizationParams.
|
||||||
*/
|
*/
|
||||||
class GTSAM_EXPORT GaussNewtonParams : public NonlinearOptimizerParams {
|
class GTSAM_EXPORT GaussNewtonParams : public NonlinearOptimizerParams {
|
||||||
|
public:
|
||||||
|
typedef GaussNewtonOptimizer OptimizerType;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ namespace gtsam {
|
||||||
template<class BaseOptimizerParameters>
|
template<class BaseOptimizerParameters>
|
||||||
class GncParams {
|
class GncParams {
|
||||||
public:
|
public:
|
||||||
|
//typedef BaseOptimizerParameters::OptimizerType GncOptimizerType;
|
||||||
|
typedef BaseOptimizerParameters::OptimizerType OptimizerType;
|
||||||
|
|
||||||
/** Verbosity levels */
|
/** Verbosity levels */
|
||||||
enum VerbosityGNC {
|
enum VerbosityGNC {
|
||||||
SILENT = 0, SUMMARY, VALUES
|
SILENT = 0, SUMMARY, VALUES
|
||||||
|
|
@ -46,8 +49,6 @@ public:
|
||||||
GM /*Geman McClure*/, TLS /*Truncated least squares*/
|
GM /*Geman McClure*/, TLS /*Truncated least squares*/
|
||||||
};
|
};
|
||||||
|
|
||||||
using BaseOptimizer = GaussNewtonOptimizer; // BaseOptimizerParameters::OptimizerType;
|
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
GncParams(const BaseOptimizerParameters& baseOptimizerParams) :
|
GncParams(const BaseOptimizerParameters& baseOptimizerParams) :
|
||||||
baseOptimizerParams(baseOptimizerParams) {
|
baseOptimizerParams(baseOptimizerParams) {
|
||||||
|
|
@ -145,6 +146,11 @@ template<class GncParameters>
|
||||||
class GncOptimizer {
|
class GncOptimizer {
|
||||||
public:
|
public:
|
||||||
// types etc
|
// types etc
|
||||||
|
// typedef BaseOptimizerParameters::OptimizerType GncOptimizerType;
|
||||||
|
// typedef GncParameters::BaseOptimizerParameters::OptimizerType BaseOptimizer; //
|
||||||
|
//typedef BaseOptimizerParameters::OptimizerType BaseOptimizer;
|
||||||
|
//typedef GaussNewtonOptimizer BaseOptimizer;
|
||||||
|
typedef GncParameters::OptimizerType BaseOptimizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NonlinearFactorGraph nfg_;
|
NonlinearFactorGraph nfg_;
|
||||||
|
|
@ -198,7 +204,7 @@ public:
|
||||||
Values optimize() {
|
Values optimize() {
|
||||||
// start by assuming all measurements are inliers
|
// start by assuming all measurements are inliers
|
||||||
weights_ = Vector::Ones(nfg_.size());
|
weights_ = Vector::Ones(nfg_.size());
|
||||||
GaussNewtonOptimizer baseOptimizer(nfg_, state_);
|
BaseOptimizer baseOptimizer(nfg_, state_);
|
||||||
Values result = baseOptimizer.optimize();
|
Values result = baseOptimizer.optimize();
|
||||||
double mu = initializeMu();
|
double mu = initializeMu();
|
||||||
double mu_prev = mu;
|
double mu_prev = mu;
|
||||||
|
|
@ -229,7 +235,7 @@ public:
|
||||||
|
|
||||||
// variable/values update
|
// variable/values update
|
||||||
NonlinearFactorGraph graph_iter = this->makeWeightedGraph(weights_);
|
NonlinearFactorGraph graph_iter = this->makeWeightedGraph(weights_);
|
||||||
GaussNewtonOptimizer baseOptimizer_iter(graph_iter, state_);
|
BaseOptimizer baseOptimizer_iter(graph_iter, state_);
|
||||||
result = baseOptimizer_iter.optimize();
|
result = baseOptimizer_iter.optimize();
|
||||||
|
|
||||||
// update mu
|
// update mu
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
class LevenbergMarquardtOptimizer;
|
||||||
|
|
||||||
/** Parameters for Levenberg-Marquardt optimization. Note that this parameters
|
/** Parameters for Levenberg-Marquardt optimization. Note that this parameters
|
||||||
* class inherits from NonlinearOptimizerParams, which specifies the parameters
|
* class inherits from NonlinearOptimizerParams, which specifies the parameters
|
||||||
* common to all nonlinear optimization algorithms. This class also contains
|
* common to all nonlinear optimization algorithms. This class also contains
|
||||||
|
|
@ -40,6 +42,7 @@ public:
|
||||||
|
|
||||||
static VerbosityLM verbosityLMTranslator(const std::string &s);
|
static VerbosityLM verbosityLMTranslator(const std::string &s);
|
||||||
static std::string verbosityLMTranslator(VerbosityLM value);
|
static std::string verbosityLMTranslator(VerbosityLM value);
|
||||||
|
typedef LevenbergMarquardtOptimizer OptimizerType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue