Fuzzy logic rule for out of range

9 次查看(过去 30 天)
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 个评论
Luca Ferro
Luca Ferro 2023-2-9
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

请先登录,再进行评论。

采纳的回答

Kartik
Kartik 2023-3-21
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 个评论
Sam Chak
Sam Chak 2023-3-22
@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 2023-3-22
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.

请先登录,再进行评论。

更多回答(1 个)

Sam Chak
Sam Chak 2023-3-22
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])

类别

Help CenterFile Exchange 中查找有关 Fuzzy Logic in Simulink 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by