0% found this document useful (0 votes)
68 views36 pages

Artificial Intelligence DITI 1113: Uniformed Search II

This document discusses uninformed search algorithms, including depth-limited search, iterative deepening search, and bi-directional search. Depth-limited search expands nodes up to a maximum depth limit, while iterative deepening search performs repeated depth-limited searches with increasing depth limits until finding the goal. Bi-directional search performs simultaneous forward and backward searches from the start and goal nodes respectively, terminating when the searches meet.

Uploaded by

Efa Zifa
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)
68 views36 pages

Artificial Intelligence DITI 1113: Uniformed Search II

This document discusses uninformed search algorithms, including depth-limited search, iterative deepening search, and bi-directional search. Depth-limited search expands nodes up to a maximum depth limit, while iterative deepening search performs repeated depth-limited searches with increasing depth limits until finding the goal. Bi-directional search performs simultaneous forward and backward searches from the start and goal nodes respectively, terminating when the searches meet.

Uploaded by

Efa Zifa
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/ 36

Artificial Intelligence

DITI 1113
Uniformed Search II
Dr. Zahriah binti Sahri
[email protected]
Lesson Outcomes
• Understand the theory of uninformed search

• Recognize the different uninformed search algorithms

• Apply these search algorithms to solve real-world problems


Outlines
1. Recap
2. Depth Limited First Search
3. Iterative Deepening Search
4. Bi-Directional Search
5. Uniform Search
Assumptions
• Search algorithms always create/choose the left branch of a
search tree first when there is a choice.
• Alphabetical ordering is the second choice when left-to-right
branching produces tie-up
• Search algorithms avoid repeated states ( nodes that have
been expanded/generated)
Notations
• Generated/Unexpanded node

• Expanded node

• Terminated node
Depth-First Search Weakness
1. Incomplete if it searches down a path that has infinite length.
Depth-First Search Weakness
2. Missing shorter path to a goal
A
A
B C
B C
D E F G H
D E F G H
VS
I J K L M N Goal
I J K L M N
Goal Q R S T U V
BFS
DFS Y Z
Alternative Search?

Depth-Limited Search
Depth-Limited Search
• The strategy:-
– a variant of Depth First Search
– expands the deepest unexpanded node in the current frontier of the
search tree up to a predetermined depth limit l ,
– nodes at depth l are treated as if they have no successors.
– if the search reaches a node at depth l where the path is not a
solution, backtrack to the next node at depth < l .
Depth-Limited Search
• The implementation:-
– Frontier is a last-in-first-out (LIFO) queue, i.e., new successors go at
the end of the frontier successor list.
– The goal test is applied to each node when it is generated.
– For equally deepest nodes, use the left to right branching search.
Depth-Limited Search
• The algorithm:-

Source : https://www.hackerearth.com/practice/algorithms/graphs/breadth-first-search/tutorial/
What to Search?
A Start
• Search a path from A to N
B C

D E F G H

I J K L M N O P
Goal

Q R S T U V W X

Y Z
Depth Limited Search
• The search begins:- 1. Assume l = 3

2. Frontier = {A}. A is not goal and A is at l =0 < 3. Expands A


l=0 A 3. Frontier = {B,C}. Both are equally deepest, not goal, and at l =1 <
3. B is chosen for expansion based on left to right branching
l=1 B C 4. Frontier = {D,E,F,C}. D,E,F are equally deepest, not goal, and at l
=2 < 3. Expands D
l=2 D E F 5. Frontier = {I,E,F,C}. I is the deepest and not the goal but at depth
l=3. Terminate I.
6. Frontier = {E,F,C}. E,F are equally deepest, not goal, and at l =2 <
l=3 I J K L 3. Expands E
7. Frontier = {J,K,L,F,C}. J,K,L are equally deepest, not goal but at
depth l=3. Terminate J,K,L.
8. Frontier = {F,C}. F is the deepest, not goal, and at l =2 < 3.
Expands F
Depth Limited Search
• The search begins:-
l=0 A 9. Frontier = {C}. C is not goal and at l =1 < 3. Expands C.

10. Frontier = {G,H}. G,H are equally deepest, not goal, and at l
l=1 B C =2 < 3. Expands G.

11. Frontier = {M,N,H}. M, N are equally deepest, and at l =3.


l=2 D E F G H Terminate M

12. Frontier = {N,H}. N is the deepest, and is the goal node. Stop
the search.
l=3 I J K L M N Goal
13. Traversed path = {ABDIEJKLFCGMN}

14. Solution path = {ACGN}


Depth-Limited Search
• The properties
– Complete?
• Yes if l < d

– Time Complexity?
 O(bl)

– Space Complexity
• O(bl)

– Optimal?
• No if l > d
Depth Limited Search
• Weaknesses:-
l=0 A Start
1. Predetermined depth l is too
small, goal is not found/reached l=1 B C
• e.g if l = 2; all nodes (D,E,F,G,H) at this
level will not be expanded, hence N is l=2 D E F G H
not reached

l=3 I J K L M N O P
Goal
l=4 QR S T U V W X

l=5 Y Z
Depth Limited Search
• Weakness 2:-
l=0 A Start
– predetermined depth l is too large,
longer solution path l=1 B C
• e.g if l = 5; some nodes at deeper
levels than depth d are expanded, l=2 D E F G H
hence the traversed path to goal N is
longer.
l=3 I J K L M N O P
• d= depth of the least cost solution Goal
• d= 3 for this example
l=4 QR S T U V W X

l=5 Y Z
Depth-Limited Search
• Suitable to use when:-
– d, the depth level of the goal node is not known
– search space is large
– space (memory) is restricted
Iterative Deepening Search
• The strategy:-
– combine the space efficiency of depth-first search with the optimality
of breadth-first search
– progressively increases the depth limit l with each iteration until it
reaches the goal .
– a variant of Depth First search
Iterative Deepening Search
• The implementation:-
– Frontier is a last-in-first-out (LIFO) queue, i.e., new successors go at
the end of the frontier successor list.
– The goal test is applied to each node when it is generated.
– For equally deepest nodes, use the left to right branching search.
– First tries depth l = 0, l = 1, then l = 2, then l = 3, etc. until a goal is
found.
– Goal will be found when l = d, where d = depth of the least-cost
solution
Iterative Deepening Search
• The search begins:-
Iterative Deepening Search
• The search continues:-
Iterative Deepening Search
 The properties
– Complete?
• Yes it always reaches goal (if b is finite) where b= maximum branching factor of
the search tree

– Time Complexity?
• O(bd) where d= depth of the least-cost solution

– Space Complexity
• O(bd)

– Optimal?
• Yes (if cost is 1 per step); not optimal in general
Testing Your Understanding
• Find the traversed path and the solution path from S to G using
Iterative Deepening Search :-
Bi-Directional Search
• The strategy:-
―searches in two directions simultaneously.
― one forward from the initial state and the other backward from the
goal.
―stop when both “meet in the middle”.
What to Search?
A Start
• Search a path from A to N
B C

D E F G H

I J K L M N O P
Goal

Q R S T U V W X

Y Z
Bi-Directional Search
• Forward search using Breadth- • Backward search using Breadth-
First Search:- First Search:-
A N

B C G

C
D E F
Node C is found at both forward and backward search.
Stop the search
The solution path = ACGN
Bi-Directional Search
 The properties
– Complete?
• Yes, if b is finite, and both direction use BFS

– Time Complexity?
• O(bd/2) since each search need only to proceed to half of the solution path.
• d = depth of the least cost solution

– Space Complexity
• O(bd/2)

– Optimal?
• Yes, if all step cost are equal, and both direction use BFS.
Bi-Directional Search
• Advantages:-
– It requires less memory.
– It is speedier.
–Can combine different search strategies in different directions.
Bi-Directional Search
• Disadvantages:-
― Doesn't work well when goal state is not unique (example: chess).

― Must be able to generate predecessors of states.

― Not always possible to search backward through possible states.

― Implementation is difficult because additional logic must be included to decide which search tree
to extend at each step.

― Must be too efficient to find the intersection of the two search trees.

― For large d, it’s impractical.


Test Your Understanding
• Find the traversed path and the solution path from S to G using
Bi-Directional Search :-
The Search : Uniform Cost Search

 Problem of Breadth-First Search


 only optimal if step costs is increasing with depth
(e.g. constant). Can we guarantee optimality for
any step cost?

 Alternative Solution?
 Uniform-Cost Search

 How?
 Expand the least-cost unexpanded node.
 FIFO queue is ordered by cost.
 Equivalent to regular breadth-first search if all step
costs are equal.
 Only use info found in problem definition. 32
Uniform Cost Search
• The search begins: 1.
2.
Start with initial state
Expand A, B, C.
3. Visit A and expand G.
4. Visit B and expand G.
5. Least-cost path: S-B-G
6. Path cost ,
g(n) = S-B + B-G
=5+5
= 10
The Search : Uniform Cost Search

 Why not stop upon reaching the goal?

 When doing Uniform Cost, it is not correct to stop


the search when the first path to a goal is
generated.

 Continue searching until the least-cost path to the


goal is found.

 In the previous example, a path to G was generated


at step 3, but a shorter path at step 4 was accepted
as the solution

34
Properties of Uniform-Cost Search
• Complete?
– Yes if the cost is greater than some threshold
– step cost >= ε
• Time?
– Complexity cannot be determined easily by b or d
– Let C* be the cost of the optimal solution
– O(bceil(C*/ ε))
• Space?
– O(bceil(C*/ ε))
• Optimal?
– Yes, Nodes are expanded in increasing order

35
Test Your Understanding
• Find the traversed path and the solution path from S to G using
Bi-Directional Search :-

You might also like