planningpddl

Why isn't PDDL compiling correctly and resulting in parse error?


I am new to PDDL so I don't understand very well what's going on but I have this issue and it seems that black-box planner isn't able to parse my PDDL code.

Here there is the domain:

(define (domain vacuum)
    (:requirements :strips)
    (:predicates
        (clean ?x)
        (in_room ?x ?r)
        (door_to ?r1 ?r2)
        (dirty ?x)
    )

    (:action moveToAction
        :parameters (?ob ?r1 ?r2)
        :precondition (and
            (in_room ?ob ?r1)
            (door_to ?r1 ?r2)
        )
        :effect (and
            (not (in_room ?r1))
            (in_room ?ob ?r2)
        )
    )
    
    (:action cleanAction
        :parameters (?r1)
        :precondition (and
            (dirty ?r1)
        )
        :effect (and
            (clean ?r1)
        )
    )
)

and here there is the problem:

(define (problem vacuum)
    (:domain vacuum)
    (:objects vacuum kitchen corridor bedroom1 bedroom2 bathroom living_room)
    (:init  
        (dirty kitchen) 
        (dirty bedroom1) 
        (dirty bedroom2)
        (dirty living_room) 
        (dirty bathroom) 
        (dirty corridor)
        (in_room vacuum living_room)
        (not in_room vacuum kitchen) 
        (not in_room vacuum bedroom1) 
        (not in_room vacuum bedroom2) 
        (not in_room vacuum bathroom) 
        (not in_room vacuum corridor) 
        (door_to bathroom corridor) 
        (door_to kitchen corridor) 
        (door_to living_room corridor) 
        (door_to bedroom1 corridor) 
        (door_to bedroom2 corridor) 
        (door_to corridor bathroom) 
        (door_to corridor kitchen)
        (door_to corridor living_room)
        (door_to corridor bedroom1)
        (door_to corridor bedroom2)
    )
    (:goal 
        (and (clean living_room))
    )
)

The exact error that the solver gives me is:

parse error
Error occurred at or near line 40

If I understood correctly the parser reads the domain file first and the problem file after that, so the error should be in the problem file, and in particular in the init. The precise line should be (dirty corridor). I do not understand what I did wrong, did I miss the syntax completely or did I just mess something?


Solution

  • you have to remove the negated predicates from the initial state in the problem due to the Closed World Assumption, plus you have a small typo in the domain in_room takes two variables, and not just one!

    Then your domain / problem will look like:

    Domain:

    (define (domain vacuum)
        (:requirements :strips)
        (:predicates
            (clean ?x)
            (in_room ?x ?r)
            (door_to ?r1 ?r2)
            (dirty ?x)
        )
    
        (:action moveToAction
            :parameters (?ob ?r1 ?r2)
            :precondition (and
                (in_room ?ob ?r1)
                (door_to ?r1 ?r2)
            )
            :effect (and
                (not (in_room ?ob ?r1))
                (in_room ?ob ?r2)
            )
        )
        
        (:action cleanAction
            :parameters (?r1)
            :precondition (and
                (dirty ?r1)
            )
            :effect (and
                (clean ?r1)
            )
        )
    )
    

    Problem

    (define (problem vacuum)
        (:domain vacuum)
        (:objects vacuum kitchen corridor bedroom1 bedroom2 bathroom living_room)
        (:init  
            (dirty kitchen) 
            (dirty bedroom1) 
            (dirty bedroom2)
            (dirty living_room) 
            (dirty bathroom) 
            (dirty corridor)
            (in_room vacuum living_room)
            (door_to bathroom corridor) 
            (door_to kitchen corridor) 
            (door_to living_room corridor) 
            (door_to bedroom1 corridor) 
            (door_to bedroom2 corridor) 
            (door_to corridor bathroom) 
            (door_to corridor kitchen)
            (door_to corridor living_room)
            (door_to corridor bedroom1)
            (door_to corridor bedroom2)
        )
        (:goal 
            (and (clean living_room))
        )
    )
    

    Output Plan:

      (:action cleanaction
        :parameters (living_room)
        :precondition
          (and
            (dirty living_room)
          )
        :effect
          (and
            (clean living_room)
          )
      )