Classical Planning Problems jonas.kvarnstrom@liu.se – 2016 ο‘ 3 Let's concisely define the most fundamental planning concepts! ο§ We need states of the world βͺ ππ = {π π 1 , π π 2 , … , π π ππ } is a set of states; A0: This set is finite ο§ We need actions βͺ π΄π΄ = {ππ1 , ππ2 , … , ππππ } is a set of actions; this set is also finite ο§ We need preconditions and effects for actions βͺ A6 says we have discrete transitions between states: Only specify where you end up βͺ πΎπΎ: ππ × π΄π΄ → 2ππ returns the set of states you may end up in βͺ πΎπΎ π π , ππ = ∅ means a cannot be executed in s βͺ πΎπΎ π π , ππ = {π π ′ } means a is executed and leads to s' βͺ πΎπΎ π π , ππ > 1 impossible due to A2, deterministic actions Together: Σ = (ππ, π΄π΄, πΎπΎ) is a state transition system (STS) jonkv@ida STS 1: States and Actions ο‘ Part of an STS for a Hanoi problem, illustrated: ο§ All orange arrows are action ππ4 : Move diskA from peg1 to peg3 4 jonkv@ida STS 2: State Transition System ο‘ 5 But: An STS does not assume internal structure in states ο§ Cannot depend on knowing what π π 1 "represents" ο§ What's important: βͺ The STS node and edge structure βͺ Defines the "world" we operate in We use our problem knowledge to define nodes (states) and edges (action transitions) But the details of this knowledge are not encoded in the STS! s1 s3 s2 s4 s6 s5 s7 s8 s9 jonkv@ida STS 3: No Internal Structure ο‘ 6 To complete the definition of the problem: ο§ We need information about the current state βͺ A2: We know the initial state, π π 0 ο§ We need information about our objectives βͺ A4: End up in one of a set of goal states, ππππ ο§ Complete planning problem: βͺ (Σ, π π 0 , ππππ ) s2 π π 0 = s1 s3 s4 s6 s5 s7 s8 s9 ππππ = {π π 27 } jonkv@ida STS 4: Problem Real World Abstraction Approximation Simplification 7 Real World + current problem Abstraction Approximation Simplification Formal Model: Restricted State Transition System Σ = (S,A,γ) Planning Problem P = (Σ, s0, Sg) Tells us: How the world works (Only those aspects that we need in our model in order to solve interesting problems!) Tells us: Which specific problem to solve jonkv@ida STS 5: Transition System vs. Problem ο‘ 8 Important concepts: ο§ Action sequence: σ = 〈a1, a2, …, an〉, where ππ1 , … , ππππ ⊆ π΄π΄ βͺ Sometimes called "plan" ο§ An action sequence is executable in state π π ∈ ππ if ∃s1 , …, sn ∈ ππ such that γ (s,a1) = { s1 }, γ (s1,a2) = { s2 }, …, γ (sn–1,an) = { sn } βͺ Sometimes called "executable action sequence", "plan", "executable plan", … ο§ An action sequence is a solution to (Σ, π π 0 , ππππ ) if it is executable in π π 0 and π π ππ ∈ ππππ βͺ Sometimes called "plan", "solution plan", … In the exam, the terminology will be unambiguous! jonkv@ida STS 6: Important Concepts ο‘ 9 A solution (for classical planning): ο§ The sequence of actions along some path from π π 0 to a state in ππππ π π 0 = s0 Is classical planning simply graph search? Graphs are enormous Requires advanced heuristics Requires advanced search methods s2 s1 It can be, but: s3 s5 s4 s6 s7 s8 Alternatives to searching the STS can be used to "indirectly" find paths! Many extended forms of planning do not map into searching an STS ππππ = {π π 26 } jonkv@ida STS 7: Solution, Visualized ο‘ Very useful: ο§ As a conceptual model, explaining basic concepts ο§ To analyze expressivity, clarify restrictions ο§ To prove properties ο‘ Very useless: ο§ As a way of actually writing down realistic planning problems (enumerate all possible states?) 10 jonkv@ida STS 8: Useful? ο‘ A good modeling language should: ο§ Provide an internal structure for states βͺ Instead of "state π π 23862497124985 ", we say "the state where all disks are on peg 1 in ascending order" ο§ Provide an internal structure for actions βͺ Instead of "applying action ππ120938 in π π 9814871345 yields π π 129084576130 ", we say "action move(diskA, peg1, peg3) can be executed under these conditions and changes the current state in this way" 11 jonkv@ida STS 9: Modeling Language Requirements ο‘ The language of Artificial Intelligence was/is logic ο§ First-order, second-order, modal, … ο‘ 1959: General Problem Solver (Newell, Shaw, Simon) 13 jonkv@ida History: 1959 ο‘ 1969: Planner explicitly built on Theorem Proving (Green) 14 jonkv@ida History: 1969 ο‘ 15 Full theorem proving generally proved impractical for planning ο§ Different techniques were found ο§ Foundations in logical languages remained! βͺ Languages use predicates, atoms, literals, formulas βͺ We define states, actions, … relative to these βͺ ο¨ Allows us to specify an STS at a higher level! Formal representation using a first-order language: "Classical Representation" (from the book) "The simplest representation that is (more or less) reasonable to use for modeling" jonkv@ida Basis in Logic ο‘ 16 Running example (from the book): Dock Worker Robots Containers shipped in and out of a harbor Cranes move containers between ”piles” and robotic trucks jonkv@ida Running Example ο‘ We are interested in objects in the world ο§ Buildings, cards, aircraft, people, trucks, pieces of sheet metal, … ο§ Must be a finite set! Modeling: Which objects exist and are relevant for the problem? 18 jonkv@ida Objects 1: Intro ο‘ Dock Worker Robots 19 A crane moves containers between piles and robots A robot is an automated truck moving containers between locations A container can be stacked, picked up, loaded onto robots loc2 c2 c3 c1 p1 A pile is a stack of containers – at the bottom, there is a pallet p2 loc1 r1 A location is an area that can be reached by a single crane. Can contain several piles, at most one robot. We can skip: Hooks Wheels Rotation angles Drivers – not relevant for this problem! jonkv@ida Objects 2: Dock Worker Robots ο‘ 20 Classical representation: ο§ We are constructing a first-order language πΏπΏ ο§ Every object is modeled as a constant ο§ Add a constant symbol ("object name") for each object: πΏπΏ contains { c1,c2,c3, p1,p2, loc1,loc2, r1,… } loc2 c2 c3 c1 p1 p2 loc1 r1 jonkv@ida Objects 3: Classical Representation ο‘ 21 All non-boolean constant values are modeled in the same way! ο§ Colors: red, green, blue ο§ … jonkv@ida Objects 4: For all non-boolean values ο‘ 23 Recall: We want an internal structure for states of the world ο§ Instead of "state π π 23862497124985 ", we say "the state where all disks are on peg 1 in ascending order" ο‘ First-order language: Start with a set of predicates ο§ Properties of the world βͺ raining – it is raining [not part of the DWR domain!] ο§ Properties of single objects… βͺ occupied(robot) – the robot has a container ο§ Relations between objects βͺ attached(pile, location) – the pile is in the given location ο§ Relations between >2 objects βͺ can-move(robot, loc, loc) – the robot can move between two locations ο§ Non-boolean properties are "relations between constants" βͺ has-color(robot, color) – the robot has the given color Essential: Determine what is relevant for the problem and objective! jonkv@ida Predicates ο‘ 24 All predicates for DWR, and their intended meaning: "Fixed/Rigid" βͺ (can't change) "Dynamic" (modified by actions) adjacent attached belong (loc1, loc2) (p, loc) (k, loc) ; can move from loc1 directly to loc2 ; pile p attached to loc ; crane k belongs to loc at occupied loaded unloaded (r, loc) (loc) (r, c) (r) ; robot r is at loc ; there is a robot at loc ; robot r is loaded with container c ; robot r is empty holding empty (k, c) (k) ; crane k is holding container c ; crane k is not holding anything in top on (c, p) (c, p) (c1, c2) ; container c is somewhere in pile p ; container c is on top of pile p ; container c1 is on container c2 jonkv@ida Predicates for DWR ο‘ Terminology: ο§ Term: Constant symbol or variable ο§ Atom: Predicate symbol applied to the intended number of terms βͺ raining βͺ occupied(location) βͺ occupied(loc2) βͺ at(r1, loc1) ο§ Ground atom: Atom without variables (only constants) ο‘ The first order language πΏπΏ has no types! ο§ Additional atoms: βͺ at(loc1,loc2) βͺ holding(loc1, c1) βͺ … 25 jonkv@ida Predicates, Terms, Atoms, Ground Atoms ο‘ 26 A state defines which ground atoms are true/false in the world We can compute differences between states take(1,B) s1 put(1,C) s2 s0 1 2 3 s0 top(1) is true top(2) is false top(3) is false on(1,1) is false on(1,2) is true on(1,3) is false on(2,1) is false … put(1,B) take(1,C) s1 top(1) is false top(2) is true top(3) is false on(1,1) is false on(1,2) is false on(1,3) is false on(2,1) is false … Structure is essential! We will see later how planners make use of structured states… jonkv@ida States 1: Factored, Internally Structured ο‘ 27 Efficient specification / storage of a single state: ο§ Specify which facts are true βͺ All other facts have to be false – what else would they be? ο§ ο¨ A state is a set of all ground atoms that are true βͺ s0 = { on(1,2), on(2,3), in(1,B), in(2,B), in(3,B), top(1), bot(3) } s0 1 2 3 s0 top(1) on(1,2) on(2,3) bot(3) in(1,B) in(2,B) in(3,B) take(1,B) s1 put(1,C) s2 put(1,B) take(1,C) s1 hold(1) top(2) on(2,3) bot(3) top(1) ∈ s0 ο¨ top(1) is true in s0 top(2) ∉ s0 ο¨ top(2) is false in s0 in(2,B) in(3,B) s2 top(1) top(2) on(2,3) bot(3) bot(1) in(1,C) in(2,B) in(3,B) Why not store all ground atoms that are false instead? jonkv@ida States 2: First-order Representation ο‘ "A state is a set of all ground atoms that are true"… ο§ Set of states in the STS: βͺ ππ = 2 ππππππππππππ ππππππππππ (powerset: all sets of ground atoms) ο§ Number of states: βͺ ππ = 2 ππππππππππππ ππππππππππ = 2number of ground atoms 28 jonkv@ida States 3: State Set ο‘ The STS assumes a single initial state π π 0 ο§ Complete information about the current state of the world ο‘ 29 Complete relative to the model: We must know everything about those predicates and objects we have specified... State = set of true facts… ο§ π π 0 = attached p1,loc1 , in c1,p1 , on c1,pallet , on c3,c1 , … c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida States 4: Initial State ο‘ 30 One way of efficiently defining a set of goal states: ο§ A goal ππ is a set of ground atoms, and ππππ = π π ∈ ππ | ππ ⊆ π π ο§ Example: ππ={in(c1,p2), in(c3,p2)} βͺ In the final state, containers 1 and 3 should be in pile 2, and we don't care about any other facts βͺ ππππ = { {in(c1,p2), in(c3,p2)}, {in(c1,p2), in(c3,p2), on(c1,c3)}, … } c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida States 5: Goal States, Positive Goals ο‘ 31 To increase expressivity: ο§ A literal is an atom or a negated atom: in(c1,p2), ¬in(c1,p2) ο§ A goal ππ is a set of ground literals βͺ in(c1,p2) ο¨ Container 1 should be in pile 2 βͺ ¬in(c2,p3) ο¨ Container 2 should not be in pile 3 ο§ "Translation": ππππ = π π ∈ ππ | π π satisfies ππ More expressive than positive goals Still not as expressive as the STS Many classical planners use one of these two alternatives; some are more expressive c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida States 6: Goal States, Literal Goals ο‘ 32 We have abstracted the real world! ο§ Motion is really continuous in 3D space βͺ Uncountably infinite number of positions for a container ο§ But for the purpose of planning: βͺ We model a finite number of interesting positions βͺ On a specific robot βͺ In a specific pile βͺ Held by a specific crane Real World Abstraction Approximation Simplification Formal Model Gives sufficient information allowing us to solve interesting problems jonkv@ida Abstraction ο‘ 34 In the classical representation: Don't define actions directly ο§ Define a set ππ of operators ο§ Each operator is parameterized, defines many actions βͺ ;; crane k at location l takes container c off container d in pile p take(k, l, c, d, p) ο§ Has a precondition βͺ precond(o): set of literals that must hold before execution βͺ precond(take) = { belong(k,l), empty(k), attached(p,l), top(c,p), on(c,d) } ο§ Has effects βͺ effects(o): set of literals that will be made to hold after execution βͺ effects(take) = { holding(k,c), ¬empty(k), ¬in(c,p), ¬top(c,p), ¬on(c,d), top(d,p) } c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida Operators ο‘ 35 In the classical representation: ο§ Every ground instantiation of an operator is an action βͺ ππ1 = take(crane1, loc2, c3, c1, p1) ο§ Also has (instantiated) precondition, effects βͺ precond(ππ1 ) = { belong(crane1,loc2), empty(crane1), attached(p1,loc2), top(c3,p1), on(c3,c1) } βͺ effects(ππ1 ) = { holding(crane1,c3), ¬empty(crane1), ¬in(c3,p1), ¬top(c3,p1), ¬on(c3,c1), top(c1,p1) } ππ is an instantiation π΄π΄ = ππ of an operator in ππ using constants in πΏπΏ c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida Actions ο‘ 36 If every ground instantiation of an operator is an action… ο§ …then so is this: βͺ take(c3, crane1, r1, crane2, r2) ;; Container c3 at location crane1 takes robot1 off crane2 in pile robot2 ο§ But when will this action be applicable? βͺ take(k, l, c, d, p): ;; crane k at location l takes container c off container d in pile p precond: belong(k,l), empty(k), attached(p,l), top(c,p), on(c,d) βͺ take(c3, crane1, r1, crane2, r2): precond: belong(c3,crane1), empty(c3), attached(r2,crane1), top(r1,r2), on(r1,crane2) For these preconditions to be true, something must already have gone wrong! jonkv@ida Untyped Actions and Applicability ο‘ 37 Standard solution: Separate type predicates ο§ Ordinary predicates that happen to represent types: βͺ crane(x), location(x), container(x), pile(x) ο§ Used as part of preconditions: βͺ take(k, l, c, d, p): ;; crane k at location l takes container c off container d in pile p crane(k), location(l), container(c), container(d), pile(p), precond: belong(k,l), empty(k), attached(p,l), top(c,p), on(c,d) ο§ DWR example was "optimized" somewhat βͺ belong(k,l) is only true for crane+location, replaces two type predicates ο§ So: βͺ take(c3, crane1, r1, crane2, r2) is an action βͺ Its preconditions can never be satisfied in reachable states! βͺ Type predicates are fixed, rigid, never modified ο¨ such actions can be filtered out before planning even starts jonkv@ida Untyped Actions and Applicability (2) ο‘ 38 Some useful properties: ο§ If βͺ βͺ βͺ βͺ a is an operator or action… precond+(a) precond–(a) effects+(a) effects–(a) = { atoms that appear positively in a’s preconditions } = { atoms that appear negated in a’s preconditions } = { atoms that appear positively in a’s effects } = { atoms that appear negated in a’s effects } ο§ Example: βͺ take(k, l, c, d, p): ;; crane k at location l takes container c off container d in pile p precond: belong(k,l), empty(k), attached(p,l), top(c,p), on(c,d) effects: holding(k,c), ¬empty(k), ¬in(c,p), ¬top(c,p), ¬on(c,d), top(d,p) βͺ effects+(take(k,l,c,d,p)) = { holding(k,c), top(d,p) } βͺ effects–(take(k,l,c,d,p)) = { empty(k), in(c,p), top(c,p), on(c,d) } Negation disappears! jonkv@ida Useful Properties ο‘ 39 Action ο¨ ground ο¨ preconds are ground atoms An action a is applicable in a state s… ο§ … if precond+(a) ⊆ s and precond–(a) ∩ s = ∅ ο‘ Example: Simple representation (sets) ο¨ simple definitions! ο‘ take(crane1, loc1, c3, c1, p1): ;; crane1 at loc1 takes c3 off c1 in pile p1 precond: { belong(crane1,loc1), empty(crane1), attached(p1,loc1), top(c3,p1), on(c3,c1) } effects: { holding(crane1,c3), ¬empty(crane1), ¬in(c3,p1), ¬top(c3,p1), ¬on(c3,c1), top(c1,p1) } ο‘ s1 = { attached(p1,loc1), in(c1,p1), on(c1,pallet), attached(p2,loc1), in(c2,p2), on(c2,pallet), belong(crane1,loc1), empty(crane1), at(r1,loc2), unloaded(r1), occupied(loc2), adjacent(loc1,loc2), adjacent(loc2,loc1) } in(c3,p1), on(c3,c1), top(c3,p1), top(c2,p2), c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida Applicable (Executable) Actions ο‘ 40 Applying will add positive effects, delete negative effects ο§ If a is applicable in s, then the new state is (s – effects–(a)) ∪ effects+(a) ο§ take(crane1, loc1, c3, c1, p1): ;; crane1 at loc1 takes c3 off c1 in pile p1 precond: belong(crane1,loc1), empty(crane1), attached(p1,loc1), top(c3,p1), on(c3,c1) effects: holding(crane1,c3), top(c1,p1), ¬empty(crane1), ¬in(c3,p1), ¬top(c3,p1), ¬on(c3,c1) c3 c1 p1 loc2 c2 p2 loc1 r1 c3 loc2 c2 c1 p1 p2 loc1 r1 jonkv@ida Result of Performing an Action ο‘ 41 From actions to πΎπΎ: ο§ πΎπΎ π π , ππ = ∅ οΏ½ π π − effects− ππ ∪ effects+ (ππ) Positive preconditions missing from state Negated preconditions present in state if precond+ ππ β π π or precond– ππ ∩ π π ≠ ∅ otherwise From the classical representation language, we know how to define Σ = (ππ, π΄π΄, πΎπΎ) and a problem (Σ, π π 0 , ππππ ) jonkv@ida Defining πΈπΈ ο‘ 42 Usual assumption in domain-independent planning: ο§ Preconditions should have to do with executability, not suitability βͺ Weakest constraints under which the action can be executed take(crane1, loc1, c3, c1, p1): These are physical precond:{ belong(crane1,loc1), empty(crane1), attached(p1,loc1), top(c3,p1), on(c3,c1) } requirements for taking a container! effects: { holding(crane1,c3), top(c1,p1), ¬empty(crane1), ¬in(c3,p1), ¬top(c3,p1), ¬on(c3,c1) } ο§ The planner chooses which actions are suitable, using heuristics (etc.) ο§ Add explicit “suitability preconditions” ο¨ domain-configurable planning βͺ ”Only pick up a container if there is a truck on which the crane can put it” βͺ ”Only pick up a container if it needs to be moved according to the goal” jonkv@ida Modeling: What Is a Precondition? Classical Representation is simple, but not easily extended with complex preconditions, effects, timing, action costs, concurrency, … Formal representation language Closer to how we think Provides more structural information, very useful for planning algorithms Underlying formal model Concepts as simple as possible: States, actions, transition function Good for analysis, correctness proofs, understanding what planning is Misc. Misc. Preconditions Effects Extensions Separation: Domain / instance PDDL object types Formulas: Disjunctions, … Conditional effects, … Timing, action costs, … Objects Fact atoms State Operators Preconditions Effects { car1, car2, car3, loc1, loc2 } { at(car1,loc1),at(car1,loc2),… } Set of true atoms drive(loc1, loc2) – with params { at(car1,loc1), ¬broken(car1) } { ¬at(car1,loc1), at(car1,loc2) } This indirectly defines γ(s,a)! States Actions s1 … s1000000000000, a1 … a10000 – no structure! Transition function defining the result of an action, γ(currentstate, action)=newstate Goals {s1,s3,s282} – set of end states Covered in the book Now: Extensible representation language ο‘ PDDL: Planning Domain Definition Language ο§ Origins: First International Planning Competition, 1998 ο§ Most used language today ο§ General; many expressivity levels ο‘ Lowest level of expressivity: Called STRIPS ο§ After the planner used by Shakey, STRIPS: Stanford Research Institute Problem Solver ο§ One specific predicate-based ("logic-based") syntax/semantics for classical planning domains/instances 45 jonkv@ida PDDL ο‘ 46 PDDL separates domains and problem instances Domain file Named (define (domain dock-worker-robots) … ) Problem instance file Named (define (problem dwr-problem-1) (:domain dock-worker-robots) Associated with … a domain ) Colon before many keywords, to avoid collisions when new keywords are added jonkv@ida PDDL: Domain and Problem Definition ο‘ 47 Domains declare their expressivity requirements βͺ (define (domain dock-worker-robots) (:requirements :strips ;; Standard level of expressivity …) ;; Remaining domain information goes here! ) We will see some other levels as well… Warning: Many planners’ parsers ignore expressivity specifications jonkv@ida PDDL: Domain and Problem Definition ο‘ 49 In PDDL and most planners: ο§ Constants have types, defined in the domain βͺ (define (domain dock-worker-robots) (:requirements :strips Tell the planner :typing ) which features you need… ) (:types location ; there are several connected locations in the harbor pile ; attached to a location, holds a pallet + a stack of containers robot ; holds at most 1 container, only 1 robot per location crane ; belongs to a location to pickup containers container) c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida PDDL Objects 1: Types ο‘ 50 Many planners support type hierarchies ο§ Convenient, but often not used in domain examples βͺ (:types ; containers and robots are movable objects container robot – movable …) ο§ Predefined ”topmost supertype”: object c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida PDDL Objects 2: Type Hierarchies ο‘ 51 Instance-specific constants are called objects ο§ (define (problem dwr-problem-1) (:domain dock-worker-robot) (:objects r1 – robot loc1 loc2 – location k1 – crane p1 p2 – pile c1 c2 c3 pallet – container) c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida PDDL Objects 3: Object Definitions ο‘ 52 jonkv@ida PDDL Objects 4: PDDL Constants Some constants should exist in all instances (define (domain woodworking) (:requirements :typing) (:types acolour awood woodobj machine surface treatmentstatus aboardsize apartsize – object highspeed-saw glazer grinder immersion-varnisher planer saw spray-varnisher – machine board part - woodobj) (:constants Define once – verysmooth smooth rough – surface use in all varnished glazed untreated colourfragments – treatmentstatus problem natural – acolour instances small medium large - apartsize) (:action do-immersion-varnish :parameters (?x - part ?m - immersion-varnisher ?newcolour - acolour ?surface - surface) :precondition (and … ο¨ Can use in the (treatment ?x untreated)) domain :effect (and definition (not (treatment ?x untreated)) (treatment ?x varnished) as well! (not (colour ?x natural)) (colour ?x ?newcolour))) …) ο‘ 54 In PDDL: Lisp-like syntax for predicates, atoms, … βͺ (define (domain dock-worker-robots) (:requirements …) (:predicates (adjacent ?l1 ?l2 - location) (attached ?p - pile ?l - location) (belong ?k - crane ?l - location) ) Variables are prefixed with “?” ; can move from ?l1 directly to ?l2 ; pile ?p attached to location ?l ; crane ?k belongs to location ?l (at ?r - robot ?l - location) (occupied ?l - location) (loaded ?r - robot ?c - container ) (unloaded ?r - robot) ; robot ?r is at location ?l ; there is a robot at location ?l ; robot ?r is loaded with container ?c ; robot ?r is empty (holding ?k - crane ?c - container) (empty ?k - crane) ; crane ?k is holding container ?c ; crane ?k is not holding anything (in (top (on ; container ?c is somewhere in pile ?p ; container ?c is on top of pile ?p ; container ?k1 is on container ?k2 ?c - container ?p - pile) ?c - container ?p - pile) ?k1 ?k2 - container ) jonkv@ida Predicates in PDDL ο‘ Modeling Issues: Single or multiple predicates? βͺ (define (domain dock-worker-robots) (:requirements …) (:predicates 3 predicates (attached ?p - pile ?l - location) with similar (belong ?k - crane ?l - location) ?r - robot ?l - location) meaning (at ; pile ?p attached to location ?l ; crane ?k belongs to location ?l ; robot ?r is at location ?l ο§ Could use type hierarchies instead – in most planners βͺ (define (domain dock-worker-robots) (:requirements …) (:types robot crane container pile – thing location (:predicates (at ?t – thing ?l - location) ; thing ?t is at location ?l ) ) 55 jonkv@ida Modeling: Different predicates per type? ο‘ Models often provide duplicate information ο§ A location is occupied ο³ there is some robot at the location βͺ (define (domain dock-worker-robots) (:requirements …) (:predicates (at ?r - robot ?l - location) ; robot ?r is at location ?l (occupied ?l - location) ; there is a robot at location ?l ο§ Strictly speaking, occupied is redundant βͺ βͺ βͺ βͺ Still necessary in many planners No support for quantification: (exists ?r (at ?r ?l)) Have to write (occupied ?l) instead Have to provide this information + update it in actions! 56 jonkv@ida Modeling: Duplicate information ο‘ 58 Initial states in PDDL: ο§ Set (list) of true atoms βͺ (define (problem dwr-problem-1) Lisp-like notation again: (:domain dock-worker-robot) (attached p1 loc), not (:objects …) attached(p1,loc) (:init (attached p1 loc1) (in c1 p1) (on c1 pallet) (in c3 p1) (on c3 c1) (top c3 p1) (attached p2 loc1) (in c2 p2) (on c2 pallet) (top c2 p2) (belong crane1 loc1) (empty crane1) (at r1 loc2) (unloaded r1) (occupied loc2) (adjacent loc1 loc2) (adjacent loc2 loc1) ) ) c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida States 1: Initial State in PDDL ο‘ 59 The :strips level supports positive conjunctive goals ο§ Example: Containers 1 and 3 should be in pile 2 βͺ We don't care about their order, or any other fact βͺ (define (problem dwr-problem-1) (:domain dock-worker-robot) (:objects …) (:goal (and (in c1 p2) (in c3 p2)))) Write as a formula (and …), not a set: Other levels support "or", "forall", "exists", … c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida States 2: Goal States ο‘ 60 Some planners: Conjunctions of positive / negative literals ο§ Example: βͺ Containers 1 and 3 should be in pile 2 βͺ Container 2 should not be in pile 4 βͺ (:requirements :negative-preconditions …) βͺ (define (problem dwr-problem-2) (:domain dock-worker-robot) (:objects …) (:goal (and (in c1 p2) (in c3 p2) (not (in c2 p4)) ) ο§ Buggy support in some planners βͺ Can be worked around βͺ Define outside predicate = inverse of in βͺ Make sure actions update this βͺ (:goal (and (in c1 p2) (in c3 p2) (outside c2 p4) ) c3 c1 p1 loc2 c2 p2 loc1 r1 jonkv@ida States 3: Goal States ο‘ 62 PDDL: Operators are called actions, for some reason… βͺ (define (domain dock-worker-robots) … (:action move :parameters (?r – robot ?from ?to - location) Typed params ο¨ can only instantiate with the intended objects :precondition (and (adjacent ?from ?to) (at ?r ?from) (not (occupied ?to))) :effect (and (at ?r ?to) (not (occupied ?from)) (occupied ?to) (not (at ?r ?from)) ) Again, written as logical conjunctions, ) instead of sets! c3 c1 p1 c2 p2 loc1 loc2 r1 jonkv@ida Operators in PDDL 63 jonkv@ida Transformation: PDDL/strips ο¨ STS Input 1: Planning domain Defines the set of states in the formal model (STS) Object Types: There are UAVs, boxes … Predicates: Every UAV has a maxSpeed, … Operators: Definition of fly, pickup, … Input 2: Problem instance Objects: Current UAVs are {UAV1,UAV2} Initial State: Box locations, … Goal: Box b1 at location l1, … Defines transitions between states in the formal model (STS) Defines initial and goal states ο‘ Consider modeling a ”drive” operator for a truck ο§ ”Natural” parameters: The truck and the destination βͺ (:action drive :parameters (?t – truck ?dest – location) :precondition … :effect … ) ο§ ”Natural” precondition: βͺ There must exist a path between the current location and the destination βͺ Should use the predicate (path-between ?loc1 ?loc2 – location) βͺ State variable representation ο¨ can express the location of the truck: (:precondition (path-between (location-of ?t) ?dest)) βͺ But in a first-order predicate representation, we can only test whether a truck is at some specific location: (at ?t ?location) 66 jonkv@ida Property Values 1 ο‘ Standard solution: ο§ Add a parameter to the operator βͺ (:action drive :parameters (?t – truck ?from – location ?dest – location) :precondition … :effect … ) ο§ Constrain that variable in the precondition βͺ :precondition (and (at ?t ?from) (path-between ?from ?dest)) βͺ Can only apply those instances of the operator where ?from is the current location of the truck 67 jonkv@ida Property Values 2 ο‘ Example: ο§ Initially: βͺ (at truck5 home) 68 These parameters are "extraneous" in the sense that they do not add choice: We can choose truck and dest (given some constraints): from is uniquely determined by state + other params! ο§ Action: βͺ (:action drive :parameters (?t – truck ?from – location ?dest – location) :precondition (and (at ?t ?from) (path-between ?from ?dest)) :effect … ) ο§ Which actions are executable? βͺ (drive truck5 work home) – no, precond false βͺ (drive truck5 work work) – no, precond false βͺ (drive truck5 work store) – no, precond false βͺ (drive truck5 home store) – precond true, can be applied! With quantification, we could have changed the precondition: (exists (?from – location) (and (at ?t ?from) (path-between ?from ?dest)) No need for a new parameter – in this case… jonkv@ida Property Values 3 ο‘ 69 What about effects? ο§ Same ”natural” parameters: The truck and the destination βͺ (:action drive :parameters (?t – truck ?dest – location) :precondition … :effect … ) ο§ ”Natural” effects: βͺ The truck ends up at the destination: βͺ The truck is no longer where it started: (at ?t ?dest) (not (at ?t …???... )) ο§ How do you find out where the truck was before the action? βͺ Using an additional parameter still works: (not (at ?t?from)) βͺ The value of ?from is constrained in the precondition – before βͺ The value is used in the effect state jonkv@ida Property Values 4 ο‘ 71 We often need at least some ”primitive” support for counting ο§ Elevator domain: βͺ Which floor is an elevator at? βͺ Which is the next floor? βͺ Which is the previous floor? ο§ Few planners support general numeric state variables jonkv@ida Counting 1 ο‘ 72 Standard solution: ο§ Create a type of ”pseudo-numbers” βͺ (:types … num …) ο§ Define a set of value objects βͺ (:objects … n0 n1 n2 n3 n4 n5 n6 n7 – num) ο§ Define the operations you need – for example, find the next number βͺ (:predicates … (next ?numA ?numB – num) βͺ (:init … (next n0 n1) (next n1 n2) (next n2 n3) … (next n6 n7)) ο§ Use the value objects as if they were numbers These are also βͺ (:action move-up "extraneous" parameters… :parameters (?e – elevator ?from ?to – num) :precondition (and (at ?elevator ?from) ;; Where is the elevator? (next ?from ?to) …) ;; Now ”to” is the next number :effects (and (not (at ?elevator ?from)) (at ?elevator ?to))) There is no ”next” for n7 ο¨ Won’t be able to move up from the top floor (an "implicitly modeled" precondition) jonkv@ida Counting 2