EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

27
EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1

Transcript of EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Page 1: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

EH 2750

Arshad Saleem

06 Oct, 2014

Modelling planning problems using PDDL

1

Page 2: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Contents• Forward and Backward chaining

• PDLL

• Modeling example in PDDL

• PDDL modeling exercise

2

Page 3: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Forwards and Backwards Chaining

If <condition> Then <conclusion>

3

If <condition> Then <conclusion>

If <condition> Then <conclusion>

If <condition> Then <conclusion>

<Goal>

Page 4: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Forwards and Backwards Chaining

If <condition> Then <conclusion>

Forwards chainingData driven

Backwards chainingGoal driven

4

Page 5: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Backwards Chaining• Match the goal to the conclusions of rules

• Set up the premises of the rules that matched as sub-goals

• Repeat until:

– all sub-goals match directly with known facts (goal is true), or

– Some sub-goal fail to match (goal is false)

5

If <condition> Then <conclusion>

Forwards chainingData driven

Backwards chainingGoal driven

Page 6: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Backwards Chaining• There may be more than one rule which

conclusion matches the goal (a conflict)• Choose the first rule we find which matches and

continue the search by trying to match its premises• If this fails, we backtrack up one or more levels of

rule and try again• Backward chaining is usually implemented as

depth-first search

6

Page 7: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Example:Backwards Chaining

Production rules:

• 1. if a then b,

• 2. if (f and k) then i

• 3. if (b and c) then d,

• 4. if (d and h) then f,

• 5. if (k or g) then h,

• 6. if b then c

• Facts: a, k

• Goal: f 7

Page 8: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Example: Backwards Chaining• Goal: we want to prove f• rule 4 says that we can prove f if d and h can be

proved• Sub-goal: we want to prove d:• rule 3 says that we could prove d if b and c can be

proved• (Sub-)sub-goal: we want to prove b:• rule 1 says that we could prove b if a can be

proved• but a is a known fact, so we have proven b• (Sub-)sub-goal: we want to prove c:• rule 6 says that we could prove c if b can be

proved• but we just proved b so we have also proven c• As we now have proved b and c, we know that d

holds• Sub-goal: we want to prove h:• rule 5 says that we could prove h if k or g can be

proved• but k is a known fact, so we have proven h• As we now have proved both d and h, we have

proven f!

Production rules:1. if a then b,

2. if (f and k) then i3. if (b and c) then d,4. if (d and h) then f,5. if (k or g) then h,

6. if b then cFacts: a, k

Goal: f

Page 9: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Forward-chaining

• Match the facts in theknowledge base to thepremises of rules

• Apply the rules and addthe conclusions as new(temporary) facts to theknowledge base

• Repeat until– the goal is achieved, or– no more rules fire

9

Page 10: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Example:Forwards Chaining

• With forward chaining, we usually make all possiblederivations of new facts with each iterations, i. e. we fire all rules which apply

• Thus, forward chaining uses a breadth first search• Example: same production rules as above

– 1. if a then b,– 2. if (f and k) then i– 3. if (b and c) then d,– 4. if (d and h) then f,– 5. if (k or g) then h,– 6. if b then c

• and the same known facts: a, k 10

Page 11: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Example: Forwards Chaining• Pass 0:

– facts a,k• Pass 1: using rule 1. We conclude b

– facts a,b,k• using rule 5. We conclude h

– facts a,b,h,k• using rule 6. We conclude c

– facts a,b,c,h,k• Pass 2: using rule 3. We conclude d

– facts a,b,c,d,h,k• using rule 4. We conclude f

– facts a,b,c,d,f,h,k• Pass 3: using rule 2. We conclude i

– facts a,b,c,d,f,h,I,k11

Production rules:1. if a then b,

2. if (f and k) then i3. if (b and c) then d,4. if (d and h) then f,5. if (k or g) then h,

6. if b then cFacts: a, k

Goal: f

Page 12: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

PDDL

• A modeling language for • PDDL = Planning Domain Definition Language• Problems modeled in this language can be

executed by a software (JavaFF library in our case)

12

Page 13: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Components of PDDL

• Objects: Things in the world that interest us.• Predicates: Properties of objects that we are

interested in; can be true or false.• Initial State: The state of the world that we start

in.• Goal specification: Things that we want to be

true.• Actions/Operators: Ways of changing the state

of the world.

13

Page 14: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Two parts of PDDL modelling

• Planning tasks specified in PDDL are separated into two files

– A domain file for predicates and actions– A problem file for objects, initial state and goal

specification

14

Page 15: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Domain file

15

Page 16: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Problem file

16

Page 17: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example

• Gripper task with four balls:

There is a robot that can move between two rooms and pick up or drop balls with either of

his two arms. Initially, all balls and the robot are in the first room. We want the balls to be in

the second room.

17

Page 18: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example• Objects: The two rooms, four balls and two robot

arms.• Predicates: Is x a room? Is x a ball? Is ball x

inside room y? Is robot arm x empty? [...]• Initial state: All balls and the robot are in the

first room. All robot arms are empty. [...]• Goal specification: All balls must be in the

second room.• Actions/Operators: The robot can move between

rooms, pick up a ball or drop a ball.

18

Page 19: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example: Objects

19

Page 20: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example: Predicates

20

Page 21: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example: Initial state

21

Page 22: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example: Goal state

22

Page 23: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example: movement action

23

Page 24: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example: pickup action

24

Page 25: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Gripper example: drop action

25

Page 26: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

PDDL small exercise

• Let’s write PDDL for:

Initial situation: GOAL

A

B

B

A

26

Page 27: EH 2750 Arshad Saleem 06 Oct, 2014 Modelling planning problems using PDDL 1.

Questions

27