573 lecture 2 - search i · what is search? • search is a class of techniques for systematically...
TRANSCRIPT
![Page 1: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/1.jpg)
Uninformed Search
Chapter 3 (Based on slides by Stuart Russell, Dan Weld, Oren Etzioni,
Henry Kautz, and other UW-AI faculty)
![Page 2: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/2.jpg)
What is Search?
• Search is a class of techniques for systematically finding or constructing solutions to problems.
• Example technique: generate-and-test. • Example problem: Combination lock.
1. Generate a possible solution. 2. Test the solution. 3. If solution found THEN done ELSE return to step
1.
2
![Page 3: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/3.jpg)
Search thru a Problem Space/State Space
– Set of states
– Operators [and costs]
– Start state
– Goal state [test]
3
• Path: start a state satisfying goal test
• [May require shortest path]
Input:
Output:
![Page 4: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/4.jpg)
Why is search interesting?
• Many (all?) AI problems can be formulated as search problems!
• Examples: • Path planning
• Games
• Natural Language Processing
• Machine learning
• …
4
![Page 5: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/5.jpg)
Example: The 8-puzzle
• states?
• actions?
• goal test?
• path cost?
5
![Page 6: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/6.jpg)
Example: The 8-puzzle
• states? locations of tiles • actions? move blank left, right, up, down • goal test? = goal state (given) • path cost? 1 per move •
• [Note: optimal solution of n-Puzzle family is NP-hard]
6
![Page 7: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/7.jpg)
Search Tree Example: Fragment of 8-Puzzle Problem Space
7
![Page 8: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/8.jpg)
Example: robotic assembly
• states?: real-valued coordinates of robot joint angles parts of the object to be assembled
• • actions?: continuous motions of robot joints • • goal test?: complete assembly • • path cost?: time to execute •
8
![Page 9: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/9.jpg)
Example: Romania
• On holiday in Romania; currently in Arad.
• Flight leaves tomorrow from Bucharest
•
• Formulate goal:
– be in Bucharest
–
• Formulate problem:
– states: various cities
– actions: drive between cities
–
• Find solution:
– sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
–
9
![Page 10: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/10.jpg)
Example: N Queens
• Input: – Set of states
– Operators [and costs]
– Start state
– Goal state (test)
• Output
10
Q
Q
Q
Q
![Page 11: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/11.jpg)
Implementation: states vs. nodes
• A state is a (representation of) a physical configuration • A node is a data structure constituting part of a search tree includes state, parent
node, action, path cost g(x), depth
• The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states.
•
11
![Page 12: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/12.jpg)
Search strategies
• A search strategy is defined by picking the order of node expansion
• Strategies are evaluated along the following dimensions:
– completeness: does it always find a solution if one exists?
– time complexity: number of nodes generated
– space complexity: maximum number of nodes in memory
– optimality: does it always find a least-cost solution?
– systematicity: does it visit each state at most once?
• Time and space complexity are measured in terms of
– b: maximum branching factor of the search tree
– d: depth of the least-cost solution
– m: maximum depth of the state space (may be ∞)
12
![Page 13: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/13.jpg)
Uninformed search strategies
• Uninformed search strategies use only the information
available in the problem definition
• Breadth-first search
• Depth-first search
• Depth-limited search
• Iterative deepening search
13
![Page 14: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/14.jpg)
Repeated states
• Failure to detect repeated states can turn a linear problem into an exponential one!
•
14
![Page 15: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/15.jpg)
Depth First Search • Maintain stack of nodes to visit
• Evaluation
– Complete?
– Time Complexity?
– Space Complexity?
15
a
b
c d
e
f g h
Yes except for infinite spaces
O(b^m)
O(bm)
http://www.youtube.com/watch?v=dtoFAvtVE4U
![Page 16: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/16.jpg)
Breadth First Search: shortest first
• Maintain queue of nodes to visit
• Evaluation
– Complete?
– Time Complexity?
– Space Complexity?
– Optimal?
16
a
b c
d e f g h
Yes (b is finite)
O(b^d)
O(b^d)
Yes, if stepcost=1
![Page 17: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/17.jpg)
Uniform Cost Search: cheapest first
• Maintain queue of nodes to visit
• Evaluation
– Complete?
– Time Complexity?
– Space Complexity?
– Optimal?
17
a
b c
d e f g h
Yes (b is finite)
O(b^(C*/e))
O(b^(C*/e))
http://www.youtube.com/watch?v=z6lUnb9ktkE
1 5
2 6 1 3 4 Yes
![Page 18: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/18.jpg)
Memory Limitation
• Suppose:
18
2 GHz CPU
1 GB main memory
100 instructions / expansion
5 bytes / node
200,000 expansions / sec
Memory filled in 100 sec … < 2 minutes
![Page 19: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/19.jpg)
Idea 1: Beam Search
• Maintain a constant sized frontier
• Whenever the frontier becomes large
– Prune the worst nodes
Optimal: no
Complete: no
![Page 20: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/20.jpg)
Idea 2: Iterative deepening search
20
![Page 21: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/21.jpg)
Iterative deepening search l =0
21
![Page 22: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/22.jpg)
Iterative deepening search l =1
22
![Page 23: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/23.jpg)
Iterative deepening search l =2
23
![Page 24: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/24.jpg)
Iterative deepening search l =3
24
![Page 25: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/25.jpg)
Iterative deepening search
• Number of nodes generated in a depth-limited search to depth d with branching factor b:
• NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd
• Number of nodes generated in an iterative deepening search to depth d with 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 –
• Overhead = (123,456 - 111,111)/111,111 = 11%
25
![Page 26: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/26.jpg)
iterative deepening search
• Complete? Yes
• Time? – (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd+1)
• Space? – O(bd)
• Optimal? – Yes, if step cost = 1 – Can be modified to explore uniform cost tree (iterative lengthening)
• Systematic?
26
![Page 27: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/27.jpg)
Summary of algorithms
28
![Page 28: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/28.jpg)
Forwards vs. Backwards
29
![Page 29: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/29.jpg)
vs. Bidirectional
30
When is bidirectional search applicable?
• Generating predecessors is easy
• Only 1 (of few) goal states
![Page 30: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/30.jpg)
Bidirectional search
• Complete? Yes
• Time? – O(bd/2)
• Space? – O(bd/2)
• Optimal? – Yes if uniform cost search used in both directions
• Systematic? – Yes
31
![Page 31: 573 lecture 2 - search I · What is Search? • Search is a class of techniques for systematically finding or constructing solutions to problems. • Example technique: generate-and-test](https://reader033.vdocuments.site/reader033/viewer/2022043002/5f800f6f39630a0d2d20dc35/html5/thumbnails/31.jpg)
Problem
• All these methods are slow (blind)
• Solution add guidance (“heuristic estimate”)
“informed search”
32