XLPack 6.0
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Optif0_r()

Sub Optif0_r ( N As  Long,
X() As  Double,
Xpls() As  Double,
Fpls As  Double,
Info As  Long,
XX() As  Double,
YY As  Double,
IRev As  Long 
)

Minimum of a multivariable nonlinear function (quasi-Newton method) (simple driver) (reverse communication version)

Purpose
This routine finds the local minimum point (xs1, xs2, ..., xsn) of general nonlinear function f(x1, x2, ..., xn) (a twice continuously differentiable real-valued function).

The first order finite difference is used to compute the gradients, and the secant method (BFGS update) is used to compute the Hessian. The steps are computed by the line search.

Optif0_r is equivalent to using Optif9_r with setting default parameters. So that the problem is solved by the quasi-Newton method (BFGS method).

Optif0_r is the reverse communication version of Optif0.
Parameters
[in]NThe order or dimension of the problem. (N > 1)
[in]X()Array X(LX - 1) (LX >= N)
Initial approximation of the solution vector.
[out]Xpls()Array Xpls(LXpls - 1) (LXpls >= N)
Local minimum.
[out]FplsFunction value at local minimum Xpls.
[out]Info= 0: Successful exit.
= -1: The argument N had an illegal value. (N <= 1)
= -2: The argument X() is invalid.
= -3: The argument Xpls() is invalid.
= -6: The argument XX() is invalid.
= -8: The argument IRev is invalid.
= 1: Last global step failed to locate a point lower than Xpls. Either Xpls is an approximate local minimum of the function, the function is too nonlinear for this algorithm, or Steptl is too large.
= 2: Iteration limit (200) exceeded.
= 3: Maximum step size Stepmx exceeded five consecutive times. Either the function is unbounded below, becomes asymptotic to a finite value from above in some direction, or Stepmx is too small.
[out]XX()Array XX(LXX - 1) (LXX >= N)
When returned with IRev = 1, XX() contains the abscissa where the function value shoule be evaluated and given in the next call.
[in]YYWhen returned with IRev = 1, the function value should be given in YY in the next call.
[in,out]IRevControl variable for reverse communication.
[in] Before first call, IRev should be initialized to zero. On succeeding calls, IRev should not be altered.
[out] If IRev is not zero, set the required values to the specified variables as follows and call the routine again.
= 0: Computation finished. See return code in Info.
= 1: User should set the function values at XX() in YY. Do not alter any variables other than YY.
Reference
CMLIB
Example Program
Find the minimum point of the following function (Rosenbrock function).
f(x1, x2) = 100(x2 - x1^2)^2 + (1 - x1)^2
The initial approximation is (x1, x2) = (-1.2, 1).
Sub Ex_Optif0_r()
Const N = 2
Dim X(N - 1) As Double, Xp(N - 1) As Double, Fp As Double
Dim Info As Long
Dim XX(N - 1) As Double, YY As Double, IRev As Long
X(0) = -1.2: X(1) = 1
IRev = 0
Do
Call Optif0_r(N, X(), Xp(), Fp, Info, XX(), YY, IRev)
If IRev = 1 Then
YY = 100 * (XX(1) - XX(0) ^ 2) ^ 2 + (1 - XX(0)) ^ 2
End If
Loop While IRev <> 0
Debug.Print "X1, X2 =", Xp(0), Xp(1)
Debug.Print "Info =", Info
End Sub
Example Results
X1, X2 = 0.999990556479338 0.999981114653297
Info = 0