LevenbergMarquardt2D Class |
f(x,y) = 0.5*||fv(x,y)||
It is using a Levenberg-Marquardt method or a Newton-Raphson method, according to UseLm.
Finding zeros of a nonlinear system of equations, i.e.fv(x,y) = [0,0]
If the Jacobian is available, it can be provided, otherwise it works by numerically calculating the Jacobian.
Namespace: DHIMath.Numerics
public class LevenbergMarquardt2D
The LevenbergMarquardt2D type exposes the following members.
Name | Description | |
---|---|---|
LevenbergMarquardt2D(VectorFunction) |
Constructor for minimizing/finding zeros of the function | |
LevenbergMarquardt2D(VectorFunction, VectorFunction) |
Constructor for minimizing/finding zeros of the function The jacobian must return a vector containing the coefficients [df1_dx1, df1_dx2, df2_dx1, df2_dx2]. |
Name | Description | |
---|---|---|
Jacobian |
Function to calculate Jacobian of input function.
| |
JacobianRecalc |
Integer specifying how often the Jacobian is completely recalculated
by a forward difference approximation.
Every iteration can either performs a rank-1 update of the the Jacobian or completely recalculate the Jacobian. This number specifies how often the Jacobian should be completely recalculated. Set to 1 to recalculate in every iteration. Set to zero to never recalculate, but only use rank-1 updates. Default is 10. When a Jacobian function is provided, this parameter is not used. | |
LambdaScaling |
Scaling factor in J'*J+lambda*I, replacing
the diagonal of I by those in LambdaScaling By default they are [1,1]. They can not be negative. | |
MaxFunctionEval |
Maximum number of function evaluations. Default 200
This may not be hit exactly, since one iteration can trigger several function evaluations. In case a Jacobian is not provided, this can be set app. MaxIter + 2*MaxIter/JacobianRecalc, | |
MaxIter |
Maximum number of iterations. Default 100
| |
MaxLineSearchIter |
Maximum number of line search iterations. Default 0.
| |
NumFunctionEval |
Hold the number of function evaluations for the last solve.
| |
NumIter |
Hold the actual number of iterations for the last solve.
| |
NumJacobianEval |
Hold the number of Jacobian evaluations for the last solve.
| |
RelativeDx |
Relative dx used when calculating Jacobian numerically
by a forward difference approximation.
Default value is 1e-6; The forward difference has the form: dx = RelativeDx*Math.Abs(x) df/dx = (f(x+dx)-f(x)) / dx; | |
Tau |
used in starting value for Marquardt parameter:
lambda = Tau * max( diag(J(x0)'*J(x0)) ) Default value is 1e-3 | |
TolG | ||
TolX |
Tolerance value for change in parameter vector, used in stopping criteria,
stopping when:
||dx||_2 <= TolX*(||x||_2 + TolX) Default value is 1e-9. | |
UseLineSearch |
Flag specifying whether a line search approach is to be used. Default false.
| |
UseLm |
Flag whether a LM algorithm should be used. Default true. If set to false
the Newton-Raphson method will be used. The Newton-Raphson method
can only be used for finding zeros, not for minimizing.
|
Name | Description | |
---|---|---|
CalcJacobian |
Calculates numerically the Jacobian
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
JacobianTest(Double, VectorFunction, VectorFunction) |
Calculates the 2-norm difference between the exact and the numeric jacobian,
on an element-wise basis (not matrix norm, but element/vector norm)
| |
JacobianTest(Double, VectorFunction, VectorFunction, Double) |
Calculates the 2-norm difference between the exact and the numeric jacobian,
on an element-wise basis (not matrix norm, but element/vector norm)
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Solve |
Minimize/Solves for zeros, using x as starting point
and updating the value of x as a result.
The user must check whether the solution is acceptable before using it. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
Iterations |
Stored iteration values. Only used when StoreIterations is set.
| |
LambdaCutRel |
Relative lambda value deceding when to set lambda to
zero, in order to try to get quadratic convergence
close to the solution.
Default value is zero (disabled). Values must be positive and reasonable values are in the range [0,1], where a value close to zero will change behavior seldomly. | |
LambdaDecreaseMinFac |
When decreasing lambda, this sets the minimum decrease factor
Default value is 1.0/5.0. Values must be positive and in the range [0,1]. | |
LambdaUpdateFactor |
When updating lambda, an optimal update factor is calculated.
This scales the update factor. Set greater than 1 in order to
get a larger lambda, which can increase stability.
Default value is 1. Value must be positive and larger than 1. | |
StoreIterations |
Flag indicating whether iteration vaues should be stored in Iterations |