|
|
◆ optif9()
| void optif9 |
( |
int |
n, |
|
|
double |
x[], |
|
|
void(*)(int, double *, double *) |
fcn, |
|
|
void(*)(int, double *, double *) |
d1fcn, |
|
|
void(*)(int, double *, int, double *) |
d2fcn, |
|
|
double |
typsiz[], |
|
|
double |
fscale, |
|
|
int |
method, |
|
|
int |
iexp, |
|
|
int |
ndigit, |
|
|
int |
maxiter, |
|
|
int |
iagflg, |
|
|
int |
iahflg, |
|
|
double |
dlt, |
|
|
double |
gradtl, |
|
|
double |
stepmx, |
|
|
double |
steptl, |
|
|
void(*)(int, double *, double, double *, int, double *, double *, int, int) |
result, |
|
|
int |
iresult, |
|
|
double |
xpls[], |
|
|
double * |
fpls, |
|
|
double |
gpls[], |
|
|
int * |
iter, |
|
|
double |
work[], |
|
|
int |
lwork, |
|
|
int * |
info |
|
) |
| |
Minimum of a multivariable nonlinear function (quasi-Newton method or trust region method)
- Purpose
- optif9 finds the local minimum point (xs1, xs2, ..., xsn) of general nonlinear function f(x1, x2, ..., xn) (a twice continuously differentiable real-valued function).
The user may supply analytic routines for the gradient and/or the Hessian. If the analytic gradient routine is not supplied, the first order finite difference is used to compute the gradients. If the analytic Hessian routine is not supplied, the secant method (BFGS update) or the second order finite difference is used to compute the Hessian.
Three global strategies, a line search, a dogleg trust region and a hookstep trust region methods have been implemented.
If the user's analytic Hessian routine is not supplied and the default parameters are used, the problem is solved by the quasi-Newton method (BFGS method).
- Parameters
-
| [in] | n | The order or dimension of the problem. (n > 1) |
| [in] | x[] | Array x[lx] (lx >= n)
Initial approximation of the solution vector. |
| [in] | fcn | The user supplied subroutine which calculates the function f(x1, x2, ..., xn) defined as follows. void fcn(int n, double x[], double *fval)
{
*fval = calculated function value from given n and x[]
}
The other variables than fval should not be altered. |
| [in] | d1fcn | The user supplied subroutine which calculates the derivative of the function f(x1, x2, ..., xn) defined as follows. void d1fcn(int n, double x[], double g[])
{
g[i] = calculated derivative value (df/dxi) from given n and x[] (i = 0 to n - 1)
}
The other variables than g[] should not be altered. |
| [in] | d2fcn | The user supplied subroutine which calculates the Hessian matrix of the function f(x1, x2, ..., xn) defined as follows. void d2fcn(int n, double x[], int ldh, double h[][ldh])
{
h[j][i] = calculated Hessian matrix d2f/dxidxj from given n and x[] (i = 0 to n-1, j = 0 to n-1). ldh is the leading dimension of the two dimensional array.
}
The other variables than h[] should not be altered. |
| [in] | typsiz[] | Array typsiz[ltypsiz] (ltypsiz >= n)
Typical size for each component of x[] to be used for scaling. For example, if x[0] = -0.001, typsiz[0] should be set to 0.001.
(if 0 is specified, 1 will be used. if negative value is specified, the absolute value will be used) |
| [in] | fscale | Estimate of scale of the function at minimum. For example, if f(Xpls) = 0.0001, Fscale should be set to 0.0001.
(if 0 is specified, 1 will be used. if negative value is specified, the absolute value will be used) |
| [in] | method | Algorithm to use to solve minimization problem.
= 1: Line search.
= 2: Double dogleg trust region.
= 3: More-Hebdon hookstep trust region.
(for other values, 1 will be assumed) |
| [in] | iexp | Evaluation time of the function.
= 0: Function evaluation is not expensive.
= 1: Function evaluation is expensive.
(for other values, 1 will be assumed)
If d2fcn is available, Hessian matrix will be updated by d2fcn. If not, it will be updated by the secant method (BFGS method) in the case of iexp = 1, and by the second order finite difference in the case of iexp = 0. |
| [in] | ndigit | Number of reliable decimal digits returned by fcn. (ndigit > 0)
(If ndigit <= 0, the full number of significant digits will be assumed) |
| [in] | maxiter | Maximum number of iterations. (maxiter > 0)
(if maxiter <= 0, 200 will be assumed) |
| [in] | iagflg | Flag for analytic gradient.
= 0: Analytic gradient d1fcn not supplied.
= 1: Analytic gradient d1fcn supplied.
= 2: Analytic gradient d1fcn supplied (do not check d1fcn).
(for other values, 0 will be assumed) |
| [in] | iahflg | Flag for analytic Hessian.
= 0: Analytic Hessian d2fcn not supplied.
= 1: Analytic Hessian d2fcn supplied.
= 2: Analytic Hessian d2fcn supplied (do not check d2fcn).
(for other values, 0 will be assumed) |
| [in] | dlt | Initial trust region radius. If -1 is given, the length of the scaled gradient is used.
(if dlt <= 0, -1 is used. If dlt > stepmx, stepmx is used) |
| [in] | gradtl | Tolerance at which gradient considered close enough to zero to terminate algorithm. (gradtl >= 0)
(if gradtl < 0, 1.0e-5 will be assumed) |
| [in] | stepmx | Maximum allowable step size.
(if stepmx <= 0, max(||X||2*1000, 1000) will be assumed) |
| [in] | steptl | Relative step size at which successive iterates considered close enough to terminate algorithm. Values between 1.0e-3 and 1.0e-7 are usual. (steptl >= 0)
(if steptl < 0, 1.0e-5 will be assumed) |
| [in] | result | The user supplied subroutine which prints the intermediate and final information of iterations defined as follows. void result(int n, double x[], double f, double g[], int ldh, double h[][ldh], double p[], int itncnt, int iflg)
{
Print necessary information;
nr: Leading dimension of array a[]. (number of rows of Hessian matrix)
n: Number of variables.
x[n]: Current variable values.
f: Function value at x[].
g[n]: Gradient values at x[].
h[n][ldh]: Hessian values at x[].
p[n]: Recent steps.
itncnt: Iteration number.
iflag: Control information.
= 1: First call to print initial values.
= 2: Calls during iteration.
= 3: Last call with final result.
}
All arguments are for input and should not be altered. |
| [in] | iresult | Switch for calling result.
= 0: result will not be called.
= 1: result will be called on each iteration.
(for other values, 0 will be assumed) |
| [out] | xpls[] | Array xpls[lxpls] (lxpls >= n)
Local minimum. |
| [out] | fpls | Function value at local minimum xpls. |
| [out] | gpls[] | Array gpls[lgpls] (lgpls >= n)
Gradient at local minimum xpls. |
| [out] | iter | Number of iterations performed to converge. |
| [out] | work[] | Array work[lwork]
Work area.
If info = 0, sub-code will be returned in work[0].
= 1: Relative gradient is close to zero.
= 2: Successive iterates within tolerance. |
| [in] | lwork | The length of work[]. (lwork >= n*(n + 11)) |
| [out] | info | = 0: Successful exit (see sub-code in work[0])
= -1: The argument n had an illegal value (n <= 1)
= -25: The argument lwork had an illegal value (lwork < n*(n + 11))
= 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 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.
= 4: Probable coding error in the user's analytic gradient routine d1fcn
= 5: Probable coding error in the user's analytic Hessian routine d2fcn |
- Reference
- CMLIB
|