CLIPS-logical条件元素-事实依赖

CLIPS规则引擎示例
本文介绍了一个使用CLIPS规则引擎实现的学生技能和成绩评估示例。通过定义模板和规则来判断学生是否达到优秀标准,即成绩高于90分或技能评价为good,并展示了事实修改后规则引擎的行为变化。

1、logical表示某事实的存在依赖于另一事实或另一组事实的存在,下例查出优秀学生的学号,优秀的标准是成绩>90或技能为good。

2、有时,某事实的存在依赖于2个或多个事实的存在,如下例中的3号学生,在其中一个事实不存在时,某事实仍然存在,只有这2个或多个事实都不存在了,某事实才不存在

3、一旦所依赖的事实不存在,则某事实也相应从事实库中删除。

4、dependents和dependencies 观察事实联系的依赖关系

5、操作

CLIPS (Quicksilver Beta 09/24/07)
CLIPS> (deftemplate student-skill
(slot no)
(slot skill)
)
CLIPS> (deftemplate student-mark
(slot no)
(slot mark)
)
CLIPS> (defrule goodstudentskill
(logical (student-skill (no ?no)(skill?skill))
(test (eq ?skill good)))
=>
(assert (good-student-no ?no))
)
CLIPS> (defrule goodstudentmark
(logical (student-mark (no ?no)(mark ?mark))
(test(> ?mark 90)))
=>
(assert (good-student-no ?no)))

CLIPS> (watch all)
CLIPS> (facts)
f-0(initial-fact)
For a total of 1 fact.
CLIPS> (assert (student-mark (no1)(mark 90))
(student-skill (no 1)(skill good)))
==>f-1(student-mark (no 1) (mark 90))
==>f-2(student-skill (no 1) (skill good))
==> Activation0goodstudentskill: f-2

CLIPS> (assert (student-mark (no2)(mark 95))
(student-skill (no 2)(skill poor)))
==>f-3(student-mark (no 2) (mark 95))
==> Activation0goodstudentmark: f-3
==>f-4(student-skill (no 2) (skill poor))

CLIPS>(assert (student-mark (no 3)(mark 95))
(student-skill (no 3)(skill good)))
==>f-5(student-mark (no 3) (mark 95))
==> Activation0goodstudentmark: f-5
==>f-6(student-skill (no 3) (skill good))
==> Activation0goodstudentskill: f-6

CLIPS> (facts)
f-0(initial-fact)
f-1(student-mark (no 1) (mark 90))
f-2(student-skill (no 1) (skill good))
f-3(student-mark (no 2) (mark 95))
f-4(student-skill (no 2) (skill poor))
f-5(student-mark (no 3) (mark 95))
f-6(student-skill (no 3) (skill good))
For a total of 7 facts.
CLIPS> (run)
FIRE 1goodstudentskill: f-6
==>f-7(good-student-no 3)
FIRE 2goodstudentmark: f-5
FIRE 3goodstudentmark: f-3
==>f-8(good-student-no 2)
FIRE 4goodstudentskill: f-2
==>f-9(good-student-no 1)
<== Focus MAIN
4 rulesfiredRun time is 0.0300000000000296 seconds.
133.333333333202 rules per second.
8 mean number of facts (10 maximum).
1 mean number of instances (1 maximum).
2 mean number of activations (4 maximum).
CLIPS> (facts)
f-0(initial-fact)
f-1(student-mark (no 1) (mark 90))
f-2(student-skill (no 1) (skill good))
f-3(student-mark (no 2) (mark 95))
f-4(student-skill (no 2) (skill poor))
f-5(student-mark (no 3) (mark 95))
f-6(student-skill (no 3) (skill good))
f-7(good-student-no 3)
f-8(good-student-no 2)
f-9(good-student-no 1)
For a total of 10 facts.
CLIPS> (modify 1 (skill poor))

[TMPLTDEF1] Invalid slot skill not defined in correspondingdeftemplate student-mark.
FALSE
CLIPS> (modify 2 (skill poor))
<==f-2(student-skill (no 1) (skill good))
<==f-9(good-student-no 1)
==>f-10(student-skill (no 1) (skill poor))

CLIPS> (refresh goodstudentskill)
==> Activation0goodstudentskill: f-6
CLIPS> (refresh goodstudentmark)
==> Activation0goodstudentmark: f-5
==> Activation0goodstudentmark: f-3
CLIPS> (facts)
f-0(initial-fact)
f-1(student-mark (no 1) (mark 90))
f-3(student-mark (no 2) (mark 95))
f-4(student-skill (no 2) (skill poor))
f-5(student-mark (no 3) (mark 95))
f-6(student-skill (no 3) (skill good))
f-7(good-student-no 3)
f-8(good-student-no 2)
f-10(student-skill (no 1) (skill poor))
For a total of 9 facts.
CLIPS> (modify 6 (skill poor))
<==f-6(student-skill (no 3) (skill good))
<== Activation0goodstudentskill: f-6
==>f-11(student-skill (no 3) (skill poor))

CLIPS> (refresh goodstudentmark)
CLIPS> (refresh goodstudentskill)
CLIPS> (facts)
f-0(initial-fact)
f-1(student-mark (no 1) (mark 90))
f-3(student-mark (no 2) (mark 95))
f-4(student-skill (no 2) (skill poor))
f-5(student-mark (no 3) (mark 95))
f-7(good-student-no 3)
f-8(good-student-no 2)
f-10(student-skill (no 1) (skill poor))
f-11(student-skill (no 3) (skill poor))
For a total of 9 facts.
CLIPS> (modify 5 (mark 80))
<==f-5(student-mark (no 3) (mark 95))
<== Activation0goodstudentmark: f-5
<==f-7(good-student-no 3)
==>f-12(student-mark (no 3) (mark 80))

CLIPS> (refresh goodstudentskill)
CLIPS> (refresh goodstudentmark)
CLIPS> (facts)
f-0(initial-fact)
f-1(student-mark (no 1) (mark 90))
f-3(student-mark (no 2) (mark 95))
f-4(student-skill (no 2) (skill poor))
f-8(good-student-no 2)
f-10(student-skill (no 1) (skill poor))
f-11(student-skill (no 3) (skill poor))
f-12(student-mark (no 3) (mark 80))
For a total of 8 facts.
CLIPS> (dependents 1)
None
CLIPS> (dependents 3)
f-8
CLIPS> (dependencies 3)
None
CLIPS> (dependencies 11)
None
CLIPS> (dependents 12)
None
CLIPS> (dependents 10)
None
CLIPS>

内容概要:本文介绍了一个基于MATLAB实现的无人机三维路径规划项目,采用蚁群算法(ACO)与多层感知机(MLP)相结合的混合模型(ACO-MLP)。该模型通过三维环境离散化建模,利用ACO进行全局路径搜索,并引入MLP对环境特征进行自适应学习与启发因子优化,实现路径的动态调整与多目标优化。项目解决了高维空间建模、动态障碍规避、局部最优陷阱、算法实时性及多目标权衡等关键技术难题,结合并行计算与参数自适应机制,提升了路径规划的智能性、安全性和工程适用性。文中提供了详细的模型架构、核心算法流程及MATLAB代码示例,涵盖空间建模、信息素更新、MLP训练与融合优化等关键步骤。; 适合人群:具备一定MATLAB编程基础,熟悉智能优化算法与神经网络的高校学生、科研人员及从事无人机路径规划相关工作的工程师;适合从事智能无人系统、自动驾驶、机器人导航等领域的研究人员; 使用场景及目标:①应用于复杂三维环境下的无人机路径规划,如城市物流、灾害救援、军事侦察等场景;②实现飞行安全、能耗优化、路径平滑与实时避障等多目标协同优化;③为智能无人系统的自主决策与环境适应能力提供算法支持; 阅读建议:此资源结合理论模型与MATLAB实践,建议读者在理解ACO与MLP基本原理的基础上,结合代码示例进行仿真调试,重点关注ACO-MLP融合机制、多目标优化函数设计及参数自适应策略的实现,以深入掌握混合智能算法在工程中的应用方法。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值