Local Search#
Local search optimizers explore the neighborhood of the current best solution. They are fast but may get stuck in local optima.
These optimizers work by iteratively improving from a starting point, making small adjustments to find better solutions nearby.
Hill Climbing#
The simplest local search: always move to a better neighbor.
from hyperactive.opt.gfo import HillClimbing
optimizer = HillClimbing(
search_space=search_space,
n_iter=100,
experiment=objective,
)
Simulated Annealing#
Like hill climbing, but sometimes accepts worse solutions to escape local optima. The “temperature” controls exploration vs exploitation.
from hyperactive.opt.gfo import SimulatedAnnealing
optimizer = SimulatedAnnealing(
search_space=search_space,
n_iter=100,
experiment=objective,
)
Stochastic Hill Climbing#
Hill climbing with a probability of accepting worse solutions. The p_accept
parameter controls exploration: higher values make it more likely to accept
non-improving moves, helping escape local optima.
from hyperactive.opt.gfo import StochasticHillClimbing
optimizer = StochasticHillClimbing(
search_space=search_space,
n_iter=100,
experiment=objective,
p_accept=0.3, # Probability of accepting worse solutions
)
Repulsing Hill Climbing#
Remembers visited regions and avoids them, encouraging broader exploration.
from hyperactive.opt.gfo import RepulsingHillClimbing
optimizer = RepulsingHillClimbing(
search_space=search_space,
n_iter=100,
experiment=objective,
)
Downhill Simplex (Nelder-Mead)#
Uses a simplex of points to navigate the search space. Good for continuous problems.
from hyperactive.opt.gfo import DownhillSimplexOptimizer
optimizer = DownhillSimplexOptimizer(
search_space=search_space,
n_iter=100,
experiment=objective,
)
When to Use Local Search#
Local search optimizers are best suited for:
Quick initial exploration: Get a baseline result fast
Smooth, unimodal landscapes: When there’s a single optimum to find
Refinement: Fine-tune solutions found by global methods
Limited budget: When you can only afford a few evaluations
Consider using global or population-based methods if:
Your landscape has many local optima
You’re not finding good solutions with local search
You need more robust exploration