blind search russell and norvig: chapter 3, sections 3.4 – 3.6 slides adapted from:...

26
Blind Search Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/hom e.htm by Prof. Jean-Claude Latombe

Upload: gyles-long

Post on 16-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Blind SearchBlind Search

Russell and Norvig: Chapter 3, Sections 3.4 – 3.6

Slides adapted from:robotics.stanford.edu/~latombe/cs121/2003/home.htmby Prof. Jean-Claude Latombe

Page 2: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Blind Search

Depth first searchBreadth first searchIterative deepeningNo matter where the goal is, these algorithms will do the same thing.

Page 3: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Depth-First1

fringe

Page 4: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Depth-First1

2

fringe

Page 5: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Depth-First1

2

3

fringe

Page 6: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Breadth First1

fringe

Page 7: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Breadth First1

2

fringe

Page 8: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Breadth First1

2

fringe

3

Page 9: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Breadth First1

2

fringe

3

4

Page 10: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Generic Search AlgorithmGeneric Search AlgorithmPath search(start, operators, is_goal) { fringe = makeList(start); while (state=fringe.popFirst()) { if (is_goal(state)) return pathTo(state); S = successors(state, operators);

fringe = insert(S, fringe); } return NULL;}

Depth-first: insert=prepend; Breadth-first: insert=append

Page 11: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Performance Measures of Performance Measures of Search AlgorithmsSearch Algorithms

CompletenessIs the algorithm guaranteed to find a solution when there is one?OptimalityIs this solution optimal?Time complexityHow long does it take?Space complexityHow much memory does it require?

Page 12: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Important ParametersImportant Parameters

Maximum number of successors of any state branching factor b of the search tree

Minimal length of a path in the state space between the initial and a goal state depth d of the shallowest goal node in the search tree

Page 13: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Evaluation of Breadth-Evaluation of Breadth-first Searchfirst Search

b: branching factor d: depth of shallowest goal node Complete Optimal if step cost is 1 Number of nodes generated: 1 + b + b2 + … + bd = (bd+1-1)/(b-1) = O(bd) Time and space complexity is O(bd)

Page 14: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Big O NotationBig O Notation

g(n) is in O(f(n)) if there exist two positive constants a and N such that:

for all n > N, g(n) af(n)

Page 15: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Time and Memory Time and Memory RequirementsRequirements

d #Nodes Time Memory

2 111 .01 msec 11 Kbytes

4 11,111 1 msec 1 Mbyte

6 ~106 1 sec 100 Mb

8 ~108 100 sec 10 Gbytes

10 ~1010 2.8 hours 1 Tbyte

12 ~1012 11.6 days 100 Tbytes

14 ~1014 3.2 years 10,000 Tb

Assumptions: b = 10; 1,000,000 nodes/sec; 100bytes/node

Page 16: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Evaluation of Depth-first Evaluation of Depth-first SearchSearch

b: branching factor d: depth of shallowest goal node m: maximal depth of a leaf node Complete only for finite search tree Not optimal Number of nodes generated: 1 + b + b2 + … + bm = O(bm) Time complexity is O(bm) Space complexity is O(bm) or O(m)

Page 17: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Depth-Limited StrategyDepth-Limited Strategy

Depth-first with depth cutoff k (maximal depth below which nodes are not expanded)

Three possible outcomes: Solution Failure (no solution) Cutoff (no solution within cutoff)

Page 18: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude
Page 19: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Iterative Deepening Iterative Deepening StrategyStrategy

Repeat for k = 0, 1, 2, …:Perform depth-first with depth cutoff k Complete Optimal if step cost =1Space complexity is: O(bd) or O(d)Time complexity is: (d+1)(1) + db + (d-1)b2 + … + (1) bd = O(bd) Same as BFS! WHY???

Page 20: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

CalculationCalculation

db + (d-1)b2 + … + (1) bd

= bd + 2bd-1 + 3bd-2 +… + db= bd(1 + 2b-1 + 3b-2 + … + db-d)

bd(i=1,…,ib(1-i))

= bd (b/(b-1))2

Page 21: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Comparison of StrategiesComparison of Strategies

Breadth-first is complete and optimal, but has high space complexity Bad when branching factor is high

Depth-first is space efficient, but neither complete nor optimal Bad when search depth is infinite

Iterative deepening is asymptotically optimal

Page 22: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Uniform-Cost StrategyUniform-Cost Strategy• Each step has some cost > 0.• The cost of the path to each fringe node N is g(N) = costs of all steps.• The goal is to generate a solution path of minimal cost.• The queue FRINGE is sorted in increasing cost.

S0

1A

5B

15CS G

A

B

C

5

1

15

10

5

5

G11

G10

Page 23: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Repeated StatesRepeated States

8-queens

No

assembly planning

Few

1 2 34 5

67 8

8-puzzle and robot navigation

Many

search tree is finitesearch tree is infinite

Page 24: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Avoiding Repeated StatesAvoiding Repeated States

Requires comparing state descriptions Breadth-first strategy: Keep track of all generated states If the state of a new node already

exists, then discard the node

Page 25: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Avoiding Repeated StatesAvoiding Repeated States

Depth-first strategy: Solution 1:

Keep track of all states associated with nodes in current path

If the state of a new node already exists, then discard the node

Avoids loops Solution 2:

Keep track of all states generated so far If the state of a new node has already been

generated, then discard the node

Space complexity of breadth-first

Page 26: Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm by Prof. Jean-Claude

Summary

Search strategies: breadth-first, depth-first, and variants Evaluation of strategies: completeness, optimality, time and space complexity Avoiding repeated states