PDDL错误编译



我是PDDL的新手,我一直在尝试一个blocksworld问题,但我遇到了错误:

未能解析问题 - 不是ARGS必须是一个只有一个元素的列表,获得[primitive sobre(default_object?obj,default_object?obj2),primitive libre(default_object?obj3),primitive en(demault_object?obj,obj,obj,obj,obj ,,default_object?来自)] /TMP/solver_planning_domains_tmp_4bmszdp37zjxs/domain.pddl:第16行中的语法错误 域定义预期

我的文件是这些:

(define (domain blocly)
   (:predicates (espacio ?e)  
        (ficha ?t)  
        (sobre ?t ?t)  
        (en ?t ?e)  
        (vacio ?e)  
        (libre ?t))  

    (:action movefichaficha
       :parameters (?ficha ?ficha2 ?ficha3 ?from ?to)
       :precondition (and  (ficha ?ficha) (ficha ?ficha2) (ficha ?ficha3) (espacio ?from) (espacio ?to)
                     (sobre ?ficha ?ficha2) (libre ?ficha) (libre ?ficha3) (en ?ficha ?from) (en ?ficha2 ?from) 
                     (en ?ficha3 ?to))
       :effect (and (sobre ?ficha ?ficha3) (en ?ficha ?to) (libre ?ficha2)
               (not (sobre ?ficha ?ficha2) (libre ?ficha3) (en ?ficha ?from)))) 
    (:action movefichaesp
       :parameters (?ficha ?ficha2 ?from ?to)
       :precondition (and  (ficha ?ficha) (ficha ?ficha2) (espacio ?from) (espacio ?to)
                     (sobre ?ficha ?ficha2) (vacio ?to) (en ?ficha ?from) (en ?ficha2 ?from))
       :effect (and  (libre ?ficha2) (en ?ficha ?to) (arriba ?ficha ?to)
               (not (vacio ?to) (en ?ficha ?from) (sobre ?ficha ?ficha2))))
    (:action moveoespficha
       :parameters  (?ficha ?ficha2 ?from ?to)
       :precondition (and  (ficha ?ficha) (ficha ?ficha2) (espacio ?from) (espacio ?to)
                     (libre ?ficha) (libre ?ficha2) (en ?ficha ?from) (en ?ficha ?to) ())
       :effect (and  (vacio ?from) (en ?ficha ?to) (sobre ?ficha ?ficha2)
             (not (libre ?ficha2) (en ?ficha ?from) (en ?ficha ?from)))))

和这些:

(define (problem blockly-world)  
   (:domain blocly)  
   (:objects t1 t2 t3 e1 e2 e3)  
   (:init (ficha t1)   
          (ficha t2)  
          (ficha t3)  
          (espacio e1)  
          (espacio e2)  
          (espacio e3)  
          (sobre t3 t2)  
          (sobre t2 t1)  
          (en t1 e1)  
          (en t2 e1)  
          (en t3 e1)  
          (libre t3)  
          (vacio e2)  
          (vacio e3))  
   (:goal (and (sobre t1 t2)  
               (sobre t2 t3)))  

源代码中有许多问题。

  • 问题文件缺少最终)

  • UNARY not逻辑操作员使用不当,例如

    (not (vacio ?to) (en ?ficha ?from) (sobre ?ficha ?ficha2))
    

    应重写为

    (not (vacio ?to))
    (not (en ?ficha ?from))
    (not (sobre ?ficha ?ficha2))
    
  • 域文件使用 undeclared predicate, arriba。由于它具有en的相同定义 - 并且在(:init ...)块中未提及它,因此我不确定这是否是由于将arriba重命名为en而忘记更改其最后一次发生的一个错字。以防万一这不是错误,您可以通过添加

    来修复它
     (arriba ?t ?e)
    

    到谓词列表。您应该检查自己是否需要在问题文件中的 (:init ...)块中添加一些东西


下面,您可以找到源代码的适当缩进的版本,并在前两个确定的问题上进行了足够的修复,并尝试解决第三个问题:

Blocky-prob.pddl:

(define (problem blockly-world)  
    (:domain blocly)  
    (:objects t1 t2 t3 e1 e2 e3)  
    (:init
          (ficha t1)   
          (ficha t2)  
          (ficha t3)  
          (espacio e1)  
          (espacio e2)  
          (espacio e3)  
          (sobre t3 t2)  
          (sobre t2 t1)  
          (en t1 e1)  
          (en t2 e1)  
          (en t3 e1)  
          (libre t3)  
          (vacio e2)  
          (vacio e3)
    )  
   (:goal (and
              (sobre t1 t2)
              (sobre t2 t3)
          )
   )
) 

block-domain.pddl:

(define (domain blocly)
    (:predicates
        (espacio ?e)  
        (ficha ?t)  
        (sobre ?t ?t)  
        (en ?t ?e)
        (arriba ?t ?e)
        (vacio ?e)  
        (libre ?t)
    )  
    (:action movefichaficha
        :parameters (?ficha ?ficha2 ?ficha3 ?from ?to)
        :precondition
            (and
                (ficha ?ficha)
                (ficha ?ficha2)
                (ficha ?ficha3)
                (espacio ?from)
                (espacio ?to)
                (sobre ?ficha ?ficha2)
                (libre ?ficha)
                (libre ?ficha3)
                (en ?ficha ?from)
                (en ?ficha2 ?from) 
                (en ?ficha3 ?to)
            )
        :effect
            (and
                (sobre ?ficha ?ficha3)
                (en ?ficha ?to)
                (libre ?ficha2)
                (not (sobre ?ficha ?ficha2))
                (not (libre ?ficha3))
                (not (en ?ficha ?from))
            )
    )
    (:action movefichaesp
        :parameters (?ficha ?ficha2 ?from ?to)
        :precondition
            (and
                (ficha ?ficha)
                (ficha ?ficha2)
                (espacio ?from)
                (espacio ?to)
                (sobre ?ficha ?ficha2)
                (vacio ?to)
                (en ?ficha ?from)
                (en ?ficha2 ?from)
            )
        :effect
            (and
                (libre ?ficha2)
                (en ?ficha ?to)
                (arriba ?ficha ?to)
                (not (vacio ?to))
                (not (en ?ficha ?from))
                (not (sobre ?ficha ?ficha2))
            )
    )
    (:action moveoespficha
        :parameters  (?ficha ?ficha2 ?from ?to)
        :precondition
            (and
                (ficha ?ficha)
                (ficha ?ficha2)
                (espacio ?from)
                (espacio ?to)
                (libre ?ficha)
                (libre ?ficha2)
                (en ?ficha ?from)
                (en ?ficha ?to) 
            )
        :effect
            (and
                (vacio ?from)
                (en ?ficha ?to)
                (sobre ?ficha ?ficha2)
                (not (libre ?ficha2))
                (not (en ?ficha ?from))
                (not (en ?ficha ?from))
            )
    )
)

我的计算机上的 pddl solver fast-downward.py 在我的计算机上正确解析了代码 ,这也可以找到解决方案。由于我不知道您要建模什么,因此我无法验证它是否与您要建模的内容相匹配。


注意:即使您只是出于个人原因学习,也要考虑习惯于为谓词,对象和变量使用英语。此外,请考虑缩进源代码并正确描述您要处理的情况的双重好处是吸引您的问题和良好的问题。

最新更新