|
|
◆ Subplex()
| Sub Subplex |
( |
N As |
Long, |
|
|
X() As |
Double, |
|
|
F As |
LongPtr, |
|
|
Tol As |
Double, |
|
|
Info As |
Long, |
|
|
Optional NFcall As |
Long, |
|
|
Optional Fval As |
Double, |
|
|
Optional Nsmin As |
Long = 0, |
|
|
Optional Nsmax As |
Long = 0, |
|
|
Optional MaxFcall As |
Long = 1000, |
|
|
Optional NFstop As |
Long = 0, |
|
|
Optional Fstop As |
Double, |
|
|
Optional Minf As |
Long = 0, |
|
|
Optional Alpha As |
Double = 1, |
|
|
Optional Beta As |
Double = 0.5, |
|
|
Optional Gamma As |
Double = 2, |
|
|
Optional Delta As |
Double = 0.5, |
|
|
Optional Psi As |
Double = 0.25, |
|
|
Optional Omega As |
Double = 0.1, |
|
|
Optional Irepl As |
Long = 0, |
|
|
Optional Ifxsw As |
Long = 1, |
|
|
Optional Bonus As |
Double = 1 |
|
) |
| |
Minimum of a multivariable nonlinear function (subspace-searching simplex method)
- Purpose
- This routine finds the local minimum point (xs1, xs2, ..., xsn) of general nonlinear function f(x1, x2, ..., xn) (a general real-valued function)
Nelder-Mead simplex method is used. Since it is a direct searching method, it does not require the derivative computation and not assume the smoothness of the objective functions. However, it is reported this method is, in general, slower than the quasi-Newton method and trust region method.
The simplex method may be inefficient when the number of variables is much larger. This routine applies the simplex method to low dimension sub-spaces of the problem in order to make up for this weakness of the simplex method. When the range of subspace dimensions is specified to the entire space of the problem, this routine works as the original simplex method routine with periodic restarts.
- Parameters
-
| [in] | N | The order or dimension of the problem. (N > 1) |
| [in,out] | X() | Array X(LX - 1) (LX >= N)
[in] Initial approximation of the solution vector.
[out] Obtained solution vector. |
| [in] | F | The user-supplied subroutine which calculates the function f(x1, x2, ..., xn) defined as follows. Sub F(N As Long, X() As Double, Fval As Double)
Calculate the function value from given N and X() and return in Fval. The other variables should not be altered.
End Sub
|
| [in] | Tol | Relative error tolerance for X(). (Tol >= 0)
(If Tol < 0, Tol = 0 is assumed) |
| [out] | Info | = 0: Successful exit.
= -1: The argument N had an illegal value. (N <= 1)
= -9: The argument Nsmin or Nsmax had an illegal value. (Nsmin > Nsmax, or N < ((N - 1)/Nsmax + 1)*Nsmin)
= 1: Maximum number of function evaluations of f (MaxFcall) exceeded.
= 2: Limit of machine precision.
= 3: Fstop reached. (See NFstop) |
| [out] | NFcall | (Optional)
Number of function evaluations of F |
| [out] | Fval | (Optional)
Function value at the obtained solution vector X() |
| [in] | Nsmin | (Optional)
|
| [in] | Nsmax | (Optional)
Nsmin and Msmax are the lower and upper limits of the range of subspace dimensions (1 <= Nsmin <= Nsmax <= N)
(default: Nsmin = Min(2, N), Nsmax = Min(5, N))
(If Nsmin < 1 or Nsmin > N, Nsmin is assumed to be the default value)
(If Nsmax < 1 or Nsmax > N, Namax is assumed to be the default value)
If Nsmin = Nsmax = N, equivalent to Nelder-Mead simplex method with periodic restarts. |
| [in] | MaxFcall | (Optional)
Maximum number of function evaluations of F (default = 1000) (If MaxFcall <= 0, the default value will be used) |
| [in] | NFstop | (Optional)
Switch to test f(x) value during iteration. (default = 0)
= 0: f(x) is not tested against fstop.
= 1: If f(x) has reached Fstop, Subplex returns with Info = 3.
>= 2: If f(x) has reached Fstop and the number of function evaluations at the current best pointn exceeds NFstop, Subplex returns with Info = 3 (only valid when Irepl > 0). |
| [in] | Fstop | (Optional)
See NFstop. |
| [in] | Minf | (Optional)
Specify minimization or maximization. (default = 0)
= 0: Subplex performs minimization.
<> 0: Subplex performs maximization. |
| [in] | Alpha | (Optional)
|
| [in] | Beta | (Optional)
|
| [in] | Gamma | (Optional)
|
| [in] | Delta | (Optional)
Alpha, Beta, Gamma and Delta are the Nelder-Mead simplex method parameters. (Alpha > 0, 0 < Beta < 1, Gamma > 1, 0 < Delta < 1)
(default: Alpha = 1, Beta = 0.5, Gamma = 2, Delta = 0.5)
Alpha, Beta, Gamma and Delta are the reflex, contraction, expansion and shrinkage coefficients, respectively.
(If the parameter value is out of above range, the default value will be used) |
| [in] | Psi | (Optional)
|
| [in] | Omega | (Optional)
Psi and Omega are the Subplex startegy parameters. (0 < Psi < 1, 0 < Omega < 1)
(default: Psi = 0.25, Omega = 0.1)
Psi and Omega are the simplex and step reduction coefficients, respectively.
(If the parameter value is out of above range, the default value will be used) |
| [in] | Irepl | (Optional)
Measurement replication switch. (default = 0)
If the objective functions are subject to large amounts of noise, Subplex can evaluate f(x) several times at each point and return the average, max or min of these trials as the function value.
= 0: No measurement replication.
= 1: Subplex performs measurement replication.
= 2: User performs measurement replication.
(For other values, the default value will be used) |
| [in] | Ifxsw | (Optional)
Measurement replication optimization switch. (default = 1)
= 1: Retain mean of trials as best function value.
= 2: Retain max.
= 3: Retain min.
(For other values, the default value will be used) |
| [in] | Bonus | (Optional)
Measurement replication bonus coefficient. (Bonus >= 0, normally 0 or 1) (default = 1)
A bonus can be added to the function value of the best point so that the best point is not replaced by a new point that only appears better because of noise.
= 0: Bonus not used.
= 1: Bonus used.
(If the value is out of above range, the default value will be used) |
- Reference
- netlib/opt
- 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 FSubplex(N As Long, X() As Double, F As Double)
F = 100 * (X(1) - X(0) ^ 2) ^ 2 + (1 - X(0)) ^ 2
End Sub
Sub Ex_Subplex()
Const N = 2
Dim X(N - 1) As Double, Tol As Double, Info As Long
X(0) = -1.2: X(1) = 1
Tol = 0.0000000001 '1.0e-10
Call Subplex(N, X(), AddressOf FSubplex, Tol, Info)
Debug.Print "X1, X2 =", X(0), X(1)
Debug.Print "Info =", Info
End Sub
Sub Subplex(N As Long, X() As Double, F As LongPtr, Tol As Double, Info As Long, Optional NFcall As Long, Optional Fval As Double, Optional Nsmin As Long=0, Optional Nsmax As Long=0, Optional MaxFcall As Long=1000, Optional NFstop As Long=0, Optional Fstop As Double, Optional Minf As Long=0, Optional Alpha As Double=1, Optional Beta As Double=0.5, Optional Gamma As Double=2, Optional Delta As Double=0.5, Optional Psi As Double=0.25, Optional Omega As Double=0.1, Optional Irepl As Long=0, Optional Ifxsw As Long=1, Optional Bonus As Double=1) Minimum of a multivariable nonlinear function (subspace-searching simplex method)
- Example Results
X1, X2 = 1.0000000000349 1.00000000007952
Info = 0
|