XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ optif9_r()

void optif9_r ( int  n,
double  x[],
double  typsiz[],
double  fscale,
int  method,
int  iexp,
int  ndigit,
int  maxiter,
int  iagflg,
int  iahflg,
double  dlt,
double  gradtl,
double  stepmx,
double  steptl,
int  iresult,
double  xpls[],
double *  fpls,
double  gpls[],
int *  iter,
double  work[],
int  lwork,
int *  info,
double  xx[],
double *  yy,
double  yyp[],
int  ldyyp2,
double  yyp2[],
int *  irev 
)

Minimum of a multivariable nonlinear function (quasi-Newton method or trust region method) (reverse communication version)

Purpose
optif9_r 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 the analytic gradient and/or Hessian values. If the analytic gradient is not supplied, the first order finite difference is used to compute the gradients. If the analytic Hessian 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 is not supplied and the default parameters are used, the problem is solved by the quasi-Newton method (BFGS method).
Parameters
[in]nThe order or dimension of the problem. (n > 1)
[in]x[]Array x[lx] (lx >= n)
Initial approximation of the solution vector.
[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]fscaleEstimate 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]methodAlgorithm 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]iexpEvaluation 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]ndigitNumber of reliable decimal digits returned by fcn. (ndigit > 0)
(If ndigit <= 0, the full number of significant digits will be assumed)
[in]maxiterMaximum number of iterations. (maxiter > 0)
(if maxiter <= 0, 200 will be assumed)
[in]iagflgFlag for analytic gradient (whether to return with irev = 30 to 34).
= 0: Analytic gradient not supplied.
= 1: Analytic gradient supplied.
= 2: Analytic gradient supplied (do not check the supplied values).
(for other values, 0 will be assumed)
[in]iahflgFlag for analytic Hessian (whether to return with irev = 35 to 37).
= 0: Analytic Hessian not supplied.
= 1: Analytic Hessian supplied.
= 2: Analytic Hessian supplied (do not check the supplied values).
(for other values, 0 will be assumed)
[in]dltInitial 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]gradtlTolerance at which gradient considered close enough to zero to terminate algorithm. (gradtl >= 0)
(if gradtl < 0, 1.0e-5 will be assumed)
[in]stepmxMaximum allowable step size.
(if stepmx <= 0, max(||X||2*1000, 1000) will be assumed)
[in]steptlRelative 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]iresultSwitch to return with irev = 50 to 52 for printing intermediate results.
= 0: Do not return with irev = 50 to 52.
= 1: Return with irev = 50 to 52.
(for other values, 0 will be assumed)
[out]xpls[]Array xpls[lxpls] (lxpls >= n)
Local minimum.
[out]fplsFunction value at local minimum xpls.
[out]gpls[]Array gpls[lgpls] (lgpls >= n)
Gradient at local minimum xpls.
[out]iterNumber 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]lworkThe length of work[]. (lwork >= 9*n)
[out]info= 0: Successful exit (see sub-code in work[0])
= -1: The argument n had an illegal value (n <= 1)
= -20: The argument ldh had an illegal value (ldh < n)
= -23: The argument lwork had an illegal value (lwork < 9*n)
= 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
[out]xx[]Array xx[lxx] (lxx >= n)
irev = 1 to 20, 30 to 34, or 35 to 37: xx[] contains the abscissa where the function value, derivatives or Hessian matrix should be evaluated and given in the next call.
irev = 50 to 52: xx[] contains the current solution vector x for printing.
[in,out]yy[in] irev = 1 to 20: The function value f(xx[]) should be given in yy in the next call.
[out] irev = 50 to 52: yy contains the function value at current x for printing.
[in,out]yyp[]Array yyp[lyyp] (lyyp >= n)
[in] irev = 30 to 34: The derivatives at xx[] should be given in yyp[] in the next call.
[out] irev = 50 to 52: yyp[] contains the derivatives at current x for printing.
[in]ldyyp2The leading dimension of the array yyp2[][]. (ldyyp2 >= n)
[in,out]yyp2[][]Array yyp2[lyyp2][ldyyp2] (lyyp2 >= n)
[in] irev = 35 to 37: The Hessian matrix at xx[] should be given in the next call.
[out] irev = 50 to 52: yyp2[][] contains the Hessian at current x for printing. yyp2[][] is also used as work area for Hessian calculation.
[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, complete the following process and call this routine again.
= 0: Computation finished. See return code in info.
= 1 to 20: User should set the function values at xx[] in yy. Do not alter any variables other than yy.
= 30 to 34: User should set the derivatives at xx[] in yyp[]. Do not alter any variables other than yyp[].
= 35 to 37: User should set the Heassian matrix at xx[] in yyp2[][]. Do not alter any variables other than yyp2[][].
= 50 to 52: Print the intermediate result (xx[], yy, yyp[], yyp2[][], iter) (when iresult = 1).
  irev = 50: First return with initial values.
  irev = 51: Returns during iteration with intermediate results.
  irev = 52: Last return with final result.
Do not alter any variables.
Reference
CMLIB