CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle...
Transcript of CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle...
![Page 1: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/1.jpg)
CSE 573: Artificial Intelligence
Problem Spaces & Search
With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer, Dana Nau…
Dan Weld
![Page 2: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/2.jpg)
Logistics
§ Read Ch 3
§ Form 2-person teams. § Post on forum if you want a partner
§ Start PS1
![Page 3: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/3.jpg)
Outline
§ Search Problems
§ Uninformed Search Methods§ Depth-First Search§ Breadth-First Search§ Iterative Deepening Search§ Uniform-Cost Search
§ Heuristic Search Methods§ Heuristic Generation
![Page 4: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/4.jpg)
Agent vs. Environment
§ An agent is an entity that perceives and acts.
§ A rational agent selects actions that maximize its utility function.
§ Characteristics of the percepts, environment,and action space dictate techniques for selecting rational actions.
Agent
Sensors
?
Actuators
Environment
Percepts
Actions
![Page 5: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/5.jpg)
Goal Based Agents
§ Plan ahead§ Ask “what if”
§ Decisions based on (hypothesized) consequences of actions
§ Must have a model of how the world evolves in response to actions
§ Act on how the world WOULD BE
![Page 6: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/6.jpg)
Search: It’s not just for Agents
11
Hardware verificationPlanning optimal repair
sequences
![Page 7: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/7.jpg)
Search thru a
§ Set of states§ Operators [and costs]§ Start state§ Goal state [or test]
• Path: start Þ a state satisfying goal test[May require shortest path][Sometimes just need a state that passes test]
• Input:
• Output:
Problem Space (aka State Space) Functions: States à States
Aka “Successor Function”
![Page 8: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/8.jpg)
Example: Simplified Pac-Man§ Input:
§ A state space
§ Successor function
§ A start state
§ A goal test
§ Output:
“N”, 1.0
“E”, 1.0
![Page 9: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/9.jpg)
Ex: Route Planning: Arad à Bucharest
§ Input:§ Set of states
§ Operators [and costs]
§ Start state
§ Goal state (test)
§ Output:
Different operators may be applicable in different states
![Page 10: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/10.jpg)
Ex:DockWorkerRobots§ A harbor with several locations
§ e.g., docks, docked ships, storage areas, parking areas§ Containers
§ going to/from ships§ Robot vehicles
§ can move containers§ Cranes
§ can load andunload containers
Slide adapted from Dana Nau “Automated Planning”, licensed under creative commons NC share alike
§ Multiple robots can operate at the same time§ Move, load & other actions have different durations
![Page 11: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/11.jpg)
Dock Worker 2Input:
§ Set of states
§ Operators [and costs]
§ Start state
§ Goal test
Partially specified plans
Plan modification operators
The null plan (no actions)
A plan which provably achieves the desired world configuration
Slide adapted from Dana Nau “Automated Planning”, licensed under creative commons NC share alike
![Page 12: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/12.jpg)
Plan Space
18
Unload 1 A
Add Action
Constrain Ordering
Move BUnload 1 A
Add Action
Move BUnload 1 A <
Blue boxes are plans = states in search spaceOperators modify plansSuccessors(p) = all possible ways of modifying p
![Page 13: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/13.jpg)
19
Multiple Problem Spaces
Real WorldStates of the world (e.g. loading dock configurations) Actions (take one world-state to another)
• Problem Space 1• PS states =
• models of world states• Operators =
• models of actions
Robot’s Head
• Problem Space 2• PS states =
• partially spec. plan• Operators =
• plan modificat’n ops
![Page 14: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/14.jpg)
Algebraic Simplification
20
§ Input:§ Set of states
§ Operators [and costs]
§ Start state
§ Goal state (test)
§ Output:
![Page 15: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/15.jpg)
State Space Graphs§ State space graph:
§ Each node is a state§ The operators are repre-
sented by arcs§ Edges may be labeled
with costs
§ We can rarely build this graph in memory (so we don’t try)
S
G
d
b
p q
c
e
h
a
f
r
Ridiculously tiny search graph for a tiny search problem
![Page 16: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/16.jpg)
State Space Sizes?
§ Search Problem:Eat all of the food
§ Pacman positions:10 x 12 = 120
§ Pacman facing:up, down, left, right
§ Food configurations: 230
§ Ghost1 positions: 12§ Ghost 2 positions: 11
10 x 12 = 120
up, down, left, right230
1211
120 x 4 x 230 x 12 x 11 = 6.8 x 1013
![Page 17: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/17.jpg)
Search Methods§ Blind Search
§ Local Search§ Informed Search§ Constraint Satisfaction§ Adversary Search
• Depth first search• Breadth first search• Iterative deepening search• Uniform cost search
![Page 18: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/18.jpg)
Search Trees
§ A search tree:§ Start state at the root node§ Children correspond to successors§ Nodes contain states, correspond to PLANS to those states§ Edges are labeled with actions and costs§ For most problems, we can never actually build the whole tree
“E”, 1.0“N”, 1.0
![Page 19: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/19.jpg)
Example: Tree Search
S
G
d
b
p q
c
e
h
a
f
r
State graph:
What is the search tree?
![Page 20: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/20.jpg)
State Graphs vs. Search Trees
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c Ga
S
G
d
b
p q
c
e
h
a
f
r
We construct both on demand – and we construct as little as possible.
Each NODE in in the search tree denotes an entire PATH in the problem graph.
![Page 21: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/21.jpg)
States vs. Nodes§ Vertices in state space graphs are problem states
§ Represent an abstracted state of the world§ Have successors, can be goal / non-goal, have multiple predecessors
§ Vertices in search trees (“Nodes”) are plans§ Contain a problem state and one parent, a path length, a depth & a cost§ Represent a plan (sequence of actions) which results in the node’s state§ The same problem state may be achieved by multiple search tree nodes
Depth 5
Depth 6
Parent
Node
Search Tree NodesProblem States
Action
![Page 22: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/22.jpg)
Building Search Trees
§ Search:§ Expand out possible nodes (plans) in the tree§ Maintain a fringe of unexpanded nodes§ Try to expand as few nodes as possible
![Page 23: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/23.jpg)
General Tree Search
Important ideas:§ Fringe (leaves of tree)§ Expansion (adding successors of a leaf)§ Exploration strategy
which fringe node to expand next?
Detailed pseudocode is in the book!
![Page 24: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/24.jpg)
Review: Depth First Search
S
G
d
b
p q
c
e
h
a
f
rStrategy: expand deepest node first
Implementation: Fringe is a stack - LIFO
![Page 25: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/25.jpg)
Review: Depth First Search
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c G
a
S
G
d
b
p q
c
e
h
a
f
rqp
hfd
ba
c
e
r
Expansion ordering:
(d,b,a,c,a,e,h,p,q,q,r,f,c,a,G)
![Page 26: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/26.jpg)
Review: Breadth First Search
S
G
d
b
p q
c
e
h
a
f
r
Strategy: expand shallowest node first
Implementation: Fringe is a queue - FIFO
![Page 27: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/27.jpg)
Review: Breadth First Search
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c G
a
S
G
d
b
p q
ce
h
a
f
r
Search
Tiers
Expansion order:(S,d,e,p,b,c,e,h,r,q,a,a,h,r,p,q,f,p,q,f,q,c,G)
![Page 28: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/28.jpg)
Search Algorithm Properties
§ Complete? Guaranteed to find a solution if one exists?§ Optimal? Guaranteed to find the least cost path?§ Time complexity?§ Space complexity?
Variables:
n Number of states in the problemb The maximum branching factor B
(the maximum number of successors for a state)C* Cost of least cost solutiond Depth of the shallowest solutionm Max depth of the search tree
![Page 29: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/29.jpg)
Depth-First Search
§ Infinite paths make DFS incomplete…§ How can we fix this?§ Check new nodes against path from S
Algorithm Complete Optimal Time SpaceDFS Depth First
SearchN N AX) O(LMAX)
START
GOALa
b
No No O(bm) O(b m)
d depth of solutionm max depth of tree
![Page 30: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/30.jpg)
DFS Search (w/ cycle checking)
Algorithm Complete Optimal Time SpaceDFS w/ Path
Checking Y if finite N
…b 1 node
b nodes
b2 nodes
bm nodes
m tiers
O(bm) O(b m)
Only if finite tree
![Page 31: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/31.jpg)
BFS Tree SearchAlgorithm Complete Optimal Time SpaceDFS w/ Path
Checking
BFS
N unlessfinite
N O(bm) O(bm)
Y* Y* O(bd) O(bd)
…b 1 node
b nodes
b2 nodes
bm nodes
d tiers
bd nodes
* Assuming finite branching factor
![Page 32: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/32.jpg)
Memory a Limitation?§ Suppose:
• 4 GHz CPU• 32 GB main memory• 100 instructions / expansion• 5 bytes / node
• 40 M expansions / sec• Memory filled in … 3 min
![Page 33: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/33.jpg)
39
§ DFS with limit; incrementally grow limit§ Evaluation
Iterative Deepening Search
a
![Page 34: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/34.jpg)
40
§ DFS Tree Search with limit; incrementally grow limit§ Evaluation
Iterative Deepening Search
a b
c d
![Page 35: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/35.jpg)
41
§ DFS Tree Search with limit; incrementally grow limit§ Evaluation
§ Complete?
§ Time Complexity?
§ Space Complexity?
Iterative Deepening Search
a b e
c f d i
g h lkj
![Page 36: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/36.jpg)
42
§ DFS with limit; incrementally grow limit§ Evaluation
§ Complete?
§ Time Complexity?
§ Space Complexity?
Iterative Deepening Search
a b e
c d
Yes *
O(bd)
O(bd)
d
* Assuming branching factor is finiteImportant Note: no cycle checking necessary!
![Page 37: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/37.jpg)
43
Cost of Iterative Deepening
b ratio ID to DFS
2 3
3 2
5 1.5
10 1.2
25 1.08
100 1.02
![Page 38: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/38.jpg)
# of duplicates
Speed
8 Puzzle
2x2x2 Rubik’s15 Puzzle
3x3x3 Rubik’s24 Puzzle
105 .01 sec
106 .2 sec
1017 20k yrs
1020 574k yrs
1037 1023 yrs
BFSNodes Time
Iter. Deep.Nodes Time
Assuming 10M nodes/sec & sufficient memory
105 .01 sec
106 .2 sec
1013 6 days
1019 68k yrs
1025 12B yrs
Slide adapted from Richard Korf presentation
Why the difference?
8x
1Mx
Rubik has higher branch factor15 puzzle has greater depth
![Page 39: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/39.jpg)
Search Methods§ Depth first search (DFS)§ Breadth first search (BFS)§ Iterative deepening depth-first search (IDS)
45
![Page 40: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/40.jpg)
Search Methods§ Depth first search (DFS)§ Breadth first search (BFS)§ Iterative deepening depth-first search (IDS)§ Best first search§ Uniform cost search (UCS)§ Greedy search§ A*§ Iterative Deepening A* (IDA*)§ Beam search§ Hill climbing 46
![Page 41: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/41.jpg)
Blind vs Heuristic Search
§ Costs on Actions
§ Heuristic Guidance
47
![Page 42: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/42.jpg)
Costs on Actions
Objective: Path with smallest overall cost
START
GOAL
d
b
p q
c
e
h
a
f
r
2
9 2
81
8
2
3
14
4
151
3 22
![Page 43: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/43.jpg)
Costs on Actions
What will BFS return?
START
GOAL
d
b
p q
c
e
h
a
f
r
2
9 2
81
8
2
3
14
4
151
3 22
… finds the shortest path in terms of number of transitions. It does not find the least-cost path.
![Page 44: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/44.jpg)
50
Best-First Search§ Generalization of breadth-first search§ Fringe = Priority queue of nodes to be explored§ Cost function f(n) applied to each node
![Page 45: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/45.jpg)
Tree vs Graph Search
In BFS, for example, we shouldn’t bother expanding the circled nodes (why?)
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c G
a
![Page 46: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/46.jpg)
Graph Search§ Very simple fix: never expand a state type twice
![Page 47: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/47.jpg)
Some Hints
§ On small problems§ Graph search almost always better than tree search
§ Implement your closed list as a dict or set!
§ On many real problems§ Storage space is a huge concern§ Graph search impractical
![Page 48: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/48.jpg)
55
Best-First Search§ Generalization of breadth-first search§ Fringe = Priority queue of nodes to be explored§ Cost function f(n) applied to each node
Add initial state to priority queueWhile queue not empty
Node = head(queue)If goal?(node) then return nodeAdd new children of node to queue
“expanding the node”
![Page 49: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/49.jpg)
56
Old Friends§ Breadth First =
§ Best First§ with f(n) = depth(n)
§ Dijkstra’s Algorithm (Uniform cost) = § Best First§ with f(n) = the sum of edge costs from start to n
![Page 50: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/50.jpg)
Uniform Cost Search
START
GOAL
d
b
pq
c
e
h
a
f
r
2
9 2
81
8
2
3
1
4
4
15
1
32
2
Best first, where f(n) = “cost from start to n”
aka “Dijkstra’s Algorithm”
![Page 51: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/51.jpg)
Uniform Cost Search
S
a
b
d p
a
c
e
p
h
f
r
q
q c G
a
qe
p
h
f
r
q
q c G
a
Expansion order:S, p, d, b, e, a, r, f, e, G S
G
d
b
p q
c
e
h
a
f
r
3 9 1
164 115
713
8
1011
17 11
0
6
3 9
1
1
2
8
8 1
15
1
2
Cost contours
(not all shown)
2
![Page 52: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/52.jpg)
Uniform Cost SearchAlgorithm Complete Optimal Time SpaceDFS w/ Path
Checking
BFS
UCS
Y if finite N O(bm) O(bm)
Y Y* O(bd) O(bd)
Y* Y O(bC*/e) O(bC*/e)
…b
C*/e tiers
C* = Optimal cost
e = Minimum cost of an action
![Page 53: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/53.jpg)
Uniform Cost Issues§ Remember: explores
increasing cost contours
§ The good: UCS is complete and optimal!
§ The bad:§ Explores options in every “direction”
§ No information about goal location Start Goal
…
c £ 3
c £ 2c £ 1
![Page 54: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/54.jpg)
Uniform Cost: Pac-Man§ Cost of 1 for each action§ Explores all of the states, but one
![Page 55: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/55.jpg)
What is a Heuristic?§ An estimate of how close a state is to a goal§ Designed for a particular search problem
10
511.2
§ Examples: Manhattan distance: 10+5 = 15Euclidean distance: 11.2
![Page 56: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/56.jpg)
What is a Heuristic?§ An estimate of how close a state is to a goal§ Designed for a particular search problem
10
§ Actual distance to goal: 2+4+2+1+8=
10
5
![Page 57: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/57.jpg)
Greedy SearchBest first with f(n) = heuristic estimate of distance to goal
![Page 58: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/58.jpg)
Greedy SearchExpand the node that seems closest…
What can go wrong?
B
A
start
goal
![Page 59: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/59.jpg)
Greedy Search§ Common case:
§ Best-first takes you straight to a (suboptimal) goal
§ Worst-case: like a badly-guided DFS§ Can explore everything§ Can get stuck in loops if no
cycle checking
§ Like DFS in completeness§ Complete w/ cycle checking§ If finite # states
…b
…b
![Page 60: CSE 573: Artificial Intelligence - courses.cs.washington.edu · # of duplicates Speed 8 Puzzle 2x2x2 Rubikʼs 15 Puzzle 3x3x3 Rubikʼs 24 Puzzle 105.01 sec 106.2 sec 1017 20k yrs](https://reader034.fdocuments.in/reader034/viewer/2022042807/5f7e40f8ca0f68334c47dd4f/html5/thumbnails/60.jpg)
A* SearchHart, Nilsson & Rafael 1968
Best first search with f(n) = g(n) + h(n)§ g(n) = sum of costs from start to n§ h(n) = estimate of lowest cost path n ® goal
h(goal) = 0
Can view as cross-breed:g(n) ~ uniform cost searchh(n) ~ greedy search
Best of both worlds…