Professional Documents
Culture Documents
Sibiu
Search Algorithms
• Exploration of state space by
3
generating successors of Arad
already-explored states
Zerind Timisoara
• Frontier: candidate nodes
for expansion Sibiu
Oradea
Fagaras
Search Algorithms
• Exploration of state space by
4
generating successors of Arad
already-explored states Timisoara
Zerind
• Frontier: candidate nodes Sibiu
for expansion
Arad Rimnicu
• Explored set Vilcea
Fagaras
Oradea
Sibiu Bucharest
Search Strategies
• A strategy is defined by picking the order of node expansion.
• Strategies are evaluated along the following dimensions:
1 A 2 A 3 A 4 A
B C B C B C
D E D E F G
A 1 2
S S
0
1 10
A B C
5 B 5 1 5 15
S G
3 S S
15 4
5
A B C A B C
C
15 5 15
G G G
11 10 11
Here we do not expand notes that have been expanded.
Uniform-Cost Search
Complete Yes
Time # of nodes with path cost g <= cost of optimal solution
(eqv. # of nodes pop out from the priority queue)
Space # of nodes with path cost g <= cost of optimal solution
Optimal Yes
Depth-First Search
Expand deepest unexpanded node which can be implemented by a Last-In-
First-Out (LIFO) stack, Backtrack only when no more expansion
1 A 2 A 3 A 4 A 5 A 6 A
B C B C B C B C C
D E D E D E E
7 A 8 A H I I
9 10 11 12
C C
E C C C C
E
F G F G F G
J K K
L M M
Depth-First Search
Denote
• m: maximum depth of the state space
Complete • infinite-depth
No
spaces: No
• finite-depth spaces
No
with loops: No
• with repeated-state
Ye checking: Yes
• finite-depth spaces
s Yewithout loops: Yes
s
Time 𝑂𝑂 𝑏𝑏𝑚𝑚
If solutions are dense, may be much faster than breadth-first
Space 𝑂𝑂(𝑏𝑏𝑏𝑏)
No
Optimal No
Depth-Limited Search
To avoid infinite searching, Depth-first search with a cutoff on the
max depth / of a path
Complete Yes, if 𝐼𝐼 ≥ 𝑑𝑑
Time 𝑂𝑂(𝑏𝑏𝐼𝐼 )
Space 𝑂𝑂(𝑏𝑏𝑏𝑏)
Optimal No
Iterative Deepening Search
Iteratively estimate the max depth / of DLS one-by-one
Limit = 0
Limit = 1
Iterative Deepening Search
Iteratively estimate the max depth / of DLS one-by-one
Limit = 2
Iterative Deepening Search
Iteratively estimate the max depth / of DLS one-by-one
Limit = 3
Iterative Deepening Search...
Function ITERATIVE-DEEPENING-SEARCH(problem) returns a solution sequence
inputs: problem, a problem
for depth 0 to ∞ do
if DEPTH-LIMITED-SEARCH(problem, depth) succeeds then return its result
end
return failure
Complete Yes
Time 𝑂𝑂(𝑏𝑏𝑑𝑑 )
Space 𝑂𝑂(𝑏𝑏𝑏𝑏)
Optimal Yes
Summary (we make assumptions for optimality)
Breadth- Uniform- Depth-First Depth- Iterative Bidirectional
Criterion first Cost Limited Deepening (if applicable)
state Arad
Arad
Bucharest
366
0
Craiova 160
366 Dobreta 242
Efoire 161
Fagaras 176
Giurgiu 77
Hirsova 151
Lasi 226
Lugoj 244
Mehadia 241
Neamt 234
Oradea 380
Pitesti 98
Rimnicu Vilcea 193
Sibiu 253
Timisoara 329
Urziceni 80
Vaslui 199
Zerind 374
Example
b) After Straight-line distance to Bucharest
expanding Arad
Arad
Bucharest
366
0
Arad Craiova
Dobreta
160
242
Efoire 161
Sibiu Timisoara Zerind Fagaras 176
Giurgiu 77
253 329 374 Hirsova 151
Lasi 226
Lugoj 244
Mehadia 241
Neamt 234
Oradea 380
Pitesti 98
Rimnicu Vilcea 193
Sibiu 253
Timisoara 329
Urziceni 80
Vaslui 199
Zerind 374
Example
c) After Straight-line distance to Bucharest
Dobreta Eforie
Craiova
Giurgiu
Answer: No
Greedy Search...
• m: maximum depth of the search space
Complete No
Time 𝑂𝑂(𝑏𝑏𝑚𝑚 )
Space 𝑂𝑂(𝑏𝑏𝑚𝑚 )(keeps all nodes in memory)
Optimal No
Question to think:
(a) The initial state (b) After expanding Arad (c) After expanding Sibiu
Arad Arad Arad
366 = 0 + 366
Sibiu Zerind Sibiu Zerind
Timisoara
393 = 140 + 253 449 = 75 + 374 449 = 75 + 374
447 = 118 + 329
Timisoara Arad
Oradea
447 = 118 + 329 646 = 280 + 366 Rimnicu
671 = 291+ 380
Vilcea
Fagaras
413 = 220 + 193
415 = 239 + 176
Example: Route-finding from Arad to Bucharest
Best-first-search with evaluation function 𝑔𝑔 + ℎ
Zerind
Sibiu
Timisoara 449 = 75 + 374
Arad 447 = 118 + 329
646 = 280 + 366 Oradea Rimnicu
Fagaras 671 = 291+ 380 Vilcea
Sibiu
Sibiu Craiova Pitesti 553 = 300 + 253
Bucharest
591 = 338 + 253 526 = 360 + 166
415 = 317 + 98
450 = 450 + 0
Example: Route-finding from Arad to Bucharest
Best-first-search with evaluation function 𝑔𝑔 + ℎ
Arad
Sibiu
Sibiu Craiova Pitesti 553 = 300 + 253
Bucharest
591 = 338 + 253 526 = 360 + 166
450 = 450 + 0
Rimnicu
Bucharest Craiova Vilcea
53𝑛𝑛𝑛𝑛 St 3 2
52𝑛𝑛𝑛𝑛 St 2 1
51𝑠𝑠𝑠𝑠 St 5 4 3 2 1
S G
50𝑡𝑡𝑡 St 7 6 5 4 3 2 1
10𝑡𝑡𝑡 Ave
6𝑡𝑡𝑡 Ave
5𝑡𝑡𝑡 Ave
9𝑡𝑡𝑡 Ave
8𝑡𝑡𝑡 Ave
4𝑡𝑡𝑡 Ave
2𝑛𝑛𝑛𝑛 Ave
3𝑟𝑟𝑟𝑟 Ave
Manhattan
7𝑡𝑡𝑡 Ave
Shortest
Path = 8
Distance
Heuristic
Example: Route-finding in Manhattan (Greedy)
53𝑛𝑛𝑛𝑛 St 3 2
52𝑛𝑛𝑛𝑛 St 2 1
51𝑠𝑠𝑠𝑠 St 5 4 3 2 1
S G
50𝑡𝑡𝑡 St 7 6 5 4 3 2 1
10𝑡𝑡𝑡 Ave
6𝑡𝑡𝑡 Ave
5𝑡𝑡𝑡 Ave
9𝑡𝑡𝑡 Ave
8𝑡𝑡𝑡 Ave
4𝑡𝑡𝑡 Ave
2𝑛𝑛𝑛𝑛 Ave
3𝑟𝑟𝑟𝑟 Ave
7𝑡𝑡𝑡 Ave
Example: Route-finding in Manhattan (UCS)
53𝑛𝑛𝑛𝑛 St 7 8
52𝑛𝑛𝑛𝑛 St 6 9
51𝑠𝑠𝑠𝑠 St 1 2 3 4 5
S G
50𝑡𝑡𝑡 St 1 2 3 4 5 6 7
10𝑡𝑡𝑡 Ave
6𝑡𝑡𝑡 Ave
5𝑡𝑡𝑡 Ave
9𝑡𝑡𝑡 Ave
8𝑡𝑡𝑡 Ave
4𝑡𝑡𝑡 Ave
2𝑛𝑛𝑛𝑛 Ave
3𝑟𝑟𝑟𝑟 Ave
7𝑡𝑡𝑡 Ave
Example: Route-finding in Manhattan (A*)
53𝑛𝑛𝑛𝑛 St 10 10
52𝑛𝑛𝑛𝑛 St 8 10
51𝑠𝑠𝑠𝑠 St 6 6 6 6 6
S G
50𝑡𝑡𝑡 St 8 8 8 8 8 8 8
10𝑡𝑡𝑡 Ave
6𝑡𝑡𝑡 Ave
5𝑡𝑡𝑡 Ave
9𝑡𝑡𝑡 Ave
8𝑡𝑡𝑡 Ave
4𝑡𝑡𝑡 Ave
2𝑛𝑛𝑛𝑛 Ave
3𝑟𝑟𝑟𝑟 Ave
7𝑡𝑡𝑡 Ave
Complexity of A*
Time Exponential in length of
solution
Space (all generated nodes
are kept in memory)
Exponential in length of
solution