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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*!
@file mf.h
@brief membership function
*/
#ifndef LIBA_MF_H
#define LIBA_MF_H
#include "a.h"
/*!
@ingroup liba
@addtogroup a_mf membership function
@{
*/
/*!
@brief enumeration for membership function
*/
enum
{
A_MF_NUL, //!< none
A_MF_GAUSS, //!< gaussian membership function
A_MF_GAUSS2, //!< gaussian combination membership function
A_MF_GBELL, //!< generalized bell-shaped membership function
A_MF_SIG, //!< sigmoidal membership function
A_MF_DSIG, //!< difference between two sigmoidal membership functions
A_MF_PSIG, //!< product of two sigmoidal membership functions
A_MF_TRAP, //!< trapezoidal membership function
A_MF_TRI, //!< triangular membership function
A_MF_LINS, //!< linear s-shaped saturation membership function
A_MF_LINZ, //!< linear z-shaped saturation membership function
A_MF_S, //!< s-shaped membership function
A_MF_Z, //!< z-shaped membership function
A_MF_PI //!< pi-shaped membership function
};
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
/*!
@brief gaussian membership function
\f[
f(x,\sigma,c)=e^{-\frac{(x-c)^2}{2\sigma^2}}
\f]
@param[in] x input value for which to compute membership value.
@param[in] sigma is the standard deviation.
@param[in] c is the mean.
@return membership value.
*/
A_EXTERN a_float a_mf_gauss(a_float x, a_float sigma, a_float c);
/*!
@brief gaussian combination membership function
\f[
f(x,\sigma_1,c_1,\sigma_2,c_2)=\begin{cases}
e^{-\frac{(x-c_1)^2}{2\sigma_1^2}} & x \lt c_1 \\
1 & c_1 \le x \le c_2 \\
e^{-\frac{(x-c_2)^2}{2\sigma_2^2}} & x \gt c_2 \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] sigma1 is the standard deviation of the left gaussian function.
@param[in] c1 is the mean of the left gaussian function.
@param[in] sigma2 is the standard deviation of the right gaussian function.
@param[in] c2 is the mean of the right gaussian function.
@return membership value.
*/
A_EXTERN a_float a_mf_gauss2(a_float x, a_float sigma1, a_float c1, a_float sigma2, a_float c2);
/*!
@brief generalized bell-shaped membership function
\f[
f(x,a,b,c)=\frac{1}{1+\left|\frac{x-c}{a}\right|^{2b}}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines the width of the membership function, where a larger value creates a wider membership function.
@param[in] b defines the shape of the curve on either side of the central plateau, where a larger value creates a more steep transition.
@param[in] c defines the center of the membership function.
@return membership value.
*/
A_EXTERN a_float a_mf_gbell(a_float x, a_float a, a_float b, a_float c);
/*!
@brief sigmoidal membership function
\f[
f(x,a,c)=\frac{1}{1+e^{-a(x-c)}}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines the width of the transition area.
@param[in] c defines the center of the transition area.
@return membership value.
*/
A_EXTERN a_float a_mf_sig(a_float x, a_float a, a_float c);
/*!
@brief difference between two sigmoidal membership functions
\f[
f(x,a_1,c_1,a_2,c_2)=\frac{1}{1+e^{-a_1(x-c_1)}}-\frac{1}{1+e^{-a_2(x-c_2)}}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a1 defines the width of the first transition area.
@param[in] c1 defines the center of the first transition area.
@param[in] a2 defines the width of the second transition area.
@param[in] c2 defines the center of the second transition area.
@return membership value.
*/
A_EXTERN a_float a_mf_dsig(a_float x, a_float a1, a_float c1, a_float a2, a_float c2);
/*!
@brief product of two sigmoidal membership functions
\f[
f(x,a_1,c_1,a_2,c_2)=\frac{1}{1+e^{-a_1(x-c_1)}}\times\frac{1}{1+e^{-a_2(x-c_2)}}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a1 defines the width of the first transition area.
@param[in] c1 defines the center of the first transition area.
@param[in] a2 defines the width of the second transition area.
@param[in] c2 defines the center of the second transition area.
@return membership value.
*/
A_EXTERN a_float a_mf_psig(a_float x, a_float a1, a_float c1, a_float a2, a_float c2);
/*!
@brief trapezoidal membership function
\f[
f(x,a,b,c,d)=\begin{cases}
0 & x \le a \\
\frac{x-a}{b-a} & a \le x \le b \\
1 & b \le x \le c \\
\frac{d-x}{d-c} & c \le x \le d \\
0 & x \ge d \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines its left foot.
@param[in] b defines its left shoulder.
@param[in] c defines its right shoulder.
@param[in] d defines its right foot.
@return membership value.
*/
A_EXTERN a_float a_mf_trap(a_float x, a_float a, a_float b, a_float c, a_float d);
/*!
@brief triangular membership function
\f[
f(x,a,b)=\begin{cases}
0 & x \le a \\
\frac{x-a}{b-a} & a \le x \le b \\
\frac{c-x}{c-b} & b \le x \le c \\
0 & x \ge c \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines its left foot.
@param[in] b defines its peak.
@param[in] c defines its right foot.
@return membership value.
*/
A_EXTERN a_float a_mf_tri(a_float x, a_float a, a_float b, a_float c);
/*!
@brief linear s-shaped saturation membership function
\f[
f(x,a,b)=\begin{cases}
0 & x \lt a \\
\frac{x-a}{b-a} & a \le x \le b \\
1 & x \gt b \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines its foot.
@param[in] b defines its shoulder.
@return membership value.
*/
A_EXTERN a_float a_mf_lins(a_float x, a_float a, a_float b);
/*!
@brief linear z-shaped saturation membership function
\f[
f(x,a,b)=\begin{cases}
1 & x \lt a \\
\frac{b-x}{b-a} & a \le x \le b \\
0 & x \gt b \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines its shoulder.
@param[in] b defines its foot.
@return membership value.
*/
A_EXTERN a_float a_mf_linz(a_float x, a_float a, a_float b);
/*!
@brief s-shaped membership function
\f[
f(x,a,b)=\begin{cases}
0 & x \le a \\
2(\frac{x-a}{b-a})^2 & a \le x \le \frac{a+b}{2} \\
1-2(\frac{b-x}{b-a})^2 & \frac{a+b}{2} \le x \le b \\
1 & x \ge b \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines its foot.
@param[in] b defines its shoulder.
@return membership value.
*/
A_EXTERN a_float a_mf_s(a_float x, a_float a, a_float b);
/*!
@brief z-shaped membership function
\f[
f(x,a,b)=\begin{cases}
1 & x \le a \\
1-2(\frac{x-a}{b-a})^2 & a \le x \le \frac{a+b}{2} \\
2(\frac{b-x}{b-a})^2 & \frac{a+b}{2} \le x \le b \\
0 & x \ge b \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines its shoulder.
@param[in] b defines its foot.
@return membership value.
*/
A_EXTERN a_float a_mf_z(a_float x, a_float a, a_float b);
/*!
@brief pi-shaped membership function
\f[
f(x,a,b,c,d)=\begin{cases}
0 & x \le a \\
2(\frac{x-a}{b-a})^2 & a \le x \le \frac{a+b}{2} \\
1-2(\frac{b-x}{b-a})^2 & \frac{a+b}{2} \le x \le b \\
1 & b \le x \le c \\
1-2(\frac{x-c}{d-c})^2 & c \le x \le \frac{c+d}{2} \\
2(\frac{d-x}{d-c})^2 & \frac{c+d}{2} \le x \le d \\
1 & x \ge d \\
\end{cases}
\f]
@param[in] x input value for which to compute membership value.
@param[in] a defines its left foot.
@param[in] b defines its left shoulder.
@param[in] c defines its right shoulder.
@param[in] d defines its right foot.
@return membership value.
*/
A_EXTERN a_float a_mf_pi(a_float x, a_float a, a_float b, a_float c, a_float d);
/*!
@brief membership function
@param[in] e enumeration for membership function
| | |
| :---------------- | -------------------------------------- |
| \ref A_MF_GAUSS | a_mf_gauss(x, sigma, c) |
| \ref A_MF_GAUSS2 | a_mf_gauss2(x, sigma1, c1, sigma2, c2) |
| \ref A_MF_GBELL | a_mf_gbell(x, a, b, c) |
| \ref A_MF_SIG | a_mf_sig(x, a, c) |
| \ref A_MF_DSIG | a_mf_dsig(x, a1, c1, a2, c2) |
| \ref A_MF_PSIG | a_mf_psig(x, a1, c1, a2, c2) |
| \ref A_MF_TRAP | a_mf_trap(x, a, b, c, d) |
| \ref A_MF_TRI | a_mf_tri(x, a, b, c) |
| \ref A_MF_LINS | a_mf_lins(x, a, b) |
| \ref A_MF_LINZ | a_mf_linz(x, a, b) |
| \ref A_MF_S | a_mf_s(x, a, b) |
| \ref A_MF_Z | a_mf_z(x, a, b) |
| \ref A_MF_PI | a_mf_pi(x, a, b, c, d) |
@param[in] x input value for which to compute membership value.
@param[in] a is an array that stores parameters.
@arg \b a[2] \ref a_mf_gauss \ref a_mf_sig \ref a_mf_lins \ref a_mf_linz \ref a_mf_s \ref a_mf_z
@arg \b a[3] \ref a_mf_gbell \ref a_mf_tri
@arg \b a[4] \ref a_mf_gauss2 \ref a_mf_dsig \ref a_mf_psig \ref a_mf_trap \ref a_mf_pi
@return membership value.
*/
A_EXTERN a_float a_mf(unsigned int e, a_float x, a_float const *a);
#if defined(__cplusplus)
} /* extern "C" */
#endif /* __cplusplus */
/*! @} a_mf */
#endif /* a/mf.h */