lisp实现的专家系统

专家系统实现室温调节,用lisp实现

In this report I am going to explore an expert system. The goal of the expert system is to produce a solution to the problem of thermostat setting based on input data. The input data is established by asking questions to users. The questions may be something like “what month is it?” or “what day is it?” or “what time of a day is it?” According to information that user supplied, the expert system is able to recommend proper temperature as following:

Thermostat setting is ’20 degrees’

Thermostat setting is ’15 degrees’

Thermostat setting is ’24 degrees’

Thermostat setting is ’27 degrees s’

Thermostat setting is ’20 degrees’

Thermostat setting is ’16 degrees’

Thermostat setting is ’18 degrees’

Thermostat setting is ’14 degrees’

 

 代码如下:

(defcontext 'tempratureadjusting

 '(

   (month

        (jan feb mar apr may jun jul aug sep oct nov dec)

        ("what is the month"

         "jan feb mar apr may jun jul aug sep oct nov dec "

         )

   )

 

   (season (Summer autumn winter spring)

        ("what is the Season"

         "like Summer autumn winter spring"

         )

    )

   (Day (sat sun mon tue wed thu fri)

        ("what the day of week"

         "sat sun mon tue wed thu fri"

         )

   )

   (today (workday weekend)

        ("what type of day today"

         " workday weekend "

         )

   )

 (setting   string )

 

   (time (9-5 before-9 After-5)

        ("what is the time"

         "9-5 before-9 after-5")

    )

 

 

(operation (working-time spare-time

)

        ("Enter operation "

         " working-time spare-time")

    )

)

'(month)

'(setting)

)

 

----------------------------------------------------------------------------------------------------

 

(defrules

 

(rule01 ($or  (same cntxt Day mon)

              (same cntxt Day tue)

              (same cntxt Day wed)

              (same cntxt Day thu)

           (same cntxt Day fri)

        )

      (conclude cntxt today workday tally 1000))

 

 

 

(rule02 ($or (same cntxt Day sat)

                 (same cntxt Day sun)

        )

      (conclude cntxt today weekend tally 1000))

 

 

(rule03 ($and (same cntxt today workday)

                 (same cntxt time 9-5)

        )

      (conclude cntxt operation working-time tally 1000))

 

(rule04 ($and (same cntxt today workday)

                 (same cntxt time before-9)

        )

      (conclude cntxt operation spare-time tally 1000))

(rule05 ($and (same cntxt today workday)

                 (same cntxt time after-5)

        )

      (conclude cntxt operation spare-time tally 400))

 

(rule06 ($and (same cntxt today weekend)

        )

      (conclude cntxt operation spare-time tally 400))

 

(rule07 ($or (same cntxt month jan)

             (same cntxt month feb)

             (same cntxt month dec)

        )

      (conclude cntxt season summer tally 400))

 

(rule08 ($or (same cntxt month mar)

             (same cntxt month apr)

             (same cntxt month may)

        )

      (conclude cntxt season autumn tally 400))

 

(rule09 ($or (same cntxt month jun)

             (same cntxt month jul)

             (same cntxt month aug)

        )

      (conclude cntxt season winter tally 400))

 

 

(rule10 ($or (same cntxt month sep)

             (same cntxt month oct)

             (same cntxt month nov)

        )

      (conclude cntxt season spring tally 400))

 

(rule11 ($and (same cntxt season spring)

             (same cntxt operation working-time)

                     )

      (conclude cntxt setting  "it-is-set-to-20-degrees" tally 1000))

 

(rule12 ($and (same cntxt season spring)

             (same cntxt operation spare-time)

                     )

      (conclude cntxt setting  "it-is-set-to-15-degrees" tally 1000))

 

(rule13 ($and (same cntxt season summer)

             (same cntxt operation working-time)

                     )

      (conclude cntxt setting  "it-is-set-to-24-degrees" tally 1000))

 

(rule14 ($and (same cntxt season summer)

             (same cntxt operation spare-time)

                     )

      (conclude cntxt setting  "it-is-set-to-27-degrees" tally 1000))

 

(rule15 ($and (same cntxt season autumn)

             (same cntxt operation working-time)

                     )

      (conclude cntxt setting  "it-is-set-to-20-degrees" tally 1000))

 

(rule16 ($and (same cntxt season autumn)

             (same cntxt operation spare-time)

                     )

      (conclude cntxt setting  "it-is-set-to-16-degrees" tally 1000))

 

 

 

 

(rule17 ($and (same cntxt season winter)

             (same cntxt operation working-time)

                     )

      (conclude cntxt setting  "it-is-set-to-18-degrees" tally 1000))

(rule18 ($and (same cntxt season winter)

             (same cntxt operation spare-time)

                     )

      (conclude cntxt setting "it-is-set-to-14-degrees" tally 1000))

 

 

)

运行结果“

 

人工智能课程上的实验 分别使用lisp语言和prolog语言实现了一个专家系统 并且有详细的实验报告 附带画的二级推理树 (1) 领域背景简介 为了更好地阐明专家系统的基本工作原理 ,我们用 PROLOG语言实现一个简单的动物识别专家系统。该系统可以识别老虎、金钱豹、斑马、长颈鹿、鸵鸟、企鹅、信天翁这 7 种动物。 (2) 求解问题的范围(如植物分类涉及哪些大类,哪些子类) 首先 ,将动物粗略地分为哺乳动物、鸟、肉食动物 3 大类 ,然后逐步缩小分类范围,再将动物分为老虎、金钱豹、斑马、长颈鹿、鸵鸟、企鹅、信天翁 在知识库中 ,并非简单地给每一种动物一条规则。首先 ,将动物粗略地分为哺乳动物、鸟、肉食动物 3 大类 , 然后逐步缩小分类范围 ,最后给出识别 7 种动物的规则。如图给出了识别长颈鹿和斑马的推理网络。 (1) 规则的前提和结论的表示方法 在本系统当中 ,知识库中的知识用产生式规则来表示。本系统能够识别 7 种动物 ,知识库中共有以下 15 条 规则。 R1 IF 该动物有毛发 THEN 该动物是哺乳动物 R2 IF 该动物有奶 THEN 该动物是哺乳动物 R3 IF 该动物有羽毛 THEN 该动物是鸟 R4 IF 该动物会飞 AND 会下蛋 THEN 该动物是鸟 (2) 规则的结论为中间结论时,规则的格式 R5 IF 该动物吃肉 THEN 该动物是肉食动物 R6 IF 该动物有犬齿 AND 有爪 AND 眼盯前方 THEN 该动物是肉食动物 R7 IF 该动物是哺乳动物 AND 有蹄 THEN 该动物是有蹄类动物 R8 IF 该动物是哺乳动物 AND 是嚼反刍动物 THEN 该动物是有蹄类动物 (3) 规则的结论为最终结论时,规则的格式 R9 IF 该动物是哺乳动物 AND 是肉食动物 AND 是黄褐色们 AND 身上有暗斑点 THEN 该动物是金钱豹 R10 IF 该动物是哺乳动物 AND 是肉食动物 AND 是黄褐色 AND 身上有黑色条纹 THEN 该动物是虎 R11 IF 该动物是有蹄类动物 AND 有长脖子 AND 有长腿 AND 身上有暗斑点 THEN 该动物是长颈鹿 R12 IF 该动物是有蹄类动物 AND 身上有黑色条纹 THEN 该动物是斑马 R13 IF 该动物是鸟 AND 有长脖子 AND 有长腿 AND 不会飞 THEN 该动物是鸵鸟 R14 IF 该动物是鸟 AND 会游泳 AND 不会飞 AND 有黑白二色 THEN 该动物是企鹅 R15 IF 该动物是鸟 AND 善飞 THEN 该动物是信天翁
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值