An iterative local search algorithm that moves toward better solutions one step at a time.
Hill climbing is a local search and optimization algorithm that works by starting from an initial candidate solution and repeatedly applying small modifications, keeping any change that improves the objective function and discarding those that do not. The name comes from the analogy of climbing a hill in a fitness landscape: at each step, the algorithm looks at neighboring states and moves to whichever neighbor is higher (or lower, for minimization problems). Because it only needs to evaluate nearby states rather than the entire search space, hill climbing is computationally lightweight and easy to implement, making it a natural first choice for many optimization tasks in machine learning and AI.
Despite its simplicity, hill climbing has well-known failure modes. The algorithm can become trapped in local optima — peaks that are not the global maximum — as well as on plateaus where all neighbors have equal value, or at ridges where progress requires moving in directions the algorithm cannot detect. These limitations mean that a basic hill climber offers no guarantee of finding the globally optimal solution. Several variants have been developed to address this: stochastic hill climbing introduces randomness in neighbor selection to escape flat regions; random-restart hill climbing runs the algorithm multiple times from different starting points; and simulated annealing allows occasional downhill moves with a probability that decreases over time, borrowing ideas from statistical mechanics to trade off exploration and exploitation.
In machine learning, hill climbing appears in hyperparameter tuning, neural architecture search, and combinatorial optimization problems where gradient information is unavailable or expensive to compute. It also serves as a conceptual baseline against which more sophisticated methods — such as evolutionary algorithms, Bayesian optimization, and gradient descent — are compared. Understanding hill climbing's strengths and weaknesses helps practitioners choose appropriate search strategies and appreciate why methods that escape local optima are necessary for complex, non-convex problems. Its enduring relevance lies in the fact that many real-world optimization landscapes are too large for exhaustive search, making greedy local improvement a practical and often surprisingly effective strategy.