pygsti.optimize.customcg.fmax_cg

Contents

pygsti.optimize.customcg.fmax_cg#

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.

Parameters:
  • f (function) – The function to optimize

  • x0 (numpy array) – The starting point (argument to fn).

  • maxiters (int, optional) – Maximum iterations.

  • tol (float, optional) – Tolerace for convergence (compared to absolute difference in f)

  • dfdx_and_bdflag (function, optional) – Function to compute jacobian of f as well as a boundary-flag.

  • xopt (numpy array, optional) – Used for debugging, output can be printed relating current optimum relative xopt, assumed to be a known good optimum.

Returns:

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.

Return type:

scipy.optimize.Result object