File LevenbergMarquardt.h¶
- Copyright
This code is licensed under the 3-clause BSD license.
Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.
See LICENSE.txt for details.
-
namespace
Scine
This header file contains functions that allow for common notation for common things that can be done at a different degree of derivatives.
This header contains alias definitions defining which classes to use for the different degrees of derivatives.
-
namespace
Utils
-
class
LevenbergMarquardt
: public Scine::Utils::Optimizer - #include <LevenbergMarquardt.h>
Levenberg-Marquardt (LM) algorithm for a least squares optimization.
Public Functions
-
LevenbergMarquardt
() Default constructor.
-
void
optimize
(Eigen::VectorXd ¶meters, 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.
Public Static Attributes
-
constexpr const char *
calculateCovarianceMatrixKey
= "calculate_covariance_matrix"¶
-
constexpr const char *
maxFuncEvalKey
= "max_function_evaluations"¶
Private Members
-
Eigen::MatrixXd
covarianceMatrix_
¶
-
struct
LMFunctor
Public Functions
-
LMFunctor
(UpdateFunctionManagerBase &updateFunctionManager) Constructor from the update function manager.
-
int
operator()
(const Eigen::VectorXd ¶meters, Eigen::VectorXd &fvec) const Calculates the errors for a given set of parameters.
-
int
df
(const Eigen::VectorXd ¶meters, 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.
-
-
-
class
-
namespace