Azzera filtri
Azzera filtri

Error with Fuzzy Tree Model

5 visualizzazioni (ultimi 30 giorni)
Layla Mohammad
Layla Mohammad il 1 Ago 2023
Commentato: Layla Mohammad il 9 Ago 2023
Hello everyone,
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 (nd_fis, lk_fis, Aggfis3). nd_fis is the node fis and it has 2 inputs: HC and EC. lk_fis is link_fis and it has 3 input: LQI,Mobility and PFI. Outputs of nd_fis and lk_fis are Inputs of fis3.
However, when I run it, the error is “Error using fistree/set.Connections
Specified connections include unrecognized FIS name "Aggfis3".
Error in fistree (line 293)
obj.Connections = p.Results.Connections;
What's wrong please, following is the code with the line underlined is where the error appears:
// Fuzzy model 1
nd_fis = mamfis('Name',"FNode");
nd_fis = addInput(nd_fis,[0 7],'Name',"HC");
nd_fis = addMF(nd_fis,"HC","trapmf",[0 0 1 2],'Name',"Short");
nd_fis = addMF(nd_fis,"HC","trapmf",[1 2 3 4],'Name',"Medium");
nd_fis = addMF(nd_fis,"HC","trapmf",[3 5 7 7],'Name',"Long");
nd_fis = addInput(nd_fis,[0 250],'Name',"EC");
nd_fis = addMF(nd_fis,"EC","trapmf",[0 0 50 100],'Name',"Low");
nd_fis = addMF(nd_fis,"EC","trapmf",[50 100 150 200],'Name',"Moderate");
nd_fis = addMF(nd_fis,"EC","trapmf",[150 200 250 250],'Name',"High");
nd_fis = addOutput(nd_fis,[0 100],'Name',"NS");
nd_fis = addMF(nd_fis,"NS","trimf",[0 25 45],'Name',"Low");
nd_fis = addMF(nd_fis,"NS","trimf",[25 45 75],'Name',"Medium");
nd_fis = addMF(nd_fis,"NS","trimf",[50 75 100],'Name',"High");
nd_rulelist = ["if HC is Short and EC is Low then NS is High";
"if HC is Short and EC is Moderate then NS is Medium";
"if HC is Short and EC is High then NS is Low";
"if HC is Medium and EC is Low then NS is High";
"if HC is Medium and EC is Moderate then NS is High";
"if HC is Medium and EC is High then NS is Medium";
"if HC is Long and EC is Low then NS is High";
"if HC is Long and EC is Moderate then NS is Medium";
"if HC is Long and EC is High then NS is Low"];
FINALnd_fis = addRule(nd_fis,nd_rulelist);
// Fuzzy model 2
lk_fis = mamfis('Name',"FLink");
lk_fis = addInput(lk_fis,[0 7],'Name',"LQI");
lk_fis = addMF(lk_fis,"LQI","trapmf",[0 0 1 2],'Name',"Fair");
lk_fis = addMF(lk_fis,"LQI","trapmf",[1 2 3 4],'Name',"Good");
lk_fis = addMF(lk_fis,"LQI","trapmf",[3 5 7 7],'Name',"Excellent");
lk_fis = addInput(lk_fis,[0 20],'Name',"Mobility");
lk_fis = addMF(lk_fis,"Mobility","trapmf",[0 0 2 6],'Name',"Slow");
lk_fis = addMF(lk_fis,"Mobility","trapmf",[4 7 11 14],'Name',"Medium");
lk_fis = addMF(lk_fis,"Mobility","trapmf",[12 18 20 20],'Name',"Fast");
lk_fis = addInput(lk_fis,[0 100],'Name',"PFI");
lk_fis = addMF(lk_fis,"PFI","trapmf",[0 0 2 40],'Name',"Low");
lk_fis = addMF(lk_fis,"PFI","trapmf",[30 45 55 70],'Name',"Medium");
lk_fis = addMF(lk_fis,"PFI","trapmf",[60 80 100 100],'Name',"High");
lk_fis = addOutput(lk_fis,[0 100],'Name',"LS");
lk_fis = addMF(lk_fis,"LS","trimf",[0 25 45],'Name',"Low");
lk_fis = addMF(lk_fis,"LS","trimf",[25 45 75],'Name',"Medium");
lk_fis = addMF(lk_fis,"LS","trimf",[50 75 100],'Name',"High");
lk_rulelist = ["if LQI is Excellent and Mobility is Slow and PFI is High then LS is High";
"if LQI is Excellent and Mobility is Slow and PFI is Medium then LS is High";
"if LQI is Excellent and Mobility is Slow and PFI is Low then LS is High";
"if LQI is Excellent and Mobility is Medium and PFI is High then LS is High";
"if LQI is Excellent and Mobility is Medium and PFI is Medium then LS is High";
"if LQI is Excellent and Mobility is Medium and PFI is Low then LS is Medium";
"if LQI is Excellent and Mobility is Fast and PFI is High then LS is Medium";
"if LQI is Excellent and Mobility is Fast and PFI is Medium then LS is Medium";
"if LQI is Excellent and Mobility is Fast and PFI is Low then LS is Low";
"if LQI is Good and Mobility is Slow and PFI is High then LS is High";
"if LQI is Good and Mobility is Slow and PFI is Medium then LS is High";
"if LQI is Good and Mobility is Slow and PFI is Low then LS is Medium";
"if LQI is Good and Mobility is Medium and PFI is High then LS is High";
"if LQI is Good and Mobility is Medium and PFI is Medium then LS is Medium";
"if LQI is Good and Mobility is Medium and PFI is Low then LS is Medium";
"if LQI is Good and Mobility is Fast and PFI is High then LS is Medium";
"if LQI is Good and Mobility is Fast and PFI is Medium then LS is Medium";
"if LQI is Good and Mobility is Fast and PFI is Low then LS is Low";
"if LQI is Fair and Mobility is Slow and PFI is High then LS is High";
"if LQI is Fair and Mobility is Slow and PFI is Medium then LS is Medium";
"if LQI is Fair and Mobility is Slow and PFI is Low then LS is Low";
"if LQI is Fair and Mobility is Medium and PFI is High then LS is Medium";
"if LQI is Fair and Mobility is Medium and PFI is Medium then LS is Medium";
"if LQI is Fair and Mobility is Medium and PFI is Low then LS is Low";
"if LQI is Fair and Mobility is Fast and PFI is High then LS is Medium";
"if LQI is Fair and Mobility is Fast and PFI is Medium then LS is Low";
"if LQI is Fair and Mobility is Fast and PFI is Low then LS is Low"
];
FINALlk_fis = addRule(lk_fis,lk_rulelist);
//Fuzzy model 3
Aggfis3 = mamfis('Name','RoutingDecision');
Aggfis3 = addInput(Aggfis3,[0 100],'Name',"LS");
Aggfis3 = addMF(Aggfis3,"LS","trimf",[0 25 45],'Name',"Low");
Aggfis3 = addMF(Aggfis3,"LS","trimf",[25 45 75],'Name',"Medium");
Aggfis3 = addMF(Aggfis3,"LS","trimf",[50 75 100],'Name',"High");
Aggfis3 = addInput(Aggfis3,[0 100],'Name',"NS");
Aggfis3 = addMF(Aggfis3,"NS","trimf",[0 25 45],'Name',"Low");
Aggfis3 = addMF(Aggfis3,"NS","trimf",[25 45 75],'Name',"Medium");
Aggfis3 = addMF(Aggfis3,"NS","trimf",[50 75 100],'Name',"High");
Aggfis3.Outputs(1).Name = "RD";
Aggfis3 = addMF(Aggfis3,"RD","trimf",[0 12 24],'Name',"VL");
Aggfis3 = addMF(Aggfis3,"RD","trimf",[12 24 26],'Name',"L");
Aggfis3 = addMF(Aggfis3,"RD","trimf",[24 36 48],'Name',"ML");
Aggfis3 = addMF(Aggfis3,"RD","trimf",[36 48 60],'Name',"M");
Aggfis3 = addMF(Aggfis3,"RD","trimf",[48 60 72],'Name',"MH");
Aggfis3 = addMF(Aggfis3,"RD","trimf",[60 72 84],'Name',"H");
Aggfis3 = addMF(Aggfis3,"RD","trimf",[72 84 100],'Name',"VH");
rulefis3d = ["if NS is Low and LS is Low then RD is VL";
"if NS is Low and LS is Medium then RD is L";
"if NS is Low and LS is High then RD is ML";
"if NS is Medium and LS is Low then RD is ML";
"if NS is Medium and LS is Medium,then RD is M";
"if NS is Medium and LS is High then RD is MH";
"if NS is High and LS is Low then RD is MH";
"if NS is High and LS is Medium then RD is H";
"if NS is High and LS is High then RD is VH"];
Aggfis3 = addRule(Aggfis3,rulefis3d);
con1 = ["FNode/NS" "Aggfis3/NS"];
con2 = ["FLink/LS" "Aggfis3/LS"];
aggTree = fistree([FINALnd_fis FINALlk_fis Aggfis3],[con1;con2]);
aggTree.FIS(3) = addRule(aggTree.FIS(3), rulefis3d)

Risposta accettata

Sam Chak
Sam Chak il 1 Ago 2023
Please check this out and see if these MFs, Surfaces, and the FIS Tree are what you are expecting.
% Fuzzy model 1
nd_fis = mamfis('Name', "FNode");
nd_fis = addInput(nd_fis, [0 7], 'Name', "HC");
nd_fis = addMF(nd_fis, "HC", "trapmf", [0 0 1 2], 'Name', "Short" );
nd_fis = addMF(nd_fis, "HC", "trapmf", [1 2 3 4], 'Name', "Medium");
nd_fis = addMF(nd_fis, "HC", "trapmf", [3 5 7 7], 'Name', "Long" );
nd_fis = addInput(nd_fis, [0 250], 'Name', "EC");
nd_fis = addMF(nd_fis, "EC", "trapmf", [ 0 0 50 100], 'Name', "Low" );
nd_fis = addMF(nd_fis, "EC", "trapmf", [ 50 100 150 200], 'Name', "Moderate");
nd_fis = addMF(nd_fis, "EC", "trapmf", [150 200 250 250], 'Name', "High" );
nd_fis = addOutput(nd_fis, [0 100], 'Name', "NS");
nd_fis = addMF(nd_fis, "NS", "trimf", [ 0 25 45], 'Name', "Low" );
nd_fis = addMF(nd_fis, "NS", "trimf", [25 45 75], 'Name', "Medium");
nd_fis = addMF(nd_fis, "NS", "trimf", [50 75 100], 'Name', "High" );
nd_rulelist = ["if HC is Short and EC is Low then NS is High";
"if HC is Short and EC is Moderate then NS is Medium";
"if HC is Short and EC is High then NS is Low";
"if HC is Medium and EC is Low then NS is High";
"if HC is Medium and EC is Moderate then NS is High";
"if HC is Medium and EC is High then NS is Medium";
"if HC is Long and EC is Low then NS is High";
"if HC is Long and EC is Moderate then NS is Medium";
"if HC is Long and EC is High then NS is Low"];
nd_fis = addRule(nd_fis, nd_rulelist); % <--- change in this line
figure(1)
tiledlayout(2,2);
nexttile
plotmf(nd_fis, 'input', 1)
nexttile
plotmf(nd_fis, 'input', 2)
nexttile
plotmf(nd_fis, 'output', 1)
nexttile
opt = gensurfOptions('NumGridPoints', 21);
gensurf(nd_fis, opt)
% Fuzzy model 2
lk_fis = mamfis('Name', "FLink");
lk_fis = addInput(lk_fis, [0 7], 'Name', "LQI");
lk_fis = addMF(lk_fis, "LQI", "trapmf", [0 0 1 2], 'Name', "Fair" );
lk_fis = addMF(lk_fis, "LQI", "trapmf", [1 2 3 4], 'Name', "Good" );
lk_fis = addMF(lk_fis, "LQI", "trapmf", [3 5 7 7], 'Name', "Excellent");
lk_fis = addInput(lk_fis, [0 20], 'Name',"Mobility");
lk_fis = addMF(lk_fis, "Mobility", "trapmf", [ 0 0 2 6], 'Name', "Slow" );
lk_fis = addMF(lk_fis, "Mobility", "trapmf", [ 4 7 11 14], 'Name', "Medium");
lk_fis = addMF(lk_fis, "Mobility", "trapmf", [12 18 20 20], 'Name', "Fast" );
lk_fis = addInput(lk_fis, [0 100], 'Name', "PFI");
lk_fis = addMF(lk_fis, "PFI", "trapmf", [ 0 0 2 40], 'Name', "Low" );
lk_fis = addMF(lk_fis, "PFI", "trapmf", [30 45 55 70], 'Name', "Medium");
lk_fis = addMF(lk_fis, "PFI", "trapmf", [60 80 100 100], 'Name', "High" );
lk_fis = addOutput(lk_fis, [0 100], 'Name', "LS");
lk_fis = addMF(lk_fis, "LS", "trimf", [ 0 25 45], 'Name', "Low" );
lk_fis = addMF(lk_fis, "LS", "trimf", [25 45 75], 'Name', "Medium");
lk_fis = addMF(lk_fis, "LS", "trimf", [50 75 100], 'Name', "High" );
lk_rulelist = ["if LQI is Excellent and Mobility is Slow and PFI is High then LS is High";
"if LQI is Excellent and Mobility is Slow and PFI is Medium then LS is High";
"if LQI is Excellent and Mobility is Slow and PFI is Low then LS is High";
"if LQI is Excellent and Mobility is Medium and PFI is High then LS is High";
"if LQI is Excellent and Mobility is Medium and PFI is Medium then LS is High";
"if LQI is Excellent and Mobility is Medium and PFI is Low then LS is Medium";
"if LQI is Excellent and Mobility is Fast and PFI is High then LS is Medium";
"if LQI is Excellent and Mobility is Fast and PFI is Medium then LS is Medium";
"if LQI is Excellent and Mobility is Fast and PFI is Low then LS is Low";
"if LQI is Good and Mobility is Slow and PFI is High then LS is High";
"if LQI is Good and Mobility is Slow and PFI is Medium then LS is High";
"if LQI is Good and Mobility is Slow and PFI is Low then LS is Medium";
"if LQI is Good and Mobility is Medium and PFI is High then LS is High";
"if LQI is Good and Mobility is Medium and PFI is Medium then LS is Medium";
"if LQI is Good and Mobility is Medium and PFI is Low then LS is Medium";
"if LQI is Good and Mobility is Fast and PFI is High then LS is Medium";
"if LQI is Good and Mobility is Fast and PFI is Medium then LS is Medium";
"if LQI is Good and Mobility is Fast and PFI is Low then LS is Low";
"if LQI is Fair and Mobility is Slow and PFI is High then LS is High";
"if LQI is Fair and Mobility is Slow and PFI is Medium then LS is Medium";
"if LQI is Fair and Mobility is Slow and PFI is Low then LS is Low";
"if LQI is Fair and Mobility is Medium and PFI is High then LS is Medium";
"if LQI is Fair and Mobility is Medium and PFI is Medium then LS is Medium";
"if LQI is Fair and Mobility is Medium and PFI is Low then LS is Low";
"if LQI is Fair and Mobility is Fast and PFI is High then LS is Medium";
"if LQI is Fair and Mobility is Fast and PFI is Medium then LS is Low";
"if LQI is Fair and Mobility is Fast and PFI is Low then LS is Low"];
lk_fis = addRule(lk_fis,lk_rulelist); % <--- change in this line
figure(2)
tiledlayout(2,2);
nexttile
plotmf(lk_fis, 'output', 1)
nexttile
opt = gensurfOptions('InputIndex', [1 2], 'NumGridPoints', 21);
gensurf(lk_fis, opt)
nexttile
opt = gensurfOptions('InputIndex', [1 3], 'NumGridPoints', 21);
gensurf(lk_fis, opt)
nexttile
opt = gensurfOptions('InputIndex', [2 3], 'NumGridPoints', 21);
gensurf(lk_fis, opt)
% Fuzzy model 3
Aggfis3 = mamfis('Name', 'RoutingDecision');
Aggfis3 = addInput(Aggfis3, [0 100], 'Name', "LS");
Aggfis3 = addMF(Aggfis3, "LS", "trimf", [ 0 25 45], 'Name', "Low" );
Aggfis3 = addMF(Aggfis3, "LS", "trimf", [25 45 75], 'Name', "Medium");
Aggfis3 = addMF(Aggfis3, "LS", "trimf", [50 75 100], 'Name', "High" );
Aggfis3 = addInput(Aggfis3, [0 100], 'Name', "NS");
Aggfis3 = addMF(Aggfis3, "NS", "trimf", [ 0 25 45], 'Name', "Low" );
Aggfis3 = addMF(Aggfis3, "NS", "trimf", [25 45 75], 'Name', "Medium");
Aggfis3 = addMF(Aggfis3, "NS", "trimf", [50 75 100], 'Name', "High" );
% Aggfis3.Outputs(1).Name = "RD";
Aggfis3 = addOutput(Aggfis3, [0 100], 'Name', "RD");
Aggfis3 = addMF(Aggfis3, "RD", "trimf", [ 0 12 24], 'Name',"VL");
Aggfis3 = addMF(Aggfis3, "RD", "trimf", [12 24 26], 'Name',"L" );
Aggfis3 = addMF(Aggfis3, "RD", "trimf", [24 36 48], 'Name',"ML");
Aggfis3 = addMF(Aggfis3, "RD", "trimf", [36 48 60], 'Name',"M" );
Aggfis3 = addMF(Aggfis3, "RD", "trimf", [48 60 72], 'Name',"MH");
Aggfis3 = addMF(Aggfis3, "RD", "trimf", [60 72 84], 'Name',"H" );
Aggfis3 = addMF(Aggfis3, "RD", "trimf", [72 84 100], 'Name',"VH");
rulefis3d = ["if NS is Low and LS is Low then RD is VL";
"if NS is Low and LS is Medium then RD is L";
"if NS is Low and LS is High then RD is ML";
"if NS is Medium and LS is Low then RD is ML";
"if NS is Medium and LS is Medium then RD is M";
"if NS is Medium and LS is High then RD is MH";
"if NS is High and LS is Low then RD is MH";
"if NS is High and LS is Medium then RD is H";
"if NS is High and LS is High then RD is VH"];
Aggfis3 = addRule(Aggfis3, rulefis3d);
figure(3)
tiledlayout(2,2);
nexttile
plotmf(Aggfis3, 'input', 1)
nexttile
plotmf(Aggfis3, 'input', 2)
nexttile
plotmf(Aggfis3, 'output', 1)
nexttile
opt = gensurfOptions('NumGridPoints', 21);
gensurf(Aggfis3, opt)
aggTree = fistree([nd_fis lk_fis Aggfis3], []); % <--- change in this line
aggTree.Connections = [
"FNode/NS" "RoutingDecision/NS"; % <--- change in this line
"FLink/LS" "RoutingDecision/LS"]; % <--- change in this line
figure(4)
plotfis(aggTree)
  7 Commenti
Sam Chak
Sam Chak il 9 Ago 2023
I recommend that you create a new post and tag it with 'MATLAB Coder' as the issue is related to generating C code from MATLAB code for the hardware platform.
Consider using the following title: "Generating C Code from FIS Tree Model using MATLAB Coder."
In your post, you can explain that you currently have a MATLAB algorithm (link to this thread) that generates the FIS Tree Model within the Workspace.
Layla Mohammad
Layla Mohammad il 9 Ago 2023
@Sam Chak Yes sure
Thank you very much for your reply and efforts

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Card games in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by