如何模糊一个脆弱的变量

How to fuzify a crispy variable

我阅读了一些有关如何在 FuzzyClips 中模糊化变量的示例。我自己尝试过,但出现了一些奇怪的行为:

(deftemplate age-template
0 100 years ; Universe
(
(young (15 0.75) (17 1) (19 1)) 
(mature (18 0.75) (25 1) (30 0.25)) 
(adult (30 0.5) (40 1) (50 0.75)) 
(old (40 0.25) (50 0.75) (65 1) )
)
)

(deftemplate person

(slot name (type STRING))
(slot age (type INTEGER))
(slot city (type STRING))
)

(deffacts start
(person (name "John") (age 25) (city "London"))
(person (name "Mike") (age 55) (city "London"))
(person (name "Eva") (age 35) (city "London"))
)


(defrule fuzzify
    (person (name ?name) (age ?age))
=>
    (assert(age-template (?age 0.0) (?age 1.0) (?age 0.0))) 
)

我不知道那些“???”到底是什么?真正的意思以及为什么每个事实在被断言后都被撤回。我还有一个疑问,我尝试不仅打印年龄,还打印每个人的姓名和年龄:

(defrule fuzzify
    (person (name ?name)(age ?age))
=>
    (assert (person-is ?name age-template (?age 0.0) (?age 1.0) (?age 0.0)))    
)

但我收到错误 "a function name must be a symbol"。

所以我解决了。我读到那个了???是一种常见的行为。所以解决方案是: 创建另一个 detemplate,它将是人名及其模糊年龄的结构。在规则的后面,实例化 deftemplate 断言某人的名字模糊年龄。

(deftemplate age-template
0 100 years ; Universe
(
(young (15 0.75) (17 1) (19 1)) 
(mature (18 0.75) (25 1) (30 0.25)) 
(adult (30 0.5) (40 1) (50 0.75)) 
(old (40 0.25) (50 0.75) (65 1) )
 )
 )

 (deftemplate person

 (slot name (type STRING))
 (slot age (type INTEGER))
 (slot city (type STRING))
 )

 (deftemplate fuzzyfication
 (slot nameperson (type STRING))
 (slot agefuzzy (type FUZZY-VALUE age-template))
 )

  (deffacts start
 (person (name "John") (age 25) (city "London"))
 (person (name "Mike") (age 55) (city "London"))
 (person (name "Eva") (age 35) (city "London"))
 )


 (defrule fuzzify
 (person (name ?name) (age ?age))
 =>
 (assert(fuzzyfication (nameperson ?name)(agefuzzy (?age 0.0) (?age 1.0) (?age 0.0)))) 
  )

并执行returns: