Searches (AI)
Searches (AI)
1
Terminology: States vs. Nodes
Tree search algorithms
A state is a property of the world, e.g., location
A node is a data structure which specifies state, parent node, action, Basic idea:
path cost g(x), depth offline, simulated exploration of state space by
A state can have multiple nodes
generating successors of already-explored states
Nodes (a.k.a.~expanding states)
State State: Sibiu
Sibiu State of Parent Node: Arad
State: Sibiu
Arad Fagaras State of Parent Node: Fagaras
2
How to Choose From Fringe Set? Breadth-First Search
One idea:
Implement fringe set as a First-in First-out
(FIFO) queue
f -> e,d,c,b -> a
We call this Breadth-First Search
Start State: A
Current State: A
Fringe Set: {}
3
Breadth-First Search Properties of BFS
Is it Complete?
Is it Optimal?
Will it always return shortest path?
Space complexity
How large can the fringe set get?
O(bd+1) :( Why?
Start State: A
Current State: C Time complexity?
Fringe Set: { G, F, E, D}
Choose next state: D
f <- f,e,d,c,b,a
Start State: A
We call this Depth-First Search Goal State: M
Current State: A
Fringe Set: {}
4
Depth-First Search Depth-First Search
5
Depth-First Search Depth-First Search
6
Depth-First Search Depth-First Search
7
Depth-First Search Properties of depth-first search
Space?
bm+1
Time?
Optimal?
Complete?
No. Why?
Start State: A
Current State: M Goal Reached. Can we fix this?
Fringe Set: {G} Algorithm Terminates
Current State = Goal State
8
Iterative deepening search l =0 Iterative deepening search l =1
9
Iterative deepening search Iterative deepening search
Number of nodes generated in a depth-limited search to depth d with
Iterative Deepening search repeatedly re- branching factor b?
NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd
expanding nodes
Number of nodes generated in an iterative deepening search to depth d with
Seems inefficient, but is it? branching factor b?
NIDS = (d+1)b0 + d b^1 + (d-1)b^2 + … + 3bd-2 +2bd-1 + 1bd
For b = 10, d = 5,
NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456
Iterative Deepening is the method of choice for searching large state spaces
when depth of solution is not known
10
Bidirectional Search Bidirectional Search
In IDS, we saw that branching factor gets In IDS, we saw that branching factor gets
exponentially worse with depth exponentially worse with depth
Idea: Minimize depth by doing two parallel
searches
11
Uniform Cost Search Uniform Cost Search
1 3 1 3
3 4 0 4 3 4 0 4
1 3 1 3
3 4 0 4 3 4 0 4
12
Summary of algorithms Summary
Agent and Environment Types
13