310 likes | 792 Views
Uninformed Search Strategies. Uninformed strategies use only information available in the problem definition Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search. Properties of Breadth-First Search. Complete?? Yes (if b is finite)
E N D
Uninformed Search Strategies • Uninformed strategies use only information available in the problem definition • Breadth-first search • Uniform-cost search • Depth-first search • Depth-limited search • Iterative deepening search
Properties of Breadth-First Search • Complete?? Yes (if b is finite) • Optimal?? Yes (if cost = 1 per step); not optimal in general • Time?? 1 + b + b2 + b3 + … + bd + b(bd – 1)= O( bd+1 ), ie, exp. in d • Space?? O( bd+1 ) (keep every node in memory) • Space is the big problem: can easily generate nodes at 10MB/sec, so 24hours = 860GB.
Uniform-cost Search • Expand least-cost unexpanded node • Implementation: • fringe = queue ordered by path cost • Equivalent to breadth-first if step costs all equal
Uniform-cost Search • Expand least-cost unexpanded node • Implementation: • fringe = queue ordered by path cost • Equivalent to breadth-first if step costs all equal • Complete?? Yes, if step cost • Optimal?? Yes – nodes expanded in increasing order of g(n) • Time?? # of nodes with g cost of optimal solution, O(b C*/) where C* is cost of optimal solution • Space?? # of nodes with g cost of optimal solution, O(b C*/)
Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal?? No • Time?? O(bm): terrible if m is much larger than dbut if solutions are dense, may be much faster than breadth-first • Space?? O(bm), I.e., linear space!
Properties of Depth-first Search • Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces • Optimal?? No • Time?? O(bm): terrible if m is much larger than dbut if solutions are dense, may be much faster than breadth-first • Space?? O(bm), I.e., linear space!
Depth-limited Search • = depth-first search with depth limit dl, i.e., nodes at depth l have no successors • Recursive implementation:
Depth-limited Search • That works as long as d<dl. • Preferably d=dl • But how are you going to get that lucky?
Iterative Deepening Search • That works as long as d<dl. • Preferably d=dl • But how are you going to get that lucky? • The answer… • Iterative deepening search
Iterative Deepening Search l = 0 • Limit = 0
Iterative Deepening Search l = 1 • Limit = 1
Iterative Deepening Search l = 2 • Limit = 2
Iterative Deepening Search l = 3 • Limit = 3
Properties of Iterative Deepening Search • Complete??
Properties of Iterative Deepening Search • Complete?? Yes
Properties of Iterative Deepening Search • Complete?? Yes • Optimal??
Properties of Iterative Deepening Search • Complete?? Yes • Optimal?? Yes, if step cost = 1
Properties of Iterative Deepening Search • Complete?? Yes • Optimal?? Yes, if step cost = 1 • Time??
Properties of Iterative Deepening Search • Complete?? Yes • Optimal?? Yes, if step cost = 1 • Time?? (d+1)b0 + db1 + (d-1)b2 + … + bd = O(bd)
Properties of Iterative Deepening Search • Complete?? Yes • Optimal?? Yes, if step cost = 1 • Time?? (d+1)b0 + db1 + (d-1)b2 + … + bd = O(bd) • Space??
Properties of Iterative Deepening Search • Complete?? Yes • Optimal?? Yes, if step cost = 1 • Time?? (d+1)b0 + db1 + (d-1)b2 + … + bd = O(bd) • Space?? O(bd)
Seems inefficient, but it’s not • Numerical comparison for • b=10 • d=5 • solution at far right • N(BFS) = 10 + 100 + 1,000 + 10,000 + 100,000 + 999,990 = 1,111,100 • N(IDS) = 50 + 400 + 3,000 + 20,000 + 100,000 = 123,450
So let’s try it again… • Consider a state space where the start state is number 1 and the successor function for state n returns two states, numbers 2n and 2n+1. • Suppose the goal state is 11. • List the order in which nodes will be visited in depth limited search with limit 4 • For iterative deepening.
Solution • Depth Limited, l=3 • 1, 2, 4, 8, 16, 17, 9, 18, 19, 5, 10, 20, 21, 11 • Iterative Deepening • 1, 1, 2, 3, 1, 2, 4, 5, 3, 6, 7, 1, 2, 4, 8, 9, 5, 10, 11
Programming Assignment #1 • Posted online – I will reference this in class
Programming Assignment #1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 There are several “optimal” solutions 2, 8, 9, 15 or 15, 9, 8, 2 or 2, 15, 9, 8 …
Programming Assignment #1 • Your language must be “approved” • Your deliverable must include a readme file about how to run your code in the WRT/ITTC labs. • Your code must take an input String describing the board • All on would be “1111111111111111” • Your final result should include the solution path, an indication of how many nodes were expanded (time) and how many nodes are still in memory (space)