-
Notifications
You must be signed in to change notification settings - Fork 1
/
trained_fis_output.m
143 lines (88 loc) · 2.42 KB
/
trained_fis_output.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
function out = trained_fis_output()
end
function P_i_out = P_i(rangeofinputs,inputs,input_data,rule_base,numofinputs,n,m,M,aggmethod,andmethod)
inputs_data_n = input_data(:,n);
rule_m = rule_base(:,m);
denom = 1;
for m = 1 : M
alpha = 1;
for k = 1 : numofinputs
x_k = rangeofinputs{k,1};
inputs_k = inputs{k,1};
stepsize = (max(x_k) - min(x_k))/(size(x_k,2)-1);
impnum = round((inputs_data_n(k,:)-min(x_k)+stepsize)/stepsize);
alpha = AND([alpha;inputs_k(rule_base(k,m),impnum)],andmethod);
end
denom = AGG([denom; alpha],aggmethod);
end
alpha_i = 1;
for k = 1 : numofinputs
x_k = rangeofinputs{k,1};
inputs_k = inputs{k,1};
stepsize = (max(x_k) - min(x_k))/(size(x_k,2)-1);
impnum = round((inputs_data_n(k,:)-min(x_k)+stepsize)/stepsize);
alpha_i = AND([alpha_i;inputs_k(rule_m(k,:),impnum)],andmethod);
end
numerator = alpha_i;
P_i_out = numerator/denom;
end
function out = AND(A,andmethod)
tnorm = ones(1,size(A,2));
if isequal(andmethod, 'min')
for i=1:size(A,1)
tnorm = min(A(i,:),tnorm);
end
elseif isequal(andmethod,'product')
for i=1:size(A,1)
tnorm = A(i,:).*tnorm;
end
else
error('incorrect AND method');
end
out = tnorm;
end
function out = OR(A,ormethod)
snorm = zeros(1,size(A,2));
if isequal(ormethod, 'max')
for i=1:size(A,1)
snorm = max(A(i,:),snorm);
end
elseif isequal(ormethod,'sum')
for i=1:size(A,1)
snorm = A(i,:)+snorm;
end
else
error('incorrect OR method');
end
out = snorm;
end
function out = IMP(A,impmethod)
tnorm = ones(1,size(A,2));
if isequal(impmethod, 'min')
for i=1:size(A,1)
tnorm = min(A(i,:),tnorm);
end
elseif isequal(impmethod,'product')
for i=1:size(A,1)
tnorm = A(i,:).*tnorm;
end
else
error('incorrect IMP method');
end
out = tnorm;
end
function out = AGG(A,aggmethod)
snorm = zeros(1,size(A,2));
if isequal(aggmethod, 'max')
for i=1:size(A,1)
snorm = max(A(i,:),snorm);
end
elseif isequal(aggmethod,'sum')
for i=1:size(A,1)
snorm = A(i,:)+snorm;
end
else
error('incorrect AGG method');
end
out = snorm;
end