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

◆ mnhb()

void mnhb ( int  n,
double  x[],
double  b[][2],
void(*)(int, double *, int *, double *)  calcf,
void(*)(int, double *, int *, double *, double *)  calcgh,
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 and Hessian computed analytically)

Purpose
mnhb 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 user supplied analytic routines is used to compute both the gradient and Hessian. Steps are computed by the double dogleg trust region method.

The arrays v[] and iv[] are the parameters and work spaces, If mnh 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]nThe 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]calcfThe 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]calcghThe user supplied subroutine which calculates both the gradient and Hessian of the objective function f(x1, x2, ..., xn) defined as follows.
void calcgh(int n, double x[], int *nf, double g[], double h[])
{
g[i] = calculated derivative value df/dxi from given n and x[] (i = 0 to
n-1)
h[k] = lower triangle part of calculated Hessian value d2f/dxidxj from given
n and x[] (i = 0 to n-1, j = 0 to n-1) in packed form (k = 0 to
n(n+1)/2-1).
}
nf is invocation counter. For same x[] value, same nf will be passed to calcgh. If derivative cannot be calculated at the given x[], nf should be set to 0. The other variables than g[], h[] 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]itsumThe 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.
ng: Number of function calls of calcgh.
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[38] (dtinit): If positive, all components of the dtol array (tolerances for adaptive scaling) are initialized to this value. If zero, then it is assumed that the user has initialized the dtol array. (dtinit >= 0) (default = 1e-6)
  v[39] (d0init): If positive, all components of the d0 array (initial values for adaptive scaling) are initialized to this value. If zero, then it is assumed that the user has initialized the d0 array. (d0init >= 0) (default = 1)
  v[40] (dfac): Factor for adaptive scaling. (0 <= dfac <= 1) (default = 0.6)     If iv[15] (dtype) = 1 or 2, a scale factor d[i] is chosen by adaptive scaling so that d[i]*x[i] has about the same magnitude for all i.
    Let d1[i] = max(sqrt(abs(Hii)), dfac*d[i]) where Hii is the diagonal element of Hessian matrix, then d[i] is chosen as follows.
      if d1[i] >= dtol: d[i] = d1[i].
      if d1[i] < dtol: d[i] = max(d0, dtol).
  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]lvThe length of array v[]. (lv >= 78 + n*(n + 15))
[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.
    If = 13, similar to iv[0] = 12, but the routine will only carry out the storage allocation and return with iv[0] = 14. When the routine is called again with iv[0] = 14, the calculation will be started. This can be used to obtain iv[58] to set the dtol and d0 arrays by the user.
  iv[15] (dtype): Choice of adaptive scaling. (dtype = 0, 1 or 2) (default = 0)
    = 0: Disable adaptive scaling. (scale factor = 1)
    = 1: Enable adaptive scaling during all iterations.
    = 2: Enable adaptive scaling during the first iteration and scale factor is left unchanged thereafter.
  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.
  iv[27] (g): The starting subscript (+ 1) in v[] of the current gradient vector.
  iv[29] (ngcall): Number of calls so far made on calcgh.
  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.
  iv[58] (dtol): Gives the starting subscript (+ 1) in v[] of the dtol array. The d0 array follows the dtol array in v[].
[in]livThe length of array iv[]. (liv >= 59 + 3*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)
= -6: The argument d had an illegal value (d has a negative component and iv[15] = 0) (iv[0] = 18)
= -8: The argument v[18], ... or v[42] had an illegal value (out of range) (iv[0] = 19 to 43)
= -9: The argument lv had an illegal value (lv too small) (iv[0] = 16)
= -10: The argument iv[0] had an illegal value (iv[0] out of range) (iv[0] = 80)
= -11: 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