Hill Climbing Algorithm

Hill Climbing Algorithm

Hill climbing search is a local search problem. The purpose of the hill climbing search is to climb a hill and reach the topmost peak/point of that hill. It is based on the heuristic search technique where the person who is climbing up on the hill estimates the direction which will lead him to the highest peak.                                         

State-space Landscape of Hill climbing algorithm

To understand the concept of hill climbing algorithm, consider the below landscape representing the goal state/peak and the current state of the climber. The topographical regions shown in the figure can be defined as:

  • Global Maximum: It is the highest point on the hill, which is the goal state.
  • Local Maximum: It is the peak higher than all other peaks but lower than the global maximum.
  • Flat local maximum: It is the flat area over the hill where it has no uphill or downhill. It is a saturated point of the hill.
  • Shoulder: It is also a flat area where the summit is possible.
  • Current state: It is the current position of the person.

Types of Hill climbing search algorithm

There are following types of hill-climbing search:

  • Simple hill climbing
  • Steepest-ascent hill climbing
  • Stochastic hill climbing
  • Random-restart hill climbing
Hill climbing search algorithm

Simple hill climbing search

Simple hill climbing is the simplest technique to climb a hill. The task is to reach the highest peak of the mountain. Here, the movement of the climber depends on his move/steps. If he finds his next step better than the previous one, he continues to move else remain in the same state. This search focus only on his previous and next step.

Simple hill climbing Algorithm

  1. Create a CURRENT node, NEIGHBOUR node, and a GOAL node.
  2. If the CURRENT node=GOAL node, return GOAL and terminate the search.
  3. Else  CURRENT node<= NEIGHBOUR node, move ahead.
  4. Loop until the goal is not reached or a point is not found.

Steepest-ascent hill climbing

Steepest-ascent hill climbing is different from simple hill climbing search. Unlike simple hill climbing search, It considers all the successive nodes, compares them, and choose the node which is closest to the solution. Steepest hill climbing search is similar to best-first search because it focuses on each node instead of one.

Note: Both simple, as well as steepest-ascent hill climbing search, fails when there is no closer node.

Steepest-ascent hill climbing algorithm

  1. Create a CURRENT node and a GOAL node.
  2. If the CURRENT node=GOAL node, return GOAL and terminate the search.
  3. Loop until a better node is not found to reach the solution.
  4. If there is any better successor node present, expand it.
  5. When the GOAL is attained, return GOAL and terminate.

Stochastic hill climbing

Stochastic hill climbing does not focus on all the nodes. It selects one node at random and decides whether it should be expanded or search for a better one.

Random-restart hill climbing

Random-restart algorithm is based on try and try strategy. It iteratively searches the node and selects the best one at each step until the goal is not found. The success depends most commonly on the shape of the hill. If there are few plateaus, local maxima, and ridges, it becomes easy to reach the destination.

Limitations of Hill climbing algorithm

Hill climbing algorithm is a fast and furious approach. It finds the solution state rapidly because it is quite easy to improve a bad state. But, there are following limitations of this search:

  • Local Maxima: It is that peak of the mountain which is highest than all its neighboring states but lower than the global maxima. It is not the goal peak because there is another peak higher than it.
Local Maxima Hill climbing search
  • Plateau: It is a flat surface area where no uphill exists. It becomes difficult for the climber to decide that in which direction he should move to reach the goal point. Sometimes, the person gets lost in the flat area.
  • Ridges: It is a challenging problem where the person finds two or more local maxima of the same height commonly. It becomes difficult for the person to navigate the right point and stuck to that point itself.

Simulated Annealing

Simulated annealing is similar to the hill climbing algorithm.  It works on the current situation. It picks a random move instead of picking the best move. If the move leads to the improvement of the current situation, it is always accepted as a step towards the solution state, else it accepts the move having a probability less than 1. This search technique was first used in 1980 to solve VLSI layout problems. It is also applied for factory scheduling and other large optimization tasks.

Local Beam Search

Local beam search is quite different from random-restart search. It keeps track of states instead of just one. It selects randomly generated states, and expand them at each step. If any state is a goal state, the search stops with success. Else it selects the best k successors from the complete list and repeats the same process. In random-restart search where each search process runs independently, but in local beam search, the necessary information is shared between the parallel search processes.

Disadvantages of Local Beam search

  • This search can suffer from a lack of diversity among the k states.
  • It is an expensive version of hill climbing search.

Note: A variant of Local Beam Search is Stochastic Beam Search which selects k successors at random rather than choosing the best k successors.

Follow Us On