Upload
cynthia-webster
View
220
Download
0
Tags:
Embed Size (px)
Citation preview
HEURISTIC SEARCH
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Portion of the state space for tic-tac-toe.
Heuristically reduced state space for tic-tac-toe.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
First three levels of the tic-tac-toe state space reduced by symmetry
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
The “most wins” heuristic applied to the first children in tic-tac-toe.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Is it possible to completely cover with non-overlapping dominos an 8x8 grid having two diagonally opposite corners removed?
Is it possible to completely cover with non-overlapping dominos an 8x8 grid having two diagonally opposite corners removed?
Is it possible to completely cover with non-overlapping dominos an 8x8 grid having two diagonally opposite corners removed?
Issues:1) Representation
(organization)2) Algorithm
(process)
The local maximum problem for hill-climbing with 3-level look ahead
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
priority queue
not necessary if states are added to open in sorted order
not necessary if using a monotone heuristic
Heuristic search of a hypothetical state space.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
(assume P3 is the goal state and lower scores are preferred)
A trace of the execution of best_first_search for previous figure.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Heuristic search of a hypothetical state space with open and closed states highlighted.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Eight Puzzle…
Compare:best-first with depth factor: 26 moves to solution(7725 in CLOSED; 7498 left in OPEN)
best-first without depth factor: 48 moves to solution(272 in CLOSED; 332 in OPEN)
30 shuffle moves
Consider this screen shot of a brute-force breath-first search in process for the 15-puzzle where the optimal solution is known (by another method) to be located at depth 26.
How long will it take to find the solution?
The start state, first moves, and goal state for an example-8 puzzle.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
1 2 34 5 67 8
or
Goal
Three heuristics applied to states in the 8-puzzle.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
The heuristic f applied to states in the 8-puzzle.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
(but should use a better heuristic…)
State space generated in heuristic search of the 8-puzzle graph.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Notice that Luger is using the “Tiles out of place” heuristic.
State space generated in heuristic search of the 8-puzzle graph.
The successive stages of open and closed that generate this graph are:
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Open and closed as they appear after the 3rd iteration of heuristic search
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Heuristic search with inclusion of a depth factor(heuristic here is # of tiles out of place) Nilsson
i.e., as long as h(n) is not overestimated(i.e., because that could prevent search of the optimal path)
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
(i.e., locally admissible)
Note: If the graph search algorithm for best-first search is used with a monotonic heuristic, a new path cannot be shorter than one already found.
Note: the best h(n) can be is the actual cost of the optimal path from node n to the goal. If h1(n) < h2(n), then h1(n) is actually underestimating the cost more than h2(n) and is, therefore, less informed.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Comparison of state space searched using heuristic search with space searched by breadth-first search. The proportion of the graph searched heuristically is shaded. The optimal search selection is in bold. Heuristic used is f(n) = g(n) + h(n) where h(n) is tiles out of place.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Number of nodes generated as a function of branching factor, B, for various lengths, L, of solution paths. The relating equation is T = (BL+1 – 1)/(B – 1), adapted from Nilsson (1980)*.
*Note: equation in text is incorrect but the one shown here is correct for root node at depth 0
Bra
nchi
ng F
acto
r =
B
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Informal plot of cost of searching and cost of computing heuristic evaluation against informedness of heuristic, adapted from Nilsson (1980).
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
(i.e., cost to run the heuristic)
(i.e., cost to traverse the search graph)
Two-“Person” GamesTwo-“Person” Games
State space for a variant of Nim. Each state partitions the seven matches into one or more piles of different sizes. First player who cannot make a legal move, wins.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Exhaustive minimax for the game of Nim. Bold lines indicate forced win for MIN. Each node is marked with its derived value (0 or 1) under minimax.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Note: Figure is slightly different from text...
Getting ready to apply minimax to a hypothetical state space. Leaf states show heuristic values.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Applying minimax to a hypothetical state space. Leaf states show heuristic values; internal states show backed-up values.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Heuristic measuring conflict applied to states of tic-tac-toe.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Two-ply minimax applied to the opening move of tic-tac-toe, from Nilsson (1971).
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Two ply minimax, and one of two possible MAX second moves, from Nilsson (1971).
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Two-ply minimax applied to X’s move near the end of the game, from Nilsson (1971).
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Let’s reconsider the application of minimax to the hypothetical state space shown a few slides back...
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Alpha-Beta Pruning
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Alpha-beta pruning applied to the previous minimax state space search. States without numbers are not evaluated.
Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005
Alpha-Beta SearchAlpha-Beta SearchAs successors of a node are given backed-up values, the bounds As successors of a node are given backed-up values, the bounds on the backed-up values can change but:on the backed-up values can change but:– Alpha values of MAX nodes can never decreaseAlpha values of MAX nodes can never decrease– Beta values of MIN nodes can never increaseBeta values of MIN nodes can never increase
Rules for discontinuing search:Rules for discontinuing search:– Discontinue search below any MIN node having a beta value ≤ to Discontinue search below any MIN node having a beta value ≤ to
alpha value of any of its MAX node ancestors. Final backed-up value alpha value of any of its MAX node ancestors. Final backed-up value of this MIN node can be set to its beta value.of this MIN node can be set to its beta value.
– Discontinue search below any MAX node having an alpha value ≥ Discontinue search below any MAX node having an alpha value ≥ the beta value of any of its MIN node ancestors. Final backed-up the beta value of any of its MIN node ancestors. Final backed-up value of this MAX node can be set to its alpha value.value of this MAX node can be set to its alpha value.
Rules for computing alpha and beta values:Rules for computing alpha and beta values:– The alpha value of a MAX node is set equal to the current largest The alpha value of a MAX node is set equal to the current largest
final backed-up value of its successors.final backed-up value of its successors.– The beta value of a MIN node is set equal to the current smallest The beta value of a MIN node is set equal to the current smallest
final backed-up value of its successors.final backed-up value of its successors.
102 8 4 5 8 3 2 7 6 2 5 1 0
Mini-Max
102 8 4 5 8 3 2 7 6 2 5 1 0
10 8 8 3 7 5 1
138
8 Max’s move
Here are the backed-up values
Min’s move
Max takes this move
Mini-Max
102 8 4 5 8 3 2 7 6 2 5 1 0
Mini-Max with Alpha-Beta Cutoffs
Mini-Max with Alpha-Beta Cutoffs
Node α-β valuesA (max) α = -, β = B (min) α = -, β = E (max) α = -, β = LE (max) α = 2, β = ME (max) α = 10, β = B (min) α = -, β = 10F (max) α = -, β = 10NF (max) α = 8, β = 10OF (max) α = 8, β = 10B (min) α = -, β = 8A (max) α = 8, β = C (min) α = 8, β = G (max) α = 8, β = PG (max) α = 8, β = QG (max) α = 8, β = C (min) α = 8, β = 8Search terminated below C because β @ C <= α @ A A (max) α = 8, β = D (min) α = 8, β = J (max) α = 8, β = VJ (max) α = 8, β = WJ (max) α = 8, β = D (min) α = 8, β = 5Search terminated below D because β @ D <= α @ A
Processing sequence for α-β assignment and visiting leaf nodes:
32 8 5 7 6 0 1 5 2 8 4 10 2
E
Max
MinB
A
F MaxG H
C
J
D
KI
Another Example of Mini-Max with Alpha-Beta Cutoffs
32 8 5 7 6 0 1 5 2 8 4 10 2
Eα=3
Max’s move
Here are the final alpha-beta (=backed-up) values(X denotes branches that do not need to be searched)
Min’s move
Max takes this move
Bβ=3
Aα=8
Fα=8
Max’s move
X
Gα=7
X
Hα=1
Cβ=1
X
Jα=8
Dβ=8
Kα=10
X
I
Another Example of Mini-Max with Alpha-Beta Cutoffs
There is no need to search below a MAX node whose value is greater than the parent node’s value (because the MIN node above wouldn’t accept anything > than its value), nor to search below a MIN node (e.g., node C) whose value is less than the parent’s value (because the MAX node above wouldn’t accept anything < than its value).
Processing sequence:
Node α or β valueE α=3B β=3F α=8No search of F’s right subtree because α @ F > β @ BG α=7No search of G’s right subtree because α @ G > β @ BA α=3H α=1C β=1No search of C’s right subtree because β @ C < α @ AJ α=8D β=8K α=10No search of K’s right subtree because α @ K > β @ DA α=8
note: α or β values are also the backed-up values...
32 8 5 7 6 0 1 5 2 8 4 10 2
Eα=3
Max’s move
Here are the final alpha-beta (=backed-up) values(X denotes branches that do not need to be searched)
Min’s move
Max takes this move
Bβ=3
Aα=8
Fα=8
Max’s move
X
Gα=7
X
Hα=1
Cβ=1
X
Jα=8
Dβ=8
Kα=10
X
I
Processing Sequence for Previous Search