Hill Climbing Algorithm in AI

Hill Climbing Algorithm

A local search technique known as "hill climbing" continuously moves toward a greater value to locate the problem's optimal solution or the highest point of the mountain. 

The hill climbing algorithm generates and tests variants while taking a greedy approach and not going back.

Hill climbing is used when the path to the goal does not matter. In this search method, the state space landscape is considered.

Hill climbing Graph

Algorithm of Hill Climbing

  • Step 1: Analyze the starting state. Return success and stop if it is in the desired state.
  • Step 2: Encircle until a fix is discovered or no more operators can apply
  • Step 3: Choose an operator and apply it to the present state
  • Step 4: Verify the new state. If it's the desired state, return to success and end the process. Otherwise, mark a new state as the current state if it is superior to the present state. If not, go back to step 2 if it's not better than the situation as it is
  • Step 5: Exit

Hill Climbing algorithm example

One type of search that is classified as informed is the Hill Climbing Algorithm. Thus, we may use it to implement any node-based search or solve problems such as the n-queens problem. To facilitate comprehension of the idea, we will use a very basic example.

Let's examine the picture below:

Selecting the right heuristic function is crucial when tackling any hill-climbing issue. Let's specify this function, h:

If the block is positioned appropriately, h(x) = +1 for every block in the support structure; if not, h(x) = -1 for every block in the support structure.

Here, if a block has the same support structure as the desired state, we shall refer to it as correctly positioned. In accordance with the previously mentioned hill-climbing process, let's examine each iteration and its corresponding heuristics to arrive at the desired state:

Features of Hill Climbing Algorithm

The following are some main features of the Hill Climbing Algorithm: 

1. Generate and Test variant

Hill Climbing is the variant of the Generate and Test method. The Generate and Test method produces feedback which helps to decide which direction to move in the search space.

2. Greedy approach

Hill-climbing algorithm search moves in the direction that optimizes the cost.

3. No backtracking

It does not backtrack the search space, as it does not remember the previous states.

Types of Hill Climbing Algorithm

Various Algorithms for Climbing Hills:

  • Simple hill Climbing 
  • The steepest ascent of a hill 
  • Stochastic hill Climbing 

1. Simple Hill Climbing

The most straightforward method of putting a hill climbing algorithm into practice is basic hill climbing. Only one neighbor node state is evaluated at a time, and the current state is set to the first that maximizes the current cost. It only looks at one successor state, and if that state proves to be superior to the current one, it moves on; otherwise, it remains in the same condition.

The features of Simple Hill Climbing algorithm are as follows:

  • Less effort 
  • Time less-than-ideal answer, and there is no guarantee of the solution 
  • It uses a greedy approach 

Simple Hill Climbing Algorithm

Step 1: Examine the current condition; if it is the desired state, return success and stop. 

Step 2: Encircle until a fix is discovered or no more operators can apply.

Step 3: Choose an operator and apply it to the present situation.

Step 4: Verify the updated state Return to success and give up if that is the desired state. Otherwise, identify the new state as the current state if it is superior to the present state. If not, go back to step 2 if it's not better than the situation as it is. 

Step 5: Go out


2. Steepest-Ascent Hill Climbing:

This method of hill climbing is a variant of the simple algorithm. The current state's neighbors are all examined by this process, which then chooses the neighbor node that is closest to the target state. This method takes longer to run because it looks for several neighbors.

The Steepest-Ascent hill climbing algorithm: 

Step 1: Examine the starting point; if it is the desired state, return success and end the process; if not, set the current state as the starting point. 

Step 2: Continue until an answer is found or the situation stays the same. 

Let Success be a state in which every state that comes after the current one is superior to it.

Regarding every operator applicable to the present state:

a. Create a new state and apply the new operator.

b. Examine the just-created state.

c. Return it and stop if it's in the goal state; if not, compare it to the Success. 

d. Establish the new state as Success if it performs better than Success.

 e. The present state should be set to Success if it is superior to it.

Step 5: Exit.

3. Stochastic hill climbing:

This technique doesn't look for every neighbor before making a move. Instead, this search algorithm arbitrarily chooses one neighbor node and determines whether to investigate alternative states or select the selected node as the current state.

Problem of Hill Climbing Algorithm

When a deformative, dependable function is present to direct the search toward a global objective, hill climbing can yield significant savings over blind searches.

If this is not the case, it has major shortcomings.

Local maxima

A local maximum is a state at the top of the landscape that is superior to every state that surrounds it, but there is also another state that is higher than the local maximum. 

Solution: The backtracking technique can be a solution to the local maximum in-state space landscape. Make a list of the most promising paths so that the algorithm can investigate other paths by going backward in the search space.

Plateau

Plateau is a level section of the search space where every neighboring state of the current state has the same value; this is the result of the algorithm not being able to determine the optimal direction for movement. On the plateau, a search involving hill climbing may prove unsuccessful.

Solution: The way to break through the plateau is to start looking for a solution, whether it be by taking large or small measures. Choose a state at random that is remote from the present state in order to increase the likelihood that the algorithm will locate a non-plateau region.

Ridge

A ridge is a special form of the local maximum. It has an area which is higher than its surrounding areas, but itself has a slope, and cannot be reached in a single move.

Solution: We can make this problem better by using bidirectional search or by going in separate directions.

     

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Below Post Ad

Ads Section