模糊逻辑控制器-RuntimeError:无法解析规则执行顺序

问题描述 投票:0回答:1

我是这个概念的新手,我一直在尝试实现淋浴的模糊逻辑控制器。输入是从最左边到最右边的旋钮位置,输出是从非常冷到非常热的温度。我在规则中遇到此运行时错误。下面是我的愚蠢代码

import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl

pos = ctrl.Consequent(np.arange(0, 180, 1), 'pos')
temp = ctrl.Consequent(np.arange(0, 100, 1), 'temp')

pos['EL'] = fuzz.trimf(pos.universe, [0, 0, 45])
pos['L'] = fuzz.trimf(pos.universe, [0, 45, 90])
pos['C'] = fuzz.trimf(pos.universe, [45, 90, 135])
pos['R'] = fuzz.trimf(pos.universe, [90, 135, 180])
pos['ER'] = fuzz.trimf(pos.universe, [135, 180, 180])

temp['VC'] = fuzz.trimf(temp.universe, [0, 0, 10])
temp['C'] = fuzz.trimf(temp.universe, [0, 10, 40])
temp['W'] = fuzz.trimf(temp.universe, [10, 40, 80])
temp['H'] = fuzz.trimf(temp.universe, [40, 80, 100])
temp['VH'] = fuzz.trimf(temp.universe, [80, 100, 100])

rule1 = ctrl.Rule(pos['EL'], temp['VC'])
rule2 = ctrl.Rule(pos['L'], temp['C'])
rule3 = ctrl.Rule(pos['C'], temp['W'])
rule4 = ctrl.Rule(pos['R'], temp['H'])
rule5 = ctrl.Rule(pos['ER'], temp['VH'])

temp_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5])
temprature = ctrl.ControlSystemSimulation(temp_ctrl)

RuntimeError: Unable to resolve rule execution order. The most likely reason is two or more rules that depend on each other. Please check the rule graph for loops.
fuzzy-logic fuzzy skfuzzy
1个回答
0
投票

我想你可能想要这个

pos = ctrl.Consequent(np.arange(0, 180, 1), 'pos')

成为这个

pos = ctrl.Antecedent(np.arange(0, 180, 1), 'pos')

所以您的规则将显示类似

if antecedent then consequent
© www.soinside.com 2019 - 2024. All rights reserved.