Class Scine::Utils::LevenbergMarquardt

class LevenbergMarquardt : public Scine::Utils::Optimizer

Levenberg-Marquardt (LM) algorithm for a least squares optimization.

Public Functions

LevenbergMarquardt()

Default constructor.

void optimize(Eigen::VectorXd &parameters, UpdateFunctionManagerBase &updateFunctionManager)

This function performs the optimization.

Parameters
  • parameters: The parameters to be optimized in a least squares way.

  • updateFunctionManager: The update function manager provided to calculate errors and the Jacobian.

void addSettingsDescriptors(UniversalSettings::DescriptorCollection &collection) const

Adds all relevant options to the given UniversalSettings::DescriptorCollection thus expanding it to include the least squares options.

Parameters
  • collection: The DescriptorCollection to which new fields shall be added.

void applySettings(const Settings &settings)

Updates the LM’s options with those values given in the Settings.

Parameters
  • settings: The settings to update the option of the LM algorithm with.

const Eigen::MatrixXd &getCovarianceMatrix()

Getter for the covariance matrix.

Public Members

int maxFuncEval = 0

Maximum number of function evaluations during an optimization.

The default value is set to zero here, but this value is only passed on to the internal Eigen parameter if it set to be greater than zero!

bool calculateCovarianceMatrix = true

Decides whether a covariance matrix should be calculated for the parameters.

struct LMFunctor

Public Functions

LMFunctor(UpdateFunctionManagerBase &updateFunctionManager)

Constructor from the update function manager.

int operator()(const Eigen::VectorXd &parameters, Eigen::VectorXd &fvec) const

Calculates the errors for a given set of parameters.

int df(const Eigen::VectorXd &parameters, Eigen::MatrixXd &fjac) const

Calculates the Jacobian of the errors for a given set of parameters.

int values() const

Getter for values.

Return

Number of values m.

int inputs() const

Getter for inputs.

Return

Number of inputs n.

Public Members

int m

Number of data points, i.e.

values.

int n

The number of parameters, i.e.

inputs.

UpdateFunctionManagerBase &updateFunctionManager_

The underlying update function manager.