lisp实现的专家系统
2009-11-02 02:50
253 查看
专家系统实现室温调节,用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))
)
运行结果“
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实现SICP约束系统
- 人工智能专家系统的简单实现
- 基于深度学习神经网络等机器学习技术实现一个医学辅助诊断的专家系统原型
- 人工智能专家系统的简单实现
- python实现明星专家系统 推荐
- Prolog实现太阳系星体识别专家系统
- 用Python3实现的Mycin专家系统简单实例
- Linux 服务器集群系统实现方案详解
- 基于关系数据库系统链式存储的树型结构数据,求某结点下的子树所有结点算法(t-sql语言实现)
- 【转帖】BPM系统实现:需要首先调整流程吗?
- VB.NET下用FSO(文件系统对象模型)实现获取硬盘信息
- 使用RecoverySystem.installPackage实现 android卡刷系统
- 活动目录ADSI实现添加系统帐号问题!!!
- 四种方法实现VC枚举系统当前进程
- 不到100行代码实现一个简单的推荐系统
- C# window Service实现调用有UI的应用程序(关于win xp以后的window系统)
- Android系统中长按事件的实现机制解析
- 美化js系统函数alert,confirm,prompt,并实现lightbox效果