|
◆ mnfb()
void mnfb |
( |
int |
n, |
|
|
double |
x[], |
|
|
double |
b[][2], |
|
|
void(*)(int, double *, int *, double *) |
calcf, |
|
|
double |
d[], |
|
|
void(*)(int, double *, int, int, int, double) |
itsum, |
|
|
double |
v[], |
|
|
int |
lv, |
|
|
int |
iv[], |
|
|
int |
liv, |
|
|
int * |
info |
|
) |
| |
Minimum of a multivariable nonlinear function (trust region method) (simply bounded) (gradient computed by finite differences)
- Purpose
- mnfb finds the local minimum point (xs1, xs2, ..., xsn) of general nonlinear function f(x1, x2, ..., xn) (a twice continuously differentiable real-valued function) under the following simple constraint (b0i and b1i are lower and upper bounds).
b0i <= xsi <= b1i (i = 1 to n)
The gradient of the objective function is calculated by the finite differences instead of calling user-supplied analytical routine. The secant method (BFGS update) is used to compute the Hessian. Steps are computed by the double dogleg trust region method.
The arrays v[] and iv[] are the parameters and work spaces, If mnf is called with iv[0] = 0, these arrays will be initialized to the defalt values before starting the calculation. See description on iv[0] below.
- Parameters
-
[in] | n | The number of variables. (n > 0) |
[in,out] | x[] | Array x[lx] (lx >= n)
[in] Initial approximation of the solution vector.
[out] Obtained solution vector. |
[in] | b[][] | Array b[lb][2] (lb >= n)
Lower and upper bounds on solution vector x.
b[i][0] <= x[i] <= b[i][1] (i = 0 to n-1) |
[in] | calcf | The user supplied subroutine which calculates the function f(x1, x2, ..., xn) defined as follows. void calcf(int n, double x[], int *nf, double *fval)
{
*fval = calculated function value from given n and x[]
}
nf is invocation counter. For same x[] value, same nf will be passed to calcf. If given x[] is out of bounds, nf should be set to 0. The other variables than fval and nf should not be altered. |
[in] | d[] | Array d[ld] (ld >= n)
A scale vector such that d[i]*x[i], i=0,1,...,n-1 are all in comparable units. (d[i] > 0) |
[in] | itsum | The user supplied subroutine to print the intermediate results defined as follows. If iv[18] = 1, the subroutine is called after every iteration. void itsum(int n, double x[], int niter, int nf, int ng, double fval)
{
Output the following information in desired format.
n: Number of variables.
x[]: Current approximation of the solution vector.
niter: Iteration counter.
nf: Number of function calls of calcf (excluding those made only for
computing gradients).
ng: Number of function calls of calcf made only for computing gradients.
fval: Function value at x[].
}
Argument values should not be altered. |
[in,out] | v[] | Array v[lv]
The array for the floating point parameters and work space.
[in]
v[25] (tuner1): Parameter to check for false convergence. (0 <= tuner1 <= 0.5) (default = 0.1)
v[30] (atol): Absolute function convergence tolerance. (0 <= atol) (default = max(1e-20, eps^2), where eps is the machine epsilon)
v[31] (rtol): Relative function convergence tolerance. (eps <= rtol <= 0.1) (default = max(1e-10, eps^(2/3))
v[32] (xctol): X-convergence tolerance. (0 <= xctol <= 1) (default = eps^(1/2))
v[33] (xftol): False convergence tolerance. (0 <= xftol <= 1) (default = 100*eps)
v[34] (lmax0): Maximum 2-norm allowed for scaled very first step. (0 < lmax0) (default = 1)
v[35] (lmaxs), v[36] (sctol): Parameters to test for singular convergence. (0 < lmaxs, 0 <= sctol <= 1)
If the function reduction predicted for a step of length bounded by lmaxs is at most sctol*abs(f). (f is the function value at the start of the current iteration)
v[37] (dinit): If nonnegative, all components of the scale vector d[] is initialized to this value. (-10 <= dinit) (default = -1)
v[41] (eta0): Estimated bound on the relative error in the function value computed by calcf. (Suppose (true value) = (computed value)*(1 + e), Abs(e) is not greater than eta0) (eps <= eta0 <= 1) (default = 1000*eps)
v[42] (bias): The bias parameter used in double dogleg method. (0 <= bias <= 1) (default = 0.8)
[out]
v[0] (dgnorm): 2-norm of diag(d)^(-1)*g. (g is most recently computed gradient)
v[1] (dstnorm): 2-norm of diag(d)^(-1)*s. (s is the current step)
v[9] (f): Current function value.
v[12] (f0): Function value at the start of the current iteration. |
[in] | lv | The length of array v[]. (lv >= 77 + n*(n + 23)/2) |
[in,out] | iv[] | Array iv[liv]
The array for the integer parameters and work space.
[in]
iv[0]: If = 0, all parameters in v[] and iv[] will be initialized to the default values before starting calculation.
If = 12, v[] and iv[] are assumed to have already been set by the user and will not be initialized by the routine. Since the subroutine ivset assigns iv[0] = 12, user can first call ivset to set default values to v[] and iv[], and then change some necessary entries to non-default values and start calculation with such non-default parameters.
iv[16] (mxfcal): Maximum number of function evaluations allowed. (default = 200)
iv[17] (mxiter): Maximum number of iterations allowed. (default = 150)
iv[18] (outlev): Controls the print of intermediate results. (default = 0)
!= 1: itsum is not referenced.
= 1: itsum is called after every iteration.
[out]
iv[0]: Return code.
= 3: x-convergence.
= 4: Relative function convergence.
= 5: Both x- and relative function convergence.
= 6: Absolute function convergence.
= 7: Singular convergence. The Hessian near the current iterate appears to be singular.
= 8: False convergence. The iterates appear to be converging to a noncritical point.
= 9: Function evaluation limit reached.
= 10: Iteration limit reached.
= 11: stopx returned true. (External interrupt)
= 17: Restart attempted with N changed.
= 18: d has a negative component and iv[dtype] < 0.
= 19...43: v[iv[0]] is out of range.
= 63: f(x) cannot be computed at the initial x.
= 64: Bad parameters passed to assess.
= 65: The gradient could not be computed at x.
= 67: Bad first parameter to ivset.
= 80: iv[0] was out of range.
= 81: n is not positive.
iv[5] (nfcall): Number of calls so far made on calcf (excluding those made only for computing gradients). mxfcal is applied to the value of nfcall.
iv[27] (g): The starting subscript (+ 1) in v[] of the current gradient vector.
iv[29] (ngcall): Number of calls so far made on calcf only for computing gradients (the total number of function calls of calcf is nfcall + ngcall).
iv[30] (niter): Number of iterations performed.
iv[43] (lastiv): The least acceptable value of liv.
iv[44] (lastv): The least acceptable value of lv. |
[in] | liv | The length of array iv[]. (liv >= 59 + n) |
[out] | info | = 0: Successful exit (iv[0] = 3 to 6)
= -1: The argument n had an illegal value (n < 1) (iv[0] = 81)
= -3: The argument b had an illegal value (b[i][0] > b[i][1]) (iv[0] = 82)
= -5: The argument d had an illegal value (d has a negative component and iv[15] = 0) (iv[0] = 18)
= -7: The argument v[18], ... or v[42] had an illegal value (out of range) (iv[0] = 19 to 43)
= -8: The argument lv had an illegal value (lv too small) (iv[0] = 16)
= -9: The argument iv[0] had an illegal value (iv[0] out of range) (iv[0] = 80)
= -10: The argument liv had an illegal value (liv too small) (iv[0] = 15)
= 7: Singular convergence (the Hessian near the current iterate appears to be singular)
= 8: False convergence (the iterates appear to be converging to a noncritical point)
= 9: Function evaluation limit reached
= 10: Iteration limit reached
= 14: iv[] and v[] have been allocated (normal exit after a call with iv[0]=13)
= 17: Restart attempted with n changed
= 63: f(x) cannot be computed at the initial x
= 65: The gradient could not be computed at x |
- Reference
- netlib/port
|