您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > AI人工智能 > 智能计算——模糊推理实验
教务处制第页1实验报告2018──2019学年第二学期一、实验目的及要求二、实验原理、实验内容三、实验仪器设备及材料四、操作方法与实验步骤五、实验数据记录及处理六、实验结果分析实验四:模糊推理1.主要代码#-*-coding:utf-8-*-importsympy#定义模糊规则RULE={'SD':{'NG':'VS','MG':'M','LG':'L'},'MD':{'NG':'S','MG':'M','LG':'L'},'LD':{'NG':'M','MG':'L','LG':'VL'}}#污泥隶属度函数defruleMD(stain):if(stain=0andstain=50):returnstain/50else:return(100-stain)/50defruleSD(stain):result=(50-stain)/50.0if(resultruleMD(stain)):return'MD'else:return'SD'defruleLD(stain):result=(stain-50)/50.0if(resultruleMD(stain)):return'MD'else:return'LD'#油脂隶属度函数defruleMG(oil):教务处制第页2if(oil=0andoil=50):returnoil/50else:return(100-oil)/50defruleNG(oil):result=(50-oil)/50.0if(resultruleMG(oil)):return'MG'else:return'NG'defruleLG(oil):result=(oil-50)/50.0if(resultruleMG(oil)):return'MG'else:return'LG'#根据洗涤时间隶属度函数求隶属度对应区间D={}deftime():D.update({'VS':'[0,'+str(solve(2*z/10.0-1.0,z)[0])+']'})D.update({'S':'['+str(solve(2*z/10.0-1.0,z)[0])+','+str(solve(35-2*z,z)[0])+']'})D.update({'M':'['+str(solve(35-2*z,z)[0])+','+str(solve(65-2*z,z)[0])+']'})D.update({'L':'['+str(solve(65-2*z,z)[0])+','+str(solve(100-2*z)[0])+']'})D.update({'VL':'['+str(solve(100-2*z)[0])+',60]'})#洗涤时间隶属及时间区间defXDSJ(stains,oils):time()print(D)forstaininstains:foroilinoils:if(stain=0andstain=100)and(oil=0andoil=100):s1=ruleSD(stain)ifstain=50elseruleLD(stain)s2=ruleNG(oil)ifoil=50elseruleLG(oil)print(污泥为:{0}油污为:{1}则洗涤时间隶属:{2}洗涤时间区间:{3}minute.format(stain,oil,RULE[s1][s2],D[RULE[s1][s2]]))else:print(输入数据有误,不在论域!!!)stains=[15,45,80]oils=[20,50,70]XDSJ(stains,oils)2、实验步骤和实验结果教务处制第页3(1)实验步骤流程如下图:推理语句:IfAANDBthenC(2)实验结果:3、不同的油污情况,需要的洗涤时间教务处制第页4仪器设备损坏、非正常损耗材料(试剂)及处理情况:无教师对报告的最终评价及处理意见:教师签字:年月日
本文标题:智能计算——模糊推理实验
链接地址:https://www.777doc.com/doc-6212902 .html