Breadth first search Uniform cost search
Robert Platt Northeastern University Some images and slides are used from:
- 1. CS188 UC Berkeley
- 2. RN, AIMA
Breadth first search Uniform cost search Robert Platt Northeastern - - PowerPoint PPT Presentation
Breadth first search Uniform cost search Robert Platt Northeastern University Some images and slides are used from: 1. CS188 UC Berkeley 2. RN, AIMA What is graph search? Goal state Start state What is a graph? Graph: Vertices: Edges:
Start state Goal state
Graph: Edges: Vertices: Directed graph
Graph: Edges: Vertices: Undirected graph
Given: a graph, G Problem: find a path from A to B – A: start state – B: goal state
Start at A
Successors of A
Successors of A parent children
Let's expand S next
Successors
A was already visited!
A was already visited!
In what order should we expand states? – here, we expanded S, but we could also have expanded Z or T – different search algorithms expand in different orders
Slide: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)
Start node
We're going to maintain a queue called the fringe – initialize the fringe as an empty queue Fringe
– add A to the fringe fringe Fringe A
fringe Fringe B C
fringe Fringe C D E
fringe Fringe D E F G
fringe Fringe D E F G Which state gets removed next from the fringe?
fringe Fringe D E F G Which state gets removed next from the fringe? What kind of a queue is this?
fringe Fringe D E F G Which state gets removed next from the fringe? What kind of a queue is this?
What is the purpose of the explored set?
Slide: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)
Notice the distances between cities
Notice the distances between cities – does BFS take these distances into account?
Notice the distances between cities – does BFS take these distances into account? – does BFS find the path w/ shortest milage?
Notice the distances between cities – does BFS take these distances into account? – does BFS find the path w/ shortest milage? – compare S-F-B with S-R-P-B. Which costs less?
Notice the distances between cities – does BFS take these distances into account? – does BFS find the path w/ shortest milage? – compare S-F-B with S-R-P-B. Which costs less?
Notice the distances between cities – does BFS take these distances into account? – does BFS find the path w/ shortest milage? – compare S-F-B with S-R-P-B. Which costs less?
Same as BFS except: expand node w/ smallest path cost Length of path
Same as BFS except: expand node w/ smallest path cost Length of path Cost of going from state A to B: Minimum cost of path going from start state to B:
Same as BFS except: expand node w/ smallest path cost Length of path Cost of going from state A to B: Minimum cost of path going from start state to B: BFS: expands states in order of hops from start UCS: expands states in order of
Same as BFS except: expand node w/ smallest path cost Length of path Cost of going from state A to B: Minimum cost of path going from start state to B: BFS: expands states in order of hops from start UCS: expands states in order of
Simple answer: change the FIFO to a priority queue – the priority of each element in the queue is its path cost.
Fringe A Path Cost Explored set:
140 118 75
Explored set: A Fringe A S T Z Path Cost 140 118 75
140 118 75 146
Explored set: A, Z Fringe A S T Z T Path Cost 140 118 75 146
140 118 75 146 229
Explored set: A, Z, T Fringe A S T Z T L Path Cost 140 118 75 146 229
140 118 75 239 220 146 229
Explored set: A, Z, T, S Fringe A S T Z T L F R Path Cost 140 118 75 146 229 239 220
140 118 75 239 220 146 229
Explored set: A, Z, T, S Fringe A S T Z T L F R Path Cost 140 118 75 146 229 239 220
140 118 75 239 220 336 317 146 229
Explored set: A, Z, T, S, R Fringe A S T Z T L F R C P Path Cost 140 118 75 146 229 239 220 336 317
140 118 75 239 220 336 317 146 229 299
Explored set: A, Z, T, S, R, L Fringe A S T Z T L F R C P M Path Cost 140 118 75 146 229 239 220 336 317 299
140 118 75 239 220 336 317 146 229 299
Explored set: A, Z, T, S, R, L Fringe A S T Z T L F R C P M Path Cost 140 118 75 146 229 239 220 336 317 299
140 118 75 239 220 336 317 146 229 299
Explored set: A, Z, T, S, R, L Fringe A S T Z T L F R C P M Path Cost 140 118 75 146 229 239 220 336 317 299
140 118 75 239 220 336 317 146 229 299
Explored set: A, Z, T, S, R, L Fringe A S T Z T L F R C P M Path Cost 140 118 75 146 229 239 220 336 317 299
S
a b d p a c e p h f r q q c
G
a q e p h f r q q c
G
a Strategy: expand a cheapest node first: Fringe is a priority queue (priority: cumulative cost) S G
d b p q c e h a f r
3 9 1 16 4 11 5 7 13 8 10 11 17 11 6 3 9 1 1 2 8 8 2 15 1 2 Cost contours 2
Slide: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)
S
a b d p a c e p h f r q q c
G
a q e p h f r q q c
G
a
S
G d b p q c e h a f r Search Tiers Strategy: expand a shallowest node fjrst Implementation: Fringe is a FIFO queue Slide: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)
Start Goal … c ≤ 3 c ≤ 2 c ≤ 1
Slide: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)