Sep 03, 2003 ------------- - Recap psychic search or heuristic search - Create the evaluation function f(n) as f(n) = g(n) + h(n) - called A* if h(n) has some properties - What do we do when we don't have a psychic - as long as your h(n) does not overestimate h*(n), you are fine! (you get completeness and optimality) - AMAZING, ISN'T IT? - One simple way to ensure that h(n) <= h*(n) - make h(n) = 0 - reduces to BFS/UCS, which is complete and optimal - A good heuristic is one - that is as close to h*(n) as possible (from below) - but doesn't take too long to compute - after all, the psychic could just be a fast supercomputer that actually does BFS, finds the answer, and comes back and gives you an estimate of the cost! - Special cases of evaluation functions - If g(n) = 0, you are only relying on the psychic - "greedy search"; does not guarantee optimality - If h(n) = 0, you are only relying on the past - reduces to BFS and UCS - Heuristics for the 8-puzzle problem - h1(n): number of misplaced tiles - h2(n): Manhattan distance - Both share the essential characteristics of a heuristic - i.e., never overestimate path cost to a goal - How do we get heuristics such as this? - an automatic way by "relaxing" problem specs - Motto: Heuristic cost for original problem = Optimal solution cost for a relaxed problem - Example of relaxation - People can fly (to compute time taken to travel from point A to point B) - tiles can magically go into their correct position - Automatic discovery of heuristics: 8-puzzle problem - formulate it as: MOVE(x,y,z) <- ON(x,y), FREE(z), NEXTTO(y,z) - Tile "x" can be moved from y to z if x is originally on y, z is free, and z is adjacent to y - Relax it in different ways: - MOVE(x,y,z) <- ON(x,y) - can move a tile to anywhere - leads to h1(n) = #misplaced tiles - Another - MOVE(x,y,z) <- ON(x,y), NEXTTO(y,z) - can move a tile to an adjacent position - leads to h2(n) = Manhattan distance - Yet Another - MOVE(x,y,z) <- ON(x,y), FREE(z) - can swap a tile for the empty position - leads to h3(n) = #swaps - How good are heuristics? - h3(n) is better than h2(n) is better than h1(n) - all approach but never cross h*(n) - some are even sometimes equal to h*(n) - when?