Fuzzy logic rule for out of range

14 vues (au cours des 30 derniers jours)
Luca Ferro
Luca Ferro le 9 Fév 2023
Commenté : Luca Ferro le 22 Mar 2023
I implemented a fuzzy logic penalty system for a particle swarm algorithm i'm working on.
Sometimes it may happen that the values considered are out of the range defined in the fuzzy logic [0 1], so i get this warning:
Warning: Input 1 expects a value in range [0 1], but has a value of 1.06985.
and by default the defuzzifier does this:
Warning: No rules fired for Output 1. Defuzzified output value set to its mean range value 0.05.
Is there a way to set a rule for the out of range values so that its default output is an arbitrary value decided by me and not the mean?
Basically i would like to keep both warnings, and have the second one like this:
Warning: No rules fired for Output 1. Defuzzified output value set to MY ARBITRARY VALUE LET'S SAY 2.
Note: i know i could just expand the fuzzy range to fit, but it would be a blind guess since i don't actually know the upper bound. If nothing works i'll do it like this (expanding to let's say to [0 1.5], so a 50% margin).
Note2: i cannot attach the fuzzy logic beacuse .fis files upload is not supported, i'll just copy paste it in the comments:
  1 commentaire
Luca Ferro
Luca Ferro le 9 Fév 2023
this is the fuzzy logic file:
[System]
Name='risetimeFuzzy'
Type='mamdani'
Version=2.0
NumInputs=1
NumOutputs=1
NumRules=5
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
[Input1]
Name='rtRatio'
Range=[0 1]
NumMFs=5
MF1='eF':'trimf',[0 0 0.08]
MF2='jR':'trimf',[0.15 0.35 0.6]
MF3='eS':'trimf',[0.75 1 1]
MF4='qF':'trimf',[0.002 0.08 0.25]
MF5='qS':'trimf',[0.45 0.7 1]
[Output1]
Name='output1'
Range=[0 0.1]
NumMFs=3
MF1='lnP':'trimf',[0 0 0.015]
MF2='hP':'trimf',[0.03 0.06 0.1]
MF3='lmP':'trimf',[0.01 0.02 0.04]
[Rules]
1, 2 (1) : 1
4, 3 (1) : 1
2, 1 (1) : 1
5, 3 (1) : 1
3, 2 (1) : 1

Connectez-vous pour commenter.

Réponse acceptée

Kartik
Kartik le 21 Mar 2023
Hi,
Yes, you can define a default output value for out-of-range inputs in your fuzzy logic system. One way to do this is by adding a new membership function to the input variable that covers the out-of-range region and assigns a fixed output value.
Here's an example of how you could modify your 'rtRatio' input variable to handle out-of-range values:
[Input1]
Name='rtRatio'
Range=[0 1]
NumMFs=6
MF1='eF':'trimf',[0 0 0.08]
MF2='jR':'trimf',[0.15 0.35 0.6]
MF3='eS':'trimf',[0.75 1 1]
MF4='qF':'trimf',[0.002 0.08 0.25]
MF5='qS':'trimf',[0.45 0.7 1]
MF6='outofrange':'trapmf', [1.01 1.05 1.1 1.2], 2
In this example, a new membership function called 'outofrange' has been added to the 'rtRatio' input variable. This membership function is a trapezoidal function that covers the out-of-range region from 1.01 to 1.2 and assigns a fixed output value of 2.
With this modification, if an input value falls within the 'outofrange' membership function, the output value for that input will be fixed at 2, regardless of the fuzzy logic rules.
Note that you can adjust the range and shape of the 'outofrange' membership function to fit your specific needs.
  3 commentaires
Sam Chak
Sam Chak le 22 Mar 2023
@Luca Ferro, can you sketch the shape of the desired MF? It helps to advise you the suitable type of MF for your application.
Luca Ferro
Luca Ferro le 22 Mar 2023
Maybe i'm misunderstanding the code but wouldn't this solution
MF6='outofrange':'trapmf', [1.01 1.05 1.1 1.2], 2
still have a upper bound that can be traspassed? like what would happen if the input is 1.5 (so major than 1.2 of the trapezoid)?
The shape i would like to have is open on the right side.

Connectez-vous pour commenter.

Plus de réponses (1)

Sam Chak
Sam Chak le 22 Mar 2023
Thanks for the sketch. I don't know your desired intervals, but linsmf should be the one that looks like your sketch.
MF6='outofrange':'linsmf', [param(1) param(2)], 2
The function looks like this:
x = 0.5:0.01:3;
y = linsmf(x, [1.0 1.5]);
plot(x, y, 'linewidth', 1.5), grid on
title('Linear Saturation function')
xlabel('linsmf, P = [1.0 1.5]')
ylabel('Membership')
ylim([-0.05 1.05])
  1 commentaire
Luca Ferro
Luca Ferro le 22 Mar 2023
yep that's it. I'll try and update you as soon as possible

Connectez-vous pour commenter.

Catégories

En savoir plus sur Fuzzy Logic in Simulink dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by