0

I currently working on a pddl project and I have some difficulties with the syntax. Right now I am trying to fill an elevator with all the workers in a floor with forall. I am not sure if this is the right implementation but here is my code. Thank you in advance!

(define (domain company)

(:requirements
  :strips                 
  :negative-preconditions 
  :equality               
)

(:predicates
  (worker ?x)
  (floor ?x)
  (elevator ?x)
  (controller ?x)
  (goes ?x )
  (at ?x ?y)  
  (in ?x ?y)
  (free ?x)
  (call ?x ?y)
)

****

(:action insert_elevator
  :parameters (?w ?el ?f)
  :precondition (and (worker ?w) (floor ?f) (elevator ?el) (at ?w ?f) (at ?el ?f) (free ?el))
  :effect (and(not (free ?el))(forall (?w)(in ?w ?el)))
)

****

)



(define (problem pb)
   (:domain company)

   (:objects floorg floor1 floor2
             elevator1
             elevator2
             worker1 worker2
             controller1)

   (:init
     (floor floorg)
     (floor floor1)
     (floor floor2)
     (worker worker1)
     (worker worker2)
     (elevator elevator1)
     (elevator elevator2)
     (controller controller1)
     (at elevator1 floor1)
     (at elevator2 floor2)
     (at worker1 floorg)
     (at worker2 floorg)
     (free elevator1)
     (free elevator2)
   )

   (:goal
     (and(at worker1 floor1)
     (at worker2 floor2))
   )
 )
codeboi
  • 11
  • 4

1 Answers1

1

So apparently you posted over here too...the comments that remain valid:

  • You can use editor.planning.domains and a saved "Session" to share your code much better. (use the read-only link)
  • You really should be using types for a domain like this.
  • The insert_elevator action is messed up a bit:
    • The forall probably needs to contain a conditional effect that suggests "if a worker is on the floor, then they are in the elevator".
    • You shouldn't use the same variable in a forall clause as you have in the parameters.
haz
  • 625
  • 4
  • 12
  • I've changed the forall variable. You can see here https://editor.planning.domains/#read_session=Zf2mJgrqse. But how do I put a conditional effect? Thank you for your response! – codeboi May 14 '20 at 13:57
  • Make sure the scoping is right...`(forall {parameters} (when {condition} {result}) )`. Notice that the `when` clause is entirely inside the `forall` clause. – haz May 15 '20 at 15:00