BASIN_HOPPING
Overview
The BASIN_HOPPING
function provides a robust global optimization method for single-variable functions using the basinhopping algorithm from SciPy. Basinhopping is a stochastic global optimization technique that combines random perturbations with local minimization to escape local minima and search for the global minimum of a scalar function. It is especially useful for non-convex optimization problems where the objective function may have multiple local minima or complex landscapes.
The basinhopping algorithm seeks to solve
where is the objective function. At each iteration, the algorithm performs a random displacement:
where is a random vector (with user-defined step size). A local minimization is then performed starting from to find:
The new minimum is accepted with probability
where and is the temperature parameter. This approach allows the algorithm to escape local minima by occasionally accepting worse solutions, similar to simulated annealing, and increases the chance of finding the global minimum.
This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=BASIN_HOPPING(func_expr, x_zero, [niter], [T], [stepsize], [minimizer_method])
func_expr
(string, required): Math expression as a string which accepts a single scalar argument and returns a scalar value. Example:"x**2 + 10*sin(x)"
x_zero
(float, required): Initial guess for the variable. Example:0
niter
(int, optional): Number of basinhopping iterations. Example:200
T
(float, optional): Temperature parameter for the acceptance test. Example:1.0
stepsize
(float, optional): Step size for random displacement. Example:0.5
minimizer_method
(string, optional): Local minimization method to use (e.g.,"L-BFGS-B"
,"BFGS"
,"Powell"
). Example:"L-BFGS-B"
The function returns a 2D list: [[minimum, x_min]]
, where the first value is the minimum found and the second value is the location of the minimum.
Examples
Example 1: Global Minimum of a Sine-Modified Quadratic
In Excel:
=BASIN_HOPPING("x**2 + 10*sin(x)", 0, 200, 1.0, 0.5, "L-BFGS-B")
Expected output:
Minimum Value | x_min |
---|---|
-7.945 | -1.306 |
This means the minimum value is approximately -7.945 at .
Live Notebook
Edit this function in a live notebook .