Lecture 5 Heuristic Search Strategies
Lecture 5 Heuristic Search Strategies
b
S G
4 5 6 6 5 4
7 8 8 7
Types of Heuristic Functions
• Admissible
This Function Never overestimate the cost of
reaching the goal
H(n) is always less than or equal to the actual A
cost of lowest path from N to Goal Node 1 1
1
• Non Admissible
H(B)=3 B
This Function overestimate the cost of reaching C D
the goal 3 H(C)=4 H(D)=5
H(n) is always greater than the actual cost of
H(E)=2 E
lowest path from N to Goal Node
5
2
H(F)=1 F G
Types of Heuristic Functions
• Admissible
This Function Never overestimate the cost of
reaching the goal
H(n) is always less than or equal to the actual A
cost of lowest path from N to Goal Node 1 1
1
• Non Admissible
H(B)=3 B
This Function overestimate the cost of reaching C D
the goal 3 H(C)=4 H(D)=5
H(n) is always greater than the actual cost of
H(E)=2 E
lowest path from N to Goal Node
5 3
2
H(F)=1 F G
Hill Climbing in Artificial Intelligence
• Local Search Algorithm ( Local Domain Knowledge)
• Greedy Approach (only looks to its good immediate neighbor state not beyond
that as well as moves in the direction which optimizes the cost.)
• No Backtracking
• It is a variant of the generate-and-test algorithm in which feedback from test
procedure is used to help generator to decide which direction to move in search
space.
• A node of hill climbing algorithm has two components which are state and
value.
• Always Moves In Single Direction
• If New State is better or Equal than current state then consider new state as
current state.
Types of Hill Climbing in AI
• Simple Hill Climbing
This examines one neighboring node at a time
and selects the first one that optimizes the
current cost to be the next node.
• Steepest Ascent Hill Climbing
This examines all neighboring nodes and
selects the one closest to the solution state.
• Stochastic Hill Climbing
This selects a neighboring node at random
and decides whether to move to it or examine
another.
Flow Chart of Hill
Climbing
Example of Hill Climbing Search
4 6
5
Simplest Ascent Hill Climbing A =4
g
bin
lim
• In Steepest Ascent Hill Climbing
ll C
Hi
Multiple points are checked. B=5
ple
Sim
• In Steepest Ascent Hill Climbing, A=4
Algorithms select the best among the
children states that are better than D=6
current State.
C=6
• All moves are considered and best one B=5
is selected as next state.
• Examine all the neighboring nodes and
selects nodes closet to solution as next D=6 F=3 G=8
node.
Steepest Ascent Hill Climbing
Evaluate Initial State
No
Better
than Yes, Solution / Quit
CS
Problems with Hill Climbing in AI
Local Maximum
A local maximum is a peak state in the landscape
which is better than each of its neighboring states,
but there is another state also present which is
higher than the local maximum.
Plateau
A plateau is the flat area of the search space in
which all the neighbor states of the current state
contains the same value, because of this algorithm
does not find any best direction to move. A
hill-climbing search might be lost in the plateau Ridge
area.
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.
Pure Heuristic Search
• Pure heuristic search is the simplest form of heuristic search algorithms that
expands nodes based on their heuristic value h(n).
• It maintains two lists, OPEN and CLOSED list.
CLOSED list contains those nodes which have already expanded
OPEN list, contains those nodes which have yet not been expanded.
• On each iteration, each node n with the lowest heuristic value is expanded and
generates all its successors and n is placed to the closed list.
• The algorithm continues unit a goal state is found.
• In the pure heuristic search two main algorithms will discussed which are given
below:
Best First Search Algorithm
A* Search Algorithm
Best-first Search Algorithm (Greedy Search)
• Best-first search algorithm always selects
the path which appears best at that Priority Queue (PQ) Containing Initial State
moment. Loop
• It is the combination of depth-first search If PQ = Empty Return Failure
and breadth-first search algorithms. It
uses the heuristic function and search. Else
• With the help of best-first search, at each Node Remove-First (PQ)
step, we can choose the most promising If Node = Goal
node.
Return Path from Initial to Node
• Utilize Evaluation algorithm (Function)
to decide which adjacent node is more Else
promising and than explore. Generate all successor of Node
and
• The Best first algorithm is implemented insert newly generated Node into
by the priority queue (PQ). (PQ) According to Cost Value
Open List Closed List
Best-first Search Algorithm [A] [ ]
(Straight Line Distance)
[C, B, D] [A ]
Path [A , C, F, G ]
Best-first Search Algorithm (Class Activity)
(Straight Line Distance)
Best-first Search Algorithm (Class Activity)
(Straight Line Distance)
• Expand the nodes of S and put in the CLOSED list
• Initialization:
Open [A, B], Closed [S]
• Iteration 1:
Open [A], Closed [S, B]
• Iteration 2:
Open [E, F, A], Closed [S, B]
Open [E, A], Closed [S, B, F]
• Iteration 3:
Open [I, G, E, A], Closed [S, B, F]
Open [I, E, A], Closed [S, B, F, G]
• Hence the final solution path will be: S----> B----->F----> G
Best-first Search Algorithm
• Time Complexity
The worst case time complexity of best first search is O(b d).
• Space Complexity
The worst case space complexity of best first search is O(b d).
Where, d is the maximum depth of the search space.
• Complete
Best-first search is also incomplete, even if the given state space is finite.
• Optimal
Best first search algorithm is not optimal.