- "ga" — genetic algorithm
- "particleswarm" — particle swarm
- "patternsearch" — pattern search
- "simulannealbnd" — simulated annealing algorithm
Why does using the "anfis" function result in invalid values for the membership function?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 16 Fév 2023
Réponse apportée : MathWorks Support Team
le 17 Fév 2023
I am using the "anfis" function from the Fuzzy Logic Toolbox in MATLAB R2022b and get the following error message when I try to train a Fuzzy Inference System with a Membership Function of type "trapmf" or "trimf":
Error using fuzzy.internal.utility/validateTriMFParameterValuesFirst parameter must be less than or equal to second parameter.
Shown below is the code I used to train a Fuzzy Inference System with a Membership Function of type "trimf":
% Load data
inputData = tr_data(:,[1:4]);
outputData = tr_data(:,5);
% Trimf ANFIS option config
opt_tri = genfisOptions('GridPartition');
opt_tri.OutputMembershipFunctionType = 'linear';
opt_tri.NumMembershipFunctions = 3;
opt_tri.InputMembershipFunctionType = "trimf";
triAnfis = genfis(inputData,outputData,opt_tri);
triAnfis.andMethod = 'prod';
triOpt = anfisOptions('InitialFis', triAnfis);
triOpt.EpochNumber = 10;
triOpt.InitialStepSize=0.01;
triOpt.OptimizationMethod=1; % hybrid optimization method
triOpt.ValidationData = ck_data; % set checking data
[triFis,triTrErr,~,triChkFis,triCkErr] = anfis(tr_data,triOpt);
I tried using the "Neuro-Fuzzy Designer" app as well but got the same error message. Why is the "anfis" function setting values for the Membership Function parameters to invalid values?
Réponse acceptée
MathWorks Support Team
le 16 Fév 2023
This issue occurs because the "anfis" function does not guarantee convergence for membership functions since each membership function has specific parameter constraints.
The "Neuro-Fuzzy Designer" app utilizes the same "anfis" function as mentioned in your code above, thus we get the same error message:
Error using fuzzy.internal.utility/validateTriMFParameterValuesFirst parameter must be less than or equal to second parameter.
A potential workaround is to change the value of "triOpt.InitialStepSize" to 0.001 from 0.01 in the code provided. This will result in the "anfis" function taking smaller steps thus reducing the probability of choosing invalid membership function parameters.
Another workaround is to use the "tunefis" function to tune the Fuzzy Inference System instead of "anfis". This can be achieved by replacing the following line of code:
[triFis,triTrErr,~,triChkFis,triCkErr] = anfis(tr_data,triOpt);
with the lines of code below:
[in,out,rule] = getTunableSettings(triAnfis);
tunefis(triAnfis,rule,inputData,outputData,tunefisOptions("Method","tune_method"));
"getTunableSettings" will provide parameters that are required for the "tunefis" function. The "tunefis" function will then tune the Fuzzy Inference System using the tuning method mentioned in "tunefisOptions". "tunefisOptions" has the following methods to choose from:
This will allow you to tune the Fuzzy Inference System using alternative methods to "anfis".
For more information on "getTunableSettings", "tunefis" and "tunefisOptions", please refer to the documentation below:
"getTunableSettings" - https://www.mathworks.com/help/releases/R2022b/fuzzy/mamfis.gettunablesettings.html
"tunefis" - https://www.mathworks.com/help/releases/R2022b/fuzzy/tunefis.html
"tunefisOptions" - https://www.mathworks.com/help/releases/R2022b/fuzzy/tunefisoptions.html
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fuzzy Logic Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!