bundles / scipy latest / scipy / optimize / _linesearch / line_search_wolfe2
function
scipy.optimize._linesearch:line_search_wolfe2
Signature
def line_search_wolfe2 ( f , myfprime , xk , pk , gfk = None , old_fval = None , old_old_fval = None , args = () , c1 = 0.0001 , c2 = 0.9 , amax = None , extra_condition = None , maxiter = 10 ) Summary
Find alpha that satisfies strong Wolfe conditions.
Parameters
f: callable f(x,*args)Objective function.
myfprime: callable f'(x,*args)Objective function gradient.
xk: ndarrayStarting point.
pk: ndarraySearch direction. The search direction must be a descent direction for the algorithm to converge.
gfk: ndarray, optionalGradient value for x=xk (xk being the current parameter estimate). Will be recomputed if omitted.
old_fval: float, optionalFunction value for x=xk. Will be recomputed if omitted.
old_old_fval: float, optionalFunction value for the point preceding x=xk.
args: tuple, optionalAdditional arguments passed to objective function.
c1: float, optionalParameter for Armijo condition rule.
c2: float, optionalParameter for curvature condition rule.
amax: float, optionalMaximum step size
extra_condition: callable, optionalA callable of the form
extra_condition(alpha, x, f, g)returning a boolean. Arguments are the proposed stepalphaand the correspondingx,fandgvalues. The line search accepts the value ofalphaonly if this callable returnsTrue. If the callable returnsFalsefor the step length, the algorithm will continue with new iterates. The callable is only called for iterates satisfying the strong Wolfe conditions.maxiter: int, optionalMaximum number of iterations to perform.
Returns
alpha: float or NoneAlpha for which
x_new = x0 + alpha * pk, or None if the line search algorithm did not converge.fc: intNumber of function evaluations made.
gc: intNumber of gradient evaluations made.
new_fval: float or NoneNew function value
f(x_new)=f(x0+alpha*pk), or None if the line search algorithm did not converge.old_fval: floatOld function value
f(x0).new_slope: float or NoneThe local slope along the search direction at the new value
<myfprime(x_new), pk>, or None if the line search algorithm did not converge.
Notes
Uses the line search algorithm to enforce strong Wolfe conditions. See Wright and Nocedal, 'Numerical Optimization', 1999, pp. 59-61.
The search direction pk must be a descent direction (e.g. -myfprime(xk)) to find a step length that satisfies the strong Wolfe conditions. If the search direction is not a descent direction (e.g. myfprime(xk)), then alpha, new_fval, and new_slope will be None.
Examples
import numpy as np from scipy.optimize import line_search✓
def obj_func(x): return (x[0])**2+(x[1])**2 def obj_grad(x): return [2*x[0], 2*x[1]]✓
start_point = np.array([1.8, 1.7]) search_gradient = np.array([-1.0, -1.0])✓
line_search(obj_func, obj_grad, start_point, search_gradient)
✗Aliases
-
scipy.optimize.line_search