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: callableThe objective function to be minimized,
func(x, *args) -> float, wherexis a 1-D array with shape(n,)andargsis 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 inx. Bounds must be finite and satisfymin < maxstrictly for every variable; equal bounds (fixing a variable) are not accepted.args: tuple, optionalAdditional fixed parameters passed to the objective function.
callback: callable, optionalCalled after each objective evaluation as
callback(x), wherexis the point that was just evaluated. If the callback raises StopIteration, the optimization stops early and returns withsuccess=False.maxfun: int, optionalMaximum number of objective function evaluations. Default is
1000 * n, wherenis the number of variables inferred frombounds.depth: int, optionalNumber 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, optionalTarget 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`}, optionalControls reproducibility. Passed to numpy.random.default_rng; the resulting Generator's bit stream directly drives BiteOpt's internal random draws.
Returns
res: OptimizeResultThe optimization result represented as an OptimizeResult object. Important attributes are:
xthe solution array,funthe value of the objective at the solution,nfevthe number of objective evaluations performed,successa boolean flag indicating whether the optimizer terminated successfully, andmessagedescribing the cause of termination. Whenf_minis set to a value greater than -inf,successisTrueonly if that target was reached. Iff_minis -inf (the default), BiteOpt runs its full iteration budget and a completed run reportssuccessasTrue.
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