A fuzzy system is an universal approximator
A fuzzy rule-base system, FRBS = (ab, R, T, S, DEF), is a family of fuzzy systems with membership functions ab a fuzzy rule base R, the t-norm, for fuzzy aggregation T (i.e. operations within one rule), the s-norm for fuzzy composition S (i.e. operations among rules), and the defuzzification method DEF. Defuzzification consists of the conversion of the fuzzy output into a single crisp output.
Any given fuzzy system FS FRBS is a universal approximator according to a theorem. Let the fuzzy rule-based system FRBS be the set of all fuzzy systems FS and f: U Rn R be a continuous function defined on a universe of discourse U. For each > 0, there exists a FSe FRBS such that
sup { f(x) - FSe(x) , x U }
Defuzzification
Process that converts a fuzzy set or fuzzy number into a crisp value or number
Defuzzification is such inverse transformation which maps the output from the fuzzy domain back into the crisp domain. The following defuzzification methods are of practical importance:
• Center-of-Area (C-o-A)
• Center-of-Maximum (C-o-M)
• Mean-of-Maximum (M-o-M)
The Center-of-Area method is often referred to as the Center-of-Gravity method because it computes the centroid of the composite area representing the output fuzzy term.
Figure shows the membership functions of a linguistic output variable MotorPower where the areas of ZE and PM are combined by the union operator and thus their contour becomes the composite fuzzy output for MotorPower. C-o-A defuzzification method computes the centroid of this area
N
iiOUT
N
iiOUTi
u
uuu
1
1*
The Center-of-Maximum requires only the peaks of the membership functions. Defuzzified value is determined by finding the fulcrum where the weights are balanced. This method is also called by Height-Method
The crisp output is computed as a weighted mean of the term membership maxima, weighted by the inference results.
Equations are very similar, except that for C-O-A it is used the areas of each membership functions. For C-O-M it is used only their maxima. Naturally the results are slightly different.
N
i
n
kikO
N
i
n
kikOi
u
uuu
1 1,
1 1,
*
The Mean-of-Maxima is used when the maxima of the membership functions are not unique, one can then take the mean of all maxima. Max (I) is the inferred fuzzy output term with the highest degree of
truth and M is the integer number of such peaks.
M
m
m
M
uu
1
*
It may be desirable to leave out the boundaries of the control inference membership function. Hence, the set over which the defuzzification is performed is only an -cut in which the is the threshold value.
The idea here is to try to make defuzzification insensitive to multimodal fuzzy output inference.
Height method is a good choice when using triangular or trapezoidal functions. However, the Gaussian membership functions have a couple of important properties:1. produces smooth mapping2. universal approximation property can be easily proven3. central limit theorem: usually data distributions tend to be normal which can be approximated well by Gaussian basis functions• Recommended to use Center of Area
Criteria for comparison:• Continuity• Disambiguity (producing a crisp output for every combination of output
membership functions• Plausibility (output lies approximately in the middle of support and has
a high degree of membership)• Computational complexity• Weight counting (weight information is not lost)
Which defuzzification method for what application? Closed-loop control: continuity is important because jumps in the
controller output can cause instabilities and oscillations. Pattern recognition: can use M-o-M defuzzification, because if one
wishes to identify objects by classification based on the most plausible result yielding the similarity of the signal to the standard objects.
Decision support: the choice of defuzzification technique depends on the context of the decision. Quantitative decisions can use C-o-M while M-o-M is recommended for qualitative decisions.
FUZZY CONTROL SYSTEM
A Fuzzy Control System consists of four blocks:
IN P U TO U T P U TD E C I S IO N
M A K I N GL O G I C
F U Z Z IF IC AT IO N D E F U Z Z IF IC AT IO N
K N O W L E D G EB A S E
Six steps for creation and execution of a rule based fuzzy system
1. Identify the inputs and their ranges and name them.
2. Identify the outputs and their ranges and name them.
3. Create the fuzzy partitions (degree of fuzzy membership function) for each input and output.
4. Construct the rule base that the system will operate under
5. Decide how the action will be executed by assigning strengths to the rules
6. Combine the rules and defuzzify the output.
A seven rules fuzzy system to output an action for an inverted pendulum
Where the fuzzy sets come from ?
Polling: The question “Do you agree that x is A?” is stated to different individuals.• An average is taken to construct the membership
function. Answers are typically yes/no type. Direct rating: “How A is x?” This approach
supposes that the fuzziness arises from individual subjective vagueness.• The person is made to classify an object over and over
again in time in such a way that it is hard for he/she to remember the past answers.
• The membership function is constructed by estimating the density function.
Reverse rating: The question “Identify x which is A to the degree A( x)” is stated to an individual or a group of individuals. • Responses are recorded and normally distributed distributions are
formed (mean and variance are estimated). Interval estimation: The person is asked to give an interval that
describes best the access of x. This is suited to random set -view of membership functions.• Membership exemplification: “To what degree x is A?” Person
may be told to draw a membership function that best describes A. Pairwise comparison: “Which is a better example of A, x1 or x2
and by how much?” • The results of comparisons could be used to fill a matrix of relative
weights and the membership function is found by taking the components of the eigenvector corresponding to the maximum eigenvalue
Clustering methods: Membership functions are constructed given a set of data.• Euclidean norm is used to form clusters on data.
Neurofuzzy techniques: Neural networks are used to construct membership functions.• An essential part of forming membership functions is the input
space partitioning.A grid, which is fixed beforehand and it does not change later. Set to some “initial value” and tuned.
• Fuzzy clusters are best suited for classification problems, because they implement a similarity measure.
Genetic algorithm techniques:• Evolutionary approach to optimize the cluster of data into fuzzy
sets
Example of Fuzzy ControllerAir – Conditioning System
BL
AS
TFA
ST
ME
DIU
MS
LO
WS
TO
P
Mot
or S
pee
d (
RP
M)
100
9080
7060
5040
3020
100
C O L D C O O L G O O D W A R M H O T
Tem p e r a tu re ( C )o
11 o 1 4 o 1 7 o 2 0 o 2 3 o 2 6 o 3 2 o2 9 o8 o
1.0
1 .0
IF C O L D ,T H E NS T O P
IF C O O L ,T H E NS L O W
IF G O O D ,T H E NM E D IU M
IF W A R M ,T H E NFA S T
IF H O T,T H E NB L A S T
Rules for the Air-Conditioning System
Rule 1
If temperature is cold then stop motor, vent is downward
Rule 2
If temperature is cool then motor speed is slow, vent is downward
Rule 3
If temperature is comfortable then motor speed is medium, vent is horizontal
Rule 4
If temperature is warm then motor speed is fast, vent is upward
Rule 5
If temperature is hot then blast motor speed, vent is upward
Fuzzy Inference RelatingMotor Speed and Vent
Angle For Temperature Input
Implementing Fuzzy Controllers
Can be either implemented in hardware or software
There are many degrees of freedom inherent to fuzzy system design, requiring a great deal regarding trial-and-error and the availability of easy ways to select different fuzzification and defuzzification schemes. Such flexibility suggests the use of software.
Development of Fuzzy Controller with Matlab
.m programs are useful to translate the implementation in other languages (C) and to have the feeling in how to implement
FIS Editor displays high-level information about a Fuzzy Inference System. At the top is a diagram of the system with each input and output clearly labeled. By double-clicking on the input or output boxes, you can bring up the Membership Function Editor. Double-clicking on the fuzzy rule box in the center of the diagram will bring up the Rule Editor.
The following program is an implementation in MatLab® of a fuzzy controller with the following characteristics:• Rule based fuzzy controller• It supports any number of inputs, limited only by the
processing capability of your computer and Matlab• It supports any number of outputs, limited only by the
processing capability of your computer and Matlab• Any input and output can have any number of triangular
membership functions. Each input or output may have different number of membership functions
• You can defuzzify either by the height method or by computing the center of gravity
Flowchart
Input Users Data
Rules Com putation
Defuzzification
Data O utput
Exit Execution
Controller Definition
Initialize execution
Screen Output Data
Fuzzification
Keyboard Data Input
Inputs and Outputs Definition
1
E x a m p le o f o n e v a ria b le w ith3 m e m b e rsh ip fu n c tio n s
U n iv e rs e o f d isc o u rse
1
E x a m p le o f o n e v a ria b le w ith5 m e m b e rsh ip fu n c tio n s
U n iv e rs e o f d isc o u rse
2112
2211_
1021
0212r _ e
4n r
s 2 )( s 1 ,t sn a m e _ o u t p u
v a r 2 )( v a r 1 ,sn a m e _ i n p u t
2n s
2n e
sr
e
Rule 1: IF var1 = Big and var2 = Small Then s1 = Big
Rule 2: IF var2 = Small Then s2 = B ig
Fuzzification
Rules Evaluation The rules were generated by the vectors r_e e r_s . For rules
evaluation, the following procedure is made: An auxiliary vector is used “aux” with ne (number of inputs)
elements equal to “1”. For each input variable it is verified if that variable (j)
participate for the antecedent of that rule, if that is positive, the element aux(j) is attributed the fuzzified input value correspondent to the membership function of that rule condition.
The truth value of the rule is the minimum value of aux and it is stored into the matrix output_aux((i,j,k) where the i indicates which is the output number, j indicates which is the membership function and k indicates the rule number.
The final output matrix is the maximum value of each input membership function evaluation
Defuzzification
Height Method
Center of Gravity
ns
1j
ns
1j
j)output(i,
1)-(nps(i)
1)-(j*j),((output(i
is )(
8
1*
1
2
1*
1
)(
1-nps(i)
1)]joutput(i,j),output(i,min([0.5,*2-1-
1-nps(i)j)a(i,double_are
1-nps(i)
j)output(i,-1-
1-nps(i)j)area(i,
j)a(i,double_arej)area(i,
1)-(nps(i)
1
1)-(nps(i)
1)-(jj)*a(i,double_are
1)-(nps(i)
1)-(jj)*area(i,
is
2
2
ns
1j
ns
1j
ns
1j
ns
1j
Two cases are presented Case 1: 2 inputs were considered, one with 2 membership
functions within an universe of discourse between 5 and 50, and another with three membership functions within an universe of discourse between 0 and 1. 2 outputs were considered, one with 2 membership functions within an universe of discourse between 1 and 10, and another with 3 membership functions within an universe of discourse between 4 and 20.
Case 2: The efficiency of fuel consumption for a car can be described linguistically. It depends on the car velocity, air dragging, thermal cycle.
The file case1.m shows the Matlab implementation for this fuzzy modeling
Simulation for Case 1
What is the variable_1 (5.0<x<50.0)? 45
What is the variable_2 (0.0<x<1.0)? 0.8
Defuzzification results with height method
The variable_3 is : 6.4
The variable_4 is : 10.56
Defuzzification results with center of gravity method
The variable_3 is : 5.944
The variable_4 is : 11.206
Simulation for Case 1
What is the variable_1 (5.0<x<50.0)? 23
What is the variable_2 (0.0<x<1.0)? 0.2
Defuzzification results with height method
The variable_3 is : 4.6
The variable_4 is : 10.8571
Defuzzification results with center of gravity method
The variable_3 is : 5.056
The variable_4 is : 11.3363
Evaluation of fuel consumption
Efficiency of fuel consumption for a car can be described linguistically. For small velocity the car takes too much fuel for the thermal cycle itself, since the RPM is
not optimized As your RPM is optimized and the speed increases the air-dragging adds friction There is an intermediate optimal speed point
The car velocity is divided into three fuzzy sets as below (Small, Medium and High)
0 10 20 30 40 50 60 70 80 90 1000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1FUNCOES DE PERTINENCIA - (OP OM OG)
SA
IDA
UNIVERSO DE DISCURSO
0 10 20 30 40 50 60 70 80 90 10010
20
30
40
50
60
70
80
90Consumo x Velocidade
Con
sum
o
Velocidade
Figure below shows the fuel consumption on the left side depicted in from the linguistic description of the car velocity.
The Rules are:
1. If Vel is Small Then Consumption is High
2. If Vel is Medium Then Consumption is Low
3. If Vel is High Then Consumption is Medium
L ow
M ediu m H igh
M ediu m L o w
M ediu m
L arge
Con
sum
pti
on
M ediu m
C a r ve lo city
10 km/h 40 km/h 80 km/h60 km/h
The file case2.m shows the Matlab implementation for this fuzzy modeling
Development of fuzzy coding can be easily done by using a Shell Environment. There are several companies with visual based development platforms, Togai, FuzzyTech, FIDE, just to name a few.
• Real-time on-line debugging and tuning of rules, membership functions and rule weights, including addition and deletion of rules
• Graphical object-based "point and click" CASE tool
• User-defined inference methods
• Color rulebase and operator visualization tools
• Fully integrated graphical simulation of fuzzy systems and conventional methods
• ANSI and Keil C code generation from the Fuzzy-C compiler
Those environments make provisions for the following:
• Reduction of programming efforts
• Fast prototyping
• Availability of several options regarding several degrees of freedom( typical of a fuzzy systems)
• Visual feedback for assessing fuzzy controller modifications
Project Editor: Defining the control structure
“Spreadsheet Editor”: Defining the rule base
Membership editor: Graphically defining the membership functions
Various types of defuzzification methods can be selected
1 5 3 0 5 5 8 0
0
0 .2
0 .4
0 .6
1
0 .8
0
0 .2
0 .4
0 .6
1
0 .8
5 0 % 1 0 0 %0 %5 1 00
0
0 .2
0 .4
0 .6
1
0 .8
PRESSURE TEM PERATUREVALVE
SETTIN G
The reason for using the fuzzy software development system described in the foregoing is to tune the initial fuzzy design. This requires many iterations involving modifications of both the rules and the membership functions. By using the Interactive Debug option the designer can immediately visualize the effect of each of such changes, thus he knows whether or not a particular change has caused an improvement in system response. This visual feedback is essential for fuzzy system design.
The Interactive Debug window, provides for entries for both inputs and displays the current output as determined by the current fuzzy controller. If the displayed value is incorrect, the designer can make modifications in the rules, or the degree of support of the rules, or the membership functions interactively, until the displayed output matches with the output value required for the specific input combinations entered. By monitoring the three-dimensional control surface the designer can also change the fuzzy inference structure from max-min to another type provided by the software package. For example, a smoother response with no creases or abrupt jumps of the control surface can be obtained by using max-product type fuzzy inference.
Fuzzy Controllers in Industrial Environment
Industrial electronics use PID control,implemented by embedded system or PLC programming
PID control works well for linear processes PID control has poor performance in non-linear
processes Fairly complex systems usually need human control
operators for operation and supervision
Fuzzy Controllers
PID fuzzy control can implement a single feedback loop
A supervisory control can be implemented with fuzzy rules to control the operation of standard PID controllers running on every loop
Let us understand the dynamics
of a controller
1 .2
1 .0
0 .8
0 .6
0 .4
0 .2
0 .0
0 5 1 0 1 5 2 0 2 5
b (6)2 b (10)3
a (1 )1
a (9 )3a (5 )2
c (3 )1
c (11)3
c (7 )2
b (2)1 d (4)1
d (12)3
d (8)2
Seco
nd
-ord
er
syst
em o
utp
ut
R e fe re n c eL e v e l
T im e (se c )
-5 -4 -3 -2 -1 0 1 2 3 4 5 PB 0 0 0 0 0 0 0 0.1 0.4 0.7 1 PM 0 0 0 0 0 0.1 0.4 0.7 1 0.7 0.4 PS 0 0 0 0.1 0.4 0.7 1 0.7 0.4 0.1 0 AZ 0 0 0.1 0.4 0.7 1 0.7 0.4 0.1 0 0 NS 0 0.1 0.4 0.7 1 0.7 0.4 0,1 0 0 0 NM 0.4 0.7 1 0.7 0.4 0.1 0 0 0 0 0 NB 1 0.7 0.4 0.1 0 0 0 0 0 0 0
E \ E NB NM NS AZ PS PM PB NB NB(3) NM NM(7) NS PM(17) AZ(19) NS(11) NS(10) NM(16) NB(2) AZ PB(4) PM(8) PS(12) AZ(13) AZ(18) NM(15) PS PS(9) PM PM(5) PB PB(1) PM(14)
Fuzzy – PI ControllerE
CE NVL NL NM NS ZE PS PM PL PVL
NVL NVL NL NM NS ZENL NL NM NS ZE PSNM NL NM NS ZE PS PMNS NL NM NS ZE PS PM PLZE NL NM NS ZE PS PM PLPS NL NM NS ZE PS PM PLPM NM NS ZE PS PM PLPL NS ZE PS PM PLPVL ZE PS PM PL PVL
Rule Table
Block Diagram
K T
r (p u )
r
r* Er
K C E
K E
rrr (p u )
F U Z Z Y
C O N T R O L
e*
Te*
i*q s (p u )
Z - 1
+
+
Z - 1
+ +
Supervising a multi-loop PID industrial process
S U P E RV IS O R YF U Z Z Y
C O N T R O L L E R
P ID
P ID
P ID
P L A N TO U T P U T SP R O C E S S
O b se rv a b lev a r ia b le s
C o n tro lVa ria b le s
Fuzzy Decision Support Algorithm