{ } Raw JSON

bundles / scipy latest / scipy / optimize / _chandrupatla / _chandrupatla_minimize

function

scipy.optimize._chandrupatla:_chandrupatla_minimize

source: /scipy/optimize/_chandrupatla.py :276

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 : callable

The 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_like

The abscissae of a standard scalar minimization bracket. A bracket is valid if x1 < x2 < x3 and func(x1) > func(x2) <= func(x3). Must be broadcastable with one another and args.

args : tuple, optional

Additional positional arguments to be passed to func. Must be arrays broadcastable with x1, x2, and x3. If the callable to be differentiated requires arguments that are not broadcastable with x, wrap that callable with func such that func accepts only x and broadcastable arrays.

xatol, xrtol, fatol, frtol : float, optional

Absolute and relative tolerances on the minimizer and function value. See Notes for details.

maxiter : int, optional

The maximum number of iterations of the algorithm to perform.

callback : callable, optional

An optional user-supplied function to be called before the first iteration and after each iteration. Called as callback(res), where res is a _RichResult similar to that returned by _chandrupatla_minimize (but containing the current iterate's values of all variables). If callback raises a StopIteration, the algorithm will terminate immediately and _chandrupatla_minimize will return a result.

Returns

res : _RichResult

An instance of scipy._lib._util._RichResult with the following attributes. (The descriptions are written as though the values will be scalars; however, if func returns 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

bounded
brent
golden

Aliases

  • scipy.optimize._chandrupatla._chandrupatla_minimize