0% found this document useful (0 votes)
450 views

Lecture 4 Heuristic Search Strategies

The document discusses various heuristic search techniques used in artificial intelligence. It describes heuristic search as a technique to solve problems faster than classic methods or find approximate solutions. The key points are: - Heuristic search uses heuristic functions to evaluate nodes and guide the search towards the goal. Common types include admissible and non-admissible heuristics. - Hill climbing is a local search algorithm that uses greedy techniques to find a local optimum. Variations include simple, steepest ascent, and stochastic hill climbing. - Pure heuristic search algorithms like best-first search use heuristics to order nodes in an open list and select the most promising nodes to expand first.

Uploaded by

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

Lecture 4 Heuristic Search Strategies

The document discusses various heuristic search techniques used in artificial intelligence. It describes heuristic search as a technique to solve problems faster than classic methods or find approximate solutions. The key points are: - Heuristic search uses heuristic functions to evaluate nodes and guide the search towards the goal. Common types include admissible and non-admissible heuristics. - Hill climbing is a local search algorithm that uses greedy techniques to find a local optimum. Variations include simple, steepest ascent, and stochastic hill climbing. - Pure heuristic search algorithms like best-first search use heuristics to order nodes in an open list and select the most promising nodes to expand first.

Uploaded by

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

Week 4

Heuristic Search Strategies


By

Dr. Fazeel Abid


Assistant Professor
The University of Lahore
Heuristic Search Techniques in AI
• Heuristic Search is also known as:
Informed Search
Heuristic Control Strategy
• These are effective if applied correctly to the right types of tasks.
• Usually demand domain-specific information.
• Extra information need to compute preference among child nodes to explore
and expand.
• Each node has a heuristic function associated with it.
What is a Heuristic Search?

• A Heuristic is a technique to solve a problem faster than classic methods, or to


find an approximate solution when classic methods cannot.
• Tries to Solve a Problem in Minimum Number of Steps/Cost.
• A Heuristic Function takes a look at search algorithms.
 At each branching step, it evaluates the available information and makes a decision on
which branch to follow.
An Estimation on the cost of getting from N-node to G-node (Goal Node)

• It does so by ranking alternatives. Example?


• The Heuristic is any device that is often effective but will not guarantee work in
every case.
Why do we need heuristics?
•  One reason is to produce in a reasonable amount of time, a solution that is good
enough for the problem .
• It doesn’t have to be the best- an approximate solution will do since this is fast
enough.
• Most problems are exponential. Since The Complexity is O():
8 Puzzle O() ()
15 Puzzle O() ()
24 Puzzle O() ()
• Heuristic Search let us reduce this to a rather polynomial number.
How to Calculate Heuristic Value?
• Euclidian Distance ( Straight Line Distance)
a

b
𝑥
  1 𝑦1 S G 𝑥  2 𝑦 2

• Manhattan Distance ( Vertical & Horizontal Distance)


1 2 3 1 3 2

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
• Non Admissible 1

This Function overestimate the cost of reaching H(B)=3 B C D


the goal 3 H(C)=4 H(D)=5
H(n) is always greater than the actual cost of
lowest path from N to Goal Node H(E)=2 E

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
• Non Admissible 1

This Function overestimate the cost of reaching H(B)=3 B C D


the goal 3 H(C)=4 H(D)=5
H(n) is always greater than the actual cost of
lowest path from N to Goal Node H(E)=2 E

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
im
• In Steepest Ascent Hill Climbing

Cl
ll
Hi
Multiple points are checked. B=5

p le
Sim
• In Steepest Ascent Hill Climbing, A=4
Algorithms select the best among the
children states that are better than D=6
current State.
• All moves are considered and best one B=5 C=6

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

Flow Chart of Steepest Goal


Yes, Solution / Quit
Ascent Hill Climbing State

No
Generate All Successor

Select the best Successor as Current State

Yes, Solution / Quit

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 Ridge
lost in the plateau 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
Node Remove-First (PQ)
• With the help of best-first search, at each
step, we can choose the most promising If Node = Goal
node. Return Path from Initial to Node
• Utilize Evaluation algorithm (Function)
Else
to decide which adjacent node is more Generate all successor of Node and
promising and than explore. insert newly generated Node into
(PQ) According to Cost Value
• The Best first algorithm is implemented
by the priority queue (PQ).
Best-first Search Algorithm Open List
[A]
Closed List
[ ]
(Straight Line Distance)
[C, B, D] [A ]

Node H(n) [B, D] [A , C ]


A→G 40
B→G 32 [F, E, B, D] [A , C ]
C→G 25
D→G 35 [E, B, D] [A , C, F ]
E→G 19
F→G 17 [G, E, B, D] [A , C, F ]
G→G 0
H→G 10 [E, B, D] [A , C, F, G ]

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.

You might also like