Document Sample

Artificial Intelligence (Lecture 7,8,9) Fakhar Mangla/IIU Islamabad CHAPTER FOUR HEURISTIC SEARCH Fakhar Mangla/IIU Islamabad Heuristics § Heuristics are formalized as: § Rules for choosing those branches in a state space that are most likely to lead toward the solution of the problem. Fakhar Mangla/IIU Islamabad Heuristics § Two basic situation for the use of Heuristics: § An inherently ambiguous problem e.g, medical diagnosis system § The cost of finding a solution by exhaustive methods like depth first search, is prohibitive § A heuristic is fallible: it is only an informed guess of next step to be taken in solving a problem § A heuristic can lead a search algorithm to a sub-optimal solution or fail to find any solution. Fakhar Mangla/IIU Islamabad Tic-Tac-Toe problem solving using Heuristic § Consider the example of state space § 9 nodes at the first level 8 nodes of each node at level–2 =9x8x7 . . 2 (9!=326880) nodes to search § Need to reduce the number of nodes or the size of the state space § Analyze carefully the rules of playing Tic-Tac-Toe or view as expert to setup heuristic Fakhar Mangla/IIU Islamabad State Space Reduced by Symmetry Fakhar Mangla/IIU Islamabad Tic-Tac-Toe problem solving using Heuristic § A simple heuristic can eliminate search entirely: § We may move to the board in which “X” has the most winning lines. § In case of states with equal numbers of potential wins, take the first such state found. § In case “X” takes the center of the grid. That will eliminates other alternates along with all of its descendants to 2/3 of the space. Fakhar Mangla/IIU Islamabad Tic-Tac-Toe problem solving using Heuristic Heuristics for State Space for TIC-TAC-TOE X X X 3 4 2 Dashed lines shows the number of potential wins at each level-1 Fakhar Mangla/IIU Islamabad IMPLEMENTING HEURISTIC EVALUATION FUNCTION 8 PUZZLE PROBLEM A) The simple heuristic count the tiles out place in each state when it is compared with the goal. B) Sum all the distances by which the tiles are out of place, one for each square a tile must be moved to reach its position in the goal state. Fakhar Mangla/IIU Islamabad IMPLEMENTING HEURISTIC EVALUATION FUNCTION 2 8 3 1 2 3 a b 1 6 4 8 4 7 5 5 6 7 6 5 2 8 3 1 4 3 4 7 6 5 2 8 3 5 6 1 6 4 7 5 Fakhar Mangla/IIU Islamabad A Possible Result of a Heuristic Search Procedure Fakhar Mangla/IIU Islamabad IMPLEMENTING HEURISTIC EVALUATION FUNCTION 8 PUZZLE PROBLEM § If two states have same heuristic value it is preferable to pick the state that is near the start state § Thus our evaluation function takes the form § f(n)=g(n) + h(n) § h(n) is the heuristic value of the state n § g(n) is the distance of the state n from the start state Fakhar Mangla/IIU Islamabad Heuristic Evaluation Function g(n) = 0 g(n) = 1 Values of f(n): 6 4 6 Fakhar Mangla/IIU Islamabad Heuristic Search using the evaluation function Fakhar Mangla/IIU Islamabad AN ALGORITHM FOR HEURISTIC SEARCH l Heuristic search can be implemented through hill climbing procedure l Generate the children of current node and keep only the best child (according to some criteria) l Hill climbing procedure can terminate at some local maxima is the current node is better than all its children l Hill climbing procedure cannot recover from a dead end situation Fakhar Mangla/IIU Islamabad AN ALGORITHM FOR HEURISTIC SEARCH l Hill climbing procedure can stuck in a loop or can go to an infinite path l If the criteria calculation function is good enough then these problems can be avoided l By combing hill climbing with best first we can have a very good algorithm Fakhar Mangla/IIU Islamabad Best-First Search § Depth first Algorithm uses LIFO style list to implement search § Breadth First Search uses FIFO style list to search § Best-first is an heuristic search that uses a priority queue to order the states on the OPEN Fakhar Mangla/IIU Islamabad Best-First Search A-5 D-6 B-4 C-4 E-5 F-5 G-4 H-3 I J K L N Q R M O-2 P-3 S T Fakhar Mangla/IIU Islamabad Best-First Search Evaluat Opened Closed e [A5] [] A5 [B4,C4,D6] [A5] B4 [C4,E5,F5,D6] [B4,A5] C4 [H3,G4,E5,F5,D6] [C4,B4,A5] H3 [O2,P3,G4,E5,F5,D6] [H3,C4,B4,A5] O2 [P3,G4,E5,F5,D6] [O2,H3,C4,B4,A5] P3 The solution Fakhar Mangla/IIU Islamabad Characteristics of Heuristics We can evaluate the behavior of heuristics on the basses of following Characteristics: § Admissible : (Shortest Path) § Informed: (have much more accurate information for next step to be taken) § Monotonic: ( min-Cost to find Shortest path) Fakhar Mangla/IIU Islamabad Admissibility § A search algorithm is admissible if , for any graph it always terminates in the optimal solution path. § The ‘h’ function must never overestimate the cost to reach the goal. h is called an admissible heuristic § Admissible functions are optimistic, as they always think the cost to the goal is less than it actually is Fakhar Mangla/IIU Islamabad Informedness § For two A heuristics h1, h2, if h1(n) < h2(n) for all states n in the search space, h2 is said to be more informed than h1 § Means if h2 have much more accurate and effective information for the next step to be taken Fakhar Mangla/IIU Islamabad Monotonicity § A heuristic function h is monotonic if § For all states ni and nj where nj is descendent of ni § h(ni) - h(nj) cost (ni, nj) § where cost (ni, nj) is the actual cost of going from state ni to nj. § The heuristic evaluation of the goal state is zero or h(goal)=0. § Consistently find the minimal path to each state they encounter in the search. Fakhar Mangla/IIU Islamabad Heuristic Search Algorithms § Heuristic Search Algorithms § Best-First Search § Maintains a priority queue to shift to heuristically promising paths § A* Search § Uses algorithm A (best-first search + evaluation function f(n)) with a constraint that h(n) never overestimates h*(n) -- the actual cost to reach the goal from any state ‘n’. § Hill-Climbing § Often called greedy search algorithm, does not maintain any information to backtrack to other paths in the state space if once adopts a fruitless “opportunist” path. Fakhar Mangla/IIU Islamabad ADMISSIBILITY MEASURES l A search algorithm is admissible if it is guaranteed to find a minimal path to solution whenever such a path exists l Breadth first is admissible because it looks at every state level n before considering level n+1 Fakhar Mangla/IIU Islamabad ADMISSIBILITY MEASURES l In the formula f(n)=h(n)+g(n), g(n) measures the depth of the node n l h(n) measures the heuristic estimate of the distance from n to goal state l Thus f(n) estimates the cost of the path from start through n to the goal state l Note that h(n) is not actual cost to path from n to goal state Fakhar Mangla/IIU Islamabad ADMISSIBILITY MEASURES l Let f*(n)=h*(n)+g*(n) l Where g*(n) is the cost of the shortest path from start to n l And h*(n) is the actual cost of the shortest path from n to goal l Therefore f*(n) is the actual cost of the shortest path from start to goal state that passes through n Fakhar Mangla/IIU Islamabad ADMISSIBILITY MEASURES l g(n)>=g*(n) l g(n) is good estimate of g*(n) l g(n)=g*(n) if the algorithm has found the shortest path from start to n Fakhar Mangla/IIU Islamabad ADMISSIBILITY MEASURES l A best first algorithm that uses the evaluation function f(n)=g(n)+h(n) is called algorithm A l A search algorithm is admissible if for any graph it always finds the optimal solution path whenever such a path exists l If h(n) <= h*(n) in an A algorithm then it is called algorithm A* l All A* algorithms are admissible l A* algorithms may not be locally admissible Fakhar Mangla/IIU Islamabad MONOTONICITY A heuristic function h is monotone if 1. For all states ni & nj, where nj is descendent of ni h(ni)-h(nj)<=cost(ni, nj) 2. The heuristic evaluation of the goal state is zero i.e. h(goal)=0 Fakhar Mangla/IIU Islamabad MONOTONICITY Statement:-Any monotonic heuristic h is A* and admissible Proof:- l We will show that h is every where admissible l Let s1 be the start state and sg be the goal state l Let us trace the path from start to goal Fakhar Mangla/IIU Islamabad MONOTONICITY Fakhar Mangla/IIU Islamabad INFORMEDNESS l Let h1 and h2 be two A* heuristics such that h1(n)<=h2(n) for all states n then h2 is said to be more informed then h1 l We can say that h2 is more informed then h1 l h2 is better than h1 Fakhar Mangla/IIU Islamabad USING HEURISTICS IN GAMES Fakhar Mangla/IIU Islamabad ADVERSARIAL SEARCH l The searches we have discussed so far involves only one person l You can say that you are the only player in the game l But in two person games the situation is different l The ordinary search methods cannot be used in these situations l The search used in two person games is called adversarial search Fakhar Mangla/IIU Islamabad MINIMAX PROCEDURE l The opponents in a game are referred to as MIN & MAX l We suppose that MIN uses the same strategy as MAX is using l MAX is the person trying to maximize its score while MIN will try to minimize the score of MAX l Each level in the search is labeled according to whose move it is at that point in the game (MIN or MAX) Fakhar Mangla/IIU Islamabad MINIMAX PROCEDURE l Each state of the game is assigned a heuristic value according to some evaluation function l The minimax procedure propagates these values up the graph according to following rules 1. If the parent is a MAX node, give it the maximum value among its children 2. If the parent is a MIN node, give it the minimum value among its children Fakhar Mangla/IIU Islamabad MINIMAX PROCEDURE 7 A MAX MIN 7 5 B C MAX D E F G 7 1 5 15 2 Fakhar Mangla/IIU Islamabad ALPHA BETA PROCEDURE l Straight minimax procedure requires two pass analysis of the search space, the first to descend to the ply depth and there apply the heuristic and the second to propagate value back up the tree l Minimax checks all the branches including many that can be ignored l Alpha beta procedure is an improvement to minimax that eliminates those branches Fakhar Mangla/IIU Islamabad ALPHA BETA PRUNING 7 A MAX MIN =7 <=5 B C MAX D E F G 7 1 5 15 2 Fakhar Mangla/IIU Islamabad ALPHA BETA PRUNING 50 MAX -α 50 30 20 MIN-β 50 20 70 30 MAX-α 50 40 70 10 60 30 80 50 20 90 70 60 Fakhar Mangla/IIU Islamabad ALPHA BETA PROCEDURE Rules for terminating search 1. Search can be stopped below any MIN node having a beta value less than or equal to the alpha value of any of its MAX ancestors 2. Search can be stopped below any MAX node having an alpha value greater than or equal to the beta value of any of its MIN node ancestors Fakhar Mangla/IIU Islamabad

DOCUMENT INFO

Shared By:

Categories:

Tags:

Stats:

views: | 2 |

posted: | 3/30/2014 |

language: | Latin |

pages: | 42 |

OTHER DOCS BY pptfiles

How are you planning on using Docstoc?
BUSINESS
PERSONAL

By registering with docstoc.com you agree to our
privacy policy and
terms of service, and to receive content and offer notifications.

Docstoc is the premier online destination to start and grow small businesses. It hosts the best quality and widest selection of professional documents (over 20 million) and resources including expert videos, articles and productivity tools to make every small business better.

Search or Browse for any specific document or resource you need for your business. Or explore our curated resources for Starting a Business, Growing a Business or for Professional Development.

Feel free to Contact Us with any questions you might have.