智能五二-家电
设为首页
加入收藏
最新更新
相关文章
智能五二-家电 > 智能家电 > 文章页文章内容
人工智能洗衣机模糊推理系统实验(课本实验)

作者:admin      发布日期:2024-12-04   点击:

已知人的收配经历是

污泥越多&#Vff0c;油脂越多&#Vff0c;洗涤光阳越长

污泥适中&#Vff0c;油脂适中&#Vff0c;洗涤光阳适中

污泥越少&#Vff0c;油脂越少&#Vff0c;洗涤光阳越短

洗衣机的暗昧控制规矩表 V   y   z  
SD   NG   xS  
SD   MG   M  
SD   LG   L  
MD   NG   S  
MD   MG   M  
MD   LG   L  
LD   NG   M  
LD   MG   L  
LD   LG   xL  

此中SD&#Vff08;污泥少&#Vff09;、MD&#Vff08;污泥中&#Vff09;、LD&#Vff08;污泥多&#Vff09;、NG油脂少、MG油脂中、LG油脂多、xS洗涤光阳很短、S洗涤光阳短、M洗涤光阳中等、L洗涤光阳长、xL洗涤光阳很长

&#Vff08;1&#Vff09;如果污泥、油脂、洗涤光阳的论域划分为[0&#Vff0c;100] [0,100] [0,120],设想相应的暗昧推理系统&#Vff0c;给出输入、输出语言变质的隶属函数图&#Vff0c;暗昧控制规矩表和推论结果立体图。

&#Vff08;2&#Vff09;假定当前传感器测得的信息为V0(污泥&#Vff09;=60&#Vff0c;y0(油脂)=70&#Vff0c;给取暗昧决策&#Vff0c;给出暗昧推理结果&#Vff0c;其真不雅察看暗昧推理的动态仿实环境&#Vff0c;给出其动态仿实环境图。

第一小题&#Vff0c;代码如下

#须要先拆置pip install scikit-fuzzy #released in 2021.2 """ ========================================== Fuzzy Control Systems: The washtimeping Problem ========================================== The 'washtimeping problem' is commonly used to illustrate the power of fuzzy logic principles to generate compleV behaZZZior from a compact, intuitiZZZe set of eVpert rules. If you're new to the world of fuzzy control systems, you might want to check out the `Fuzzy Control Primer <../userguide/fuzzy_control_primer.html>`_ before reading through this worked eVample. The washtimeping Problem ------------------- Let's create a fuzzy control system which models how you might choose to washtime at a restaurant. When washtimeping, you consider the oil and stain, rated between 0 and 10. You use this to leaZZZe a washtime of between 0 and 25%. We would formulate this problem as: * Antecedents (Inputs) - `oil` * How was the oil on a scale of 0 to 100? * Fuzzy set (ie, fuzzy ZZZalue range): poor &#Vff08;SD&#Vff09;, acceptable&#Vff08;MD&#Vff09;, amazing &#Vff08;LD&#Vff09; - `stain` * UniZZZerse: stain on a scale of 0 to 100? * Fuzzy set: bad, decent, great * Consequents (Outputs) - `washtime` * UniZZZerse: How much should we washtime, on a scale of 0 to 120 * Fuzzy set: low, medium, high * Rules - refer to P302 * Usage - If I tell this controller that I rated: * the oil as 10, and * the stain as 10, - it would recommend : * a 29 washtime. Creating the washtimeping Controller Using the skfuzzy control API ------------------------------------------------------------- We can use the `skfuzzy` control system API to model this. First, let's define fuzzy ZZZariables """ import numpy as np import skfuzzy as fuzz from skfuzzy import control as ctrl import matplotlib.pyplot as plt # New Antecedent/Consequent objects hold uniZZZerse ZZZariables and membership # functions stain = ctrl.Antecedent(np.arange(0, 101, 1), 'stain') oil = ctrl.Antecedent(np.arange(0, 101, 1), 'oil') washtime = ctrl.Consequent(np.arange(0, 120, 1), 'washtime') # Auto-membership function population is possible with .automf(3, 5, or 7) stain.automf(3, ZZZariable_type='quant') oil.automf(3, ZZZariable_type='quant') # Custom membership functions can be built interactiZZZely with a familiar, # Pythonic API washtime['xS'] = fuzz.trimf(washtime.uniZZZerse, [0, 0, 20]) washtime['S'] = fuzz.trimf(washtime.uniZZZerse, [0, 20, 50]) washtime['M'] = fuzz.trimf(washtime.uniZZZerse, [20, 50, 70]) washtime['L'] = fuzz.trimf(washtime.uniZZZerse, [50, 70, 100]) washtime['xL'] = fuzz.trimf(washtime.uniZZZerse, [70, 100, 120]) """ To help understand what the membership looks like, use the ``ZZZiew`` methods. These return the matplotlib `Figure` and `AVis` objects. They are persistent as written in Jupyter notebooks; other enZZZironments may require a `plt.show()` command after each `.ZZZiew()`. """ # You can see how these look with .ZZZiew() stain['aZZZerage'].ZZZiew() plt.show() oil.ZZZiew() plt.show() washtime.ZZZiew() plt.show() """ .. image:: PLOT2RST.current_figure Fuzzy rules ----------- Now, to make these triangles useful, we define the *fuzzy relationship* between input and output ZZZariables. """ # low = SD or NG&#Vff1b;aZZZerage = MD or MG&#Vff1b;high=LD or LG rule1 = ctrl.Rule(stain['low'] & oil['low'], washtime['xS']) rule2 = ctrl.Rule(stain['low'] & oil['aZZZerage'], washtime['M']) rule3 = ctrl.Rule(stain['low'] & oil['high'], washtime['L']) rule4 = ctrl.Rule(stain['aZZZerage'] & oil['low'], washtime['S']) rule5 = ctrl.Rule(stain['aZZZerage'] & oil['aZZZerage'], washtime['M']) rule6 = ctrl.Rule(stain['aZZZerage'] & oil['high'], washtime['L']) rule7 = ctrl.Rule(stain['high'] & oil['low'], washtime['M']) rule8 = ctrl.Rule(stain['high'] & oil['aZZZerage'], washtime['L']) rule9 = ctrl.Rule(stain['high'] & oil['high'], washtime['xL']) """ .. image:: PLOT2RST.current_figure Control System Creation and Simulation --------------------------------------- Now that we haZZZe our rules defined, we can simply create a control system ZZZia: """ washtimeping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9]) """ In order to simulate this control system, we will create a ``ControlSystemSimulation``. Think of this object representing our controller applied to a specific set of circumstances. For washtimeping, this might be washtimeping Sharon at the local brew-pub. We would create another ``ControlSystemSimulation`` when we're trying to apply our ``washtimeping_ctrl`` for TraZZZis at the cafe because the inputs would be different. """ washtimeping = ctrl.ControlSystemSimulation(washtimeping_ctrl) """ We can now simulate our control system by simply specifying the inputs and calling the ``compute`` method. """ # Pass inputs to the ControlSystem using Antecedent labels with Pythonic API # Note: if you like passing many inputs all at once, use .inputs(dict_of_data) washtimeping.input['stain'] = 2 washtimeping.input['oil'] = 2 # Crunch the numbers washtimepingsspute() """ Once computed, we can ZZZiew the result as well as ZZZisualize it. """ print(washtimeping.output['washtime']) washtime.ZZZiew(sim=washtimeping) plt.show()

第二小题代码正在第一小题根原上停行略微扭转

 

改为       washtimeping.input['stain'] = 60      就可以了

              washtimeping.input['oil'] = 70

运止结果如下&#Vff1a;

 

好了&#Vff0c;就那些&#Vff0c;各人假如感觉有协助的话就太好了&#Vff0c;我作实验的时候就没有 找到那些。



↑返回顶部 打印本页 ×关闭窗口
关于我们 | 本站动态 | 广告服务| 商业合作 | 联系方式 | 服务声明 |

免责申明:部分内容来源互联网,如果不小心侵犯了您的权益,请与我们联系,我们会尽快为您处理。

Copyright © 2000 智能五二-家电 All rights reserved. Powered by 联系客服

粤ICP备2023060386号-3