A custom conjugate gradient descent algorithm

Module Contents


fmax_cg(f, x0[, maxiters, tol, dfdx_and_bdflag, xopt])

Custom conjugate-gradient (CG) routine for maximizing a function.

pygsti.optimize.customcg.fmax_cg(f, x0, maxiters=100, tol=1e-08, dfdx_and_bdflag=None, xopt=None)

Custom conjugate-gradient (CG) routine for maximizing a function.

This function runs slower than scipy.optimize’s ‘CG’ method, but doesn’t give up or get stuck as easily, and so sometimes can be a better option.



The function to optimize

x0numpy array

The starting point (argument to fn).

maxitersint, optional

Maximum iterations.

tolfloat, optional

Tolerace for convergence (compared to absolute difference in f)

dfdx_and_bdflagfunction, optional

Function to compute jacobian of f as well as a boundary-flag.

xoptnumpy array, optional

Used for debugging, output can be printed relating current optimum relative xopt, assumed to be a known good optimum.


scipy.optimize.Result object

Includes members ‘x’, ‘fun’, ‘success’, and ‘message’. Note: returns the negated maximum in ‘fun’ in order to conform to the return value of other minimization routines.