Defuzzification methods obtain the representative value of a fuzzy set.
These methods are used in the final stage of the fuzzy inference process, when
it is not possible to work with fuzzy conclusions. The structure of a
defuzzification method definition in a function package is as follows:
defuz identifier { blocks }
|
The blocks that can appear in a defuzzification method definition are alias,
parameter, requires, definedfor, java, ansi_c,
cplusplus and source.
The block alias is used to define alternative names to identify the
method. Any of these identifiers can be used to refer the method. The
syntax of the block alias is:
alias identifier, identifier, ... ;
|
The block parameter allows the definition of those parameters which the
method depends on. Its format is:
parameter identifier, identifier, ... ;
|
The block requires expresses the constraints on the parameter values by
means of a Java Boolean expression that validates the parameter values.
The structure of this block is:
The block definedfor is used to enumerate the types of membership
functions that the method can use as partial conclusions. This block has been
included because some simplified defuzzification methods only work with certain
membership functions. This block is optional. By default, the method is assumed
to work with all the membership functions. The structure of the block is:
definedfor identificador, identificador, ... ;
|
The block source is used to define Java code that is directly included
in the class code generated for the method definition. This code allows to
define local functions that can be used into other blocks. The structure is:
The blocks java, ansi_c and cplusplus describe the
behavior of the method by means of its description as a function body in Java, C
and C++ programming languages, respectively. The format of these blocks is the
following:
java { Java_function_body } |
ansi_c { C_function_body } |
cplusplus { C++_function_body } |
The input variable for these functions is the object 'mf', which
encapsulates the fuzzy set obtained as the conclusion of the inference process.
The code can use the value of the variables 'min', 'max' and
'step', which represent respectively the minimum, maximum and division
of the universe of discourse of the fuzzy set. Conventional defuzzification
methods are based on sweeps along all the values of the universe of discourse,
and they compute the membership degree of each value in the universe. On the
other side, simplified defuzzification methods use sweeps along the partial
conclusions, and they compute the representative value in terms of the
activation degree, center, basis and parameters of these partial conclusions.
The way this information is accessed by the object mf depends on the
programming language, as shown in the next table.
Description |
java |
ansi_c |
cplusplus |
membership degree |
mf.compute(x) |
mf.compute(x) |
mf.compute(x) |
partial conclusions |
mf.conc[] |
mf.conc[] |
mf.conc[] |
number of partial conclusions |
mf.conc.length |
mf.length |
mf.length |
activation degree of the i-th conclusion |
mf.conc[i].degree() |
mf.degree[i] |
mf.conc[i]->degree() |
center of the i-th conclusion |
mf.conc[i].center() |
mf.conc[i].center() |
mf.conc[i]->center() |
basis of the i-th conclusion |
mf.conc[i].basis() |
mf.conc[i].basis() |
mf.conc[i]->basis() |
j-th parameter of the i-th conclusion |
mf.conc[i].param(j) |
mf.conc[i].param(j) |
mf.conc[i]->param(j) |
number of the input variables in the rule base |
mf.input.length |
mf.inputlength |
mf.inputlength |
values of the input variables in the rule base |
mf.input[] |
mf.input[] |
mf.input[] |
The following example shows the definition of the classical CenterOfArea defuzzification method.
defuz CenterOfArea {
alias CenterOfGravity, Centroid;
java {
double num=0, denom=0;
for(double x=min; x<=max; x+=step) {
double m = mf.compute(x);
num += x*m;
denom += m;
}
if(denom==0) return (min+max)/2;
return num/denom;
}
ansi_c {
double x, m, num=0, denom=0;
for(x=min; x<=max; x+=step) {
m = compute(mf,x);
num += x*m;
denom += m;
}
if(denom==0) return (min+max)/2;
return num/denom;
}
cplusplus {
double num=0, denom=0;
for(double x=min; x<=max; x+=step) {
double m = mf.compute(x);
num += x*m;
denom += m;
}
if(denom==0) return (min+max)/2;
return num/denom;
}
}
|
The following example shows the definition of a simplified defuzzification
method (Weighted Fuzzy Mean).
defuz WeightedFuzzyMean {
definedfor triangle, isosceles, trapezoid, bell, rectangle;
java {
double num=0, denom=0;
for(int i=0; i<mf.conc.length; i++) {
num += mf.conc[i].degree()*mf.conc[i].basis()*mf.conc[i].center();
denom += mf.conc[i].degree()*mf.conc[i].basis();
}
if(denom==0) return (min+max)/2;
return num/denom;
}
ansi_c {
double num=0, denom=0;
int i;
for(i=0; i<mf.length; i++) {
num += mf.degree[i]*mf.conc[i].basis()*mf.conc[i].center();
denom += mf.degree[i]*mf.conc[i].basis();
}
if(denom==0) return (min+max)/2;
return num/denom;
}
cplusplus {
double num=0, denom=0;
for(int i=0; i<mf.length; i++) {
num += mf.conc[i]->degree()*mf.conc[i]->basis()*mf.conc[i]->center();
denom += mf.conc[i]->degree()*mf.conc[i]->basis();
}
if(denom==0) return (min+max)/2;
return num/denom;
}
}
|
This final example shows the definition of the 1st order Takagi-Sugeno method.
defuz TakagiSugeno {
definedfor parametric;
java {
double denom=0;
for(int i=0; i<mf.conc.length; i++) denom += mf.conc[i].degree();
if(denom==0) return (min+max)/2;
double num=0;
for(int i=0; i<mf.conc.length; i++) {
double f = mf.conc[i].param(0);
for(int j=0; j<mf.input.length; j++) f += mf.conc[i].param(j+1)*mf.input[j];
num += mf.conc[i].degree()*f;
}
return num/denom;
}
ansi_c {
double f,num=0,denom=0;
int i,j;
for(i=0; i<mf.length; i++) denom += mf.degree[i];
if(denom==0) return (min+max)/2;
for(i=0; i<mf.length; i++) {
f = mf.conc[i].param(0);
for(j=0; j<mf.inputlength; j++) f += mf.conc[i].param(j+1)*mf.input[j];
num += mf.degree[i]*f;
}
return num/denom;
}
cplusplus {
double num=0,denom=0;
for(int i=0; i<mf.length; i++) {
double f = mf.conc[i]->param(0);
for(int j=0; j<mf.inputlength; j++) f += mf.conc[i]->param(j+1)*mf.input[j];
num += mf.conc[i]->degree()*f;
denom += mf.conc[i]->degree();
}
if(denom==0) return (min+max)/2;
return num/denom;
}
}
|
|