PDDL 2.1

PDDL 2.1 gave planning numbers and time. Written by Maria Fox and Derek Long for the 2002 competition, it added numeric fluents, plan metrics and durative actions, the basis of numeric and temporal planning in PDDL since.

The five levels

The paper describes the competition's language in levels:

LevelAdds
1The STRIPS fragment, as in earlier PDDL
2Numeric extensions
3Discretised durative actions
4Continuous durative actions
5All of these, with spontaneous events and physical processes: see PDDL+

The competition used levels 1, 2 and 3.

Numeric fluents and metrics

Functions declared under :functions hold numbers. Conditions compare them, and effects change them with assign, increase, decrease, scale-up and scale-down. A :metric in the problem says what to optimise.

demos/pddl-guide/courier-fuel/domain.pddl
; PDDL 2.1 numeric fluents: driving burns fuel, refuelling costs money.
(define (domain courier-fuel)
  (:requirements :typing :fluents)
  (:types van parcel location)
  (:predicates
    (road ?from ?to - location)
    (van-at ?v - van ?l - location)
    (parcel-at ?p - parcel ?l - location)
    (in ?p - parcel ?v - van)
    (pump ?l - location))
  (:functions
    (distance ?from ?to - location)
    (fuel ?v - van)
    (tank ?v - van)
    (spent))

  (:action drive
    :parameters (?v - van ?from ?to - location)
    :precondition (and (van-at ?v ?from) (road ?from ?to)
                       (>= (fuel ?v) (distance ?from ?to)))
    :effect (and (not (van-at ?v ?from)) (van-at ?v ?to)
                 (decrease (fuel ?v) (distance ?from ?to))))

  (:action refuel
    :parameters (?v - van ?l - location)
    :precondition (and (van-at ?v ?l) (pump ?l) (< (fuel ?v) (tank ?v)))
    :effect (and (increase (spent) (* 2 (- (tank ?v) (fuel ?v))))
                 (assign (fuel ?v) (tank ?v))))

  (:action load
    :parameters (?p - parcel ?v - van ?l - location)
    :precondition (and (van-at ?v ?l) (parcel-at ?p ?l))
    :effect (and (not (parcel-at ?p ?l)) (in ?p ?v)))

  (:action unload
    :parameters (?p - parcel ?v - van ?l - location)
    :precondition (and (van-at ?v ?l) (in ?p ?v))
    :effect (and (not (in ?p ?v)) (parcel-at ?p ?l))))
demos/pddl-guide/courier-fuel/problem.pddl
(define (problem out-and-back)
  (:domain courier-fuel)
  (:objects
    van1 - van
    book - parcel
    depot market harbour - location)
  (:init
    (van-at van1 depot)
    (parcel-at book depot)
    (pump market)
    (road depot market) (road market depot)
    (road market harbour) (road harbour market)
    (= (distance depot market) 6) (= (distance market depot) 6)
    (= (distance market harbour) 5) (= (distance harbour market) 5)
    (= (fuel van1) 8)
    (= (tank van1) 12)
    (= (spent) 0))
  ; The tank cannot reach the harbour without stopping at the market.
  (:goal (parcel-at book harbour))
  (:metric minimize (spent)))

Durative actions

A :durative-action has a :duration, a :condition and an :effect, and all conditions and effects are annotated with when they apply. Conditions are at start, at end or over all; effects are at start or at end. An over all condition holds on an interval open at both ends, so a fact that must hold throughout needs all three.

demos/pddl-guide/courier-durative/domain.pddl
; PDDL 2.1 durative actions: actions take time, and two vans work at once.
(define (domain courier-durative)
  (:requirements :typing :fluents :durative-actions)
  (:types van parcel location)
  (:predicates
    (road ?from ?to - location)
    (van-at ?v - van ?l - location)
    (parcel-at ?p - parcel ?l - location)
    (in ?p - parcel ?v - van))
  (:functions
    (distance ?from ?to - location)
    (speed ?v - van))

  (:durative-action drive
    :parameters (?v - van ?from ?to - location)
    :duration (= ?duration (/ (distance ?from ?to) (speed ?v)))
    :condition (and (at start (van-at ?v ?from))
                    (over all (road ?from ?to)))
    :effect (and (at start (not (van-at ?v ?from)))
                 (at end (van-at ?v ?to))))

  (:durative-action load
    :parameters (?p - parcel ?v - van ?l - location)
    :duration (= ?duration 2)
    :condition (and (at start (parcel-at ?p ?l))
                    (over all (van-at ?v ?l)))
    :effect (and (at start (not (parcel-at ?p ?l)))
                 (at end (in ?p ?v))))

  (:durative-action unload
    :parameters (?p - parcel ?v - van ?l - location)
    :duration (= ?duration 2)
    :condition (and (at start (in ?p ?v))
                    (over all (van-at ?v ?l)))
    :effect (and (at start (not (in ?p ?v)))
                 (at end (parcel-at ?p ?l)))))
demos/pddl-guide/courier-durative/problem.pddl
(define (problem two-vans)
  (:domain courier-durative)
  (:objects
    fast slow - van
    book lamp - parcel
    depot market harbour - location)
  (:init
    (van-at fast depot) (van-at slow depot)
    (parcel-at book depot) (parcel-at lamp depot)
    (road depot market) (road market depot)
    (road depot harbour) (road harbour depot)
    (= (distance depot market) 12) (= (distance market depot) 12)
    (= (distance depot harbour) 30) (= (distance harbour depot) 30)
    (= (speed fast) 3)
    (= (speed slow) 2))
  (:goal (and (parcel-at book market) (parcel-at lamp harbour)))
  (:metric minimize (total-time)))

A plan is now a schedule, with a start time and a duration for each action. Here the two vans work at once:

0:      (load book fast depot) [2]
0:      (load lamp slow depot) [2]
2.001:  (drive fast depot market) [4]
2.001:  (drive slow depot harbour) [15]
6.002:  (unload book fast market) [2]
17.002: (unload lamp slow harbour) [2]

The metric (total-time) asks for a short schedule, its makespan.

Continuous effects

Inside a durative action, #t stands for the time since the action began, and an effect using it changes a value continuously. With :duration-inequalities a duration can be a range, which the planner chooses from.

demos/pddl-guide/courier-continuous/domain.pddl
; PDDL 2.1 continuous effects: charge drains while the van drives and
; rises while it is plugged in, in proportion to #t, the time elapsed.
(define (domain courier-continuous)
  (:requirements :typing :fluents :durative-actions :continuous-effects :duration-inequalities)
  (:types van location)
  (:predicates
    (road ?from ?to - location)
    (van-at ?v - van ?l - location)
    (charger ?l - location))
  (:functions
    (distance ?from ?to - location)
    (charge ?v - van))

  (:durative-action drive
    :parameters (?v - van ?from ?to - location)
    :duration (= ?duration (distance ?from ?to))
    :condition (and (at start (van-at ?v ?from))
                    (over all (road ?from ?to))
                    (over all (>= (charge ?v) 0)))
    :effect (and (at start (not (van-at ?v ?from)))
                 (at end (van-at ?v ?to))
                 (decrease (charge ?v) (* #t 2))))

  ; The planner chooses how long to charge, from 1 to 60.
  (:durative-action plug-in
    :parameters (?v - van ?l - location)
    :duration (and (>= ?duration 1) (<= ?duration 60))
    :condition (and (over all (van-at ?v ?l)) (over all (charger ?l)))
    :effect (increase (charge ?v) (* #t 5))))
demos/pddl-guide/courier-continuous/problem.pddl
(define (problem charge-on-the-way)
  (:domain courier-continuous)
  (:objects
    van1 - van
    depot market harbour - location)
  (:init
    (van-at van1 depot)
    (charger market)
    (road depot market) (road market harbour)
    (= (distance depot market) 10)
    (= (distance market harbour) 15)
    (= (charge van1) 25))
  (:goal (van-at van1 harbour))
  (:metric minimize (total-time)))

The van starts with charge 25, needs 20 to reach the market and 30 to go on. So the plan has to charge for at least five time units, and Autoplan works that length out:

0:          (drive van1 depot market) [10]
10.001:     (plug-in van1 market) [5.0000002]
15.0020002: (drive van1 market harbour) [15]

Requirement flags

  • :fluents: functions, assignment effects and arithmetic conditions.
  • :durative-actions: durative actions. This does not imply :fluents.
  • :duration-inequalities: duration constraints using inequalities.
  • :continuous-effects: effects on fluents continuously over an action.
  • :negative-preconditions: not in goal descriptions. It is in this version's table and not in that of PDDL 1.2.

Sources

  1. Maria Fox, Derek Long. PDDL2.1: An Extension to PDDL for Expressing Temporal Planning Domains. Journal of Artificial Intelligence Research 20, 61-124, 2003.
  2. Derek Long, Maria Fox. The 3rd International Planning Competition: Results and Analysis. Journal of Artificial Intelligence Research 20, 1-59, 2003.