【问题标题】:Clips Expert System剪辑专家系统
【发布时间】:2020-11-04 01:27:53
【问题描述】:

我正在尝试创建一个专家系统来决定您是否可以买房。我想知道如何表述允许人们在超过一定年龄时购买房屋的规则。例如,如果您输入您已超过 40 岁,系统会返回并告诉您不允许购买房屋。 我在下面尝试过这段代码,但它不起作用

(defrule age-over-forty
    (student yes)
    (income low)
    (credit excellent)
    (age 40>)
    =>
    (printout t "You can not buy a house" crlf))

编辑:我所说的“它不起作用”是什么意思;当我运行它时,你输入一个年龄,假设我输入了 46。它会将它添加到事实中,但它应该打印出“你不能买房子”,所以它不满足(年龄40>) 部分代码。

【问题讨论】:

  • “它不起作用”是什么意思?相反会发生什么?你有什么努力让它发挥作用?
  • @NicoHaase 当我运行它时,你输入一个年龄,假设我输入了 46。它会将它添加到事实中,但它应该打印出“你不能买房子" 所以它不满足代码的 (age 40>) 部分。
  • 请通过编辑为您的问题添加所有说明
  • @NicoHaase 完成

标签: clips


【解决方案1】:

使用谓词约束(CLIPS 6.3 Basic Programming Guide 的第 5.4.1.5 节)或测试条件元素来执行数字比较。

         CLIPS (6.31 6/12/19)
CLIPS> 
(defrule age-over-forty
   (student yes)
   (income low)
   (credit excellent)
   (age ?age&:(> ?age 40))
   =>
   (printout t "You can not buy a house" crlf))
CLIPS> 
(assert (student yes)
        (income low)
        (credit excellent)
        (age 46))
<Fact-4>
CLIPS> (agenda)
0      age-over-forty: f-1,f-2,f-3,f-4
For a total of 1 activation.
CLIPS> (run)
You can not buy a house
CLIPS> 

【讨论】:

    猜你喜欢
    • 2018-03-05
    • 1970-01-01
    • 2010-09-15
    • 2011-12-22
    • 2010-09-27
    • 2013-05-05
    • 2017-07-08
    • 2012-05-01
    • 2011-01-02
    相关资源
    最近更新 更多