110 likes | 241 Views
Ch. 10 – Planning. Supplemental slides for CSE 327 Prof. Jeff Heflin. Goal-Based Agent. sensors. State. What the world is like now. How the world evolves. Environment. What it will be like if I do action A. What my actions do. What action I should do now. Goals. actuators. Agent.
E N D
Ch. 10 – Planning Supplemental slides for CSE 327 Prof. Jeff Heflin
Goal-Based Agent sensors State What the world is like now How the world evolves Environment What it will be like if I do action A What my actions do What action I should do now Goals actuators Agent From Fig. 2.13, p. 52
Blocks World Example • initial state • On(A,Table) On(B,Table) Clear(A) Clear(B) Clear(Table) Block(A) Block(B) • goal • On(A,B) • actions Action(Move(b,x,y) , Precond: On(b,x) Clear(b) Clear(y) Block(y), Effect: On(b,y) Clear(x) On(b,x) Clear(y)) Action(MoveToTable(b,x), Precond: On(b,x) Clear(b), Effect: On(b,Table) Clear(x) On(b,x))
Action(Move(b,x,y), Precond: On(b,x) Clear(b) Clear(y) Block(y), Effect: On(b,y) Clear(x) On(b,x) Clear(y)) Action(MoveToTable(b,x), Precond: On(b,x) Clear(b), Effect: On(b,Table) Clear(x) On(b,x)) an action a is applicable in any state that satisfies the precondition e.g., Move(A,Table,B) is applicable in initial state unify with action description apply substitution ={b/A, x/Table, y/B} to the action’s Precondition initial state satisfies On(A,Table) Clear(A) Clear(B) Block(B) Applicable Actions Initial State: On(A,Table) On(B,Table) Clear(A) Clear(B) Clear(Table) Block(A) Block(B)
A Blocks World Problem • initial state • On(A,Table) On(B,Table) On(C,Table) Clear(A) Clear(B) Clear(C) Clear(Table) Block(A) Block(B) Block(C) • goal state • On(B,C) On(A,B) On(C,Table) • actions • Action(Move(b,x,y) , Precond: On(b,x) Clear(b) Clear(y) Block(y), Effect: On(b,y) Clear(x) On(b,x) Clear(y)) • Action(MoveToTable(b,x), Precond: On(b,x) Clear(b), Effect: On(b,Table) Clear(x) On(b,x))
Forward State-Space Search Move(A,T,B) MoveToTable(B,C) Move(A,T,C) Move(B,T,A) Move(B,C,A) On(A,T) ^ On(B,T) ^ On(C,T) ^ Clear(A) ^ Clear(B) ^ Clear(C) ^ Clear(T) On(A,T) ^ On(B,T) ^ On(C,T) ^ Clear(A) ^ Clear(B) ^ Clear(C) ^ Clear(T) ^ On(B,C) On(A,T) ^ On(C,T) ^ Clear(A) ^ Clear(B) ^ Clear(T) ^ On(B,C) ^ On(A,B) Move(B,T,C) Move(A,T,B) Move(A,T,A) Move(C,T,A) spurious actions Move(B,C,B) Move(C,T,B) MoveToTable(A,T) MoveToTable(A,T) MoveToTable(B,T) MoveToTable(C,T) spurious actions Move(A,T,A) Move(B,T,B) Move(C,T,C)
Backward State-Space Search On(B,C) ^ On(A,B) ^ On(C,T) GOAL: MoveToTable(C,x) Move(B,x,C) xC Move(A,x,B) xB Move(C,x,T) On(A,B) ^ On(C,T) ^ On(B,x) ^ Clear(B) ^ Clear(C) On(B,C) ^ On(C,T) ^ On(A,x) ^ Clear(A) ^ Clear(B) ? ? Move(B,y,C) yC Move(A,y,B)? On(C,T) ^ On(A,x) ^ Clear(A) ^ Clear(B) ^ On(B,y) ^ Clear(C) INITIAL STATE: (if x=T and y= T) Not relevant:has effect delete Clear(B) bold – literal that was added to the predecessor underline – goal is not satisfied by initial state
Planning Graph Example • Init(Have(Cake) • Goal(Have(Cake) Eaten(Cake)) • Action(Eat(Cake) • PRECOND: Have(Cake) • EFFECT: Have(Cake) Eaten(Cake)) • Action(Bake(Cake) • PRECOND: Have(Cake) • EFFECT: Have(Cake) Missing from book From Fig. 10.8, p. 380
GraphPlan function GRAPHPLAN(problem) returns solution or failure graph INITIAL-PLANNING-GRAPH(problem)goals CONJUNCTS(problem.GOAL)nogoods an empty hash tablefort = 0 to doif goals all non-mutex in Stof graph thensolution EXTRACT-SOLUTION(graph, goals, NUMLEVELS(graph),nogoods)ifgraph and nogoods have both leveled off then return failure graph EXPAND-GRAPH(graph, problem) From Fig. 10.9, p. 383
Spare Tire Problem Init(Tire(Flat) Tire(Spare) At(Flat,Axle) At(Spare,Trunk)) Goal(At(Spare,Axle)) Action(Remove(obj,loc),PRECOND: At(obj,loc),EFFECT: At(obj,loc) At(obj,Ground)) Action(PutOn(t, Axle),PRECOND: Tire(t) At(t,Ground) At(Flat,Axle),EFFECT: At(t,Ground) At(t,Axle)) Action(LeaveOvernight,PRECOND: ,EFFECT: At(Spare,Ground) At(Spare,Axle) At(Spare,Trunk) At(Flat,Ground) At(Flat,Axle) At(Flat,Trunk)) From Fig. 10.2, p. 370
Spare Tire Planning Graph From Fig. 10.10, p. 384