2

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.

steveb
  • 43
  • 4

3 Answers3

1

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.

steveb
  • 43
  • 4
0

The when clause needs to be wrapped in (brackets)

haz
  • 625
  • 4
  • 12
  • Tried bracket just around the ```when``` clause and also around the ```when``` and the following clause. Same error... – steveb Jul 20 '20 at 20:48
  • Ah, right. Missed that this was in a `condition` block and not an `effect` one. For the former you only use `imply` and for the latter you only use `when`. – haz Jul 21 '20 at 00:16
0

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.

jbx
  • 21,365
  • 18
  • 90
  • 144