_check_unknown_options(unknown_options)
if line_search not in ("cheng", "cruz"):
raise ValueError("Invalid value %r for "line_search"" % (line_search,))
nexp = 2
if eta_strategy is None:
// Different choice from [1], as their eta is not invariant
// vs. scaling of F.
def eta_strategy(k, x, F):
// Obtain squared 2-norm of the initial residual from the outer scope
return f_0 / (1 + k)**2
if fnorm is None:
def fnorm(F):
// Obtain squared 2-norm of the current residual from the outer scope
return f_k**(1.0/nexp)
def fmerit(F):
return np.linalg.norm(F)**nexp
nfev = [0]
f, x_k, x_shape, f_k, F_k, is_complex = _wrap_func(func, x0, fmerit, nfev, maxfev, args)
k = 0
f_0 = f_k
sigma_k = sigma_0
F_0_norm = fnorm(F_k)
// For the "cruz" line search
prev_fs = collections.deque([f_k], M)
// For the "cheng" line search
Q = 1.0C = f_0
converged = False
message = "too many function evaluations required"