【问题标题】:How do I solve the clips error to construct a rule?如何解决剪辑错误以构建规则?
【发布时间】:2023-04-08 07:01:01
【问题描述】:

我正在使用第一次剪辑来在剪辑中创建基于规则的指南。

(deftemplate personal-data
   (slot name)
   (slot age)
   (slot gender)
   (slot personal_history_breast_cancer)
   (slot previosly_diagnosed_high-risk_breast_lesion)
   (slot genetic_mutation_increase_risk_breast_cancer)
   (slot history_exposure_radiation_chest_childhood)
   (slot life_expectancy)
)

;add the rules

;R1

(defrule average-risk-women-between-40-and-49
   (personal-data (name ?name)
                  (age ?age) 
                  (gender ?gender) 
                  (personal_history_breast_cancer ?personal_history_breast_cancer) 
                  (previosly_diagnosed_high-risk_breast_lesion ?previosly_diagnosed_high-risk_breast_lesion) 
                  (genetic_mutation_increase_risk_breast_cancer ?genetic_mutation_increase_risk_breast_cancer)
                  (history_exposure_radiation_chest_childhood ?history_exposure_radiation_chest_childhood))
   (and (test (>= ?age 40))
        (test (< ?age 49))
        (and (test (eq ?gender female))
        (and (test (eq ?personal_history_breast_cancer no))
        (and (test (eq ?previosly_diagnosed_high-risk_breast_lesion no))
        (and (test (eq ?genetic_mutation_increase_risk_breast_cancer no))
   (and (test (eq ?history_exposure_radiation_chest_childhood no))))))))
   =>
   (printout t ?name " should discuss the benefits and risks of breast cancer screening. [1, p. I‐18]" crlf)
)

;R2

(defrule average-risk-women-between-50-and-74
   (personal-data (name ?name)
                  (age ?age) 
                  (gender ?gender) 
                  (personal_history_breast_cancer ?personal_history_breast_cancer) 
                  (previosly_diagnosed_high-risk_breast_lesion ?previosly_diagnosed_high-risk_breast_lesion) 
                  (genetic_mutation_increase_risk_breast_cancer ?genetic_mutation_increase_risk_breast_cancer)
                  (history_exposure_radiation_chest_childhood ?history_exposure_radiation_chest_childhood))
   (and (test (>= ?age 50))
        (test (< ?age 74))
        (and (test (eq ?gender female))
             (and (test (eq ?personal_history_breast_cancer no))
                  (and (test (eq ?previosly_diagnosed_high-risk_breast_lesion no))
                       (and (test (eq ?genetic_mutation_increase_risk_breast_cancer no))
                            (and (test (eq ?history_exposure_radiation_chest_childhood no))))))))
   =>
   (printout t ?name " should be offered breast cancer screening with a mamogram every 2 years. [1, p. I‐18]" crlf)
)

;R3

(defrule average-risk-women-over-75
   (personal-data (name ?name)
                  (gender ?gender)
                  (age ?age)
                  (personal_history_breast_cancer ?personal_history_breast_cancer)
                  (previosly_diagnosed_high-risk_breast_lesion ?previosly_diagnosed_high-risk_breast_lesion)
                  (genetic_mutation_increase_risk_breast_cancer ?genetic_mutation_increase_risk_breast_cancer)
                  (history_exposure_radiation_chest_childhood ?history_exposure_radiation_chest_childhood)
                  (life_expectancy ?life_expectancy))
   (and (test (eq ?gender female))
        (or (test (>= ?age 75))
            (and (test (eq ?personal_history_breast_cancer no)) 
                 (and (test (eq ?previosly_diagnosed_high-risk_breast_lesion no))
                      (and (test (eq ?genetic_mutation_increase_risk_breast_cancer no)) 
                           (and (test (eq ?history_exposure_radiation_chest_childhood no))
                                (test (<= ?life_expectancy 11))))))))

   => 
   (printout t ?name " should stop screening for breast cancer. [1, p. I‐18]" crlf)
)

; add facts
; Fact1
(assert (personal-data (name "Maria")
                       (age 45)
                       (gender female)
                       (personal_history_breast_cancer no)
                       (previosly_diagnosed_high-risk_breast_lesion no)
                       (genetic_mutation_increase_risk_breast_cancer no)
                       (history_exposure_radiation_chest_childhood no)))

并收到错误: [ARGACCES5] 函数

[DRIVE1] 在加入网络时出现此错误 问题在于关联连接 规则中的模式 #1 平均风险超过 75 岁的女性

我不知道我做错了什么,谁能救我。

【问题讨论】:

    标签: system clips


    【解决方案1】:

    您断言的事实没有为 life_expectancy 指定值,因此使用默认值 nil:

    CLIPS> (ppfact 1)
    (personal-data 
       (name "Maria") 
       (age 45) 
       (gender female) 
       (personal_history_breast_cancer no) 
       (previosly_diagnosed_high-risk_breast_lesion no) 
       (genetic_mutation_increase_risk_breast_cancer no) 
       (history_exposure_radiation_chest_childhood no) 
       (life_expectancy nil))
    CLIPS>
    

    规则 average-risk-women-over-75 使用

    (test (<= ?life_expectancy 11))
    

    您需要在断言事实时提供一个数值;在其 deftemplate 中指定插槽的数字默认值;或修改您的规则以使用 numberp/integerp 函数测试该值是否为数字/整数,以便在该值为非数字时不调用

    【讨论】:

      猜你喜欢
      • 2019-05-05
      • 2021-01-09
      • 1970-01-01
      • 2020-06-06
      • 2018-01-17
      • 2021-03-09
      • 2016-11-02
      • 1970-01-01
      • 2012-05-15
      相关资源
      最近更新 更多