Parallel Grid Search in Python: A Faster Alternative to scipy.optimize.brute
Building a Python Grid Search Optimizer Faster than scipy.optimize.brute Grid search is one of the simplest ways to optimize a function: evaluate the objective function at every point on a grid, th...

Source: DEV Community
Building a Python Grid Search Optimizer Faster than scipy.optimize.brute Grid search is one of the simplest ways to optimize a function: evaluate the objective function at every point on a grid, then keep the best result. Python already ships with a tool for this in scipy.optimize.brute. It works well, but once the grid gets large, performance becomes a bottleneck because the search cost grows exponentially with each added dimension. I built gridoptim to make that workflow faster while keeping the brute-force, deterministic behavior that makes grid search useful in the first place. The Problem with scipy.optimize.brute Consider this 4-variable objective: f(x, y, z, w) = x^2 + y^2 + z^2 + w^2 + 0.10xy - 0.20zw + 0.05xz + 0.03yw + 3x - 2y + z - 0.5w If we evaluate it on a grid with 64 points per dimension, that gives: 64^4 = 16,777,216 evaluations Here is what that looks like with SciPy: from scipy.optimize import brute def objective(v): x, y, z, w = v return ( x * x + y * y + z * z + w