200 likes | 278 Views
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
E N D
CS 385 Fall 2006Chapter 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 "Intelligence for a system with limited resources consists in making wise choices of what to do next." Newell and Simon Heuristics can • choose a most likely solution when exact is impossible (diagnosis) • guide a search along the most promising path when the state space is too large for complete search
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?
Figure 4.3:Heuristically reduced state space for tic-tac-toe.
Algorithms • Hill climbing (gradient search) Select the best child for further expansion. Don't retain siblings or parent • Dynamic programming (Math 305) • Best first States 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 are Lost and trying to find your way to Auburn? Looking for your keys? Integrating a function? Other examples?
best_first_search for Figure 4.4 Step Evaluate Open 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
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
Figure 4.9:The heuristic f applied to states in the 8-puzzle.
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 rules savings_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?
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
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
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?
Figure 4.19:Minimax for nim (0 = win for MIN, 1= win for MAX) Bold lines indicate forced win for MAX
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
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.
Figure 4.26:Alpha-beta pruning applied to state space of Figure 4.15. States without numbers are not evaluated.