-
Notifications
You must be signed in to change notification settings - Fork 6
/
generateTriangleFuzzyRulesUsingCoverage.m
47 lines (44 loc) · 1.74 KB
/
generateTriangleFuzzyRulesUsingCoverage.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
fprintf('Generating Triangle Fuzzy Rules Using Coverage\n');
trainInputShuffled = trainInput;
mf = [];
if nDimensions == 1
% Create a rule for first data
mf = fismf('trimf',[trainInputShuffled(1)-ruleSigma trainInputShuffled(1) trainInputShuffled(1)+ruleSigma]);
for ii = 2:nData
% Check Coverage
membershipValue = evalmf(mf,trainInputShuffled(ii));
membershipValueSUM = sum(membershipValue);
if membershipValueSUM < coverageThreshold
% Create new Rule
mf = [mf ; fismf('trimf',[trainInputShuffled(ii)-ruleSigma trainInputShuffled(ii) trainInputShuffled(ii)+ruleSigma])];
end
end
elseif nDimensions > 1
% Create a rule for first data
for ii = 1:nDimensions
mf = [mf fismf('trimf',[trainInputShuffled(1,ii)-ruleSigma trainInputShuffled(1,ii) trainInputShuffled(1,ii)+ruleSigma])];
end
for ii = 2:nData
if mod(ii,500) == 0
ii
end
% Check Coverage
membershipValue = [];
for jj = 1:nDimensions
membershipValue = [membershipValue evalmf(mf(:,jj),trainInputShuffled(ii,jj))];
end
membershipValueProduct = 1;
for jj = 1:nDimensions
membershipValueProduct = membershipValueProduct .* membershipValue(:,jj);
end
membershipValueSUM = sum(membershipValueProduct);
if membershipValueSUM < coverageThreshold
% Create new Rule
newRuleMf = [];
for jj = 1:nDimensions
newRuleMf = [newRuleMf fismf('trimf',[trainInputShuffled(ii,jj)-ruleSigma trainInputShuffled(ii,jj) trainInputShuffled(ii,jj)+ruleSigma])];
end
mf = [mf ; newRuleMf];
end
end
end