Sunteți pe pagina 1din 10

BAB V

Sistem berbasis aturan fuzzy

Pendahuluan

Sistem berbasis aturan fuzzy terdiri dari 3 komponen utama:


 Fuzzification
 Inference
 defuzzification

Pengolahan Fuzzy, Input-Output Crisp


Contoh 1 : Kendali kecepatan fan

Gambarkan fuzzy set untuk pengautran kecepatan fan dengan ketentuan sbb;

If temperature is cool then fan_speed is low


If temperature is moderate then fan_speed is medium
If temperature is hot then fan_speed is high

Program matlab

function out = defuzzy(x, mf, option)


%DEFUZZY Defuzzification of MF.
% DEFUZZY(x, mf, option) returns a representative value of mf
% using different defuzzification strategies:
% option = 1 ---> center of area
% option = 2 ---> bisecter of area
% option = 3 ---> mean of max
x = x(:);
mf = mf(:);
data_n = length(x);

if option == 1,
out = sum(mf.*x)/sum(mf);
elseif option == 2,
total_area = sum(mf);
tmp = 0;
for k=1:data_n,
tmp = tmp + mf(k);
if tmp > total_area/2,
break;
end
end
out = (x(k) + x(k-1))/2;
elseif option == 3,
index = find(mf == max(mf));
out = mean(x(index));
else
error('Unknown defuzzification option!');
end

x=[0:1:120]; %temperatur
y=[0:1:10]; % fan speed

%temperatur
cool_mf=trapmf(x,[0 0 30 50]);
moderate_mf =trimf(x,[30 55 80])
hot_mf=trapmf(x,[60 80 120 120])
antecendent_mf=[cool_mf;moderate_mf;hot_mf];
plot(x,antecendent_mf)
title('cool,moderat and hot temperatur')
xlabel('Temperatur')
ylabel('Membership')
text(25,.8,'Cool')
text(50,.8,'moderate')
text(80,.8,'hot')

cool,moderat and hot temperatur


1

0.9

0.8 Cool moderate hot

0.7

0.6
Membership

0.5

0.4

0.3

0.2

0.1

0
0 20 40 60 80 100 120
Temperatur

%fan speed
low_mf=trapmf(y,[0 0 2 5]);
medium_mf =trapmf(y,[2 4 6 8])
high_mf=trapmf(y,[5 8 10 10])
consequent_mf=[low_mf;medium_mf;high_mf];
plot(y,consequent_mf)
title('Low,Medium and High fan speed')
xlabel('Fan speed')
ylabel('Membership')
text(2,.8,'Low')
text(5,.8,'Medium')
text(8,.8,'High')

Low,Medium and High fan speed


1

0.9

0.8 Low Medium High

0.7

0.6
Membership

0.5

0.4

0.3

0.2

0.1

0
0 1 2 3 4 5 6 7 8 9 10
Fan speed
Jika diinginkan temperatur 720 C , berapakah kecepatan fan ?

temp=72
dof1=cool_mf(find(x==temp))
dof2=moderate_mf(find(x==temp))
dof3=hot_mf(find(x==temp))
DOF=[dof1;dof2;dof3]

DOF =

0
0.3200
0.6000

Proses implikasi

consequent1=min(low_mf,dof1);
consequent2=min(medium_mf,dof2);
consequent3=min(high_mf,dof3);
plot(y,[consequent1;consequent2;consequent3]);
axis([0 10 0 1.0])
title('Consequent Fuzzy set')
xlabel('Fan Speed')
ylabel('Membership')

Consequent Fuzzy set


1

0.9

0.8

0.7

0.6
Membership

0.5

0.4

0.3

0.2

0.1

0
0 1 2 3 4 5 6 7 8 9 10
Fan Speed

Proses agregasi

output_mf=max([consequent1;consequent2;consequent3]);
plot(y,output_mf)
axis([0 10 0 1])
title('Consequent Fuzzy set')
xlabel('Fan Speed')
ylabel('Membership')
%output=centroid(y,output_mf)
output = defuzzy(y, output_mf, 1)
Consequent Fuzzy set
1

0.9

0.8

0.7

0.6
Membership

0.5

0.4

0.3

0.2

0.1

0
0 1 2 3 4 5 6 7 8 9 10
Fan Speed

output =

7.1047

Contoh 2.Sistem kendali temperatur dengan 2 input dan 1 output dengan rule sebagai berikut :

x=[0:5:100]
y=[0:1:10];
z=[0:1:10]
%temperature
cool_mf=trapmf(x,[0 0 30 50]);
moderate_mf=trimf(x,[30 55 80]);
hot_mf=trapmf(x,[60 80 100 100]);
antecendent=[cool_mf;moderate_mf;hot_mf];
plot(x,antecendent)
axis([-inf inf 0 1.2])
title ('antecendent MF for temperature')
text(10, 1.1, 'cool')
text(50, 1.1, 'moderate')
text(90, 1.1, 'hot')
xlabel('temperatur')
ylabel('Membership')
figure

low_act=trapmf(y,[0 0 2 8])
high_act = trapmf(y,[2 8 10 10])
antecendent_a=[low_act;high_act];
plot(y,antecendent_a);
axis([-inf inf 0 1.2]);
title('antecendent MF for activity')
text(1, 1.1, 'Low');text(8, 1.1, 'high')
xlabel('activity Level');ylabel('membership')
figure

%fan speed consequent value


very_low_mf=1;
low_mf=2;
low_medium_mf=4;
medium_mf=6;
medium_high_mf=8;
high_mf=10;
consequent_mf=[very_low_mf;low_mf;low_medium_mf;medium_mf;medium_high_mf;high
_mf]
stem(consequent_mf,ones(size(consequent_mf)));
axis([0 11 0 1.2])
title('consequent value for fan speed');
xlabel('fan speed');
ylabel('membership');
text(.5, 1.1, 'very_low');
text(2.1, .6, 'low');
text(3.5, 1.1, 'low_medium');
text(6.1, 0.6, 'medium');
text(7.5, 1.1, 'medium_high');
text(10.1 , .6,'high');
figure
%temperatur
temp =72.5;
mut1=trapmf(temp,[0 0 30 50]);
mut2=trimf(temp,[30 55 80]);
mut3=trapmf(temp,[60 80 100 100]);
mu_t=[mut1;mut2;mut3]

%activitas
act=6.1;
mua1=trapmf(act,[0 0 2 8]);
mua2=trapmf(act,[ 2 8 10 10]);
mu_a=[mua1;mua2]

DOF1=min([mu_t(1),mu_a(1)]);
DOF2=min([mu_t(1),mu_a(2)]);
DOF3=min([mu_t(2),mu_a(1)])
DOF4=min([mu_t(2),mu_a(2)]);
DOF5=min([mu_t(3),mu_a(1)]);
DOF6=min([mu_t(3),mu_a(2)])
antecendent_DOF=[DOF1;DOF2;DOF3;DOF4;DOF5;DOF6]
stem(consequent_mf,antecendent_DOF)
axis([0 11 0 .7]);
title('consequent firing strength')
xlabel('fan speed');
ylabel('firing strength');
text(0.2, antecendent_DOF(1)+.02,'very_low');
text(1.5, antecendent_DOF(2)+.04,'low');
text(3.0, antecendent_DOF(3)+.02,'low_medium');

text(5.1, antecendent_DOF(4)+.02,'Low_medium');
text(1.5, antecendent_DOF(5)+.02,'medium');
text(3.2, antecendent_DOF(6)+.02,'high');

output_y = sum(antecendent_DOF.*consequent_mf)/ sum(antecendent_DOF)

output_y =

7.6432

antecendent MF for temperature antecendent MF for activity


1.2 1.2
cool moderate hot Low high
1 1

0.8 0.8
Membership

membership

0.6 0.6

0.4 0.4

0.2 0.2

0 0
0 10 20 30 40 50 60 70 80 90 100 0 1 2 3 4 5 6 7 8 9 10
temperatur activity Level

consequent firing strength


0.7
consequent value for fan speed
1.2 high
very low lowmedium mediumhigh 0.6

1
0.5
firing strength

0.8
0.4
membership

medium low edium Lowmedium


0.6 low medium high 0.3 m

0.4 0.2

0.2 0.1

very low low


0 0
0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11
fan speed fan speed

Tugas

1. Sistem kendali kecepatan motor DC dengan persamaan input (error) sebagai


berikut:
Persamaan output (tegangan) adalah:

• Dari penjelasan diatas dapat ditentukan ada 3 aturan pengendalian sebagai


berikut:
• Aturan #1:
• IF error IS negatif THEN teg IS kecil
• Aturan #2:
• IF error IS zero THEN teg IS sedang
• Aturan #3:
• IF error IS positif THEN teg IS besar

Diharapkan dengan aturan tersebut motor akan berputar dengan kecepatan yang stabil pada 270
rpm. Ketika kecepatan motor 285 rpm, dimana lebih besar dari kecepatan yang diinginkan yaitu
260 rpm, berapakah tegangan yang dikeluarkan kontroler agar motor berputar pada kecepatan
normalnya (260 rpm)?
1. Sebuah mesin cuci dengan MF input dan output sebagai berikut:

short medium long

0 20 40 60

Wash-time

MF of Input Variable type_of_dirt MF of Output Variable wash_time

Tentukan waktu yang dibutuhkan jika tipe_of_dirt = 75

2. Sistem kontrol dibawah ini dengan input : suhu udara (0C) dan kelembaban tanah (%).Output
: waktu penyiraman (menit),

Cold Cool normal Warm Hot


1

-10 0 3 12 15 24 27 36 39 50 Suhu (0C)

Dry Moist Wet


1 Short Medium Long
1

0 10 20 40 50 70 Kelembaban (0C) 0 20 28 40 48 90 Waktu penyiraman (menit)

short medium long

0 20 40 60

Durasi penyiraman
Tentukan lamanya waktu penyiraman dengan model mamdani dan sugeno untuk suhu 240C
dengan kelembaban tanah 15 % . Aturan fuzzy untuk sistem kontrol penyiraman air

suhu cold cool normal warm hot

kelembaban
Dry Long long Long Long Long
Moist Long Medium Medium Medium Medium

wet short Short short short short

S-ar putea să vă placă și