fminLBFGSB#

swordfish.function.fminLBFGSB()#

Minimize a function func using the L-BFGS-B 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 (f, g = func(x, *args)).

  • bounds (Constant, optional) – A numeric matrix indicating the bounds on parameters of X0. The matrix must be in the shape of (N,2), where N=size(X0). The two elements of each row defines the bounds (min, max) on that parameter. float(“inf”) can be specified for no bound in that direction.

  • m (Constant, optional) – A positive integer indicating the maximum number of variable metric corrections used to define the limited memory matrix. The default value is 10.

  • factr (Constant, optional) – A positive number. Typical values for factr are: 1e12 for low accuracy; 1e7 (default) for moderate accuracy; 10.0 for extremely high accuracy.

  • pgtol (Constant, optional) – A positive number. The default value is 1e-5.

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

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

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

  • maxLS (Constant, optional) – A non-negative integer indicating the maximum number of line search steps (per iteration). The default value is 20.

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, i.e., gopt=func’(xopt).

  • iterations: The number of iterations.

  • fcalls: The number of function calls made.

  • warnFlag: An integer, which can be

    • 0: Minimization performed.

    • 1: Maximum number of evaluations/iterations exceeded.

    • 2: Stopped for other reasons.

Return type:

Constant