Graduate AI Lecture 16: Planning 2 Teachers: Martial Hebert Ariel Prcaccia (this time)
Reminder State is a cnjunctin f cnditins, e.g., at(truck 1,Shadyside) at(truck 2,Oakland) States are transfrmed via peratrs that have the frm Precnditins Effects (pstcnditins) 2
Reminder Pre is a cnjunctin f psitive and negative cnditins that must be satisfied t apply the peratin Effect is a cnjunctin f psitive and negative cnditins that becme true when the peratin is applied We are given the initial state We are als given the gals, a cnjunctin f psitive and negative cnditins 3
Planning as search Search frm initial state t gal Can use standard search techniques, including heuristic search At(P 1,A) At(P 2,A) Fly(P 1,A,B) Fly(P 2,A,B) At(P 1,B) At(P 2,A) At(P 1,A) At(P 2,B) 4
Ptential bstacles Example: inefficient search Operatin Buy(isbn) with n precnditins and effect Own(isbn) fr each f the 10 billin ISBN numbers Uninfrmed search must enumerate all ptins Example: large state space 10 airprts, each has 5 planes and 20 pieces f carg Gal: mve the carg at airprt A t B Search graph up t the depth f the bvius slutin can have > 10 100 ndes Frm 1961 t 1998 frward search was cnsidered t inefficient t be practical 5
Backward search Searching backward frm gal t initial state Can help in the examples Hard t cme up with heuristics mdern systems use frward search with killer heuristics 6
Heuristics fr planning Define a relaxed prblem that is easier t slve and gives an admissible heuristic Tw general appraches: add edges t the search graph r grup multiples ndes tgether 7
Ignre precnditins Heuristic drps all precnditins frm peratins Any gal cnditin can be achieves in ne step Cmplicatins: 1. Sme peratins achieve multiple gals 2. Sme peratins und the effects f thers Ignre 2 but nt 1: remve precnditins and all effects except gal cnditins Cunt min number f peratins s.t. the unin f their effects cntains gals 8
Set cver This is exactly the set cver prblem Prblem is NP-hard Hard t apprximate t a factr better than lgn Apprximatin is inadmissible g 5 g 1 g 3 g 2 g 4 g 6 9
Ignre precnditins Pssible t ignre specific precnditins Sliding blck puzzle; On(t,s 1 ) Blank(s 2 ) Adjacent(s 1,s 2 ) On(t,s 2 ) Blank(s 1 ) On(t,s 1 ) Blank(s 2 ) Remving Blank(s 2 ) Adjacent(s 1,s 2 ) gives... #misplaced tiles heuristic Remving Blank(s 2 ) gives... Manhattan distance heuristic Can derive dmain-specific heuristics 5 6 1 7 2 8 3 4 Example state 1 4 5 6 7 2 8 3 Gal state 10
Ignre delete lists Assume that gals and precnditins cntain nly psitive literals Can rewrite if nt Remve delete lists frm all peratins Make mntnic prgress twards gals Still NP-hard t find a slutin (prved in lecture 15, slide 19) Why desn t this fllw frm NP-hardness f set cver? Hill-climbing wrks well 11
Hill climbing Hffman, JAIR 2005 12
State abstractin Relaxed prblem is still an expensive way t cmpute a heuristic if there are many states Cnsider air carg prblem with 10 airprts, 50 planes, 200 pieces f carg #states = 10 50 (50+10) 200 > 10 250 Assume all packages are in 5 airprts, packages in airprt have the same destinatin 5 planes and 5 packages #states = 10 5 (5+10) 5 < 10 11 13
Planning graphs Leveled graph: vertices rganized int levels, with edges nly between levels Tw types f vertices n alternating levels: Cnditins Operatins Tw types f edges: Precnditin: cnditin t peratin Effect: peratin t cnditin 14
Generic planning graph Cnditin Precnditin Operatin Effect Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 15
Graph cnstructin S 0 cntains cnditins that hld in initial state Add peratin t level O i if its precnditins appear in level S i Add cnditin t level S i if it is the effect f an peratin in level O i-1 (n-p actin als pssible) Idea: S i cntains all cnditins that culd hld at time i; O i cntains all peratins that culd have their precnditins satisfied at time i Can ptimistically estimate hw many steps it takes t reach a gal 16
Mutual exclusin Tw peratins r cnditins are mutually exclusive (mutex) if n valid plan can cntain bth A bit mre frmally: Tw peratins are mutex if their precnditins r effects are mutex Tw cnditins are mutex if ne is the negatin f the ther, r all actins that achieve them are mutex Even mre frmally... 17
Mutex cases Incnsistent effects (tw ps): ne peratin negates the effect f the ther Interference (tw ps): an effect f ne peratin negates precnditin f ther Incnsistent Effects Interference Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 18
Mutex cases Cmpeting needs (tw ps): a precnditin f ne peratin is mutex with a precnditin f the ther Incnsistent supprt (tw cnditins): every pssible pair f peratins that achieve bth cnditins is mutex Cmpeting Needs Incnsistent Supprt Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 19
Dinner date example Initial state: garbage cleanhands quiet Gals: dinner present garbage Actins: Ck: cleanhands dinner Wrap: quiet present Carry: nne garbage cleanhands Dlly: nne garbage quiet What s the plan? Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 20
Dinner date example garb cleanhands Carry Dlly garb garb cleanhands Interference quiet Ck Wrap cleanhands quiet quiet dinner present Incnsistent supprt Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 21
Dinner date example garb Carry Dlly garb garb Carry Dlly garb garb cleanhands cleanhands cleanhands Ck cleanhands cleanhands Ck quiet quiet quiet Wrap Wrap quiet quiet dinner dinner present present Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 22
Observatin 1 p O 1 p p O 1 p p O 2 q q q q r r r Cnditins mntnically increase (always carried frward by n-ps) Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 23
Observatin 2 p O 1 p p O 1 p p O 2 q q q q r r r Operatins mntnically increase Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 24
Observatin 3 p p O 1 q q r r Prpsitin mutex relatinships mntnically decrease Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 25
Observatin 4 Operatin mutexes mntnically decrease Incnsistent effects and interference are prperties f the peratins themselves hld at every level Cmpeting needs: prpsitin mutexes are mntnically decreasing T be frmal, need t d a duble inductin n prpsitin and peratin mutexes 26
Leveling ff As a crllary f the bservatins, we see that the planning graph levels ff Prf: Cnsecutive levels becme identical Upper bund n #peratins and #cnditins Lwer bund f 0 n #mutexes 27
Heuristics frm graphs Level cst f gal g = level where g first appears T estimate the cst f all gals: Max level: max level cst f any gal (admissible?) Level sum: sum f level csts (admissible?) Set level: level at which all gals appear withut any pair being mutex (admissible?) 28
The Graphplan algrithm 1. Grw the planning graph until all gals are reachable and nt mutex (If planning graph levels ff first, fail) 2. Call EXTRACT-SOLUTION n current planning graph 3. If nne fund, add a level t the planning graph and try again Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 29
Extract-Slutin Search where each state crrespnds t a level and a set f unsatisfied gals Initial state is the last level f the planning graph, alng with the gals f the planning prblem Actins available at level S i are t select any cnflict-free subset f peratins in A i-1 whse effects cver the gals in the state Resulting state has level S i-1 and its gals are the precnditins fr selected actins Gal is t reach a state at level S 0 30
Extract-Slutin illustrated Slide based n Brafman which in turn is based n Ambite, Blyth, and Weld 31
Graphplan guarantees The size f the t-level planning graph and the time t create it are plynmial in t, #peratins, #cnditins Graphplan returns a plan if ne exists, and returns failure if ne des nt exists 32