You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

水下探索PDDL领域与问题求解的语法错误排查请求

PDDL问题排查与解决

一、语法错误修复(对应报错:line25的语法错误)

1. 谓词参数类型不匹配

Domain中at谓词定义为(at ?s - sub ?l - location),仅接受**潜艇(sub)**作为第一个参数,但Problem的:init中出现了(at cw1 l1)——cw1是command-centre(属于location类型),违反了参数类型约束。

解决方式:

  • 若要表达“指挥中心位于l1”,需在Domain中新增谓词:

    (:predicates
      // 原有谓词保留
      (located ?loc - location ?parent - location)  // 新增:描述位置间的从属关系
    )
    

    然后将Problem中的(at cw1 l1)替换为(located cw1 l1)。

  • 若需让at谓词支持任意位置,修改Domain中的at谓词定义:

    (at ?obj - object ?l - location)  // 将第一个参数类型改为object,覆盖sub和location
    

2. 缺少ADL需求支持

Problem的:goal中使用了forall和when,这是ADL(Action Description Language)的特性,但Domain的:requirements仅声明了:strips :typing,Strips不支持这类量化目标,导致解析错误。

解决方式:
在Domain的:requirements中添加:adl:

(:requirements :strips :typing :adl)

二、超时问题修复

超时通常因规划器无法处理无效状态或目标逻辑问题,结合当前场景:

1. 初始状态与移动规则冲突

初始状态中潜艇s1位于cw1(指挥中心),但move动作要求起始位置必须是浅/深水区,若未明确cw1的水域类型,潜艇无法出发移动,导致规划器陷入无效搜索。

解决方式:
在Problem的:init中添加cw1的水域类型声明,例如:

(shallow-water cw1)  // 声明指挥中心属于浅水区,允许潜艇从这里出发

2. 目标逻辑优化

当前目标使用forall遍历所有潜艇、飞行员和位置,逻辑过于宽泛,增加了规划器的计算量。可简化为明确的目标:

(:goal
  (and
    (onboard p1 s1)
    (or (at s1 sw1) (at s1 dw1))
  )
)

直接指定当前唯一潜艇s1搭载飞行员p1时处于浅/深水区,减少规划器的搜索范围。

修正后的完整代码

修正后的Domain

(define (domain underwater-exploration)
  (:requirements :strips :typing :adl)
  
  (:types
    location - object
    sub personnel - object
    scientist engineer pilot - personnel
    land shallow-water deep-water command-centre - location
  )

  (:predicates
    (at ?s - sub ?l - location)
    (onboard ?p - personnel ?s - sub)
    (shallow-water ?l - location)
    (deep-water ?l - location)
    (land ?l - location)
    (command-centre ?l - location)
    (located ?loc - location ?parent - location)  // 新增谓词
  )

  (:action move
    :parameters (?s - sub ?from - location ?to - location ?p - pilot)
    :precondition (and
      (at ?s ?from)
      (onboard ?p ?s)
      (or (and (shallow-water ?from) (shallow-water ?to))
          (and (deep-water ?from) (deep-water ?to))
      )
    )
    :effect (and
      (not (at ?s ?from))
      (at ?s ?to)
    )
  )
)

修正后的Problem

(define (problem carry-construction-kit)
  (:domain underwater-exploration)
  
  (:objects
    s1 - sub
    p1 - pilot
    cw1 - command-centre
    sw1 - shallow-water
    dw1 - deep-water
    l1 l2 l3 - location
  )

  (:init
    (at s1 cw1)
    (onboard p1 s1)
    (located cw1 l1)  // 替换原错误的(at cw1 l1)
    (shallow-water sw1)
    (deep-water dw1)
    (shallow-water cw1)  // 声明指挥中心属于浅水区
    (land l2)
    (command-centre l3)
  )

  (:goal
    (and
      (onboard p1 s1)
      (or (at s1 sw1) (at s1 dw1))
    )
  )
)

内容的提问来源于stack exchange,提问作者uknow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 04:44:52