21 Nature of heuristicsDomain knowledge: some knowledge about the game, the problem to chooseHeuristic: a guess about which is best, not exactHeuristic function, h(n): estimate the distance from current node to goal
22 Heuristic for the 8-puzzle # tiles out of place (h1)Manhattan distance (h2)Sum of the distance of each tile from its goal positionTiles can only move up or down city blocks
24 Best first searches A class of search functions Choose the “best” node to expand nextUse an evaluation function for each nodeEstimate of desirabilityImplementation: sort fringe, open in order of desirabilityToday: greedy search, A* search
25 Greedy search Evaluation function = heuristic function Expand the node that appears to be closest to the goal
26 Greedy Search OPEN = start node; CLOSED = empty While OPEN is not empty doRemove leftmost state from OPEN, call it XIf X = goal state, return successPut X on CLOSEDSUCCESSORS = Successor function (X)Remove any successors on OPEN or CLOSEDCompute f=heuristic function for each nodePut remaining successors on either end of OPENSort nodes on OPEN by value of heuristic functionEnd while
30 Analysis of Greedy Search Like depth-firstNot OptimalComplete if space is finite
31 A* Search Try to expand node that is on least cost path to goal Evaluation function = f(n)f(n)=g(n)+h(n)h(n) is heuristic function: cost from node to goalg(n) is cost from initial state to nodef(n) is the estimated cost of cheapest solution that passes through nIf h(n) is an underestimate of true cost to goalA* is completeA* is optimalA* is optimally efficient: no other algorithm using h(n) is guaranteed to expand fewer states
32 A* Search OPEN = start node; CLOSED = empty While OPEN is not empty do Remove leftmost state from OPEN, call it XIf X = goal state, return successPut X on CLOSEDSUCCESSORS = Successor function (X)Remove any successors on OPEN or CLOSEDCompute f(n)= g(n) + h(n)Put remaining successors on either end of OPENSort nodes on OPEN by value of heuristic functionEnd while
37 Admissable heuristics A heuristic that never overestimates the cost to the goalh1 and h2 for the 8 puzzle are admissable heuristicsConsistency: the estimated cost of reaching the goal from n is no greater than the step cost of getting to n’ plus estimated cost to goal from n’h(n) <=c(n,a,n’)+h(n’)
38 Which heuristic is better? Better means that fewer nodes will be expanded in searchesh2 dominates h1 if h2 >= h1 for every node nIntuitively, if both are underestimates, then h2 is more accurateUsing a more informed heuristic is guaranteed to expand fewer nodes of the search spaceWhich heuristic is better for the 8-puzzle?
41 Relaxed ProblemsAdmissable heuristics can be derived from the exact solution cost of a relaxed version of the problemIf the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h1 gives the shortest solutionIf the rules are relaxed so that a tile can move to any adjacent square, then h2 gives the shortest solutionKey: the optimal solution cost of a relaxed problem is no greater than the optimal solution cost of the real problem.
42 Heuristics for other problems Shortest path from one city to anotherTouring problem: visit every city exactly onceChallenge: Is there an admissable heuristic for sodoku?
47 Language ModelsKnowledge about what letters in words are most frequentBased on a sample of languageWhat is the probability that A is the first letterHaving seen A, what do we predict is the next letter?Tune our language model to a situation3 letter words onlyMedical vocabularyNewspaper text
48 Formulation Left-right, top-down as path Choose a letter at a time Heuristic: Based on language modelCost of choosing letter A first = 1 – probability of A nextSubtract subsequent probabilitiesSuccessor function: Choose next best letter, if 3rd in a row, is it a word?Goal test?