Particle swarm algorithm in Fuzzy Logic Designer is breaking unity sum property of membership functions, how can I stop this?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ben Hatrick
el 6 de Abr. de 2024
Respondida: Ben Hatrick
el 12 de Abr. de 2024
I am using the Fuzzy Logic Designer App to fine-tune a Type-I Mamdani FIS. I have preset a number of inputs with three membership functions each, using Trapezoidal->Triangular->Trapezoidal. I want to optimize the parameters of these membership functions using the built-in PSO algorithm, but when I do, it significantly warps the shape of my membership functions (see the example below).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1662001/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1662006/image.png)
The new membership functions do not adhere to the key property of unity, where the sum of the membership values for a given input is 1. Is there a way to stop this from happening, or should I just tune my functions empirically?
2 comentarios
Sam Chak
el 6 de Abr. de 2024
Hi @Ben Hatrick
Could you please share the code that produced the unexpected result? If you used the standard triangular membership function 'trimf()' as a tunable object for the built-in PSO algorithm 'particleswarm()' to adjust the three parameters, it seems unlikely to achieve such a result unless you manually scaled the standard triangular membership function, when I attempted to construct it below.
x = 0:1e-2:5;
mf = trimf(x, [0.9 2.0 2.8]); % standard triangular MF
plot(x, mf), grid on, xticks(0:0.5:5), ylim([0, 1]), xlabel('Input'), ylabel('Degree of Membership'), title('Standard Triangular MF')
amp = 0.43; % amplitude
y = amp*mf; % scaled triangular MF
plot(x, y), grid on, xticks(0:0.5:5), ylim([0, 1]), xlabel('Input'), ylabel('Degree of Membership'), title('Scaled Triangular MF')
Respuesta aceptada
Sam Chak
el 8 de Abr. de 2024
Hi @Ben Hatrick
I have rarely used PSO to tune fuzzy systems, and I hadn't realized this phenomenon until you brought it up.
As a test, I applied PSO to tune a fuzzy system for a Clipped Sine wave. Although the error between the observed data and the PSO-tuned fuzzy system is relatively small, I'm facing a challenge in logically interpreting the degrees of some membership functions (MFs). Specifically, the 'in1mf' MFs exhibit an illogical sequence, and 'in1mf4' completely overlaps with 'in1mf1', 'in1mf2', 'in1mf5', 'in1mf6', and 'in1mf7'. Are such overlaps and inconsistencies acceptable from a human reasoning perspective?
This raises a deeper question to ponder:
- Is it acceptable to achieve numerical matching between the observed data and the tuned fuzzy system without considering the logical foundation of the MFs?
- Or, should we prioritize the logical validity during the tuning process?
I'm afraid that the answers to these questions have to be evaluated on a case-by-case basis. It is essential to consider the specific context and requirements of each situation.
Similarly, I have observed numerous users in the forum blindly fitting popular polynomial models to finite response data from dynamical systems. However, it is important to note that these systems often have well-established mathematical models or even analytical solutions. Blindly fitting polynomial models without considering the underlying mathematical structure might not yield meaningful results for prediction purposes.
%% Data generated by a Clipped Sine wave
x = (0:0.1:10)';
y = max(-0.5, min(sin(pi/5*x), 0.5));
%% Generate FIS
fisOpts = genfisOptions('GridPartition');
fisOpts.NumMembershipFunctions = 7;
fisOpts.InputMembershipFunctionType = "trapmf";
fisOpts.OutputMembershipFunctionType = "linear";
fisin = genfis(x, y, fisOpts);
%% Tune FIS
[in, out, rule] = getTunableSettings(fisin);
metOpts = tunefisOptions("Method", "particleswarm", "Display", "none");
fisout = tunefis(fisin, [in; out; rule], x, y, metOpts)
%% Plots
figure(1)
plotmf(fisin, 'input', 1), grid on, title('Input MFs before tuning with pso')
plotmf(fisout, 'input', 1), grid on, title('Input MFs after tuning with pso')
yTuned = evalfis(fisout, x);
figure(2)
plot(x, y, x, yTuned), grid on, ylim([-1 1])
xlabel('x'), ylabel('y'), legend('data', 'pso-tuned'), title('Results')
"Elapsed time is 3383.380043 seconds."
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1663521/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1663526/image.png)
1 comentario
Sam Chak
el 8 de Abr. de 2024
Hi @Ben Hatrick
You may want to explore alternative tuning methods. In my Clipped Sine example, I found that the ANFIS-tuned fuzzy system produced superior and meaningful results compared to the PSO-tuned fuzzy system.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1663536/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1663541/image.png)
Más respuestas (1)
Ver también
Categorías
Más información sobre Fuzzy Logic Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!