0% found this document useful (0 votes)
65 views27 pages

Hill Climbing Algo

Uploaded by

nmmishra77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views27 pages

Hill Climbing Algo

Uploaded by

nmmishra77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

INTRODUCTION TO AI

(Hill Climbing Algorithm)


Dr. Virendra Singh Kushwah
Assistant Professor Grade-II
School of Computing Science and Engineering
[email protected]
7415869616
What is Hill Climbing Algorithm?
• Hill Climbing is a heuristic search used for mathematical optimization problems in
the field of Artificial Intelligence.

• So, given a large set of inputs and a good heuristic function, the algorithm tries to
find the best possible solution to the problem in the most reasonable time period.
This solution may not be the absolute best(global optimal maximum) but it is
sufficiently good considering the time allotted.

• The definition above implies that hill-climbing solves the problems where we need to
maximize or minimize a given real function by selecting values from the given inputs.

• A great example of this is the Travelling Salesman Problem where we need to


minimize the distance travelled by the salesman.
Features of Hill Climbing
• It carries out a Heuristic search.

• A heuristic function is one that ranks all the potential alternatives in a


search algorithm based on the information available. It helps the
algorithm to select the best route to its solution.

• This basically means that this search algorithm may not find the
optimal solution to the problem but it will give the best possible
solution in a reasonable amount of time.
• It is a variant of the generate-and-test algorithm.

• The algorithm is as follows :

• Step1: Generate possible solutions.

• Step2: Evaluate to see if this is the expected


solution.

• Step3: If the solution has been found quit else go


back to step 1.
Hill climbing takes the feedback from the test
procedure and the generator uses it in deciding
the next move in the search space. Hence, we call
it as a variant of the generate-and-test algorithm.
• It uses the Greedy approach.

• At any point in state space, the search moves in that direction only
which optimizes the cost of function with the hope of finding the
most optimum solution at the end.
State Space diagram for Hill
Climbing
• The State-space diagram is a graphical representation of the set
of states(input) our search algorithm can reach vs the value of
our objective function(function we intend to
maximize/minimize). Here;
• 1. The X-axis denotes the state space i.e. states or configuration
our algorithm may reach.
• 2. The Y-axis denotes the values of objective function
corresponding to a particular state.
• The best solution will be that state space where objective
function has maximum value or global maxima.
• Following are the different regions in the State Space Diagram;

• Local maxima: It is a state which is better than its neighboring state however there exists
a state which is better than it (global maximum). This state is better because here the value
of the objective function is higher than its neighbors.
• Global maxima: It is the best possible state in the state space diagram. This because at
this state, objective function has the highest value.
• Plateau/flat local maxima: It is a flat region of state space where neighboring states have
the same value.
• Ridge: It is a region which is higher than its neighbor's but itself has a slope. It is a special
kind of local maximum.
• Current state: The region of state space diagram where we are currently present during
the search. (Denoted by the highlighted circle in the given image.)
Types of Hill Climbing
• 1. Simple Hill Climbing

• Simple hill climbing is the simplest way to implement a hill-climbing


algorithm. It only evaluates the neighbor node state at a time and selects
the first one which optimizes current cost and set it as a current state. It
only checks it’s one successor state, and if it finds better than the current
state, then move else be in the same state. This algorithm has the
following features:

• Less time consuming


• Less optimal solution
• The solution is not guaranteed
Algorithm for Simple Hill Climbing
• Step 1: Evaluate the initial state, if it is goal state then return
success and Stop.
• Step 2: Loop Until a solution is found or there is no new operator
left to apply.
• Step 3: Select and apply an operator to the current state.
• Step 4: Check new state:
• If it is goal state, then return success and quit.
• else if it is better than the current state then assign new state as
a current state.
• else if not better than the current state, then return to step 2.
• Step 5: Exit.
• 2. Steepest-Ascent hill climbing

• The steepest-Ascent algorithm is a variation of the simple hill-


climbing algorithm. This algorithm examines all the neighboring
nodes of the current state and selects one neighbor node which is
closest to the goal state. This algorithm consumes more time as it
searches for multiple neighbors.
Algorithm for Steepest-Ascent hill
climbing
• Step 1: Evaluate the initial state, if it is goal state then return success and stop,
else make the current state as your initial state.
• Step 2: Loop until a solution is found or the current state does not change.
• Let S be a state such that any successor of the current state will be better
than it.
• For each operator that applies to the current state;
• Apply the new operator and generate a new state.
• Evaluate the new state.
• If it is goal state, then return it and quit, else compare it to the S.
• If it is better than S, then set new state as S.
• If the S is better than the current state, then set the current state to S.
• Step 3: Exit.
• 3. Stochastic hill climbing

• Stochastic hill climbing does


not examine for all its
neighbors before moving.
Rather, this search algorithm
selects one neighbor node at
random and evaluate it as a
current state or examine
another state.
Problems in different regions in Hill
climbing
• Hill climbing cannot reach the best possible state if it enters any of the following
regions :

• 1. Local maximum: At a local maximum all neighboring states have values which are
worse than the current state. Since hill-climbing uses a greedy approach, it will not
move to the worse state and terminate itself. The process will end even though a
better solution may exist.

To overcome the local maximum problem:


Utilize the backtracking technique. Maintain a
list of visited states. If the search reaches an
undesirable state, it can backtrack to the
previous configuration and explore a new path.
• 2. Plateau: On the plateau, all neighbors have the same value. Hence, it is not
possible to select the best direction.

• To overcome plateaus: Make a big jump. Randomly select a state far away
from the current state. Chances are that we will land at a non-plateau region
• 3. Ridge: Any point on a ridge can look like a peak because the movement in
all possible directions is downward. Hence, the algorithm stops when it
reaches such a state.
• To overcome Ridge: You could use two or more rules before testing. It implies
moving in several directions at once.
Applications of Hill Climbing
Technique
• Hill Climbing technique can be
used to solve many problems,
where the current state allows
for an accurate evaluation
function, such as Network-Flow,
Travelling Salesman problem, 8-
Queens problem, Integrated
Circuit design, etc.

• Hill Climbing is used in


inductive learning methods too.
This technique is also used in
robotics for coordinating
multiple robots in a team.
• Robotics

• Hill climbing Is mostly used in robotics which helps their system to work as
a team and maintain coordination.

• Marketing

• The algorithm can be helpful in team management in various marketing


domains where hill climbing can be used to find an optimal solution. The
travelling time taken by a sale member or the place he visited per day can
be optimized using this algorithm.
Simulated Annealing
• A hill-climbing algorithm which never makes a move towards a lower value
guaranteed to be incomplete because it can get stuck on a local maximum.
And if algorithm applies a random walk, by moving a successor, then it may
complete but not efficient. Simulated Annealing is an algorithm which yields
both efficiency and completeness.

• In mechanical term Annealing is a process of hardening a metal or glass to a


high temperature then cooling gradually, so this allows the metal to reach a
low-energy crystalline state. The same process is used in simulated annealing
in which the algorithm picks a random move, instead of picking the best
move. If the random move improves the state, then it follows the same path.
Otherwise, the algorithm follows the path which has a probability of less than
1 or it moves downhill and chooses another path.
Advantage of Hill Climbing
Algorithm in Artificial Intelligence
• Advantage of Hill Climbing Algorithm in Artificial Intelligence is given below:

• Hill Climbing is very useful in routing-related problems like Travelling Salesmen


Problem, Job Scheduling, Chip Designing, and Portfolio Management
• It is good in solving the optimization problem while using only limited
computation power
• It is more efficient than other search algorithms

• Hill Climbing Algorithm is a very widely used algorithm for Optimization related
problems as it gives decent solutions to computationally challenging problems. It
has certain drawbacks associated with it like its Local Minima, Ridge, and Plateau
problem which can be solved by using some advanced algorithm.
Advantages of Hill Climbing In
Artificial Intelligence
1. Hill Climbing In Artificial Intelligence can be utilized nonstop, just like a
domain. It is beneficial in routing the related problems—for example,
portfolio management, chip designing, and job scheduling.
2. Hill Climbing is a good option in optimizing the problems when you
are limited to computational power.
3. This one is more efficient in contrast to other search algorithms.
4. Hill Climbing procedures are valuable in terms of vehicle routing,
automatic programming, circuit designing, etc.
5. It can tackle unadulterated advancement issues where the goal is to
point out the best suitable state (following the procedure or the goal
work).
Disadvantages of Hill Climbing In
Artificial Intelligence
• Hill Climbing Algorithm is one of the widely used algorithms for
optimizing the given problems. It provides outstanding solutions to
computationally challenging situations and has certain drawbacks also.
The disadvantages related to it are:

• Local Minima
• Ridge
• Plateau

• You can solve these drawbacks by using some advanced algorithms.

You might also like