I have built a fuzzy control system that takes three inputs (x,y,z) that accept (poor, average, or good) values and returns one output (w) with (low, average, or high) value. unfortunately, when I test the system I get an assertion error without any additional information. the code used to build the system is shown below.
import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl
import matplotlib.pyplot as plt
from matplotlib import rc
x=ctrl.Antecedent(np.arange(0,1,0.001), 'x')
y=ctrl.Antecedent(np.arange(0,1,0.001), 'y')
z=ctrl.Antecedent(np.arange(0,1,0.001), 'y')
w=ctrl.Consequent(np.arange(0,1,0.1),'w')
x.automf(3)
y.automf(5)
z.automf(7)
w['low'] = fuzz.trimf(w.universe, [0, 0, 0.3])
w['average'] = fuzz.trimf(w.universe, [0.25, 0.5, 0.75])
w['high'] = fuzz.trimf(w.universe, [0.7, 1, 1])
rule1 = ctrl.Rule(x['poor'] & y['poor'] & z['poor'], w['low'])
rule2 = ctrl.Rule(x['poor'] & y['poor'] & z['good'], w['low'])
rule3 = ctrl.Rule(x['poor'] & y['good'] & z['poor'], w['high'])
rule4 = ctrl.Rule(x['poor'] & y['good'] & z['good'], w['average'])
rule5 = ctrl.Rule(x['good'] & y['poor'] & z['poor'], w['low'])
rule6 = ctrl.Rule(x['good'] & y['poor'] & z['good'], w['low'])
rule7 = ctrl.Rule(x['good'] & y['good'] & z['poor'], w['average'])
rule8 = ctrl.Rule(x['good'] & y['good'] & z['good'], w['low'])
w_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8])
wResults= ctrl.ControlSystemSimulation(w_ctrl)
wResults.input['x'] = 0.03
wResults.input['y'] = 0.7
wResults.input['z'] = 0.01
wResults.compute()
and the error I get is:
AssertionError Traceback (most recent call last)
<ipython-input-162-4519156d7582> in <module>()
25 wResults= ctrl.ControlSystemSimulation(w_ctrl)
26 wResults.input['x'] = 0.03
---> 27 wResults.input['y'] = 0.7
28 wResults.input['z'] = 0.01
29 wResults.compute()
C:\Users\user01\Anaconda3\lib\site-packages\skfuzzy\control\controlsystem.py in __setitem__(self, key, value)
129 if len(matches) == 0:
130 raise ValueError("Unexpected input: " + key)
--> 131 assert len(matches) == 1
132 var = matches[0]
133
AssertionError:
I wonder if anybody have an idea where this code went wrong.