如何在 fuzzyclips 中模糊化?

how to fuzzify in fuzzyclips?

我想写一个项目获取卡路里的精确值来计算当时部分的精确值(体重增加了多少?)。这是我的规则:

if calorie is high then increase weight

为此我准备了这套卡路里:

(highCalorie (20 0)(40 .2) (60 .5) (100 .8) (180 1))

另一方面,为了增加重量的价值,我有这套:

 (increase(50 0) (100 .4) (120 .8) (150 1))

换句话说,我想映射一个卡路里值来增加体重。 为此,我编写了这段代码:

(deftemplate calories
   20 180 
   (high(20 0)(40 .2) (60 .5) (100 .8) (180 1))
)
(deftemplate fat
   50 150 
   (increase(50 0) (100 .4) (120 .8) (150 1))
)

; We first get a precise value for calorie and fuzzify it.

(defrule getCalorie
   (declare (salience 100))
   =>
   (printout t "Enter calorie: ")
   (bind ?t (read))
   (assert (calorie ?t))
)

(defrule fuzzifyCalorie
   (calorie ?t)
   =>
   (assert (calories (?t 0) (?t .2) (?t .5)(?t .8)(?t 1))))

; Here we add rules to prescribe amounts of increased weight

(defrule result
    (declare (salience -1))
   (calories high)
   =>
   (assert (fat increase)))

(defrule ShowPenicillin
   (declare (salience -100))
   ?f <- (fat ?p)
   =>
   (printout t "for this colrie" (moment-defuzzify ?f) " grams of fat increased to weight" crlf))

我的错误是什么?

非常感谢。

您的 deftemplates 缺少括号。更正后的代码是

(deftemplate calories
   20 180 
   ((high (20 0)
          (40 .2) 
          (60 .5) 
          (100 .8) 
          (180 1))))

(deftemplate fat
   50 150 
   ((increase (50 0) 
              (100 .4) 
              (120 .8) 
              (150 1))))