minimize(method=’BFGS’)#
- scipy.optimize.minimize(fun, x0, args=(), method=None, jac=None, hess=None, hessp=None, bounds=None, constraints=(), tol=None, callback=None, options=None)
Minimization of scalar function of one or more variables using the BFGS algorithm.
See also
For documentation for the rest of the parameters, see
scipy.optimize.minimize
- Options:
- ——-
- dispbool
Set to True to print convergence messages.
- maxiterint
Maximum number of iterations to perform.
- gtolfloat
Terminate successfully if gradient norm is less than gtol.
- normfloat
Order of norm (Inf is max, -Inf is min).
- epsfloat or ndarray
If jac is None the absolute step size used for numerical approximation of the jacobian via forward differences.
- return_allbool, optional
Set to True to return a list of the best solution at each of the iterations.
- finite_diff_rel_stepNone or array_like, optional
If jac in [‘2-point’, ‘3-point’, ‘cs’] the relative step size to use for numerical approximation of the jacobian. The absolute step size is computed as
h = rel_step * sign(x) * max(1, abs(x))
, possibly adjusted to fit into the bounds. Forjac='3-point'
the sign of h is ignored. If None (default) then step is selected automatically.- xrtolfloat, default: 0
Relative tolerance for x. Terminate successfully if step size is less than
xk * xrtol
wherexk
is the current parameter vector.- c1float, default: 1e-4
Parameter for Armijo condition rule.
- c2float, default: 0.9
Parameter for curvature condition rule.
- hess_inv0None or ndarray, optional
Initial inverse hessian estimate, shape (n, n). If None (default) then the identity matrix is used.
Notes
Parameters c1 and c2 must satisfy
0 < c1 < c2 < 1
.If minimization doesn’t complete successfully, with an error message of
Desired error not necessarily achieved due to precision loss
, then consider setting gtol to a higher value. This precision loss typically occurs when the (finite difference) numerical differentiation cannot provide sufficient precision to satisfy the gtol termination criterion. This can happen when working in single precision and a callable jac is not provided. For single precision problems a gtol of 1e-3 seems to work.