首页 > 分享 > 基于MATLAB产生式系统(植物识别系统)

基于MATLAB产生式系统(植物识别系统)

1. 实验报告应包括:实验目的
熟悉一阶谓词逻辑和产生式表示法,掌握产生式系统的运行机制,以及基于规则推理的基本方法。
2. 实验内容
运用所学知识,设计并编程实现一个小型人工智能系统(如分类、诊断、预测等类型)。
3. 实验原理
(1)一个产生式系统由三个部分组成
1)综合数据库:用来存放与求解问题有关的数据以及推理过程环境的当前状态的描述。
2)产生式规则库:主要存放问题求解中的规则。
3)控制策略:其作用是说明下一步应该选用什么规则,也就是说如何应用规则。
三个部分如图所示:
在这里插入图片描述

(2)产生式系统的实现有三种方法
1)正向推理:从一组表示事实的谓词或命题出发,使用一组产生式规则,用以证明该谓词公式或命题是否成立。
2)逆向推理:从表示目标的谓词或命题出发,使用一组产生式规则证明事实谓词或命题成立,即首先提出一批假设目标,然后逐一验证这些假设。
3)双向推理:双向推理的推理策略是同时从目标向事实推理和从事实向目标推理,并在推理过程中的某个步骤,实现事实与目标的匹配。
4. 实验器材
····计算机
5. 实验步骤
基于如图1所示的产生式系统实验程序,设计并实现一个小型人工智能系统:
1)系统设置,包括设置系统名称和系统谓词,给出谓词名及其含义。
2)编辑知识库,通过输入规则或修改规则等,完成整个规则库的建立。
3)建立事实库(综合数据库),输入多条事实或结论。
4)运行推理,包括正向推理和反向推理,给出相应的推理过程、事实区和规则区。
6.代码
shengchanshi.m

%生产式系统 %要求部分 % R1:种子有果皮 -> 被子植物 % R2:种子无果皮 -> 裸子植物 % R3:无茎叶 & 无根 -> 藻类植物 % R4:被子植物 & 有托叶 -> 蔷薇科 % R5:被子植物 & 吸引菜粉蝶 -> 十字花科 % R6:被子植物 & 十字形花冠 -> 十字花科 % R7:被子植物 & 缺水环境 -> 仙人掌科 % R8:被子植物 & 蔷薇科 & 有刺 -> 玫瑰 % R9:被子植物 & 水生 & 可食用 & 结果实 -> 荷花 % R10:被子植物 & 仙人掌科 & 喜阳 & 有刺 -> 仙人球 % R11:藻类植物 & 水生 & 药用 -> 水棉 % R12:被子植物 & 蔷薇科 & 木本 & 可食用 & 结果实 -> 苹果树 % R13:被子植物 & 十字花科 & 黄色花 & 可食用 & 结果实 -> 油菜 % R14:藻类植物 & 水生 & 可食用 & 有白色粉末 -> 海带 % R15:裸子植物 & 木本 & 叶片针状 & 结果实 -> 松树 %% 代码部分 % 设定所有的陈述与结论 % set all statements and conclusions disp('请根据特征输入1或0'); q=input('有果皮?'); state{1}.C = '有果皮'; if q==1 state{1}.T = 1; else state{1}.T = 0; end state{2}.C = '被子植物'; state{2}.T = 0; q=input('无果皮?'); state{3}.C = '无果皮'; if q==1 state{3}.T = 1; else state{3}.T = 0; end state{4}.C = '裸子植物'; state{4}.T = 0; q=input('无茎叶?'); state{5}.C = '无茎叶'; if q==1 state{5}.T = 1; else state{5}.T = 0; end q=input('无根?'); state{6}.C = '无根'; if q==1 state{6}.T = 1; else state{6}.T = 0; end state{7}.C = '藻类植物'; state{7}.T = 0; q=input('有托叶?'); state{8}.C = '有托叶'; if q==1 state{8}.T = 1; else state{8}.T = 0; end state{9}.C = '蔷薇科'; state{9}.T = 0; q=input('吸引菜粉蝶?'); state{10}.C = '吸引菜粉蝶'; if q==1 state{10}.T = 1; else state{10}.T = 0; end state{11}.C = '十字花科'; state{11}.T = 0; q=input('十字形花冠?'); state{12}.C = '十字形花冠'; if q==1 state{12}.T = 1; else state{12}.T = 0; end q=input('缺水环境?'); state{13}.C = '缺水环境'; if q==1 state{13}.T = 1; else state{13}.T = 0; end state{14}.C = '仙人掌科'; state{14}.T = 0; q=input('有刺?'); state{15}.C = '有刺'; if q==1 state{15}.T = 1; else state{15}.T = 0; end state{16}.C = '玫瑰'; state{16}.T = 0; q=input('水生?'); state{17}.C = '水生'; if q==1 state{17}.T = 1; else state{17}.T = 0; end q=input('可食用?'); state{18}.C = '可食用'; if q==1 state{18}.T = 1; else state{18}.T = 0; end q=input('结果实?'); state{19}.C = '结果实'; if q==1 state{19}.T = 1; else state{19}.T = 0; end state{20}.C = '荷花'; state{20}.T = 0; q=input('喜阳?'); state{21}.C = '喜阳'; if q==1 state{21}.T = 1; else state{21}.T = 0; end state{22}.C = '仙人球'; state{22}.T = 0; q=input('药用?'); state{23}.C = '药用'; if q==1 state{23}.T = 1; else state{23}.T = 0; end state{24}.C = '水棉'; state{24}.T = 0; q=input('木本?'); state{25}.C = '木本'; if q==1 state{25}.T = 1; else state{25}.T = 0; end state{26}.C = '苹果树'; state{26}.T = 0; q=input('黄色花?'); state{27}.C = '黄色花'; if q==1 state{27}.T = 1; else state{27}.T = 0; end state{28}.C = '油菜'; state{28}.T = 0; q=input('白色粉末?'); state{29}.C = '白色粉末'; if q==1 state{29}.T = 1; else state{29}.T = 0; end state{30}.C = '海带'; state{30}.T = 0; q=input('叶片针状?'); state{31}.C = '叶片针状'; if q==1 state{31}.T = 1; else state{31}.T = 0; end state{32}.C = '松树'; state{32}.T = 0; %% 打印初始的状态 % print initial status fprintf('初始状态为:n'); for i = 1 : length(state) if state{i}.T == 1 fprintf(state{i}.C); fprintf(','); end end fprintf('n'); %% 生产式规则 % production rules change = 1; while change == 1 change = 0; if JudgeState(state, '有果皮') && change == 0 [change, state] = TrueState(state, '被子植物' ); end if JudgeState(state, '无果皮') && change == 0 [change, state] = TrueState(state, '裸子植物' ); end if JudgeState(state, '无茎叶') && JudgeState(state, '无根') && change == 0 [change, state] = TrueState(state, '藻类植物' ); end if JudgeState(state, '被子植物') && JudgeState(state, '有托叶') && change == 0 [change, state] = TrueState(state, '蔷薇科' ); end if JudgeState(state, '被子植物') && JudgeState(state, '吸引菜粉蝶') && change == 0 [change, state] = TrueState(state, '十字花科' ); end if JudgeState(state, '被子植物') && JudgeState(state, '十字形花冠') && change == 0 [change, state] = TrueState(state, '十字花科' ); end if JudgeState(state, '被子植物') && JudgeState(state, '缺水环境') && change == 0 [change, state] = TrueState(state, '仙人掌科' ); end if JudgeState(state, '被子植物') && JudgeState(state, '蔷薇科') && JudgeState(state, '有刺') && change == 0 [change, state] = TrueState(state, '玫瑰' ); end if JudgeState(state, '被子植物') && JudgeState(state, '水生') && JudgeState(state, '可食用') && JudgeState(state, '结果实') && change == 0 [change, state] = TrueState(state, '荷花' ); end if JudgeState(state, '被子植物') && JudgeState(state, '仙人掌科') && JudgeState(state, '喜阳') && JudgeState(state, '有刺') && change == 0 [change, state] = TrueState(state, '仙人球' ); end if JudgeState(state, '藻类植物') && JudgeState(state, '水生') && JudgeState(state, '药用') && change == 0 [change, state] = TrueState(state, '水棉' ); end if JudgeState(state, '被子植物') && JudgeState(state, '蔷薇科') && JudgeState(state, '木本') && JudgeState(state, '可食用') && JudgeState(state, '结果实') && change == 0 [change, state] = TrueState(state, '苹果树' ); end if JudgeState(state, '被子植物') && JudgeState(state, '十字花科') && JudgeState(state, '黄色花') && JudgeState(state, '可食用') && JudgeState(state, '结果实')&& change == 0 [change, state] = TrueState(state, '油菜' ); end if JudgeState(state, '藻类植物') && JudgeState(state, '水生') && JudgeState(state, '可食用') && JudgeState(state, '白色粉末') && change == 0 [change, state] = TrueState(state, '海带' ); end if JudgeState(state, '裸子植物') && JudgeState(state, '木本') && JudgeState(state, '叶片针状') && JudgeState(state, '结果实') && change == 0 [change, state] = TrueState(state, '松树' ); end if change == 1 fprintf('状态变化为:n'); for i = 1 : length(state) if state{i}.T == 1 fprintf(state{i}.C); fprintf(','); end end fprintf('n'); end end

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309

两个子函数
JudgeState.m

function output = JudgeState(state, in) % 生产式系统实验子函数 % 输入状态列表(state)与当前状态(in) % 输出当前状态是否在状态列表中的判断结果 output = 0; for i = 1: length(state) if strcmp(state{i}.C, in) && state{i}.T == 1 output = 1; break; end end end 12345678910111213

TrueState.m

function [change, state] = TrueState(state, in) % 生产式系统实验子函数 % 输入状态列表(state)与当前状态(in) % 将输入状态的在状态列表中置为真 change = 0; for i = 1: length(state) if strcmp(state{i}.C, in) && state{i}.T == 0 change = 1; state{i}.T = 1; break; end end end 12345678910111213

相关知识

MATLAB植物虫害识别
基于Matlab植物虫害检测(GUI,注释svm算法)
基于MATLAB的农业病虫害识别系统
基于颜色特征的农作物病虫害检测(MATLAB程序+word报告)
【病虫害识别】SVM病虫害识别系统【含GUI Matlab源码 2429期】
基于深度学习和SVM的植物叶片识别系统的研究与测试
病虫害识别系统:农业智能化的利器
深度学习基于python+TensorFlow+Django的花朵识别系统
人工智能毕业设计基于python的花朵识别系统
基于深度学习/YOLOv8的植物叶片病害识别系统【附源码+可远程安装部署】

网址: 基于MATLAB产生式系统(植物识别系统) https://m.huajiangbk.com/newsview514127.html

所属分类:花卉
上一篇: 浇花水壶十大品牌排名
下一篇: 辅助诊疗系统