HEURISTIC SERCH George F Luger RTIFICIL INTELLIGENCE 6th edition Structures and Strategies for Complex Problem Solving Introduction Two main concerns of I researchers 1) Representation of the knowledge ddresses the capturing of the full range of knowledge using a proper language 2) Search for a logical alternative Concerned with the searching of an alternative solution based on the knowledge 1 2 Introduction Two problems with the search process problem may not have an exact solution due to inherent ambiguities in the problem statement or available data E.g. medical diagnosis problem may have an exact solution, but the computational cost of finding it may be prohibitive E.g. chess Heuristics are often used to solve the two problems Heuristics In state space search, heuristics are rules for choosing the branches that will most likely lead to an acceptable problem solution (a goal state) heuristic is an informed guess of the next step to be taken in solving a problem It is often based on experience or intuition It can lead to a suboptimal solution or fail to find any solution at all 3 4
Heuristic Search It is helpful to think of heuristic search from two perspectives The heuristic measure n algorithm that uses the heuristics to search for the state space Tic-Tac-Toe Example The combinatorics for exhaustive search are high but not insurmountable Total number of states = 9! Many problem configurations are equivalent under symmetric operations of the game board Use of symmetry reduces initial moves from nine to three Use of symmetry on the second level further reduces the number of states to 12 7! 5 6 Fig 4.1 First three levels of the tic-tac-toe state space reduced by symmetry Tic-Tac-Toe Example-Continued simple heuristic can almost eliminate exhaustive search entirely Move to the state with the most winning opportunities If two states have the same number of opportunities, move to the first state found Total number of states will be reduced from 9! To less than 25 7 8
Fig 4.2 The most wins heuristic applied to the first children in tic-tac-toe. Fig 4.3 Heuristically reduced state space for tic-tac-toe. 9 10 Hill-Climbing Hill-Climbing The simplest way to implement heuristic search It starts with an arbitrary solution to a problem Then it finds a better solution by incrementally changing a single element of the solution It repeats until no further improvements can be found To determine if a solution is better, it uses a heuristic function to estimate how close a given state is to the goal state Tic-tac-toe ( take the state with the most possible wins ) is an example of hill-climbing algorithm It expands the current state of the search and evaluates its children The best child is selected for further expansion Neither its siblings nor its parents are retained Since it keeps no history, it cannot recover (backtrack) from failures of its strategy 11 12
Hill-Climbing Fig 4.4 The local maximum problem for hill-climbing with 3-level look ahead major problem with hill-climbing strategy is their tendency to become stuck at local maxima E.g.: In the 8-puzzle game, in order to move a tile to its destination, other tiles already in goal position need be moved out, worsening the board state It cannot distinguish between local and global maxima 13 14 Best-First Search Best-First Search Depth-first search: not all competing branches having to be expanded. Breadth-first search: not getting trapped on deadend paths. Combining the two is to follow a single path at a time, but switch paths whenever some competing path look more promising than the current one. 15 It uses a heuristic function to estimate how close the end of a path is to a solution (goal) The paths which are judged to be closer to a solution are extended first It does not search all the space Unlike hill-climbing, it can recover from errors and find the correct goal The best-first search algorithm uses two queues open: keeps states generated but not examined close: records states already visited 16
Fig 4.10 Heuristic search of a hypothetical state space. 17 The heuristic is fallible: O has a lower value than the goal P. 18 trace of the execution of best_first_search for Figure 4.4 Fig 4.11 Heuristic search of a hypothetical state space with open and closed states highlighted. 19 20
Best-First Search Fig 4.12 The start state, first moves, and goal state for an example-8 puzzle. B C D 3 5 1 B 3 C 5 E 4 D F 6 B C G H 5 E 6 5 4 D F 6 B C D G H 5 E 6 5 I J 2 1 F 6 21 22 Heuristics for Solving the 8-Puzzle Fig 4.14 Three heuristics applied to states in the 8-puzzle. 1) Count the tiles out of place in each state when compared with the goal It does not take into account the distance the tiles must be moved 2) Sum all the distances by which the tiles are out of place Both 1) & 2) fail to acknowledge the difficulty of tile reversal 3) Multiply a small number (e.g. 2) times each direct tile reversal 4) dd the sum of the distances the tiles are out of place and 2 times the number of direct reversals 23 24
Evaluation Function for 8-Puzzle Fig 4.15 The heuristic f applied to states in the 8-puzzle. If two states have the same or nearly the same heuristic evaluations, choose the state that is nearer to the root state Evaluation function: f(n) = g(n) + h(n) g(n): actual length of the path from state n to the start state h(n): a heuristic estimate of the distance from state n to a goal 25 26 Implement f(n) with Best First Search The successive stages of open and closed that generate this graph are: Operations on states generate children of the state under examination Each new state is checked to see if it has occurred before (on either open or closed queue) to prevent loops Each state n is given an f value States on open are sorted by their f values to allow the algorithm to recover from dead ends 27 28
Fig 4.16 State space generated in heuristic search of the 8-puzzle graph. 29 Fig 4.17 Open and clos sed as they appear after the 3rd iterat tion of heuristic search 30 dmissibility search algorithm is admissible if it is guaranteed to find a minimal path to a solution whenever such a path exists E.g. breath-first search (too inefficient for practical use) If an algorithm uses a heuristic function whose value for any state n is less than or equal to the actual cost from n to the goal, it is called * ll * algorithms are admissible E.g. the three heuristics from 8-puzzle examples are admissible and guarantee optimal solutions 31 32
Monotonicity Informedness monotonic heuristic is everywhere admissible, reaching each state along the shortest path from its ancestors Number of tiles out of place heuristic is more informed than breath-first search where h(n)=0 Sum of distances out of place heuristic is more informed than number of tiles out of place heuristic If h 2 is more informed than h 1, h 2 needs less space to expand to get the optimal solution (both will find the optimal path) 33 34 Fig 4.18 (see next slide) compares the state space searched using heuristic search with the state 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 number of tiles out of place. 35 36