0

Hope you all are doing well. I have a problem by solving PDDL domain and problem file. The task is as follows:

Two athletes A0;A1 and trainer T are preparing for a competition in the training setting shown in the figure. They start in P0 and they have to be all in P3 in order to finish a trial. Connections among places are highlighted by two paths: the athlete path (solid) and the trainer path (dotted). A0;A1 can only use the athlete path and they must jump over the first obstacle O0, and then crouch and pass underneath the second O1. T instead, can only walk the trainer path. Agents cannot move simultaneously, only one agent can move at each step from one place Pi to the next place in the path. Moreover, the trainer has to stay one or more steps ahead, to check the performance of the athletes, thus A0 and A1 must never anticipate T (i.e. they are allowed to be only in places already visited by T). Athletes and trainer can be all together in the same location of the training path. For example, if T is in P2 then A0;A1 can be in P0; P1 or P2. The athletes can take steps in arbitrary order (i.e. they can always agree on who makes the next step).

Image of the task

I have implemented both domain and problem files, but it doesn't work as expected in the statement. What am I doing wrong? Any help is appreciated.

The code:

1. Domain

;Header and description

(define (domain competition-domain)
(:requirements :strips )
(:predicates ;todo: define predicates here
  (a1 ?x)(a2 ?x)(t ?x)(o ?x)(location ?x)(at ?x ?y))

;define actions here
(:action goto
    :parameters (?athlete ?from ?to)
    :precondition (and (a1 ?athlete)(a2 ?athlete)(location ?from)(location ?to)(at ?athlete ?from))
    :effect (and(at ?athlete ?to)
             (not(at ?athlete ?from))))

(:action jump
    :parameters (?athlete ?obstacle ?from ?to)
    :precondition (and (a1 ?athlete) (a2 ?athlete) (o ?obstacle)
                    (location ?from) (location ?to) 
                    (at ?athlete ?from))
    :effect (and(at ?athlete ?to)(not(at ?athlete ?from))))

(:action crouch
    :parameters (?athlete ?obstacle ?from ?to)
    :precondition (and (a1 ?athlete) (a2 ?athlete) (o ?obstacle)
                    (location ?from) (location ?to) 
                    (at ?athlete ?from))
    :effect (and(at ?athlete ?to)(not(at ?athlete ?from))))
)

2. Problem

(define (problem competition-problem) (:domain competition-domain)
(:objects A1 A2 T O0 O1 P0 P1 P2 P3
)

(:init
    ;todo: put the initial state's facts and numeric values here
    (a1 A1) (a2 A2) (t T) (location P0) (location P1) (location P2) (location P3)
    (at A1 P0) (at A2 P0) (at T P0) 
)

(:goal (and
    ;todo: put the goal condition here
    (at A1 P3) (at A2 P3) (at T P3)
))

)

Thus, my main problem here is to apply actions and statements for checking the obstacles.

Any kind of help is appreciated.

Nijat Mursali
  • 930
  • 1
  • 8
  • 20

1 Answers1

0

Have you considered using typing rather than just predicates see here

https://planning.wiki/ref/pddl/domain#object-types

I would suggest that you need additional actions, one action for "move trainer" and one action for "move athlete" the precondition of the move athlete action would then be a fact that is added by the move trainer action. That is to say there is a requirement that the trainer is "at" the next location before the athlete

Edit:

(define (domain competition-domain)
(:requirements :strips :typing)
(:types
   person location - object
   athlete trainer - person
   obstacle position - location 
   jump crouch - obstacle
)
(:predicates 
  (at ?p - person ?l - location)
  (jump ?o - obstacle)
  (crouch ?o - obstacle)
  (link ?ls - location ?le - location)
  (trainer-link ?ls - location ?le - location)
)

(:action JUMP
   :parameters (?a - athlete ?p - position ?j - jump)
   :precondition (and
       (at ?a ?p)
       (link ?p ?j)
   )
   :effect (and
       (not (at ?a ?p)
       (at ?a ?j)
   )
)
(:action MOVE-AFTER-JUMP
   :parameters (?a - athlete ?j - jump ?p - position)
   :precondition (and
       (at ?a ?j)
       (link ?j ?p)
   )
   :effect (and
       (not (at ?a ?j)
       (at ?a ?p)
   )
)
..rinse and repeat with trainer and crouch obstacles and move from position to position
)
Adam Green
  • 1
  • 1
  • 1
  • Thank you for your comment, but this is the requirement that I have for writing PDDL. Additionally, for the comments you can reply to the question if it is not the answer to my question. I would appreciate your contribution. – Nijat Mursali Feb 08 '20 at 23:24
  • I am unclear on what you're saying. Are you saying you cannot use typing? The answer to your question is that you need to consider what your plan should end up looking like. For example is traversing the object the only important thing? In that case you only need move when you're not transitioning your Athlete via an object. Otherwise, you need to represent the object as a location itself – Adam Green Feb 09 '20 at 00:06
  • What I tried to say was if your answer is not clear and not the real answer to the question you need to add a comment instead of using answer section. Additionally, I can use :strips for these kind of problems in the requirement part. – Nijat Mursali Feb 09 '20 at 00:20
  • Please, make changes in my code and put it in your answer, so I might accept it as correct answer if it works. – Nijat Mursali Feb 09 '20 at 00:21
  • There is not a single correct answer to this question, because the question doesn't make clear what the correct output of your plan should be, and therefore give a clear idea of what you wish for your domain to model specifically. – Adam Green Feb 09 '20 at 00:52
  • There is a correct answer for sure, but none of us could find it yet here. – Nijat Mursali Feb 09 '20 at 11:41
  • Again, I'll try to reiterate. PDDL is a declarative modelling language and things can be modelled in many ways. Is this an exam question? It feels a lot like an exam question – Adam Green Feb 09 '20 at 17:58