2

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?

Bilal
  • 3,191
  • 4
  • 21
  • 49
Neskelogth
  • 91
  • 3
  • 12
  • 1
    +1 for @Bilal's answer - the negative intializations should be removed from the `:init`, but if you need to negate a predicate, the syntax you used in the `move` action effect was correct: `(not (in_room ?r1))` This is NOT how negation is written: `(not in_room vacuum kitchen)` – Jan Dolejsi Jun 27 '22 at 13:48

1 Answers1

2

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)
      )
  )
Bilal
  • 3,191
  • 4
  • 21
  • 49
  • 1
    While it is true that most planners assume a Closed World, PDDL still accepts negative literals in the initial state. The PDDL BNF states that ` ::= ` and ` ::= ` and ` ::= (not )`. So it is perfectly valid without requirements. If the OP used the correct syntax `(not (in_room vacuum kitchen))` it would be valid. Whether the black-box planner likes it is another story, but it is perfectly valid PDDL. While CW makes it redundant, it is sometimes used for readability or due to automatic state generation. – jbx Aug 29 '22 at 10:59