Issues with classic planning
Classic planning has some issues which may be difficult or impossible to apply to problems:
- actions are instantaneous
- actions don’t define quantity or resources
- goals cannot define resource constraints
Typing in PDDL
We can declare types in PDDL by adding it to our requirements:
# in domain
(:requirements typing)
(:types vehicle location)
(:predicates
# use a dash to introduce a type
(at ?v - vehicle ?p - location)
(accessible ?v - vehicle ?p1 ?p2 - location)
)Metric Planning
PDDL 2.1 introduces the ability to model numeric values through fluents. Fluents allow us to manage resources.
We can include this by using:
(:requirements fluents)We can now create functions:
(:functions
(fuel-level ?v - vehicle)
(fuel-used ?v - vehicle)
(fuel-required ?p1 ?p2 - location)
(total-fuel-used)
)And use them in our actions:
(:action drive
:parameters (?v - vehicle ?from ?to - location)
:precondition (and
(at ?v ?from)
(accessible ?v ?from ?to)
(>= (fuel-level ?v) (fuel-required ?from ?to))
)
:effect (and
(not (at ?v ?from))
(at ?v t?to)
(decrease (fuel-level ?v) (fuel-required ?from ?to))
(increase (total-fuel-used) (fuel-required ?from ?to))
(increase (fuel-used ?v) (fuel-required ?from ?to))
)
)Now let’s try defining a problem:
(:objects
truck car - vehicle
Paris Berlin Rome Madrid - location
)
(:init
(at truck Rome)
(at car Paris)
(= (fuel-level truck) 100)
(= (fuel-level car) 100)
(accessible car Paris Berlin)
(accessible car Berlin Rome)
(accessible car Rome Madrid)
(accessible truck Rome Paris)
(accessible truck Rome Berlin)
(accessible truck Berlin Paris)
(= (fuel-required Paris Berlin) 40)
(= (fuel-required Berlin Rome) 30)
(= (fuel-required Rome Madrid) 50)
(= (fuel-required Rome Paris) 35)
(= (fuel-required Rome Berlin) 40)
(= (fuel-required Berlin Paris) 40)
(= (total-fuel-used) 0)
(= (fuel-used car) 0)
(= (fuel-used truck) 0)
)
(:goal (and
(at truck Paris)
(at car Rome)
))
(:metric minimize (total-fuel-used))Temporal Planning
Conditions may hold true at different times.
We can define a durative action which includes a duration:
(:durative-action move-up-slow
:parameters (?lift - slow-elevator ?f1 - floor ?f2 - floor)
:duration (= ?duration (travel-slow ?f1 ?f2))
:condition (and
(at start (lift-at ?lift ?f1))
(at start (above ?f1 ?f2))
(at start (reachable-floor ?lift ?f2))
)
:effect (and
(at start (not (lift-at ?lift ?f1)))
(at end (lift-at ?lift ?f2))
)
)In the problem file we define:
(above f0 f1)
(reachable-floor slow1 f1)
(= (travel-slow f0 f1) 12)