CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart...
-
Upload
reginald-francis -
Category
Documents
-
view
216 -
download
0
Transcript of CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart...
![Page 1: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/1.jpg)
CSE 573: Artificial IntelligenceAutumn 2012
Heuristic Search
With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer
Dan Weld
![Page 2: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/2.jpg)
Todo
Integrate the following slides
2
![Page 3: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/3.jpg)
General Tree Search Paradigm
3
function tree-search(root-node) fringe successors(root-node) while ( notempty(fringe) ) {node remove-first(fringe)
state state(node)if goal-test(state) return solution(node)fringe insert-all(successors(node),fringe) }
return failureend tree-search
![Page 4: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/4.jpg)
Extra Work?
Failure to detect repeated states can cause exponentially more work (why?)
![Page 5: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/5.jpg)
General Graph Search Paradigm
5
function tree-search(root-node) fringe successors(root-node) explored empty while ( notempty(fringe) ) {node remove-first(fringe)
state state(node)if goal-test(state) return solution(node)explored insert(node,explored)fringe insert-all(successors(node),fringe, if node not in explored)
} return failureend tree-search
![Page 6: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/6.jpg)
Some Hints
Graph search is almost always better than tree search (when not?)
Implement your closed list as a dict or set!
Nodes are conceptually paths, but better to represent with a state, cost, last action, and reference to the parent node
![Page 7: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/7.jpg)
Informed (Heuristic) Search
7
Idea: be smartabout what pathsto try.
![Page 8: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/8.jpg)
Blind Search vs. Informed Search
What’s the difference?
How do we formally specify this?
A node is selected for expansion based on an evaluation function that estimates cost to goal.
8
![Page 9: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/9.jpg)
Best-First Search Use an evaluation function f(n) for node n. Always choose the node from fringe that has
the lowest f value. Fringe = priority queue
9
3 5 1
4 6
![Page 10: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/10.jpg)
Uniform Cost Search f(n) = cost from root
The good: UCS is complete and optimal!
The bad: Explores options in every
“direction” No information about goal
location
Start Goal
…
c 3
c 2
c 1
![Page 11: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/11.jpg)
Greedy Search f(n) = estimate of cost from n to goal
A common case: Takes you straight to the (wrong) goal
Worst-case: like a badly-guided DFS
…b
…b
![Page 12: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/12.jpg)
A* search f(n) = estimated total cost of path thru n to goal
f(n) = g(n) + h(n) g(n) = cost so far to reach n h(n) = estimated cost from n to goal
(satisfying some important conditions)
![Page 13: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/13.jpg)
Admissible heuristics
• A heuristic h(n) is admissible if for every node n,
• h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state from n.
• An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic
• Example: hSLD(n) (never overestimates the actual road distance)
• Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal
![Page 14: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/14.jpg)
Consistent Heuristics
• h(n) is consistent if – for every node n– for every successor n´ due to legal action a– h(n) <= c(n,a,n´) + h(n´)
• Every consistent heuristic is also admissible.• Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal 14
n
n´ G
c(n,a,n´) h(n´)
h(n)
![Page 15: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/15.jpg)
When should A* terminate?
Should we stop when we enqueue a goal?
S
B
A
G
2
3
2
2h = 1
h = 2
h = 0
h = 3
No: only stop when we dequeue a goal
![Page 16: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/16.jpg)
18
Which Algorithm?
![Page 17: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/17.jpg)
Which Algorithm?
![Page 18: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/18.jpg)
Which Algorithm?
![Page 19: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/19.jpg)
21
Which Algorithm?
Uniform cost search (UCS):
![Page 20: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/20.jpg)
Which Algorithm?
A*, Manhattan Heuristic:
![Page 21: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/21.jpg)
Which Algorithm?
Best First / Greedy, Manhattan Heuristic:
![Page 22: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/22.jpg)
End todo
24
![Page 23: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/23.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
Enviro
nm
ent
Percepts
Actions
![Page 24: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/24.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 25: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/25.jpg)
27
Search thru a
Set of states Operators [and costs] Start state Goal state [test]
Path: start a state satisfying goal test [May require shortest path] [Sometimes just need state passing test]
• Input:
• Output:
Problem Space / State Space Problem Space / State Space
![Page 26: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/26.jpg)
Example: N Queens
Input: Set of states
Operators [and costs]
Start state
Goal state (test)
Output
Q
Q
Q
Q
![Page 27: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/27.jpg)
Machine Learning : predict fuel efficiency
Discrete Data
Predict MPG
mpg cylinders displacement horsepower weight acceleration modelyear maker
good 4 low low low high 75to78 asiabad 6 medium medium medium medium 70to74 americabad 4 medium medium medium low 75to78 europebad 8 high high high low 70to74 americabad 6 medium medium medium medium 70to74 americabad 4 low medium low medium 70to74 asiabad 4 low medium low low 70to74 asiabad 8 high high high low 75to78 america: : : : : : : :: : : : : : : :: : : : : : : :bad 8 high high high low 70to74 americagood 8 high medium high high 79to83 americabad 8 high high high low 75to78 americagood 4 low low low low 79to83 americabad 6 medium medium medium high 75to78 americagood 4 medium low low low 79to83 americagood 4 low low medium high 79to83 americabad 8 high high high low 70to74 americagood 4 low medium low medium 75to78 europebad 5 medium medium medium medium 75to78 europe
X Y
Need to find “Hypothesis”: f : X Y
![Page 28: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/28.jpg)
Hypotheses: decision trees f : X Y
• Each internal node tests an attribute xi
• Each branch assigns an attribute value xi=v
• Each leaf assigns a class y
• To classify input x?
traverse the tree from root to leaf, output the labeled y
Cylinders
3 4 5 6 8
good bad badMaker Horsepower
low med highamerica asia europe
bad badgoodgood goodbad
![Page 29: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/29.jpg)
Search thru Space of Decision Trees
31
operator
![Page 30: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/30.jpg)
32
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 31: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/31.jpg)
State Space Graphs
State space graph: Each node is a state The successor function
is represented by arcs Edges may be labeled
with costs We can rarely build this
graph in memory (so we don’t)
S
G
d
b
p q
c
e
h
a
f
r
Ridiculously tiny search graph for a tiny search
problem
![Page 32: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/32.jpg)
State Space Sizes?
Search Problem: Eat all of the food
Pacman positions: 10 x 12 = 120
Pacman facing: up, down, left, right
Food Count: 30 Ghost positions: 12
![Page 33: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/33.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 34: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/34.jpg)
Example: Tree Search
S
G
d
b
p q
c
e
h
a
f
r
State Graph:
What is the search tree?
![Page 35: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/35.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 36: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/36.jpg)
States vs. Nodes Nodes in state space graphs are problem states
Represent an abstracted state of the world Have successors, can be goal / non-goal, have multiple predecessors
Nodes in search trees are plans Represent a plan (sequence of actions) which results in the node’s state Have a problem state and one parent, a path length, a depth & a cost The same problem state may be achieved by multiple search tree nodes
Depth 5
Depth 6
Parent
Node
Search Tree NodesProblem States
Action
![Page 37: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/37.jpg)
Building Search Trees
Search: Expand out possible plans Maintain a fringe of unexpanded plans Try to expand as few tree nodes as possible
![Page 38: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/38.jpg)
General Tree Search
Important ideas: Fringe Expansion Exploration strategy
Main question: which fringe nodes to explore?
Detailed pseudocode is in the book!
![Page 39: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/39.jpg)
Review: Depth First Search
S
G
d
b
p q
c
e
h
a
f
r
Strategy: expand deepest node first
Implementation: Fringe is a LIFO queue (a stack)
![Page 40: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/40.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 FIFO queue
![Page 41: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/41.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 problem
b The maximum branching factor B(the maximum number of successors for a state)
C* Cost of least cost solution
d Depth of the shallowest solution
m Max depth of the search tree
![Page 42: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/42.jpg)
DFS
Infinite paths make DFS incomplete… How can we fix this? Check new nodes against path from S
Infinite search spaces still a problem
Algorithm Complete Optimal Time Space
DFS Depth First Search
N N O(BLMAX) O(LMAX)
START
GOALa
b
No No Infinite Infinite
![Page 43: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/43.jpg)
DFS
Algorithm Complete Optimal Time Space
DFS w/ Path Checking Y if finite N O(bm) O(bm)
…b
1 node
b nodes
b2 nodes
bm nodes
m tiers
* Or graph search – next lecture.
![Page 44: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/44.jpg)
BFS
When is BFS optimal?
Algorithm Complete Optimal Time Space
DFS w/ Path Checking
BFS
Y N O(bm) O(bm)
Y Y O(bd) O(bd)
…b
1 node
b nodes
b2 nodes
bm nodes
d tiers
bd nodes
![Page 45: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/45.jpg)
Extra Work?
Failure to detect repeated states can cause exponentially more work (why?)
![Page 46: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/46.jpg)
Graph Search Very simple fix: never expand a state type twice
Can this wreck completeness? Why or why not? How about optimality? Why or why not?
![Page 47: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/47.jpg)
53
Memory a Limitation?
Suppose:• 4 GHz CPU• 6 GB main memory• 100 instructions / expansion• 5 bytes / node
• 400,000 expansions / sec• Memory filled in 300 sec … 5 min
![Page 48: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/48.jpg)
Comparisons
When will BFS outperform DFS?
When will DFS outperform BFS?
![Page 49: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/49.jpg)
Iterative DeepeningIterative deepening uses DFS as a subroutine:
1. Do a DFS which only searches for paths of length 1 or less.
2. If “1” failed, do a DFS which only searches paths of length 2 or less.
3. If “2” failed, do a DFS which only searches paths of length 3 or less.
….and so on.
Algorithm Complete Optimal Time Space
DFS w/ Path Checking
BFS
ID
Y N O(bm) O(bm)
Y Y O(bd) O(bd)
Y Y O(bd) O(bd)
…b
![Page 50: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/50.jpg)
56
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 51: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/51.jpg)
57
# of duplicates
Speed
8 Puzzle
2x2x2 Rubik’s
15 Puzzle
3x3x3 Rubik’s
24 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 branching factor 15 puzzle has greater depth
![Page 52: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/52.jpg)
© Daniel S. Weld 58
When to Use Iterative Deepening
N Queens?Q
Q
Q
Q
![Page 53: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/53.jpg)
Costs on Actions
Notice that BFS finds the shortest path in terms of number of transitions. It does not find the least-cost path.
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
![Page 54: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/54.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
Expand cheapest node first:
Fringe is a priority queue
![Page 55: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/55.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
16411
5
713
8
1011
17 11
0
6
39
1
1
2
8
8 1
15
1
2
Cost contours
2
![Page 56: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/56.jpg)
Uniform Cost SearchAlgorithm Complete Optimal Time Space
DFS w/ Path Checking
BFS
UCS
Y N O(bm) O(bm)
Y Y O(bd) O(bd)
Y* Y O(bC*/) O(bC*/)
…b
C*/ tiers
![Page 57: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/57.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 2
c 1
![Page 58: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/58.jpg)
Uniform Cost: Pac-Man
Cost of 1 for each action Explores all of the states, but one
![Page 59: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/59.jpg)
Exponentials Everywhere
66
“I think we’re going to need a stronger donkey…”
![Page 60: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/60.jpg)
Heuristics
67
![Page 61: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/61.jpg)
Search Heuristics
Any estimate of how close a state is to a goal Designed for a particular search problem
10
511.2
Examples: Manhattan distance, Euclidean distance
![Page 62: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/62.jpg)
Heuristics
![Page 63: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/63.jpg)
Best First / Greedy SearchExpand closest node first: Fringe is a priority queue
![Page 64: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/64.jpg)
Greedy Search
Expand the node that seems closest…
What can go wrong?
B
A
start
goal
![Page 65: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/65.jpg)
Best First / Greedy Search
A common case: Best-first takes you straight
to the (wrong) goal
Worst-case: like a badly-guided DFS in the worst case Can explore everything Can get stuck in loops if no
cycle checking
Like DFS in completeness (finite states w/ cycle checking)
…b
…b
![Page 66: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/66.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
If h(n) is admissible and monotonic
then A* is optimal
Underestimates cost of reaching goal from node
} f values increase fromnode to descendants(triangle inequality)
{
![Page 67: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/67.jpg)
Graph Search Detail
When do we check for goals? When adding to queue? When removing from queue?
![Page 68: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/68.jpg)
84
Optimality of A*
![Page 69: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/69.jpg)
85
Optimality Continued
![Page 70: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/70.jpg)
86
A* Summary
Pros
Cons
![Page 71: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/71.jpg)
87
Iterative-Deepening A* Like iterative-deepening depth-first, but... Depth bound modified to be an f-limit
Start with f-limit = h(start) Prune any node if f(node) > f-limit Next f-limit = min-cost of any node pruned
a
b
c
d
e
f
FL=15
FL=21
![Page 72: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/72.jpg)
88
IDA* Analysis Complete & Optimal (ala A*) Space usage depth of solution Each iteration is DFS - no priority queue! # nodes expanded relative to A*
Depends on # unique values of heuristic function In 8 puzzle: few values close to # A* expands In traveling salesman: each f value often unique
1+2+…+n = O(n2) where n=nodes A* expands
if n is too big for main memory, n2 is too long to wait!
Generates duplicate nodes in cyclic graphs
![Page 73: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/73.jpg)
© Daniel S. Weld 89
Forgetfulness
A* used exponential memory How much does IDA* use?
During a run? In between runs?
![Page 74: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/74.jpg)
© Daniel S. Weld 90
SMA* Use all available memory Start like A* When memory is full…
Erase node with highest f-value First, backup parent with this f-value So… parent knows cost-bound on best child
![Page 75: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/75.jpg)
© Daniel S. Weld 91
Alternative Approach to Finite Memory…
Optimality is nice to have, but…
![Page 76: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/76.jpg)
© Daniel S. Weld 93
No
O(b^d)
O(b + N)
Beam Search Idea
Best first but only keep N best items on priority queue
Evaluation Complete?
Time Complexity?
Space Complexity?
![Page 77: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/77.jpg)
© Daniel S. Weld 94
Hill ClimbingIdea Always choose best child; no
backtracking Beam search with |queue| = 1
Problems?• Local maxima
• Plateaus
• Diagonal ridges
“Gradient ascent”
![Page 78: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/78.jpg)
© Daniel S. Weld 95
Randomizing Hill Climbing
Randomly disobeying heuristic Random restarts
( heavy tailed distributions )
Local Search Local Search
![Page 79: CSE 573: Artificial Intelligence Autumn 2012 Heuristic Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld.](https://reader036.fdocuments.us/reader036/viewer/2022070400/56649f0d5503460f94c21376/html5/thumbnails/79.jpg)
© Daniel S. Weld96
Simulated Annealing Objective: avoid local minima Technique:
For the most part use hill climbing When no improvement possible
Choose random neighbor Let be the decrease in quality Move to neighbor with probability e --/T
Reduce “temperature” (T) over time Optimal?
temp
• If T decreased slowly enough, will reach optimal state Widely used
• See also WalkSAT