artificial-intelligenceplanningpddl

PDDL - invalid predicates and correct usage of forall


I am new to pddl planning and now I am trying to create a domain and problem file as an exercise. Short domain description: I have a couple of cars which can be taken and put at places A and B. The task is simple: take all the cars from place A and move them to place B. I created the following domain file:

(define (domain test) ; Domain name must match problem's

  ; Define what the planner must support to execute this domain
  ; Only domain requirements are currently supported
  ( :requirements
    :strips                 
    :negative-preconditions 
    :equality               
    :typing               
    :adl
  )
 
 
  (:types
   car
   place
  )
  
  
  (:predicates
    (at ?o - car ?p - place )
    (taken ?o - car )
  )
  
   (:action take
   :parameters (?o1 - car  ?o2 - place )
   :precondition (and 
                    (at ?o1 ?o2)
                    (not (taken ?o1))
                 )   
   :effect (and 
             (not (at  ?o1 ?o2 ))
             (taken ?o1)
           )
   )
   
   
   (:action put
   :parameters (?o1 - car  ?o2 - place )
   :precondition (and 
                    (not (at ?o1 ?o2))
                    (taken ?o1)
                 )   
   :effect (and 
             (at  ?o1 ?o2) 
             (not (taken ?o1) )
           )
   )
   
   (:action takeAll
   :parameters ()
   :precondition (forall (?c - car ?p - place)
                    (and 
                    (at ?c ?p)
                    (not (taken ?c))
                    )
            )
   :effect (forall (?c - car)
                    (taken ?c)
                    )
            )
            
   )

The problem file looks like this:

(define (problem test)
    (:domain test)
    
    (:objects
    c1 - car
    c2 - car
    c3 - car
    
    A - place
    B - place
    )
    
    (:init
        (at c1 A)
        (at c2 A)
        (at c3 A)
        (not (taken c1))
        (not (taken c2))
        (not (taken c3))
    )

    (:goal (and
            (at c1 B)
            (at c2 B)
            (at c3 B)
            )
    )
    
  )

I am using the online planner and solver available here and I am wondering why it outputs that I have several invalid predicates

test
  takeall precondition contains ["forall", ["?c", "-", "car", "?p", "-", "place"], ["and", ["at", "?c", "?p"], ["not", ["taken", "?c"]]]], not a valid predicate
  takeall effect contains ["forall", ["?c", "-", "car"], ["taken", "?c"]], not a valid predicate
  :equality requirement is unnecessary
test
  Initial state contains ["not", ["taken", "c1"]], not a valid predicate
  Initial state contains ["not", ["taken", "c2"]], not a valid predicate
  Initial state contains ["not", ["taken", "c3"]], not a valid predicate

Could someone explain to me what exactly I am doing wrong? With the takeAll action I wanted to experiment a bit with forall. And it should be interpreted like this: the preconditions says that all objects of type car are not in a state taken and are at some place. The effect should be that all cars are in a state taken. The shortest solution should be (according to my common sense) takeAll, put(c1, B), (put c2, B), (put c3, B) I appreciate your help!


Solution

  • You're doing classical planning, which means that the initial state only needs to specify what's true (everything else is assumed to be false). Remove those negative fluents from your init, and it may work out.