bundles / scipy 1.17.1 / scipy / optimize / _chandrupatla / _chandrupatla_minimize
function
scipy.optimize._chandrupatla:_chandrupatla_minimize
Signature
def _chandrupatla_minimize ( func , x1 , x2 , x3 , * , args = () , xatol = None , xrtol = None , fatol = None , frtol = None , maxiter = 100 , callback = None ) Summary
Find the minimizer of an elementwise function.
Extended Summary
For each element of the output of func, _chandrupatla_minimize seeks the scalar minimizer that minimizes the element. This function allows for x1, x2, x3, and the elements of args to be arrays of any broadcastable shapes.
Parameters
func: callableThe function whose minimizer is desired. The signature must be
func(x: ndarray, *args) -> ndarray where each element of ``x`` is a finite real and ``args`` is a tuple, which may contain an arbitrary number of arrays that are broadcastable with `x`. ``func`` must be an elementwise function: each element ``func(x)[i]`` must equal ``func(x[i])`` for all indices ``i``. `_chandrupatla` seeks an array ``x`` such that ``func(x)`` is an array of minima.
x1, x2, x3: array_likeThe abscissae of a standard scalar minimization bracket. A bracket is valid if
x1 < x2 < x3andfunc(x1) > func(x2) <= func(x3). Must be broadcastable with one another andargs.args: tuple, optionalAdditional positional arguments to be passed to
func. Must be arrays broadcastable withx1,x2, andx3. If the callable to be differentiated requires arguments that are not broadcastable withx, wrap that callable withfuncsuch thatfuncaccepts onlyxand broadcastable arrays.xatol, xrtol, fatol, frtol: float, optionalAbsolute and relative tolerances on the minimizer and function value. See Notes for details.
maxiter: int, optionalThe maximum number of iterations of the algorithm to perform.
callback: callable, optionalAn optional user-supplied function to be called before the first iteration and after each iteration. Called as
callback(res), whereresis a_RichResultsimilar to that returned by _chandrupatla_minimize (but containing the current iterate's values of all variables). Ifcallbackraises aStopIteration, the algorithm will terminate immediately and _chandrupatla_minimize will return a result.
Returns
res: _RichResultAn instance of scipy._lib._util._RichResult with the following attributes. (The descriptions are written as though the values will be scalars; however, if
funcreturns an array, the outputs will be arrays of the same shape.)success
success
status
status
x
x
fun
fun
nfev
nfev
nit
nit
xl,xm,xr
xl, xm, xr
fl,fm,fr
fl, fm, fr
Notes
Implemented based on Chandrupatla's original paper [1].
If x1 < x2 < x3 are the points of the bracket and f1 > f2 <= f3 are the values of func at those points, then the algorithm is considered to have converged when x3 - x1 <= abs(x2)*xrtol + xatol or (f1 - 2*f2 + f3)/2 <= abs(f2)*frtol + fatol. Note that first of these differs from the termination conditions described in [1]. The default values of xrtol is the square root of the precision of the appropriate dtype, and xatol = fatol = frtol is the smallest normal number of the appropriate dtype.
Examples
from scipy.optimize._chandrupatla import _chandrupatla_minimize def f(x, args=1): return (x - args)**2 res = _chandrupatla_minimize(f, -5, 0, 5)✓
res.x
✗c = [1, 1.5, 2] res = _chandrupatla_minimize(f, -5, 0, 5, args=(c,)) res.x✓
See also
Aliases
-
scipy.optimize._chandrupatla._chandrupatla_minimize