580 likes | 728 Views
Ch4 Heuristic Search. Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011. 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”
E N D
Ch4 Heuristic Search Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011
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 Introduction
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…
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
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
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
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
Introduction • 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
Introduction • The following topics in Heuristic includes: • Hill-Climbing and Dynamic Programming • Best-first-search • Using heuristic in Games
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
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
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
Hill-Climbing • 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
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
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
Dynamic Programming (DP) • One optimal alignment, among several possible, would be: • BAADDCABDDA • BBA_DC_B_ _A
Dynamic Programming (DP) • DP requires a data structure to keep track of the subproblem related to the state currently being processed • BAADDCABDDA • BBADCBA
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
Dynamic Programming (DP) • Start with a simple example • BCA • BA • We know the answer is • BCA • B_A
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)
Dynamic Programming (DP) • Once the array is filled, we begin the backward stage of the algorithm that produces particular solutions • We select where the match came from
Dynamic Programming (DP) _ B C A _ B _ A
Dynamic Programming (DP) • BAADDCABDDA • BBA_DC_B_ _A
Dynamic Programming (DP) • G A A T T C A G T T A • G G A _ T C _ G _ _ A
Introduction • The following topics in Heuristic includes: • Hill-climbing and dynamic programming • Best-first-search • Using heuristic in Games
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
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
Best First Search • 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
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
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
Best First Search • 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
Best First Search • Compare with BFS & DFS:
Introduction • The following topics in Heuristic includes: • Hill-climbing and dynamic programming • Best-first-search • Using heuristic in Games
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
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
Minimax Procedure on Exhaustively Search Graphs • Let’s have fun ^^ • Now we play a game with 7 cards
Minimax Procedure on Exhaustively Search Graphs State space for a variant of nim. Each state partitions the seven matches into one or more piles.
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
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
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)