Anda di halaman 1dari 5

2008 IEEE Pacific-Asia Workshop on Computational Intelligence and Industrial Application

Automatic Fuzzy Membership Function Tuning Using the Particle Swarm


Optimisation
Gu Fang1, Ngai Ming Kwok2 and Quang Ha2
1
School of Engineering
University of Western Sydney, NSW 1797 Australia
2
Faculty of Engineering, University of Technology, Sydney
Broadway, NSW 2007, Australia
g.fang@uws.edu.au, {nmkwok, quang.ha}@eng.uts.edu.au
[7]

. Due to its simplicity in implementation, PSO has


gained popularities in engineering applications, such as in
image processing [8] and in system modelling [9]. A
number of publications have also been reported in using
PSO to automatically tune the FLC parameters [10] - [13].
These publications are focused on tuning the parameters
involved in the TS-type fuzzy controllers. In general, the
PSO is used to perform the learning tasks that are usually
associated with the NN in the TS FLC. A PSO based
fuzzy MF tuning method is also introduced to a fixed
point control problem, i.e. parking a car into a predefined
garage location [14], [15].
Although there are research results in the area of
automatic fuzzy MF tuning, most of them are in the area
of TS type of fuzzy controllers. To the best of our
knowledge, there is no report on using PSO for the
Mamdani-type of fuzzy controller MF tuning.
Furthermore, the problem addressed there is not a tracking
control problem.
In this paper, we have used the PSO to automatically
adjust the MFs of a Mamadani-type fuzzy controller in
performing tracking control. In particular, we are using
the proposed FLC to control the water levels of a
nonlinear water tank system.
This paper is organized as follows: section 2 briefly
explains the PSO method and how it can be used in the
fuzzy MF tuning process. In section 3, the simulation
setup and control results are shown to demonstrate the
effectiveness of the proposed MF tuning method.
Discussions are given in section 4 where further
comparisons between the proposed FLC controller and a
PSO tuned PID controller are given. Conclusions are then
provided in section 5.

Abstract
Fuzzy logic controllers (FLCs) are developed to
exploit human expert knowledge in designing control
systems. While the fuzzy rules are relatively easy to
obtain, fuzzy membership function (MF) tuning could be a
time consuming exercise. In this paper the particle
swarm optimization technique is employed to
automatically tune the MFs of a Mamdani-type of fuzzy
controller. The effectiveness of the proposed controller is
demonstrated by the control performance of such an FLC
of a nonlinear water tank system. The results are
compared favourably to a PSO tuned PID controller.

1. Introduction
Fuzzy logic controllers (FLCs) are developed to utilise
human expert knowledge in controlling various systems,
in particular those ill-defined and nonlinear systems [1]. It
is well known that while fuzzy rules are relatively easy to
derive from human experts, the fuzzy membership
functions (MFs) are difficult to obtain. Tuning of MFs is
a time consuming and often frustrating exercise.
To overcome these difficulties various techniques have
been reported to automate the tuning process of MFs. An
adaptive network based fuzzy inference system (ANFIS)
was introduced [2], where an adaptive neural network (NN)
was used to learn the mapping between the inputs and
outputs and a Sugeno-type of fuzzy system could be
generated based on the neural network. A quantum NN
was also used to learn the data space of a Tagaki-Sugeno
(TSK) fuzzy controller [3].
Genetic algorithm (GA) has been used in the automatic
design of fuzzy controllers [4] [5] in the areas of mobile
robotics. GA has been used in tuning both the fuzzy MFs
and the fuzzy rule bases.
The particle swarm optimization (PSO) was inspired
by the natural behaviour of animals in forming swarms [6],
978-0-7695-3490-9/08 $25.00 2008 IEEE
DOI 10.1109/PACIIA.2008.105

2. Autonomous fuzzy MF tuning using a PSO


2.1. Particle swarm optimisation (PSO)

324

PSO is a non-parametric optimisation method


introduced by Kennedy [6] [7]. It is inspired by the
formation of swarms by animals such as birds and fish.
The principle behind PSO is that each individual in the
swarm, called a particle, will move towards the best
performing particle (leader) in the swarm while exploring
the best experience each particle has.
In particular, the velocity associated with each particle
(total of N particles) i, (i=1, 2, , N) at time k+1 in PSO
is calculated as:
vi (k 1) vi (k ) 1 ( x g xi (k ))
(1)
2 ( xip xi ( k ))
where is the momentum or inertia factor of the
particle, vi(k) is the velocity of the particle i at time step k,
xg is the global best performing particle up to time step k
in the entire population, xip is the best experience particle i
has had up to time step k. xi(k) is the current location of
particle i. 1 and 2 are random weighting factors that
decides the influences of global best xg and personal
best xip particle to the movement of particle i. In general,
these weighting factors 1 and 2 are chosen according to
a uniform probability distribution function and
To limit the
1 min 1 1 max , 2 min 2 2 max .
searching space, vi(k+1) is limited to be within a certain
range of vi min vi vi max
The new location of particle i can be calculated as:
xi ( k 1) xi ( k ) vi ( k 1)
(2)
The evaluation of the particle performance is based on
a problem specific objective function that decides the
closeness of the particle to the optimal solution. For
instance, if it is a problem that requires the minimisation
of function f (x( k )) , then the global best performing
particle will be decided on the basis of
min f ( x ( )) , where
(3)
1, 2, ..., k .

Figure 1. A typical set of MFs in an FLC.

There are two types of expressions for consequent C.


In Tagaki-Sugeno (TS)-type FLCs, the C is expressed as a
linear combination of all inputs. On the other hand, if a
Mamdani-type of FLC is used, C is expressed by a set of
MFs.
The process that is used to calculate the overall control
action in FLC is determined by different type of
defuzzification process. In general, a Centre of Area
(CoA) method is commonly used, where the output u* is
calculated as:
u

um (u)du
m (u)du
O

(6)

In (6), u is the output variable, O is the output fuzzy set


and mO is the MF of the output fuzzy set.
In general, fuzzy rules expressed in (5) are relatively
easier to obtain from expert knowledge. However, the
MF design which involves the determination of where in
the variable space each membership function should
locate is a time consuming process.
It can be seen in Figure 1, the Gaussian type MFs are
determined by parameters such as the mean and deviation
values of each MF. For other types of MFs, such as
triangular or trapezoidal MFs, there are similar parameters
that determine the shapes of the MFs. Therefore, it is
possible to use PSO as a global optimisation search
method to find a set of such parameters that will produce
the best control performance of the FLC.
The strategy of using a PSO for MF tuning in FLC is
depicted in Figure 2. In the proposed PSO process, each
particle is formed to represent the MF parameters of the
FLCs inputs and outputs. As the purpose of the PSO is
to minimise the control error of the FLC, the objective
function of PSO is defined as:

xg

In (3), x is a vector that represents N particles in the


swarm. Similarly, the personal best experience of
particle i is determined by:
min
f ( xi ( )) , where 1, 2, ..., k .
(4)
p
xi

tf

2.2. PSO for fuzzy MF tuning

f ( x( k )) 2

(7)

t 0

Fuzzy logic controllers (FLCs) are designed based on


expert knowledge that is in the form of rule-based
behaviour. In general the FLC rules are expressed in the
form:
if input 1 is A and input 2 is B then output is C (5)
where antecedents A and B are expressed by
membership functions (MFs). A typical set of MFs are
depicted in Figure 1.

where tf is the total running time of the FLC, is the


control error.
PSO

Reference
input

Control
error

FLC

Plant

Figure 2. The proposed PSO MF tuning method.

325

3. Simulation Results
3.1. A water tank system
To demonstrate the effectiveness of the proposed PSO
MF tuning method, a nonlinear system is used in
simulation. In particular, the system used is a water tank
level control system. The water tank system is shown in
Figure 3.

Figure 4. The initial MFs for the FLC inputs.

The initial MFs for the output of the FLC is shown in


Figure 5.

Inlet control valve

Qin
D1

Figure 5. The initial MFs of the FLC output.

h
h1

The 5 control rules used in the FLC are:


1. If (level is okay) then (valve is no_change)
2. If (level is low) then (valve is open_fast)

D2

Figure 3. A Water tank system.

3. If (level is high) then (valve is close_fast)


4. If (level is okay) and (rate is positive) then (valve is close_slow)

The dynamic equation of such a system can be


expressed as:
dh
(8)
(Qin Cout h ) / A
dt
where h is the water level of the tank system, Qin is the
input flow-rate to the tank, Cout is the outflow pipe
constant of the tank and A is the cross-section area of the
tank. D1 and D2 are the diameters of the water tank at
different heights above or below h1. As there is a certain
pipe volume (v), between the inlet control valve and the
water entry point to the tank, a time delay is also present
in the controlled system.
A SIMULINK model that reflects the system
behaviour which includes the delay response is built to
test the proposed FLC. The parameters are extracted from
a physical system and are listed in Table 1:

5. If (level is okay) and (rate is negative) then (valve is open_slow)

The controller performance of this FLC to the water


tank system is shown in Figure 6. The reference input is a
saturated saw signal. As expected, the performance of
such a controller is not satisfactory.

Figure 6. The initial FLC control output.

Table 1 Parameters of the water tank


h1
D1
D2
Cout
v

3.3. PSO tunned FLC

0.05m
0.08m
0.015m
1.8510-4
2.8010-4m3

The MFs used in this FLC are all of Gaussian forms.


The parameters that define the MFs are the mean c and
the deviation of each MF. The membership function is
defined as:

3.2. Conventional FLC

f mf ( x ) e ( x c )

To control the water tank, a FLC was designed. There


are two inputs to the FLC. The first input, labeled
Level, is the difference between the reference input and
the current water level. This input is converted to a
voltage signal to reflect the sensor that is to be used. The
other input to the FLC, labeled Rate, is the information
relating to the change rate of the water tank level. The
output of the FLC is the voltage change required to
operate the valve to achieve desired height.
The initial MFs for the 2 inputs are shown in Figure 4:

/( 2 2 )

(9)

Since there are 6 input MFs and 5 output MFs, there


are a total of 22 parameters that need to be tuned.
Therefore, in the PSO, each particle is to have 22
dimensions. It is set that there are 40 particles in the
swarm and the total searching iterations are set to be 100.
It is also defined in the searching process that if the error
does not reduce within 10 iterations then the search
should be terminated. The inertia factor was set to be
0.5 and weighting factors1 and 2 were set to be 1 and
0.2, respectively.

326

The objective function that evaluates the fitness of


each particle was defined as (7). Therefore, after the
proper tuning of the MFs, the FLC will have a minimised
control error.
In Figure 7, the fitness function value during the search
of the optimal solution is given. As it can be seen in the
figure, the searching was terminated after 71 iterations
when there is no reduction in total control error was
observed.

The control performance of the tunned FLC to the


reference signal shown in Figure 6 are demonstrated in
Figure 9. It can be observed that a marked improvement
has been obtained by this automatic MF tuning process.
The maximum error has been reduced to 3% from its
original 30%. To further evaluate the performance of the
developed FLC, the reference signals were varied to be a
sine wave signal and a step signal. The responses and
their corresponding tracking errors are presented in
Figures 10 and 11, respectively. Benefits obtained from
the tunned FLC are further concurred.

Figure 7. The reduction of control error during the PSO


searching process.

Figure 9. The tuned FLC control output for a saturated


saw reference signal.

At the completion of the PSO tuning, the MFs for the


inputs and outputs of the FLC have been modified
significantly. They are shown in Figure 8.

Figure 10. The tuned FLC control output for a sine


reference signal.

Figure 8. The tuned MFs of the FLC.

Table 2 shows the MF parameters before and after the


PSO tuning process:

Figure 11. The tuned FLC control output for a step


reference signal.

4. Discussions

Table 2 MF Parameters before and after the PSO


Before PSO

MF

Level

Rate

Valve

After PSO

Mean (c )

STD ()

Mean (c )

high

-1

0.3

-0.86

0.01

ok

0.3

0.02

0.23

low

0.3

0.89

0.39

negative

-0.005

0.0015

-0.01

0.00

none

0.0015

-0.01

0.01

4.1. A PSO tuned PID controller

STD ()

positive

0.005

0.0015

0.01

0.00

closefast

-5

-5.45

1.87

closeslow

-3

-3.31

1.60

nochange

-0.01

1.60

openslow

3.20

1.68

openfast

5.39

1.99

The effectiveness of the proposed FLC controller is


further evaluated where a PID controller is used as a
comparison base. It is well known that the PID controller
gains Kp, Ki, and Kd are tuneable parameters that affect the
performance of the control outputs. In this paper, the
PSO is also used to find the best PID gain values.
Similar PSO searching process is performed in getting
the PID gains. The performance of the PID controller is
tuned to be best for a step input, with total square error
minimised to be 301.85 (the best FLC performance was
302.12) as shown in Figure 12.

327

[2] Jang, J.S.R., ANFIS: Adaptive-Network-Based Fuzzy


Inference System, IEEE Transactions on Systems, Man,
and Cybernetics, Vol. 23, No. 3, May/Jun 1993, pp. 665685.
[3] Lin C.J., Chen C.H., Lee C. Y. (2006) TSK-type quantum
neural fuzzy network for temperature control.
International Mathematical Forum, Vol. 1, No 18, pp. 853
- 866.
[4] Pratihar D.K., Deb K., Ghosh A. (1999) A genetic-fuzzy
approach for mobile robot navigation among moving
obstacles. International Journal of Approximate
Reasoning, Vol 20, No. 2 , pp. 145172.
[5] Mucientes M., Moreno D.L., Bugarin A., and Barro S.
(2007), Design of a fuzzy controller in mobile robotics
using genetic algorithms. Applied Soft Computing. 7, pp.
540-546.
[6] Kennedy, J. and Eberhart, R. (1995) Particle swarm
optimization. Proceedings of 1995 IEEE International
Conference on Neural Networks, Perth, Australia,
pp.1942-1948.
[7] Clerc, M. and Kennedy, J. (2002) The particle swarm explosion,
stability,
and
convergence
in
a
multidimensional complex space. IEEE Transactions on
Evolutionary Computation, Vol 6, No. 1, pp. 58-73.
[8] Kwok, N.M., Ha, Q.P., Liu, D.K. and Fang, G. (2006)
Intensity-preserving contrast enhancement for gray-level
images
using
multi-objective
particle
swarm
optimization. Proceedings of 2006 IEEE Conf. on
Automation Science and Engineering, Shanghai, P. R.
China, pp. 19-24.
[9] Kwok, N.M., Ha, Q.P., Nguyen, T.H., Li, J. and Samali,
B. (2006) A novel hysteretic model for magneto
rheological fluid dampers and parameter identification
using particle swarm optimization. Sensors & Actuators:
A. Physical, Vol 132, No 2, pp. 441-451.
[10] Karakuzu C. (2008) Fuzzy controller training using
particle swarm optimisation for nonlinear system control.
ISA Transactions. Vol. 47, pp. 229 239
[11] Niu B., Zhu Y., He X., and Shen H., (2008) A multiswarm optimizer based fuzzy modeling approach for
dynamic systems processing. Neurocomputing. Vol 71.
pp. 1436-1448.
[12] Mukherjee V., Ghoshal S.P. (2007) Intelligent particle
swarm optimized fuzzy PID controller for AVR system.
Electric Power Systems Research, Vol. 77, pp. 1689-1698.
[13] Lin C., Hong S. (2007) The design of neuro-fuzzy
networks using particle swarm optimisation and recursive
singular value decomposition. Neurocomputing, Vol 71,
pp. 271-310.
[14] Esmin A.A.A., Aoki A., Lambert-Torres G. (2002),
Particle swarm optimisation for fuzzy membership
functions optimisation. Proceedings on 2002 IEEE
International Confereence on Ssytems, Man, and
Cybernetics, Hammamet, Tunisia.
[15] Esmin A.A.A., Lambert-Torres G. (2006), Fitting fuzzy
membership functions using hybrid particle swarm
optimization. Proceedings on 2006 IEEE International
Conference on Fuzzy Systems, Vancouver, BC, Canada.
pp. 2112 2119.

Figure 12. The tuned PID control output for a step


reference signal.

4.2. Comparison with PID controller


When this PID controller is used in controlling the
water tank to follow the desired sine wave reference
inputs, the comparisons are shown in Figure 13. It can be
seen that although the PID has been tuned to follow a step
input better than the FLC, its performance in following an
alternative reference signal is not as accurate as the FLC.
This is expected, as the PID controller is a linear
controller while the FLC is a nonlinear controller that has
a better performance over a larger operating range. In
following the sine wave trajectory, the total squared error
of the PID is 5.66 compared with the FLC control error of
1.97. In following a saturated saw signal (shown in
Figures 6 and 9), the PID error was 2.73 and that of FLC
was 2.02. It is obvious that the developed FLC is
performing better in all these signal followings.

Figure 13. Performance comparison of the tuned FLC


controller and a PID controller for a sine reference signal.

5. Conclusions
In fuzzy logic controller design, the process of tuning
membership functions is a time consuming and often
frustrating exercise. In this paper an autonomous MF
tuning method in designing FLC is introduced to perform
tracking control of a nonlinear system. The results have
shown that the tuned FLC is performing satisfactorily
compared with a PID controller even when the PID is
tuned to perform in an optimal fashion. We are in process
of integrating the tuning of fuzzy rules into the FLC
design using the PSO.

References
[1] Lin C.T. and Lee C.S.G. (1996). Neural fuzzy systems.
Upper Saddle River, Prentice Hall, Inc.

328

Anda mungkin juga menyukai