fminNCG#

swordfish.function.fminNCG()#

Perform unconstrained minimization of a function using the Newton-CG method.

Parameters:
  • func (Constant) – The function to minimize. The return value of the function must be numeric type.

  • X0 (Constant) – A numeric scalar or vector indicating the initial guess.

  • fprime (Constant) – The gradient of func.

  • fhess (Constant) – The function to compute the Hessian matrix of func.

  • xtol (Constant, optional) – A positive number. Convergence is assumed when the average relative error in the minimizer falls below this amount. The default value is 1e-5.

  • maxIter (Constant, optional) – A non-negative integer indicating the maximum number of iterations. The default value is 15000.

  • c1 (Constant, optional) – A number in (0,1) indicating the parameter for Armijo condition rule. The default value is 1e-4.

  • c2 (Constant, optional) – A number in (0,1) indicating the parameter for curvature condition rule. The default value is 0.9. Note that c2 must be greater than c1.

Returns:

A dictionary with the following members:

  • xopt: A floating-point vector indicating the parameters of the minimum.

  • fopt: A floating-point scalar indicating the value of func at the minimum, i.e., fopt=func(xopt).

  • iterations: The number of iterations.

  • fcalls: The number of function calls made.

  • hcalls: The number of Hessian calls made.

  • warnFlag: An integer, which can be

    • 0: Minimization performed.

    • 1: Maximum number of iterations exceeded.

    • 2: Line search failure (precision loss).

    • 3: Null result encountered.

Return type:

Constant