scipy.optimize.

biteopt#

scipy.optimize.biteopt(func, bounds, *, args=(), callback=None, maxfun=None, depth=1, f_min=-inf, rng=None)[source]#

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

Parameters:
funccallable

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.

boundssequence 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.

argstuple, optional

Additional fixed parameters passed to the objective function.

callbackcallable, 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.

maxfunint, optional

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

depthint, 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_minfloat, 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:
resOptimizeResult

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.

Added in version 2.0.0.

References

[1]

Aleksey Vaneev. “BiteOpt - Derivative-Free Global Optimization Method (C++)”. avaneev/biteopt

[2]

Andrea Gavana. “NIST benchmark”. https://infinity77.net/go_2021/nist.html

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.90353406, -2.90353401]), -78.3323279095383, 2000  # may vary

For reproducible results, pass a seed to rng:

>>> result = biteopt(styblinski_tang, bounds, rng=1)
>>> result.x, result.fun, result.nfev
array([-2.90353402, -2.90353405]), -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.67348466, -2.67348466]), -76.64070151847848, 38