fminBFGS#

swordfish.function.fminBFGS()#

Minimize a function using the BFGS algorithm.

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, optional) – The gradient of func. If not provided, then func returns the function value and the gradient.

  • gtol (Constant, optional) – A postive number. Iteration will terminates if gradient norm is less than gtol. The default value is 1e-5.

  • norm (Constant, optional) – A positive number indicating the order of norm. Maximum norm is used by default.

  • epsilon (Constant, optional) – A positive number indicating the step size used for numerically calculating the gradient. The default value is 1.4901161193847656e-08.

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

  • xrtol (Constant, optional) – A non-negative number indicating the relative tolerance. Iteration will terminate if step size is less than xk * xrtol where xk is the current parameter vector. The default value is 0.

  • 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).

  • gopt: A floating-point vector indicating the gradient at the minimum. gopt=func’(xopt), which should be near 0.

  • Hinv: A floating-point matrix representing the inverse Hessian matrix.

  • iterations: Number of iterations.

  • fcalls: Number of function calls made.

  • gcalls: Number of gradient calls made.

  • warnFlag: An integer, which can be

    • 0: Minimization performed.

    • 1: Maximum number of iterations exceeded.

    • 2: Line search failed or extreme values encountered.

    • 3: Null result encountered.

Return type:

Constant