53 double currentFactor,
unsigned int _iterations = 0,
54 unsigned int totalNumberInnerIterations = 0)
57 currentFactor(currentFactor),
58 totalNumberInnerIterations(totalNumberInnerIterations) {}
62 unsigned int _iterations = 0,
unsigned int totalNumberInnerIterations = 0)
65 currentFactor(currentFactor),
71 lambda *= currentFactor;
72 totalNumberInnerIterations += 1;
82 Values&& newValues,
double newError)
const {
83 double newLambda = lambda, newFactor = currentFactor;
85 newLambda /= currentFactor;
88 newLambda *= std::max(1.0 / 3.0, 1.0 - pow(2.0 * stepQuality - 1.0, 3));
89 newFactor = 2.0 * currentFactor;
92 return std::unique_ptr<This>(
new This(std::move(newValues), newError, newLambda, newFactor,
93 iterations + 1, totalNumberInnerIterations + 1));
101 : A(Matrix::Identity(dim, dim)),
102 b(Vector::Zero(dim)),
104 CachedModel(
int dim,
double sigma,
const Vector& diagonal)
105 : A(Eigen::DiagonalMatrix<double, Eigen::Dynamic>(diagonal)),
106 b(Vector::Zero(dim)),
110 SharedDiagonal model;
114 mutable std::vector<CachedModel> noiseModelCache;
116 if (dim >= noiseModelCache.size())
117 noiseModelCache.resize(dim+1);
126 noiseModelCache.
resize(0);
130 for (
const auto& key_dim : dims) {
131 const Key& key = key_dim.first;
132 const size_t& dim = key_dim.second;
142 noiseModelCache.
resize(0);
144 for (
const auto& key_vector : sqrtHessianDiagonal) {
146 const Key key = key_vector.first;
147 const size_t dim = key_vector.second.size();
149 item->A.diagonal() = sqrtHessianDiagonal.at(key);
151 }
catch (
const std::out_of_range&) {
Definition: LevenbergMarquardtParams.h:35
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
Definition: FactorGraph.h:196
A non-templated config holding any types of Manifold-group elements.
const size_t iterations
Definition: NonlinearOptimizerState.h:43
Definition: LevenbergMarquardtState.h:98
Definition: VectorValues.h:74
size_t size() const
Definition: FactorGraph.h:334
const Values values
Definition: NonlinearOptimizerState.h:37
bool useFixedLambdaFactor
if true applies constant increase (or decrease) to lambda according to lambdaFactor ...
Definition: LevenbergMarquardtParams.h:57
Definition: LevenbergMarquardtState.h:42
Linear Factor Graph where all factors are Gaussians.
size_t size() const
Definition: Values.h:178
GaussianFactorGraph buildDampedSystem(GaussianFactorGraph damped) const
Build a damped system for a specific lambda, vanilla version.
Definition: LevenbergMarquardtState.h:125
typedef and functions to augment Eigen's MatrixXd
GaussianFactorGraph buildDampedSystem(GaussianFactorGraph damped, const VectorValues &sqrtHessianDiagonal) const
Build a damped system, use hessianDiagonal per variable (more expensive)
Definition: LevenbergMarquardtState.h:140
Definition: JacobianFactor.h:91
Definition: chartTesting.h:28
typedef and functions to augment Eigen's VectorXd
double lambdaLowerBound
The minimum lambda used in LM (default: 0)
Definition: LevenbergMarquardtParams.h:52
std::map< Key, size_t > dims() const
virtual void resize(size_t size)
Definition: FactorGraph.h:389
Private class for NonlinearOptimizer state.
Definition: NonlinearOptimizerState.h:34
int totalNumberInnerIterations
The total number of inner iterations in the.
Definition: LevenbergMarquardtState.h:48
void reserve(size_t size)
Definition: FactorGraph.h:186
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
Definition: GaussianFactorGraph.h:73
static shared_ptr Sigma(size_t dim, double sigma, bool smart=true)