scipy.optimize.fmin_cg

scipy.optimize.fmin_cg(f, x0, fprime=None, args=(), gtol=1e-05, norm=inf, epsilon=1.4901161193847656e-08, maxiter=None, full_output=0, disp=1, retall=0, callback=None)[source]

Minimize a function using a nonlinear conjugate gradient algorithm.

Parameters :

f : callable f(x,*args)

Objective function to be minimized.

x0 : ndarray

Initial guess.

fprime : callable f’(x,*args), optional

Function which computes the gradient of f.

args : tuple, optional

Extra arguments passed to f and fprime.

gtol : float, optional

Stop when norm of gradient is less than gtol.

norm : float, optional

Order of vector norm to use. -Inf is min, Inf is max.

epsilon : float or ndarray, optional

If fprime is approximated, use this value for the step size (can be scalar or vector).

callback : callable, optional

An optional user-supplied function, called after each iteration. Called as callback(xk), where xk is the current parameter vector.

Returns :

xopt : ndarray

Parameters which minimize f, i.e. f(xopt) == fopt.

fopt : float

Minimum value found, f(xopt).

func_calls : int

The number of function_calls made.

grad_calls : int

The number of gradient calls made.

warnflag : int

1 : Maximum number of iterations exceeded. 2 : Gradient and/or function calls not changing.

allvecs : ndarray

If retall is True (see other parameters below), then this vector containing the result at each iteration is returned.

Other Parameters:
 

maxiter : int

Maximum number of iterations to perform.

full_output : bool

If True then return fopt, func_calls, grad_calls, and warnflag in addition to xopt.

disp : bool

Print convergence message if True.

retall : bool

Return a list of results at each iteration if True.

See also

minimize
Interface to minimization algorithms for multivariate functions. See the ‘CG’ method in particular.

Notes

Optimize the function, f, whose gradient is given by fprime using the nonlinear conjugate gradient algorithm of Polak and Ribiere. See Wright & Nocedal, ‘Numerical Optimization’, 1999, pg. 120-122.

Previous topic

scipy.optimize.fmin_powell

Next topic

scipy.optimize.fmin_bfgs