Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch4 Heuristic Search Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011.

Similar presentations


Presentation on theme: "Ch4 Heuristic Search Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011."— Presentation transcript:

1 Ch4 Heuristic Search Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

2 Introduction George Polya defines heuristic as: “the study of the methods and rules of discovery and invention” This meaning can be traced to the term’s Greek root, the verb eurisco, which means “I discover” When Archimedes emerged from his famous bath clutching the golden crown, he shouted “Eureka!!”, meaning I have found it IN AI, heuristics are formalized as Rules for choosing those branches in a state space that are most likely to lead to an acceptable problem solution

3 Introduction AI problem solvers employ heuristics in two basic situations: A problem may not have an exact solution because of inherent ambiguities in the problem statement or available data A problem may have an exact solution, but the computational cost of finding it may be prohibitive For example…

4 Introduction A problem may not have an exact solution because of inherent ambiguities in the problem statement or available data Medical diagnosis. Doctors use heuristic to choose the most likely diagnosis based on patient’s symptoms and description Vision. Vision systems often use heuristics to select the most likely of several possible interpretations of a scene

5 Introduction A problem may have an exact solution, but the computational cost of finding it may be prohibitive When brute force search techniques (BFS, DFS) may fail to find a solution within a reasonable amount of time

6 Introduction Unfortunately, like all rules of discovery and invention, heuristic are fallible A heuristic is only an informed guess of the next step to take A heuristic can lead a search to a suboptimal solution or fail to find any solution at all, because heuristic use limited information of the present situation

7 Introduction Consider heuristic in the game of tic-tac-toe A simple analysis put the total number of states for 9! Symmetry reduction decrease the search space Thus, there are not 9 but 3 initial moves: to a corner to the center of a side to the center of the grid

8 Introduction

9 Use of symmetry on the second level further reduces the number of path to 3* 12 * 7! A simple heuristic, can almost eliminate search entirely: we may move to the state in which X has the most winning opportunity In this case, X takes the center of the grid as the first step

10 Introduction

11

12 The following topics in Heuristic includes: Hill-Climbing and Dynamic Programming Best-first-search Using heuristic in Games

13 Hill-Climbing Te simplest way to implement heuristic search is through a procedure called hill- climbing It expend the current state of the search and evaluate its children The Best child is selected for further expansion Neither it sibling nor its parent are retained Tic-Tac-Toe we just saw is an example

14 Hill-Climbing Because it keeps no history, the algorithm cannot recover from failures of its strategy A major problem of hill-climbing is their tendency to become stuck at local maxima

15 Hill-Climbing Hill Climbing is named for the strategy that might be used by an eager, but blind mountain climber: Go uphill along the closest-to-the-top path until you can go no further up

16 Hill-Climbing

17 An example of local maximum in games occurs in the 8-puzzle. Often, in order to move a particular tile to its destination, other tiles already in their position need to move out This is a necessary step but temporarily worsens the board state Thus, hill climbing is not useful to the 8- puzzle game

18 Dynamic Programming (DP) DP keeps track of and reuses of multiple interacting and interrelated subproblems An example might be reuse the subseries solutions within the solution of the Fibonacci series The technique of subproblem caching for reuse is sometimes called memorizing partial subgoal solutions

19 Dynamic Programming (DP) One of the most famous current application in DP is “sequence alignment” Suppose we want to find the best possible alignment for the characters in the strings BAADDCABDDA BBADCBA

20 Dynamic Programming (DP) One optimal alignment, among several possible, would be: BAADDCABDDA BBA_DC_B_ _A

21 Dynamic Programming (DP) DP requires a data structure to keep track of the subproblem related to the state currently being processed BAADDCABDDA BBADCBA

22 Dynamic Programming (DP) The array reflects the global alignment success to that point in the matching process There are 3 possible costs for creating the current state: Cost is 0 when characters are identical Cost is 1 when a character is shifted or inserted Cost is 2 when a character is shifted and inserted

23 Dynamic Programming (DP) Start with a simple example BCA BA We know the answer is BCA B_A

24 Dynamic Programming (DP) The function is try to find the minimum of (x-1,y),(x,y-1),(x-1,y-1) for (x,y) If there’s a match for (x,y), add 0 to (x-1,y-1) If there’s no match for (x,y), add 1 to (x- 1,y),(x,y-1), as well as add 2 to (x-1,y-1)

25 Dynamic Programming (DP) _BCA _0123 B1 012 A2 121

26 Once the array is filled, we begin the backward stage of the algorithm that produces particular solutions We select where the match came from

27 Dynamic Programming (DP) _BCA _ 0 123 B1 01 2 A2 12 1 _ B C A _ B _ A

28 Dynamic Programming (DP) _BAADDCABDDA _01234567891011 B1012345678910 B212345676789 A321234567898 D432323456789 C543434345678 B654545454567 A765456545676

29 Dynamic Programming (DP) BAADDCABDDA BBA_DC_B_ _A

30 Dynamic Programming (DP) _ GAATTCAGTTA _01234567891011 G 1012345678910 G 212345676789 A 321234567898 T 432323456789 C 543434345678 G 654545454567 A 765456545676

31 Dynamic Programming (DP) G A A T T C A G T T A G G A _ T C _ G _ _ A

32 Introduction The following topics in Heuristic includes: Hill-climbing and dynamic programming Best-first-search Using heuristic in Games

33 Best First Search For the 8-puzzle game, we may add 3 different types of information into the code: The simplest heuristic counts the tiles out of space in each state A “better” heuristic would sum all the distances by which the tiles are out of space

34 Best First Search Both of these heuristics can be criticized for failing to acknowledge the difficulty of tile reversals That is, if two tiles are next to each other and the goal requires their being in opposite locations, it takes several moves to put them back 213 84 765

35 Best First Search

36 In previous figure, the sum of distance heuristics does provide a much accurate estimate of the work This example illustrates the difficulty of devising good heuristics The design of good heuristic is an empirical problem; judgment and intuition help, but the final measure of a heuristic must be its actual performance

37 Best First Search If two states have the same or nearly the same heuristic evaluation, it is generally preferable to examine the state that is nearest to the root So that we may obtain the shortest path to the goal

38 Best First Search For 8-puzzle problem, let’s make our evaluation function f to be : f(n) = g(n) + h(n) g(n) means the actual length of path from n to the root h(n) is a heuristic estimate (sum of distance out of space) of the distance from state n to a goal

39 Best First Search

40

41 In step 3, both e and f have a heuristic of 5 State e is examined first, producing h and i Compare with all children, select the best move

42 Best First Search Compare with BFS & DFS:

43 Introduction The following topics in Heuristic includes: Hill-climbing and dynamic programming Best-first-search Using heuristic in Games

44 Minimax Procedure on Exhaustively Search Graphs Games have always been an important application area for heuristic algorithm Two person games are more complicated than simple puzzle because of the existence of a “hotile” and unpredictable opponent

45 Minimax Procedure on Exhaustively Search Graphs Let’s consider a variant of the game nim To play this game, a number of tokens are placed on a table between the two players At each move, the player must divide a pile of tokens into two nonempty piles of different sizes Thus, 6 tokens my be divided into piles of 5&1 or 4&2 but not 3&3 The first player who can no longer make a move loses the game

46 Minimax Procedure on Exhaustively Search Graphs Let’s have fun ^^ Now we play a game with 7 cards

47 Minimax Procedure on Exhaustively Search Graphs State space for a variant of nim. Each state partitions the seven matches into one or more piles.

48 Minimax Procedure on Exhaustively Search Graphs In playing games whose state space may be exhaustively delineated, the primary difficulty is in accounting for the actions of the opponent A simple way to handle this assumes that your opponent uses the same knowledge Minimax searches the games space under this assumption

49 Minimax Procedure on Exhaustively Search Graphs The opponents in a game are referred to as MIN and MAX MAX represents the player trying to win MIN is the opponent who attempts to minimize MAX’s score

50 Minimax Procedure on Exhaustively Search Graphs We label each level in the search space according to whose move it is at the point in the game Each leaf node is given a value of 1 or 0, depending on whether a win for MAX (1) or for MIN (0)

51 Minimax Procedure on Exhaustively Search Graphs

52 Minimax propagates these values up the graph through successive parent nodes according to the rule: If the parent is a MAX node, give it the maximum value among its children If the parent is a MIN node, give it the minimum value among its children

53 Minimax Procedure on Exhaustively Search Graphs

54 Because all of MIN’s possible first moves lead to nodes with a derived values of 1, the second player always can force the game to a win, regardless of MIN’s first move

55 Minimax to Fixed Ply Depth In applying minimax to more complicated games, it is seldom possible to expand the state space search graph out to the leaf node Instead, the state space is searched to a predefined number of levels This is called an n-ply look ahead

56 Minimax to Fixed Ply Depth As the leaves of this subgraph is not complete, it is not possible to give them win or loss Instead, each node is given a value according to some heuristic evaluation In chess, you may consider the number of pieces belonging to MAX and MIN A more sophisticated strategy might assign different values to each piece

57 Minimax to Fixed Ply Depth Minimax propagates these values up the graph through successive parent nodes according to the rule: If the parent is a MAX node, give it the maximum value among its children If the parent is a MIN node, give it the minimum value among its children

58 Minimax to Fixed Ply Depth


Download ppt "Ch4 Heuristic Search Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011."

Similar presentations


Ads by Google