This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / optimize / _biteopt_py / biteopt

function

scipy.optimize._biteopt_py:biteopt

source: build-install/usr/lib/python3.14/site-packages/scipy/optimize/_biteopt_py.py:13

Signature

def biteopt(func: Callable[Concatenate[np.ndarray, ...], float], bounds: Iterable | Bounds, *, args: tuple = (), callback: Callable[[np.ndarray], object] | None = None, maxfun: int | None = None, depth: int = 1, f_min: float = -inf, rng: int | np.random.Generator | None = None)

Summary

Find the global minimum of a function using the BiteOpt algorithm.

Parameters

func : callable

The objective function to be minimized, func(x, *args) -> float, where x is a 1-D array with shape (n,) and args is a tuple of fixed parameters.

bounds : sequence or `Bounds`

Bounds for variables, specified either as an instance of Bounds or as (min, max) pairs for each element in x. Bounds must be finite and satisfy min < max strictly for every variable; equal bounds (fixing a variable) are not accepted.

args : tuple, optional

Additional fixed parameters passed to the objective function.

callback : callable, optional

Called after each objective evaluation as callback(x), where x is the point that was just evaluated. If the callback raises StopIteration, the optimization stops early and returns with success=False.

maxfun : int, optional

Maximum number of objective function evaluations. Default is 1000 * n, where n is the number of variables inferred from bounds.

depth : int, optional

Number of BiteOpt instances run cooperatively. Whenever one instance finds an improved solution, that solution is injected into another randomly chosen instance for further refinement. This cooperative multi-instance strategy improves the chance of escaping local minima on complex, multi-modal functions but requires a larger function evaluation budget. Valid range is [1, 36]. Default is 1.

f_min : float, optional

Target objective value. The optimization stops early once the best objective value found is less than or equal to f_min. By default (-inf) this criterion is disabled and the full iteration budget is used.

rng : {None, int, `numpy.random.Generator`}, optional

Controls reproducibility. Passed to numpy.random.default_rng; the resulting Generator's bit stream directly drives BiteOpt's internal random draws.

Returns

res : OptimizeResult

The optimization result represented as an OptimizeResult object. Important attributes are: x the solution array, fun the value of the objective at the solution, nfev the number of objective evaluations performed, success a boolean flag indicating whether the optimizer terminated successfully, and message describing the cause of termination. When f_min is set to a value greater than -inf, success is True only if that target was reached. If f_min is -inf (the default), BiteOpt runs its full iteration budget and a completed run reports success as True.

Notes

BiteOpt (BITmask Evolution OPTimization) is a stochastic, population-based, global optimizer that maintains a portfolio of candidate-generation strategies and dynamically tracks their efficiency, favouring whichever works best for the current objective function. This contrasts with classical Differential Evolution, which uses a single fixed strategy throughout [1].

BiteOpt targets low- to medium-dimensional continuous problems with finite box bounds and requires no gradient information. Because the search is stochastic, results depend on the random stream; pass rng for reproducible runs. BiteOpt has proven to be very competitive especially for nonlinear least squares problems [2].

The lock of the Generator derived from rng is held for the duration of the optimization. Drawing from the same Generator inside func is safe.

Examples

The following example is a 2-D problem with four local minima: minimizing the Styblinski-Tang function (https://en.wikipedia.org/wiki/Test_functions_for_optimization).
from scipy.optimize import biteopt, Bounds
def styblinski_tang(pos):
    x, y = pos
    return 0.5 * (x**4 - 16*x**2 + 5*x + y**4 - 16*y**2 + 5*y)
bounds = Bounds([-4., -4.], [4., 4.])
result = biteopt(styblinski_tang, bounds)
✓
result.x, result.fun, result.nfev
✗
(array([-2.904, -2.904]), -78.33233140754281, 2000)
For reproducible results, pass a seed to `rng`:
result = biteopt(styblinski_tang, bounds, rng=1)
✓
result.x, result.fun, result.nfev
✗
(array([-2.904, -2.904]), -78.33233140754281, 2000)
To stop the optimization early once a target objective value is reached, pass `f_min`:
result = biteopt(styblinski_tang, bounds, f_min=-70, rng=1)
✓
result.x, result.fun, result.nfev
✗
(array([-2.673, -2.673]), -76.64070151847848, 38)

Aliases

  • scipy.optimize.biteopt