问:PDDL 无法编译问题和域

发布于 2025-01-13 22:08:50 字数 1301 浏览 2 评论 0原文

我不知道为什么它不起作用。这是我的代码:

(define (domain tren_mover)
    (:requirements :adl)
    (:predicates
       (conectado ?x ?y)
       (en ?x ?y)
       (movil ?x)
    )
    (:action mover
        :parameters (?tren ?origen ?destino)
        :precondition 
        (and 
          (movil ?tren)
          (en ?origen ?destino)
          (conectado ?origen ?destino)
        )
        :effect 
        (and 
           (en ?tren ?destino)
           (not (en ?tren ?origen))
        )
    )
)

问题

(define (problem tren_en_movimiento)
    (:domain tren_mover)
    (:objects
        T - tren
        F1- Fábrica1
        F2 - Fábrica2
        A - almacén
        P - puerto
    )
    (:init
        (en puerto tren)
        (mover tren)
        (conectado A P)
        (conectado P F2)
        (conectado F2 F1)
        (conectado F1 A)
        (conectado A F1)
        (conectado F1 F2)
        (conectado F2 P)
        (conectado P A)
    )
    (:goal (and
                (en F1 T)
           )
    )

)

出现的错误消息是:

Failed to parse the problem -- invalid syntax (, line 37)

/tmp/solver_planning_domains_tmp_4C4oEmiiY8B3Q/domain.pddl:
syntax error in line 16, '':
domain definition expected

I don't know why it doesn't work. here is my code:

Domain

(define (domain tren_mover)
    (:requirements :adl)
    (:predicates
       (conectado ?x ?y)
       (en ?x ?y)
       (movil ?x)
    )
    (:action mover
        :parameters (?tren ?origen ?destino)
        :precondition 
        (and 
          (movil ?tren)
          (en ?origen ?destino)
          (conectado ?origen ?destino)
        )
        :effect 
        (and 
           (en ?tren ?destino)
           (not (en ?tren ?origen))
        )
    )
)

Problem

(define (problem tren_en_movimiento)
    (:domain tren_mover)
    (:objects
        T - tren
        F1- Fábrica1
        F2 - Fábrica2
        A - almacén
        P - puerto
    )
    (:init
        (en puerto tren)
        (mover tren)
        (conectado A P)
        (conectado P F2)
        (conectado F2 F1)
        (conectado F1 A)
        (conectado A F1)
        (conectado F1 F2)
        (conectado F2 P)
        (conectado P A)
    )
    (:goal (and
                (en F1 T)
           )
    )

)

The Error message that appears is:

Failed to parse the problem -- invalid syntax (, line 37)

/tmp/solver_planning_domains_tmp_4C4oEmiiY8B3Q/domain.pddl:
syntax error in line 16, '':
domain definition expected

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妳是的陽光 2025-01-20 22:08:50

您的代码中有几个逻辑和语法错误:

逻辑

(en ?origen ?destino) 你怎么能把两个位置放在同一个地方!应该是 tren 必须处于原点位置。

句法

  1. 问题中的对象,你必须理解类型对象之间的区别,你在混合它们!
  2. 初始状态存在拼写错误,您使用的是 mover 而不是 movil
  3. goal 中,您使用的是不需要的 and() ,而且会导致错误,因为您没有两个谓词可以组合!

(define (domain tren_mover)
    (:requirements :adl)
    (:predicates
       (conectado ?x ?y)
       (en ?x ?y)
       (movil ?x)
    )
    (:action mover
        :parameters (?tren ?origen ?destino)
        :precondition 
        (and 
          (movil ?tren)
          (en ?tren ?origen)
          (conectado ?origen ?destino)
        )
        :effect 
        (and 
           (en ?tren ?destino)
           (not (en ?tren ?origen))
        )
    )
)

问题

(define (problem tren_en_movimiento)
    (:domain tren_mover)
    (:objects tren Fabrica1 Fabrica2 almacen puerto)
    (:init
        (en tren puerto)
        (movil tren)
        (conectado almacen puerto)
        (conectado puerto Fabrica2)
        (conectado Fabrica2 Fabrica1)
        (conectado Fabrica1 almacen)
        (conectado almacen Fabrica1)
        (conectado Fabrica1 Fabrica2)
        (conectado Fabrica2 puerto)
        (conectado puerto almacen)
    )
    (:goal
        (en tren Fabrica1)
    )

)

解决方案测试

There are several logical and syntactical mistakes in your code:

Logical

(en ?origen ?destino) how can you put two positions in the same place! it should be the tren who has to be in the origin position.

Syntactical

  1. The objects in the problem, you have to understand the difference between types and objects, you are mixing between them!
  2. There is a typo in the initial state, you are using mover instead of movil.
  3. in the goal, you are using and() which is not needed, and moreover causes an error as you don't have two predicates to combine!

Domain

(define (domain tren_mover)
    (:requirements :adl)
    (:predicates
       (conectado ?x ?y)
       (en ?x ?y)
       (movil ?x)
    )
    (:action mover
        :parameters (?tren ?origen ?destino)
        :precondition 
        (and 
          (movil ?tren)
          (en ?tren ?origen)
          (conectado ?origen ?destino)
        )
        :effect 
        (and 
           (en ?tren ?destino)
           (not (en ?tren ?origen))
        )
    )
)

Problem

(define (problem tren_en_movimiento)
    (:domain tren_mover)
    (:objects tren Fabrica1 Fabrica2 almacen puerto)
    (:init
        (en tren puerto)
        (movil tren)
        (conectado almacen puerto)
        (conectado puerto Fabrica2)
        (conectado Fabrica2 Fabrica1)
        (conectado Fabrica1 almacen)
        (conectado almacen Fabrica1)
        (conectado Fabrica1 Fabrica2)
        (conectado Fabrica2 puerto)
        (conectado puerto almacen)
    )
    (:goal
        (en tren Fabrica1)
    )

)

Solution Test

黎夕旧梦 2025-01-20 22:08:50

我认为您应该考虑包含要求 :typing 对谓词和操作中使用的参数进行分类。由于此错误,问题文件中的 :objects 无法正确解析。

请参考此链接:https://planning.wiki/ref/pddl/requirements#typing< /a>
并尝试纠正错误。

另外,您可以使用可用于 PDDL 的 VS Code 插件来避免语法错误并解决计划。可以在这里找到:https://marketplace.visualstudio.com/items? itemName=jan-dolejsi.pddl

致以诚挚的问候!

I think you should consider including the requirement :typing to categorize the parameters used in predicates and actions. Due to this error, the :objects in the problem file can't be parsed correctly.

Please refer to this link: https://planning.wiki/ref/pddl/requirements#typing
and try to rectify errors.

Also, You can use VS Code plugin available for PDDL to avoid syntax errors and solve the plan. It can be found here: https://marketplace.visualstudio.com/items?itemName=jan-dolejsi.pddl

Best Regards!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文