Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Local Search

Hill Climbing
Introduction
• Hill climbing is a heuristic search technique that makes use of local
knowledge in its attempt to achieve global solution of a given
problem.
• Imagine you are trying to reach the top of a hill in foggy weather. You
are too small to see the peak while you are crawling on the surface of
the hill and there is no clue regarding any path towards the peak.
• How should you proceed?
• One possible way would be to look around your current position and take that step
which elevates you to a higher level.
• You continue in this way until a point is arrived from where all steps result in
positions at lower heights.
• This point is considered to be the maximal point and corresponds to the solution to
be returned.
• The hill climbing strategy is also applied to problems where the purpose is to
reach the lowest point, and not the highest point.
• In such cases, steps which take us to lower heights are followed. This sometimes
referred to as valley descending.
• The hill climbing strategy is widely employed to solve complex optimization problems.
• A hill climbing search must have the following elements

• An objective function whose value is to be optimized. The objective function should somehow
reflect the quality of a solution to the given problem so that the optimized solution corresponds
to the optimal value of the objective function.

• A procedure to map a solution (perhaps sub-optimal) of the given problem to the corresponding
value of the objective function.

• A procedure to generate a new solution from a given solution of the problem


EX 1: A tiny traveling salesperson problem (TSP) with five
cities.

A tour is defined as a path that starts from a given city, travels through the paths to visit every other city
exactly once, and returns to the starting city. We are required to find a minimal cost tour.

If the tour is t = abcdea then its cost cost(t) = cost(ab) + cost(bc) + cost(cd) + cost(de) + cost(ea) = 3 + 10 +
7 + 50 + 12 = 82.
How to generate a new solution of the TSP from a given one?
Now, to illustrate the hill climbing procedure we may consider the of TSP presented in Fig. below

Constraints
1. Every cities are visited once
2. Visit all cities
3. Reach City from where salesman have
started

A random solution adecba denoting the tour a → d → e → c → b → a is considered as the initial solution

The cost of the tour is 109.


To obtain a new tour the links ad and ec are removed from the tour and are substituted by ae and cd. So we obtain
the tour abcdea with cost 82
Only three tours, viz., acebda, abedca, and acbdea shown in Fig can be generated from this tour.

These three tours have costs 69, 78 and 94, respectively. Since all of these are higher than 42, the hill climbing
procedure assumes to have reached a minimal value and the procedure stops here.

It is easy to verify that the other possible tours have costs greater than 42.

The solution returned by the hill climbing process is thus acdbea and the cost of the solution is 42.
Steepest ascent hill climbing

In Algorithm Hill-Climbing a new solution is generated from the current solution and if it is found to be a
better solution then the search proceeds along this new solution without any consideration of any other possible solution
obtainable from the current one.

Steepest ascent hill climbing is a variation of hill climbing, where instead of one all possible solutions from the current
solution are generated and the best among these is chosen for further progress.

For example, if we follow the steepest ascent hill climbing strategy on the initial tour adecba shown in
Fig then the entire set of tours that can be obtained from adecba should be generated and their
costs be evaluated.

Five different tours, acbeda, adbcea, abecda, abdeca, and abcdea, can be generated by transforming adecba. These
tours have costs 99, 73, 57, 100 and 82, respectively . Obviously, tour abecda of cost 57 would be selected for further
exploration.
• It may be noted that the hill climbing method does not create a solution tree.
• The only things it maintains are the current and the newly generated solutions.
• If the new solution is better than the current then it discards the current solution
and update it with the new solution.
• In other words, hill climbing grabs a good neighbour without bothering the after
effects. For this reason hill climbing is also referred to as greedy local search.
Problem Reduction
AND-OR Graphs
• The AND OR graph (or tree),is useful for representing the solution of problems that can be solved by
decomposing them into a set of smaller problems, all of which must then be solved.
• This decomposition, or reduction, generates arcs that we call AND arcs.
• One AND arc may point to any number of children nodes, all of which must be solved in order for the arc to
point to a solution.
Just as in an OR graph, several arcs may emerge from a single node, indicating a variety of ways in which
the original problem might be solved
• In order to find solution in an AND-OR graph, we need an algorithm
similar to best first search but with the ability to handle the AND arcs
appropriately.
• To see why our best first algorithm is not adequate for searching
AND-OR graphs
The most promising single node is G with an f’ value of 3

The problem is that the choice of which node to expand next must be depend not only on the heuristic value of that
node but also on whether that node is part of the current best path from the initial node.
In order to describe an algorithm for searching an AND-OR graph, we need to
exploit a value that we call FUTILITY.

•If the estimated cost of a solution becomes greater than the value of
FUTILITY, then we abandon the search.

•FUTILITY should be chosen to correspond to at threshold such that any


solution with a cost above it is too expensive to be practical, even if it could
ever be found.
A network of four cities

So the given problem a−d is now decomposed into three disjoint


sub-problems, ‘a −d’, ‘a − d via b’, and ‘a − d via c’.

Since the given problem can be solved through any of these three
AND-OR tree for reaching city d from city a.
sub-problems, we have an instance of an OR node.

You might also like