Section 3
Section 3
Frontier
[b : 0 + 1, e : 0 + 2, c : 0 + 3]
Unexplored
Frontier
[c : 1 + 1, e : 0 + 2]
Unexplored
In the frontier, b has the lowest cost. Thus, we can add it to the
explored set. We add all neighbors of b to the frontier, updating
costs to reach some nodes if necessary (we updated c).
Problem - UCS
Explored
[a : 0, b : 1, c : 2]
Frontier
[e : 0 + 2, d : 2 + 1]
Unexplored
Frontier
[d : 2 + 1, f : 2 + 1, h : 2 + 3]
Unexplored
In the frontier, e has the lowest cost. Thus, we can add it to the
explored set. We add all neighbors of e to the frontier, updating
as necessary.
Problem - UCS
Explored
[a : 0, b : 1, c : 2, e : 2, d : 3]
Frontier
[f : 2 + 1, g : 3 + 1, h : 2 + 3]
Unexplored
In the frontier, d has the lowest cost. Thus, we can add it to the
explored set. We add all neighbors of d to the frontier, updating
as necessary.
Problem - UCS
Explored
[a : 0, b : 1, c : 2, e : 2, d : 3, f : 3]
Frontier
[g : 3 + 1, h : 3 + 1]
Unexplored
In the frontier, f has the lowest cost. Thus, we can add it to the
explored set. We add all neighbors of f to the frontier, updating
as necessary.
Problem - UCS
Explored
[a : 0, b : 1, c : 2, e : 2, d : 3, f : 3, g : 4]
Frontier
[h : 3 + 1]
Unexplored
In the frontier, g has the lowest cost. Thus, we can add it to the
explored set. We add all neighbors of f to the frontier, updating
as necessary.
Problem - UCS
Explored
[a : 0, b : 1, c : 2, e : 2, d : 3, f : 3, g : 4,
h : 4]
Frontier
Unexplored
In the frontier, h has the lowest cost. Thus, we can add it to the
explored set. There are no more nodes in the frontier, so we are
done.
Uniform Cost Search
Contents
2
5 2
7
1 1 4 5 1, 1
3 6
3
Simulation of DP Visiting Successors Completed
Cache
2
5 2
7
1 1 4 5 1, 1
3 6
3
Simulation of DP Visiting Successors Completed
Cache
2, 0
2
5 2 5
7
1 1 4 5 1, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2, 0
2
5 2 5
7
1 1 4 5 1, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2, 0
2
5 2 5
7
1 1 4 5 1, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2
2, 0 4,-1
2
5 2 5 1
7
1 1 4 5 1, 1 3, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2
2, 0 4,-1
2
5 2 5 1
7
1 1 4 5 1, 1 3, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2
2, 0 4,-1
2
5 2 5 1
7
1 1 4 5 1, 1 3, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2
2, 0 4,-1
2
5 2 5 1
7 6
1 1 4 5 1, 1 3, 1 4, 0
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2
2, 0 4,-1
2
5 2 5 1
7 6
1 1 4 5 1, 1 3, 1 4, 0
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2
2, 0 4,-1
2
5 2 5 1
7 6
1 1 4 5 1, 1 3, 1 4, 0
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
2
2, 0 4,-1
2
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2
2, 0 4,-1
2
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2
2, 0 4,-1 (4, 0) 0+7
2
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2
2, 0 4,-1 (4, 0) 7
2 (3, 1) 7 + 6 = 13
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2
2, 0 4,-1 (4, 0) 7
2 (3, 1) 13
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2
2, 0 4,-1 (4, 0) 7
2 (3, 1) 13
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2
2, 0 4,-1 (4, 0) 7
2 (3, 1) 13
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 13+1 = 14
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3
3
3, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3
3 6
3, 2 4, 1
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3
3 6
3, 2 4, 1
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3
3 6
3, 2 4, 1
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3
3 6 7
3, 2 4, 1 5, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3 (5, 2) 0
3 6 7
3, 2 4, 1 5, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3 (5, 2) 0
3 6 7 (4, 1) 7
3, 2 4, 1 5, 2
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3 (5, 2) 0
3 6 7 (4, 1) 7
3, 2 4, 1 5, 2
(3, 2) 13
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3 (5, 2) 0
3 6 7 (4, 1) 7
3, 2 4, 1 5, 2
(3, 2) 13
(1, 1) 16
Simulation of DP Visiting Successors Completed
Cache
(5, 1) 0
2 7
2, 0 4,-1 5, 0 (4, 0) 7
2 (3, 1) 13
5 2 5 1
(5, 0) ∞
7 6 7
1 1 4 5 1, 1 3, 1 4, 0 5, 1
(4, -1) ∞
(2, 0) 14
3 6 3 (5, 2) 0
3 6 7 (4, 1) 7
3, 2 4, 1 5, 2
(3, 2) 13
(1, 1) 16
Improve UCS: A* Search
Contents
city 1 2 3 4 5
h 14 9 13 7 0
Modified State Graph
0 0
2, 0 4,-1 5, 0
0 5
6 0
1, 1 3, 1 4, 0 5, 1
2
0 0
3, 2 4, 1 5, 2
Simulation of UCS (A*)
0 0 Explored: Frontier:
2, 0 4,-1 5, 0 (1, 1) : 0 (2, 0) : 5 + 9 - 14 = 0
0 5 (3, 2) : 3 + 13 - 14 = 2
6 0
1, 1 3, 1 4, 0 5, 1
2
0 0
3, 2 4, 1 5, 2
Simulation of UCS (A*)
0 0 Explored: Frontier:
2, 0 4,-1 5, 0 (1, 1) : 0 (3, 2) : 3 + 13 - 14 = 2
0 5 (2, 0): 0 (3, 1): 1 + 13 - 9 = 5
6 0 (4, -1): 2 + 7 - 9 = 0
1, 1 3, 1 4, 0 5, 1
2
0 0
3, 2 4, 1 5, 2
Simulation of UCS (A*)
0 0 Explored: Frontier:
2, 0 4,-1 5, 0 (1, 1) : 0 (3, 2) : 3 + 13 - 14 = 2
0 5 (2, 0): 0 (3, 1): 1 + 13 - 9 = 5
6 0 (4, -1): 0 (5, 0): 7 + 0 - 7 = 0
1, 1 3, 1 4, 0 5, 1
2
0 0
3, 2 4, 1 5, 2
Simulation of UCS (A*)
0 0 Explored: Frontier:
2, 0 4,-1 5, 0 (1, 1) : 0 (3, 2) : 3 + 13 - 14 = 2
0 5 (2, 0): 0 (3, 1): 1 + 13 - 9 = 5
6 0 (4, -1): 0
1, 1 3, 1 4, 0 5, 1 (5, 0): 0
2
0 0
3, 2 4, 1 5, 2
Simulation of UCS (A*)
0 0 Explored: Frontier:
2, 0 4,-1 5, 0 (1, 1) : 0 (3, 1): 1 + 13 - 9 = 5
0 5 (2, 0): 0 (4, 1): 6 + 7 - 13 = 0
6 0 (4, -1): 0
1, 1 3, 1 4, 0 5, 1 (5, 0): 0
(3, 2): 2
2
0 0
3, 2 4, 1 5, 2
Simulation of UCS (A*)
0 0 Explored: Frontier:
2, 0 4,-1 5, 0 (1, 1) : 0 (3, 1): 1 + 13 - 9 = 5
0 5 (2, 0): 0 (5, 2): 7 + 0 - 7 = 0
6 0 (4, -1): 0
1, 1 3, 1 4, 0 5, 1 (5, 0): 0
(3, 2): 2
2 (4, 1): 0
0 0
3, 2 4, 1 5, 2
Simulation of UCS (A*)
0 0 Explored: Frontier:
2, 0 4,-1 5, 0 (1, 1) : 0 (3, 1): 1 + 13 - 9 = 5
0 5 (2, 0): 0
6 0 (4, -1): 0
1, 1 3, 1 4, 0 5, 1 (5, 0): 0
(3, 2): 2 STOP!
2 (4, 1): 0
0 0 (5, 2): 0
3, 2 4, 1 5, 2
Comparison of States visited
UCS UCS(A*)
Explored: Frontier: Explored: Frontier:
(1, 1) : 0 (5, 1) : 19 (1, 1) : 0 (3, 1): 5
(3, 2) : 3 (2, 0): 0
(2, 0) : 5 (4, -1): 0
(3, 1) : 6 (5, 0): 0
(4, -1) : 7 (3, 2): 2
(4, 1) : 9 (4, 1): 0
(4, 0) : 12 (5, 2): 0
(5, 0) : 14
(5, 2) : 16
Summary
● States Representation/Modelling
○ make state representation as compact as possible, remove
unneccesary information
● DP
○ underlying graph cannot have cycles
○ visit all reachable states, but no log overhead
● UCS
○ actions cannot have negative cost
○ visit only a subset of states, log overhead
● A*
○ ensure that relaxed problem can be solved more efficiently