Modelling planning problems using PDDL EH 2750 Modelling planning problems using PDDL Arshad Saleem 06 Oct, 2014
Contents Forward and Backward chaining PDLL Modeling example in PDDL PDDL modeling exercise
Forwards and Backwards Chaining If <condition> Then <conclusion> If <condition> Then <conclusion> If <condition> Then <conclusion> If <condition> Then <conclusion> <Goal>
Forwards and Backwards Chaining If <condition> Then <conclusion> Forwards chaining Data driven Backwards chaining Goal driven
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) If <condition> Then <conclusion> Forwards chaining Data driven Backwards chaining Goal driven
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
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
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!
Forward-chaining Match the facts in the knowledge base to the premises of rules Apply the rules and add the conclusions as new (temporary) facts to the knowledge base Repeat until – the goal is achieved, or – no more rules fire
Example: Forwards Chaining With forward chaining, we usually make all possible derivations 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
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,k 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
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)
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.
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
Domain file
Problem file
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.
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.
Gripper example: Objects
Gripper example: Predicates
Gripper example: Initial state
Gripper example: Goal state
Gripper example: movement action
Gripper example: pickup action
Gripper example: drop action
PDDL small exercise Let’s write PDDL for:
Questions