« Back to top page

Hill Climb Local Search Sampler

This sampler used the Hill Climb Algorithm to improve the searching, by selecting the best neighbors and moving in that direction.

Abstract

The hill climbing algorithm is an optimization technique that iteratively improves a solution by evaluating neighboring solutions in search of a local maximum or minimum. Starting with an initial guess, the algorithm examines nearby “neighbor” solutions, moving to a better neighbor if one is found. This process continues until no improvement is possible, resulting in a locally optimal solution. Hill climbing is efficient and easy to implement but can get stuck in local optima, making it suitable for simple optimization landscapes or applications with limited time constraints. Variants like random restarts and stochastic selection help overcome some limitations.

Class or Function Names

  • HillClimbingSampler

Example

import optuna
import optunahub
   
def objective(trial):
    x = trial.suggest_int("x", -10, 10)
    y = trial.suggest_int("y", -10, 10)
    return -(x**2 + y**2)

mod = optunahub.load_module("samplers/hill_climb_search")
sampler = mod.HillClimbingSampler()
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=20)
Package
samplers/hill_climb_search
Author
Chinmaya Sahu
License
MIT License
Verified Optuna version
  • 4.0.0
Last update
2024-11-08