Topic 2 - Problem Solving Using Search
Topic 2 - Problem Solving Using Search
Topic 2:
Problem Solving using Search
Learning Outcomes
Problem Solving
Problem Solving
Problem Solving
Formulate goal:
– get to Bucharest on time
Formulate problem:
– states: various cities
– actions: traverse between cities
Find solution:
– sequence of cities
(e.g. AradSibiuFagarasBucharest)
Search
• States: Cities
(Luger, 2011)
• Initial state: A
• Actions: Travel from one city to another connected by a road
• Goal test: The trip visits each city only once that starts and ends at A
• Path cost: Traveling time
Topic 2 Problem Solving with Search - 2.11
• States?
• Initial state?
• Actions?
• Goal test?
• Path cost?
(Luger, 2011)
Topic 2 Problem Solving with Search - 2.12
(Luger, 2011)
Topic 2 Problem Solving with Search - 2.14
Search Algorithms
Breadth-First Search
Breadth-First Search
Traversed sequence: 1, 2, 3, 4, 5, 6,
7, 8
Topic 2 Problem Solving with Search - 2.18
Breadth-First Search
• Algorithm
Topic 2 Problem Solving with Search - 2.19
Breadth-First Search
• Example
(Luger, 2011)
Breadth-First Search
A trace of breadth-first search on the tree
7 [H, I, J, K, L, M, N] [G, F, E, D, C, B, A]
8 [I, J, K, L, M, N, O, P] [H, G, F, E, D, C, B, A]
9 [J, K, L, M, N, O, P, Q] [I, H, G, F, E, D, C, B, A]
10 [K, L, M, N, O, P, Q, R] [J, I, H, G, F, E, D, C, B,
A]
Topic 2 Problem Solving with Search - 2.21
Breadth-First Search
A trace of breadth-first search on the tree
• Open is a queue that records generated nodes but not yet expanded
• Closed records nodes already expanded
Topic 2 Problem Solving with Search - 2.22
(Luger, 2011)
Breadth-first search of the 8-puzzle, showing order in which states were removed from open.
Topic 2 Problem Solving with Search - 2.23
Checkpoint Summary
Depth-First Search
Depth-First Search
Traversed sequence: 1, 2, 5, 6, 3, 4,
7, 8
Topic 2 Problem Solving with Search - 2.26
Depth-First Search
• Algorithm
Topic 2 Problem Solving with Search - 2.27
Depth-First Search
• Example
(Luger, 2011)
Depth-First Search
A trace of depth-first search on the
tree
Iteratio Open Closed
n
0 [A] []
1 [B, C, D] [A]
2 [E, F, C, D] [B, A]
3 [K, L, F, C, D] [E, B, A]
4 [S, L, F, C, D] [K, E, B, A]
5 [L, F, C, D] [S, K, E, B, A]
6 [T, F, C, D] [L, S, K, E, B, A]
7 [F, C, D] [T, L, S, K, E, B, A]
8 [M, C, D] [F, T, L, S, K, E, B, A]
(L is not added as already on closed)
(Luger, 2011)
Depth-first search of the 8-puzzle, showing order in which states were removed from open. A
depth bound of 5 was imposed on this search to keep it from getting lost deep in the space.
Topic 2 Problem Solving with Search - 2.30
Uniform-Cost Search
Uniform-Cost Search
2 5 5 1
There are two paths to the goal, the optimal path cost is
(1, 2, 6)
Topic 2 Problem Solving with Search - 2.32
Greedy Search
Greedy Search
A* Search
A* Search
Summary
References
Any Questions?