cs 385 fall 2006 chapter 4

20
1 CS 385 Fall 2006 Chapter 4 Heuristic Search

Upload: ora-kerr

Post on 01-Jan-2016

20 views

Category:

Documents


1 download

DESCRIPTION

CS 385 Fall 2006 Chapter 4. Heuristic Search. Heuristics. eurisko ("I discover" in Greek) "the study of the methods and rules of discovery and invention." Polya 1945 rules of thumb - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS 385 Fall 2006 Chapter 4

1

CS 385 Fall 2006Chapter 4

Heuristic Search

Page 2: CS 385 Fall 2006 Chapter 4

2

Heuristics

eurisko ("I discover" in Greek)

"the study of the methods and rules of discovery and invention." Polya 1945

rules of thumb

"Intelligence for a system with limited resources consists in making wise choices of what to do next." Newell and Simon

Heuristics can

1. choose a most likely solution when exact is impossible (diagnosis)

2. guide a search along the most promising path when the state space is too large for complete search

Page 3: CS 385 Fall 2006 Chapter 4

3

Examples

Tic tac toe: Pick the arc with the most winning paths

Chess: Use a board strength metric (pieces in danger, domination of center)

Soccer:Consider distance to goal, position of opposing team, surprise,...

Homework assignments?

Your life?

Page 4: CS 385 Fall 2006 Chapter 4

4

Figure 4.3: Heuristically reduced state space for tic-tac-toe.

Page 5: CS 385 Fall 2006 Chapter 4

5

Algorithms

1. Hill climbing (gradient search)Select the best child for further expansion.

Don't retain siblings or parent

2. Dynamic programming (Math 305)

3. Best firstStates on the open list sorted by a heuristic evaluation function.

When children are generated, all are added to open, in order

What do you use when you areLost and trying to find your way to Auburn?

Looking for your keys?

Integrating a function?

Other examples?

Page 6: CS 385 Fall 2006 Chapter 4

6

Step EvaluateOpen Closed

1 [A5] [ ]

2 A5 [B4, C4, D6] [A5]

3 B4 [C4, E5, F5, D6] [B4, A5]

4 C4 [H3, G4, E5, F5, D6] [C4, B4, A5]

5 H3 [O2, P3, G4, E5, F5, D6] [H3, C4, B4, A5]

6 O2 [P3, G4, E5, F5, D6] [O2, H3, C4, B4, A5]

7 P3 solution found

best_first_search for Figure 4.4

Page 7: CS 385 Fall 2006 Chapter 4

7

Heuristic search with open and closed states highlighted.

Page 8: CS 385 Fall 2006 Chapter 4

8

Heuristics applied to the 8-puzzle

Page 9: CS 385 Fall 2006 Chapter 4

9

Evaluation function f(n)

f(n) = g(n) + h(n)g(n): length of path from start state to n

h(n): heuristic estimate of the distance from n to goal

What does g do?If n is nearer the root, it is more likely to be on the shorted path to

the goal

This favors equally good states closer to the start

Page 10: CS 385 Fall 2006 Chapter 4

10

Figure 4.9: The heuristic f applied to states in the 8-puzzle.

Page 11: CS 385 Fall 2006 Chapter 4

11

Is there a single evaluation function?

No. Each step may have different reasoning.

E.g. chess, identical states may have different h(n) depending on history.

Real world: the pattern matcher picks the right heuristic to apply at each step.

Financial advisor: add certainty factors ( -1 to 1) to the rulessavings_account(adequate) ^ income(adequate)→ investment(stocks) confidence

0.8

savings_account(adequate) ^ income(adequate)→ investment(combination) confidence 0.5

savings_account(adequate) ^ income(adequate)→ investment(savings) confidence 0.1

What's funny here?

How would you use this?

Page 12: CS 385 Fall 2006 Chapter 4

12

Minimax for Games

You: want to MAX your gains

Opponent want to MIN your gains

Traditional Operations Research:Strategies 1-n for each player

Payoff matrix (i,j)th position is payoff to 1 if 1 picks strategy i and 2 picks strategy j

Game: Each player shows 0 or 1 fingers.

Even sum: player 1 wins $1, odd: player 2 wins $1

Payoff matrix: 1\2 0 1

0

1 1 -1

-1 1

Page 13: CS 385 Fall 2006 Chapter 4

13

Minimax for Games

What about this one?Payoff matrix: 1\2 0 1

0

1

1's reasoning: The worst I can do with strategy 1 is -10

The worst I can do with strategy 2 is 0

The best of the worst is 0

Pick strategy 2

max (min(-10, 0)) → payoff 0

1 -10

2 0

Page 14: CS 385 Fall 2006 Chapter 4

14

Nim

Start with 7 tokens in a pile

Each player divides a pile into an unequal number of tokens

The first player who cannot move, loses

Strategy?

Page 15: CS 385 Fall 2006 Chapter 4

15

Figure 4.19: Minimax for nim(0 = win for MIN, 1= win for MAX)Bold lines indicate forced win for MAX

Page 16: CS 385 Fall 2006 Chapter 4

16

Figure 4.21: Minimax to a hypothetical state space. Leaf states show heuristic values; internal states show backed-up values.

Note, we seem to be using min/max inconsistently

Page 17: CS 385 Fall 2006 Chapter 4

17

Alpha-Beta Pruning

Minimax investigates all paths to ply depth

Sometimes a path is obviously not worth following

Alpha-beta pruning removes those known to be worse than a possible outcome.

Page 18: CS 385 Fall 2006 Chapter 4

18

Figure 4.26: Alpha-beta pruning applied to state space of Figure 4.15. States without numbers are not evaluated.

Page 19: CS 385 Fall 2006 Chapter 4

19

Fig 4.30.

9

Page 20: CS 385 Fall 2006 Chapter 4

20

Figure 4.25