I create a fuzzy tree (aggregated structure) in MATLAB and I have an error which I hope to be supported.
My fuzzy tree has 3 fuzzy models (fis1
, fis2
, fis3
). fis1
is the tipper1 and it has 2 inputs: service and food. fis2
is tipper2 and it has 2 input: service and food. Outputs of fis1
and fis2
are Inputs of fis3
.
However, when I run it, the error is:
Error using FuzzyInferenceSystem/addRule (line 1148). Invalid input
membership function name in rule description.
I think maybe error comes because I don’t create membership function for inputs of fis3
. But I have already created membership function for outputs of fis1
and fis2
, so if I create membership function for fis3
, the inputs of fis3
will have 2 times of membership function. Could you support me with this issue? Thank you.
Aggregated fuzzy tree model:
% Fuzzy model 1
fis1 = mamfis('Name',"tipper1");
fis1 = addInput(fis1,[0 10],'Name',"service");
fis1 = addMF(fis1,"service","gaussmf",[1.5 0],'Name',"poor");
fis1 = addMF(fis1,"service","gaussmf",[1.5 5],'Name',"good");
fis1 = addMF(fis1,"service","gaussmf",[1.5 10],'Name',"excellent");
fis1 = addInput(fis1,[0 10],'Name',"food");
fis1 = addMF(fis1,"food","trapmf",[-2 0 1 3],'Name',"rancid");
fis1 = addMF(fis1,"food","trapmf",[7 9 10 12],'Name',"delicious");
fis1 = addOutput(fis1,[0 30],'Name',"tip1");
fis1 = addMF(fis1,"tip1","trimf",[0 5 10],'Name',"cheap");
fis1 = addMF(fis1,"tip1","trimf",[10 15 20],'Name',"average");
fis1 = addMF(fis1,"tip1","trimf",[20 25 30],'Name',"generous");
rulefis1a = "service==poor | food==rancid => tip1=cheap";
rulefis1b = "service==good => tip1=average";
rulefis1c = "service==excellent | food==delicious => tip1=generous";
rulefis1d = [rulefis1a rulefis1b rulefis1c];
fis1b = addRule(fis1,rulefis1d);
%Fuzzy model 2
fis2 = mamfis('Name',"tipper2");
fis2 = addInput(fis2,[0 10],'Name',"service");
fis2 = addMF(fis2,"service","gaussmf",[1.5 0],'Name',"poor");
fis2 = addMF(fis2,"service","gaussmf",[1.5 5],'Name',"good");
fis2 = addMF(fis2,"service","gaussmf",[1.5 10],'Name',"excellent");
fis2 = addInput(fis2,[0 10],'Name',"food");
fis2 = addMF(fis2,"food","trapmf",[-2 0 1 3],'Name',"rancid");
fis2 = addMF(fis2,"food","trapmf",[7 9 10 12],'Name',"delicious");
fis2 = addOutput(fis2,[0 30],'Name',"tip2");
fis2 = addMF(fis2,"tip2","trimf",[0 5 10],'Name',"cheap");
fis2 = addMF(fis2,"tip2","trimf",[10 15 20],'Name',"average");
fis2 = addMF(fis2,"tip2","trimf",[20 25 30],'Name',"generous");
rulefis2a = "service==poor | food==rancid => tip2=cheap";
rulefis2b = "service==good => tip2=average";
rulefis2c = "service==excellent | food==delicious => tip2=generous";
rulefis2d = [rulefis2a rulefis2b rulefis2c];
fis2b = addRule(fis2,rulefis2d);
%Fuzzy model 3
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);
fis3.Outputs(1).Name = "final_tip";
con1 = ["tipper1/tip1" "fis3/input1"];
con2 = ["tipper2/tip2" "fis3/input2"];
fis3 = addMF(fis3,"final_tip","trapmf",[-2 0 1 3],'Name',"rancid");
fis3 = addMF(fis3,"final_tip","trapmf",[7 9 10 12],'Name',"delicious");
rulefis3a = "input1==cheap | input2==average => final_tip=rancid";
rulefis3b = "input1==average => final_tip=rancid";
rulefis3c = "input1==generous | input2==generous => final_tip=delicious";
rulefis3d = [rulefis3a rulefis3b rulefis3c];
fis3b = addRule(fis3,rulefis3d);
aggTree = fistree([fis1b fis2b fis3b],[con1;con2]);
output = evalfis(aggTree,[0.2 0.25 0.3 0.2]);