40
CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

Embed Size (px)

Citation preview

Page 1: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

CS.462Artificial Intelligence

SOMCHAI THANGSATHITYANGKUL

Lecture 07 : Planning

Page 2: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

2

Planning as Problem Solving Planning:

• Start state (S) • Goal state (G) • Set of actions

In planning, the idea is that you're given some description of a starting state or states; a goal state or

states; and some set of possible actions that the agen t can take. And you want to find the sequence of action s that get you from the start state to the goal state.

Page 3: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

3

Planning as Problem Solving

Page 4: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

4

Planning as Problem Solving

Page 5: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

5

Strips Example • Action • Buy(x, store) – Pre: At(store), Sells(store, x) – Eff: Have(x) • Go(x, y) – Pre: At(x) – Eff: At(y), ¬At(x)•Goal • Have(Milk) Have(Banana)• Start • At(Home) Sells(SM, Milk) Sells(SM, Banana) We’regoi ng t o st ar t at home and knowi ng t hat t he super mar ke

t sel l s milk, and t he super mar ket sel l s bananas.

Page 6: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

6

Planning Algorithms

Page 7: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

7

- Plan Space Search • Situation space

– both progressive and regressive planners plan in space o f situations

• Plan space – start with null plan and add steps to plan until it achieves

the goal • Decouples planning order from execution order • - Least commitment – First think of what actions before thinking about what or der t o do t he act i ons • - Means ends analysis – Try to match the available means to the current ends

Page 8: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

8

Initial Plan • Steps: {start, finish} • Ordering: {start < finish}

• start • Pre: none • Effects: start conditions

• finish • Pre: goal conditions • Effects: none

Page 9: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

9

Plan Example

Here’s our initial plan. With the start and finish steps. We’ll draw ordering constraints using dashed red lines. We put the effects of a

step below it, and the preconditions of a step above it. We’ll do a simplified version of the whole problem, deleting the requirement for

a drill, and just having as our goal that we have milk and bananas.

Page 10: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

10

We’ll start by adding a step that says we’re going to by milk at some place called x1. It has preconditions at(x1) and sells(x1, milk); and it

has the effect have(milk).

Page 11: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

11

Now, we can add a blue causal link that says we are going to use this effect of have(Milk) to satisfy the

precondition have(Milk) in the finish step.

Page 12: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

12

Everycausall i nk al so i mpl i es an or der i ng l i nk, so we’l l add an ordering link as well between this step and finish. And we sh

ould also require that this step happen after start.

Page 13: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

13

Now, let's buy bananas. We add a step to buy

bananas at location x2, including its preconditions and effects.

Page 14: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

14

Now we add a causal link and temporal constraints,

just as we did for the buy milk step.

Page 15: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

15

1Now, a relatively straightforward thing to do is satisfy sells(x ,Milk)bb

bb bb bbb bbbbbbbbbbbb bb bbb b bbbbbbbb bbbbbbb 1. 1constraint, saying that x is equal to the supermarket. And that

allows us to put a causal link between Sells(SM,M) in the effects of start, and the precondition here on buy.

Page 16: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

16

2Similarly, we can satisfy sells(x ,Bananas) by adding a bbbbbbb bbbbbbbbbb bbbb bb b bbb bb bbb 2 bbbbbb b bbbbbb bbbbb , .

Page 17: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

17

Now, the only preconditions that remain unsatisfied are at(x 1) and

at(x2). Sincex1andx2ar e bot h const r ai ned t o be t he super mar ket , i t seems like we should add a step to go to the supermarket.

Page 18: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

18

The effect of at(SM) can be used to satisfy both preconditions, so we add causal links to the at

preconditions and temporal links to the buy actions.

Page 19: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

19

And we add another temporal constraint to force this step to come after start.

Page 20: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

20

Now, the At(x3) precondition can be satisfied by adding a variable binding constraint to force x3 to be

bbbbb

Page 21: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

21

We can add a causal link from the At(home) effect of start to this precondition, and we’re done!

Page 22: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

22

Block World Example

Page 23: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

23

• Let's do the problem. First we add the start step, wh ich produces the following facts for us: clear(T), on (

C, A), on (A, table), on (B, table), clear(C), and clear (B). That's what we know when we wake up.

• And the finish step requires on (A,B) and on(B,C).

Page 24: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

24

• What would you like to do? Where's a precondition that ne eds to be made true. Let’s work on making on(A,B) true. It

doesn't look like we can just use some fact we already ha ve to make it true, so we have to add another step. It look

s like move would be good. And we want to be in sort of le ast commitment in our moving, so we're going to move A

from somewhere to B.

Page 25: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

25

• Let's write out all the postconditions, just s o that we're shown all the effects. So, we'll

get on(A,B). We'll get not on(A,X1 ). We'll 1get clear(X ) and we’ll get not clear(B).

Page 26: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

26

• Our preconditions are on (A,X1), clear(A), clear-- (B) and I'm going to leave the block preconditi on out, just because it's trivial and tedious. We

would have to assert block(A), block(B), and bl ock(C) in the start state.

Page 27: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

27

• Now let’s work on Clear (A); that's going to be a hard one. H ow can we make A clear? Well, the way we make things clea

r is by moving something off of them. Right? So, the thing th at we're moving off of A, we can either move to some block or to the table. Let me just guide you to the choice of movin

g it to the table, so this doesn’t take too long (but a compute r might very well try moving it somewhere inconvenient, lik - e on to B). So, we can move table something off of A.

Page 28: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

28

• That will produce On (Y,table), clear(A) and not on(Y,A). So we can add a causal link between t

his clear(A) and the clear(A) in the preconditio n of our other move.

Page 29: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

29

• We can satisfy on(y,A) by letting y be C , and adding a causal connection from

on(C,A) in the effects of start.

Page 30: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

30

• Since y is bound to C, we need clear C, w hich we can also find in the effects of star

t.

Page 31: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

31

• bbbbb bbbbbb bbb bb bbbbbb bbbb bbbbbb bb bbb bbbb bbbb bb b bbb bysatisfyingclear(B) withone of t he eff ect s of st ar t .

Page 32: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

32

• bb b bbbbbbbbbbbbb bbbb bb b bbb bbb bbb, : ( bb bbbbb ,1 ) ( ,). ( , 1 )

1the on(A,T) from start, and letting x be the table.

Page 33: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

33

• Now, what's left is on(B,C). To get B to be on C, it means we're going to have to move it. So, w

e’ll add the step move(B, X2, C).

Page 34: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

34

• That produces on(B,C), not on(B,x2), clear(x2) and not clear( C ). And it has as preconditions

on(B,X2), clear(B), and clear(C).

Page 35: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

35

• Now one thing we have to do is to be sure that we haven't intro duced any threats. There don’t seem to be any right now, so th

en we have to just deal with the preconditions of this. So, how a bout the clears. Maybe they just come for free. It looks like may

be. We get clear B from start and clear C from start as well, And start makes on(B,X2 ) true if we let X2 be the table.

Page 36: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

36

• Now there are some threats that we have to deal with. First, notice the possibility that we move B onto C before we mov

e C off of A. That is, the Move(B, x2, C) step threatens the ca usal link between clear(C ) in the start step and the MoveT( C,A) step.

Page 37: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

37

• Howcanweresolvethisthreat? Wecan’trequireanythingtohappenbef or e st ar t , so we’l l have t o add an o rdering constraint that requires move(B,T,C) to happen after moveTable(C,A).

Page 38: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

38

• There’s still another lurking threat. We’re currently allowe d to move A onto B before we move B onto C. That is, the

Move(A, x1, B) step threatens the causal link between cle 2ar(B) in the start step and the Move(B, x , C) step.

Page 39: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

39

• Again, we can resolve this one with an ordering constraint, requiring us to mo

ve A onto B after we move B onto C.

Page 40: CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 07 : Planning

40

• Atthispoint, wehaveacompl et e and cor r ect pl an. We fi r st move C from A to the table, Then we move B onto C. And

finally, we move A onto B.