LevenbergMarquardt Class |
f(x) = ||fv(x)||
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) = [0]
If the Jacobian is available, it can be provided, otherwise it works by numerically calculating the Jacobian.
Namespace: DHIMath.Numerics
public class LevenbergMarquardt
The LevenbergMarquardt type exposes the following members.
Name | Description | |
---|---|---|
LevenbergMarquardt(Int32, Int32, VectorFunction) |
Constructor for minimizing/finding zeros of the function | |
LevenbergMarquardt(Int32, Int32, VectorFunction, VectorFunction) |
Constructor for minimizing/finding zeros of the function The jacobian must return the jacobian as a vector in column major ordering containing the coefficients [df1_dx1, df2_dx1, df1_dx2, df2_dx2]. |
Name | Description | |
---|---|---|
Fx |
Current function value in iteration
| |
Jacobian |
Setter for Jacobian.
| |
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 Max(dimx,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 + dimx*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 in generel,
and only for square systems, dimx = dimf.
| |
X |
Current value in iteration
|
Name | Description | |
---|---|---|
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(Int32, Int32, 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(Int32, Int32, 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 |
Stores all intermediate x-array solution values for all iterations,
in case StoreIterations is set. If the StoreIterations
is not set, this is null.
The residual is decreasing with each x-array in the list. | |
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. | |
NewValueAction |
If set, the action method is called every time a new x value
has been computed. If the x-array argument is changed, the method
must return true, otherwise it should return false.
Changing the x-values can be used to constrain the x values to a certain set of values. Changing the x-values may significantly decrease convergence speed, and it may produce a suboptimal solution, even though an optimal solution is nearby. | |
StoreIterations |
Flag indicating whether x-array solution values for all iterations should
be stored. .
|