Announcements Project : erch It s live! Due 9/. trt erly nd sk questions. It s longer thn most! Need prtner? Come up fter clss or try Pizz ections: cn go to ny, ut hve priority in your own C 88: Artificil Intelligence Fll 0 Lecture : A* erch 9//0 Dn Klein UC Berkeley Multiple slides from turt Russell or Andrew Moore Tody Recp: erch A* erch rph erch Heuristic Design UC A* reedy erch prolem: ttes (configurtions of the world) uccessor function: function from sttes to lists of (stte, ction, cost) triples; drwn s grph trt stte nd gol test erch tree: Nodes: represent plns for reching sttes Plns hve costs (sum of ction costs) erch Algorithm: ystemticlly uilds serch tree Chooses n ordering of the fringe (unexplored nodes) Optiml: finds lest-cost plns Exmple: Pncke Prolem Exmple: Pncke Prolem tte spce grph with costs s weights Cost: Numer of pnckes flipped
enerl Tree erch Uniform Cost erch trtegy: expnd lowest pth cost The good: UC is complete nd optiml! c c c Action: flip top two Cost: Action: Pth flip to ll rech fourgol: Flip Cost: four, flip three Totl cost: 7 The d: Explores options in every direction No informtion out gol loction trt ol [demo: countours UC] Exmple: Heuristic Function Exmple: Heuristic Function Heuristic: the lrgest pncke tht is still out of plce h(x) 0 h(x) Best First (reedy) trtegy: expnd node tht you think is closest to gol stte Heuristic: estimte of distnce to nerest gol for ech stte A common cse: Best-first tkes you stright to the (wrong) gol Worst-cse: like dlyguided DF Comining UC nd reedy Uniform-cost orders y pth cost, or ckwrd cost g(n) reedy orders y gol proximity, or forwrd cost h(n) d h=6 h=5 h= c h=7 h=6 A* erch orders y the sum: f(n) = g(n) + h(n) 5 e h= h=0 [demo: countours greedy] Exmple: Teg renger
When should A* terminte? hould we stop when we enqueue gol? A h = h = B h = No: only stop when we dequeue gol h = 0 h = 7 Is A* Optiml? A h = 6 5 h = 0 Wht went wrong? Actul d gol cost < estimted good gol cost We need estimtes to e less thn ctul costs! Admissile Heuristics Optimlity of A*: Blocking A heuristic h is dmissile (optimistic) if: Nottion: g(n) = cost to node n where is the true cost to nerest gol h(n) = estimted cost from n to the nerest gol (heuristic) Exmples: 5 Coming up with dmissile heuristics is most of wht s involved in using A* in prctice. f(n) = g(n) + h(n) = estimted totl cost vi n *: lowest cost gol node : nother gol node Optimlity of A*: Blocking Properties of A* Proof: Wht could go wrong? We d hve to hve to pop suoptiml gol off the fringe efore * This cn t hppen: Imgine suoptiml gol is on the queue ome node n which is supth of * must lso e on the fringe (why?) n will e popped efore Uniform-Cost A*
UC vs A* Contours Uniform-cost expnded in ll directions trt ol Creting Admissile Heuristics Most of the work in solving hrd serch prolems optimlly is in coming up with dmissile heuristics Often, dmissile heuristics re solutions to relxed prolems, where new ctions re ville A* expnds minly towrd the gol, ut does hedge its ets to ensure optimlity trt ol 66 Indmissile heuristics re often useful too (why?) 5 [demo: countours UC / A*] Exmple: 8 Puzzle 8 Puzzle I Heuristic: Numer of tiles misplced Why is it dmissile? Wht re the sttes? How mny sttes? Wht re the ctions? Wht sttes cn I rech from the strt stte? Wht should the costs e? h(strt) = 8 This is relxedprolem heuristic Averge nodes expnded when optiml pth hs length steps 8 steps steps UC 6,00.6 x 0 6 TILE 9 7 8 Puzzle II 8 Puzzle III Wht if we hd n esier 8-puzzle where ny tile could slide ny direction t ny time, ignoring other tiles? Totl Mnhttn distnce Why dmissile? h(strt) = + + + = 8 Averge nodes expnded when optiml pth hs length steps 8 steps steps TILE 9 7 MANHATTAN 5 7 How out using the ctul cost s heuristic? Would it e dmissile? Would we sve on nodes expnded? Wht s wrong with it? With A*: trde-off etween qulity of estimte nd work per node!
Trivil Heuristics, Dominnce Dominnce: h h c if Heuristics form semi-lttice: Mx of dmissile heuristics is dmissile Trivil heuristics Bottom of lttice is the zero heuristic (wht does this give us?) Top of lttice is the exct heuristic Other A* Applictions Pthing / routing prolems Resource plnning prolems Root motion plnning Lnguge nlysis Mchine trnsltion peech recognition [demo: pln tiny UC / A*] Tree erch: Extr Work! Filure to detect repeted sttes cn cuse exponentilly more work. Why? rph erch In BF, for exmple, we shouldn t other expnding the circled nodes (why?) d e p c e h r q h r p q f p q f q c q c rph erch A* rph erch one Wrong? Ide: never expnd stte twice tte spce grph erch tree How to implement: Tree serch + set of expnded sttes ( closed set ) Expnd the serch tree node-y-node, ut Before expnding node, check to mke sure its stte is new If not new, skip it Importnt: store the closed set s set, not list Cn grph serch wreck completeness? Why/why not? How out optimlity? h= A h= B h= h= C (0+) A (+) B (+) C (+) C (+) (5+0) (6+0) Wrning: e ook hs more complex, ut lso correct, vrint h=0 5
Consistency of Heuristics Optimlity of A* rph erch A h= C h= tronger thn dmissiility Definition: cost(a to C) + h(c) h(a) cost(a to C) h(a) - h(c) rel cost cost implied y heuristic Consequences: The f vlue long pth never decreses Proof: New possile prolem: some n on pth to * isn t in queue when we need it, ecuse some worse n for the sme stte dequeued nd expnded first (disster!) Tke the highest such n in tree Let p e the ncestor of n tht ws on the queue when n ws popped f(p) < f(n) ecuse of consistency f(n) < f(n ) ecuse n is suoptiml p would hve een expnded efore n Contrdiction! A* grph serch is optiml Optimlity Tree serch: A* is optiml if heuristic is dmissile (nd non-negtive) UC is specil cse (h = 0) rph serch: A* optiml if heuristic is consistent UC optiml (h = 0 is consistent) Consistency implies dmissiility In generl, most nturl dmissile heuristics tend to e consistent, especilly if from relxed prolems ummry: A* A* uses oth ckwrd costs nd (estimtes of) forwrd costs A* is optiml with dmissile / consistent heuristics Heuristic design is key: often use relxed prolems Mzeworld Demos 6