PDDL forall with when condition in durative-action

818 Views Asked by At

This question builds on a previous question about forall clauses. I would like to limit the forall with a 'when' statement as shown below:

(:durative-action finish
  :parameters (?r - robot ?p - part)
  :duration ( = ?duration 1)
  :condition (and
      (at start (robot_free ?r))
      (at start (forall (?f - fastener_loc)
                    when (part_fastener ?p ?f)
                     (loc_not_fastened ?f)
                )
      )
     )
  :effect (and
      (at start(not (robot_free ?r)))
      (at end (part_free ?p))
      (at end (robot_free ?r))
     )
)

This works without the 'when' statement. When I include the 'when' statement, I receive several errors:

Error: Syntax error in durative-action declaration.
Error: Unreadable structure
Error: Syntax error in domain

Thanks in advance for any help.

3

There are 3 best solutions below

2
On

The when clause needs to be wrapped in (brackets)

0
On

I was able to get this to work with an imply statement.

(:durative-action finish
  :parameters (?r - robot ?p - part)
  :duration ( = ?duration 1)
  :condition (and
      (at start (robot_free ?r))
      (at start (forall (?f - fastener_loc)
                    (imply (part_fastener ?p ?f)(loc_not_fastened ?f))
                )
      )
     )
  :effect (and
      (at start(not (robot_free ?r)))
      (at end (part_free ?p))
      (at end (robot_free ?r))
     )
)

Not sure if this could also work the the when syntax.

0
On

The when keyword is restricted to conditional effects. You can see the definition in the PDDL3.1 BNF.

Be a bit careful when combining forall with imply, because it could lead to a nasty combinatorial explosion. Keep in mind that imply typically gets flattened (Negation Normal Form) to a disjunction. So in your case it would become:

(or (not (part_fastener ?p ?f)) (loc_not_fastened ?f))

Which planners typically split into two separate actions (to remove disjunctions), one with (not (part_fastener ?p ?f)) as its precondition, and one with (loc_not_fastened ?f).

The forall then explodes this to all pairwise combinations of the disjunction, to ground it to all instances of fastener_loc, combined with all grounded combinations of robot and part action parameters (to generate the grounded actions themselves).

If you only have a few objects of each type I guess you should be OK.