scipy.optimize.brute

scipy.optimize.brute(func, ranges, args=(), Ns=20, full_output=0, finish=<function fmin at 0x431e9b0>)[source]

Minimize a function over a given range by brute force.

Parameters :

func : callable f(x,*args)

Objective function to be minimized.

ranges : tuple

Each element is a tuple of parameters or a slice object to be handed to numpy.mgrid.

args : tuple

Extra arguments passed to function.

Ns : int

Default number of samples, if those are not provided.

full_output : bool

If True, return the evaluation grid.

finish : callable, optional

An optimization function that is called with the result of brute force minimization as initial guess. finish should take the initial guess as positional argument, and take take args, full_output and disp as keyword arguments. See Notes for more details.

Returns :

x0 : ndarray

Value of arguments to func, giving minimum over the grid.

fval : int

Function value at minimum.

grid : tuple

Representation of the evaluation grid. It has the same length as x0.

Jout : ndarray

Function values over grid: Jout = func(*grid).

Notes

The range is respected by the brute force minimization, but if the finish keyword specifies another optimization function (including the default fmin), the returned value may still be (just) outside the range. In order to ensure the range is specified, use finish=None.

Previous topic

scipy.optimize.anneal

Next topic

scipy.optimize.minimize_scalar