PDDL语法错误求助:第36行解析失败且oneof未被识别
PDDL规划问题排查与修复方案
问题1:PDDL语法解析错误(第36行)
- 核心错误:PDDL中参数分隔使用空格而非逗号,代码中多处存在逗号误用:
- 谓词定义:
(relative ?x, ?y)需改为(relative ?x ?y) - 动作参数:
(?x ,?s, ?r)需改为(?x ?s ?r)(staging_test和biopsy_test的参数均存在此问题)
- 谓词定义:
- 额外问题:Problem文件中对象未指定类型,
(:objects p )需补充类型声明,示例:(:objects p - person)
问题2:oneof关键字未被识别
- 原因:当前Domain的requirements仅声明了
:strips :typing,而oneof属于非确定性效果,需要添加对应扩展需求。 - 修复:将Domain中的requirements修改为:
ADL扩展包含对非确定性效果(如(:requirements :strips :typing :adl)oneof)的支持,兼容多数现代规划器。
问题3:执行脚本段错误
- 段错误通常是规划器解析存在语法错误的PDDL文件时触发的崩溃,修复上述所有语法错误后,该问题大概率会自动解决。
修正后的domain.pddl
(define (domain cancer_diagnostics) (:requirements :strips :typing :adl) (:constants left_lung_lower_lope left_lung_upper_lope right_lung_upper_lope right_lung_middle_lope right_lung_lower_lope - is_lung_region stage1 stage2 stage3 stage4 - valid_stage ) (:predicates (has_long_standing_cough ?x) (lost_weight ?x) (is_old ?x) (exposure_to_dust ?x) (is_smoker ?x) (had_cancer ?x) (relative ?x ?y) (person ?x) (patient ?x) (is_lung_region ?r) (valid_stage ?s) (cancer_suspicion ?x) (negative_diagnosis ?x) (positive_diagnosis ?x) (cancer-location_in_the_lung ?x ?r) (cancer_stage ?x ?s) (types_of_lung_cancer ?x) (inconclusive ?x) ) (:action clinical_test :parameters (?x) :precondition (and (patient ?x) (has_long_standing_cough ?x) (lost_weight ?x) (is_old ?x) (is_smoker ?x) (exposure_to_dust ?x) (exists (?y) (and (person ?y) (relative ?x ?y) (had_cancer ?y)))) :effect (cancer_suspicion ?x) ) (:action x-ray_test :parameters (?x) :precondition (and (patient ?x) (cancer_suspicion ?x) ) :effect (oneof (positive_diagnosis ?x) (negative_diagnosis ?x) (inconclusive ?x) ) ) (:action imaging_modality :parameters (?x) :precondition (and (inconclusive ?x) (cancer_suspicion ?x) ) :effect (oneof (positive_diagnosis ?x) (negative_diagnosis ?x) ) ) (:action staging_test ;conclusivy diagnosis action-imaging modality :parameters (?x ?s ?r) :precondition (and (patient ?x) ;lung part (positive_diagnosis ?x) (exists (?r) (is_lung_region ?r)) (exists (?s) (valid_stage ?s)) ) :effect (and (cancer-location_in_the_lung ?x ?r) (cancer_stage ?x ?s) ) ) (:action biopsy_test :parameters (?x ?s ?r) :precondition (and (patient ?x) (exists (?r) (is_lung_region ?r)) (exists (?s) (valid_stage ?s)) (cancer-location_in_the_lung ?x ?r) (cancer_stage ?x ?s) ) :effect (types_of_lung_cancer ?x) ) )
修正后的problem.pddl
(define (problem lung_cancer_diagnostics) (:domain cancer_diagnostics) (:objects p - person y - person ) (:init (patient p) (has_long_standing_cough p) (lost_weight p) (is_old p) (is_smoker p) (exposure_to_dust p) (relative p y) (had_cancer y) ) (:goal (cancer_suspicion p) ) )
注:Problem文件的init部分补充了clinical_test动作所需的全部前置条件,否则将无可行规划路径。
内容的提问来源于stack exchange,提问作者Ndinelago
相关产品推荐
相关产品推荐

