World Academy of Science, Engineering and Technology 47 2008
Auto Tuning PID Controller based on Improved
         Genetic Algorithm for Reverse Osmosis Plant
                          Jin-Sung Kim, Jin-Hwan Kim, Ji-Mo Park, Sung-Man Park, Won-Yong Choe
                                                                   and Hoon Heo
                                                                                   of water that passes through the membrane reducing strongly
    Abstract— An optimal control of Reverse Osmosis (RO) plant is                   the solute concentration is called permeate. The remaining
studied in this paper utilizing the auto tuning concept in conjunction              water (brine) is discharged with a high salt concentration.
with PID controller. A control scheme composing an auto tuning                         In the last years, significant advances in the membrane
stochastic technique based on an improved Genetic Algorithm (GA) is
                                                                                    technology have allowed an essential improvement in the
proposed. For better evaluation of the process in GA, objective
function defined newly in sense of root mean square error has been                  filtering quality and simultaneously a general reduction of costs.
used. Also in order to achieve better performance of GA, more                       Hence, RO plants have today lower energy consumption,
pureness and longer period of random number generation in operation                 investment cost, space requirements and maintenance than
are sought. The main improvement is made by replacing the uniform                   other desalination processes [2].
distribution random number generator in conventional GA technique                      On the other hand, RO desalination plants are energy
to newly designed hybrid random generator composed of Cauchy
                                                                                    intensive and require fine tuned components. Therefore, a good
distribution and linear congruential generator, which provides
independent and different random numbers at each individual steps in                control design is necessary to maintain water production costs
Genetic operation. The performance of newly proposed GA tuned                       at acceptable level and to elevate the plant availability,
controller is compared with those of conventional ones via simulation.              particularly in regions with high water scarcity. Therefore, an
                                                                                    advanced control technique is required for more efficient
                                                                                    operation of RO plant. In this paper new GA technique is
  Keywords—Genetic Algorithm, Auto tuning, Hybrid random                            implemented on RO system. [3].
number generator, Reverse Osmosis, PID controller                                      Many PID tuning methods are introduced. The Ziegler
                                                                                    Nichols method is an experimental one that is widely used,
                        I. INTRODUCTION                                             despite the requirement of a step input application with stopped
A    ccording to a report from UNESCO, by the middle of this
     century, at worst 7 billion people in sixty countries will be
water scarce, at best 2 billion people in forty eight countries.
                                                                                    process [4]. One of disadvantage on this method is the
                                                                                    necessary of the prior knowledge regarding plant model. Once
                                                                                    tuned the controller by Ziegler Nichols method a good but not
This expectation makes necessary for humanity to look for new                       optimum system response will be reached. The transient
alternative ways of ensuring a dependable supply of drinking                        response can be even worse if the plant dynamics change. It
water. The significance of this problem is increasing in the                        must be noticed that a great amount of plants has time-varying
underdeveloped countries as well as in industrialized regions.                      dynamics due to external/environmental causes, e.g.
   Desalination of seawater and brackish water is one of the                        temperature and pressure. To assure an environmentally
alternatives for ensuring a dependable supply of drinking water.                    independent good performance, the controller must be able to
In recent years the process of reverse osmosis (RO) has become                      adapt the changes of plant dynamic characteristics [5].
a significant technical option to solve this problem through the                       For these reasons, it is highly desirable to increase the
desalination of seawater [1].                                                       capabilities of PID controllers by adding new features. Many
   RO is a process used to clean brackish water or to desalt                        random search methods, such as genetic algorithm (GA) have
seawater. The process consists in recovering water from a                           recently received much interest for achieving high efficiency
saline solution pressurized by pumping it into a closed vessel to                   and searching global optimal solution in problem space [6].
a point grater than the osmotic pressure of the solution. Thus,                     Due to its high potential for global optimization, GA has
the solution is pressed against a membrane so that it is                            received great attention in control systems such as the search of
separated from the solutes (the dissolved material). The portion                    optimal PID controller parameters. Although GA has widely
                                                                                    been applied to many control systems, its natural genetic
                                                                                    operations would still result in enormous computational efforts
   Jin-Sung Kim, Jin-Hwan Kim, Ji-Mo Park, Sung-Man Park, Won-Yong
Choe., and Hoon Heo are with Department of Control and Instrumentation              [7].
Engineering, Korea University, Seoul 137-701 South. Korea (e-mail: {yawaya,
2000240636, lockhart, yamjun99, untamed, heo257}@korea.ac.kr}.
                                                                              384
                                       World Academy of Science, Engineering and Technology 47 2008
                   II. PID CONTROLLER                                                                    KD s 2  KP s  KI
   The PID controller is well known and widely used to                                       CPID(s)                                     (4)
                                                                                                                  s
improve the dynamic response as well as to reduce or eliminate
the steady state error. The derivative controller adds a finite
zero to the open loop plant transfer function and improves the                             III. GENETIC ALGORITHM
transient response. The integral controller adds a pole at the
origin, thus increasing system type by one and reducing the                   The basic principles of GA were first proposed by Holland.
steady state error due to a step function to zero.                         This technique was inspired by the mechanism of natural
   PID control consists of three types of control, Proportional,           selection, a biological process in which stronger individual is
Integral, and Derivative control.                                          likely to be the winners in a competing environment. GA uses a
                                                                           direct analogy of such natural evolution to do global
                                                                           optimization in order to solve highly complex problems [14]. It
                                                                           presumes that the potential solution of a problem is an
                                                                           individual and can be represented by a set of parameters. These
                                                                           parameters are regarded as the genes of a chromosome and can
                                                                           be structured by a string of concatenated values. The form of
                                                                           variables representation is defined by the encoding scheme.
                                                                           The variables can be represented by binary, real numbers, or
                                                                           other forms, depending on the application data. Its range, the
         Fig.1 schematic of conventional PID controller                    search space, is usually defined by the problem.
   A. Proportional Control
   The proportional controller output uses a ‘proportion’ of the
system error to control the system. However, this introduces an
offset error into the system.
                    Pterm KP u ERROR                           (1)
  B. Integral control
  The integral controller output is proportional to the amount
of time there is an error present in the system. The integral
action removes the offset introduced by the proportional
control but introduces a phase lag into the system.
                   I term K I u ³ ERRORdt                      (2)
   C. Derivative control
   The derivative controller output is proportional to the rate of
change of the error. Derivative control is used to                                  Fig. 2 flow chart of the general genetic algorithm
reduce/eliminate overshoot and introduces a phase lead action
that removes the phase lag introduced by the integral action.                 GA has been successfully applied to many different
                                                                           problems, such as: traveling salesman, graph partitioning
                                 d (ERROR.)                                problem, filters design, power electronics, etc. It has also been
                   Dterm KI u                                  (3)         applied to machine learning, dynamic control system using
                                     dt                                    learning rules and adaptive control. The combination of GA
                                                                           with other Artificial Intelligence techniques, like Fuzzy Sets
  D. Continuous PID control                                                and Artificial Neural Network, in hybrid system has been the
  The three types of control are combined together to form a               solution for a great amount of problems. Success of GA solving
PID controller with the transfer function [8].                             high dimensional problem has been reported in the literature
                                                                           too. An illustrative flowchart of the GA algorithm
                                                                           implementation is presented in Figure 2. In the beginning an
                                                                           initial chromosome population is randomly generated. The
                                                                     385
                                        World Academy of Science, Engineering and Technology 47 2008
chromosomes are candidate solutions to the problem. Than, the                there exist some crossover types. The so called arithmetic
fitness values of all chromosomes are evaluated by calculating               crossover generates an offspring as a component wise linear
the objective function in a decoded form. So, based on the                   combination of the parents in later phases of evolution it is
fitness of each individual, a group of the best chromosomes is               more desirable to keep individuals intact, so it is a good idea to
selected through the selection process. The genetic operators,               use an adaptively changing crossover rate: higher rates in early
crossover and mutation, are applied to this “surviving”                      phases and a lower rate at the end of the GA. Sometimes it is
population in order to improve the next generation solution.                 also helpful to use several different types of crossover at
Crossover is a recombination operator that combines subparts                 different stages of evolution
of two parent chromosomes to produce offspring. This operator
                                                                                C. Mutation
extracts common features from different chromosomes in order
to achieve even better solutions. Mutation is an operator that                  A new individual is created by making modifications to one
introduces variations into the chromosome. This operation                    selected individual. The modifications can consist of changing
occurs occasionally with a small probability. It randomly alters             one or more values in the representation or adding/deleting
the value of a bit, in case of binary coding. In real coding it              parts of the representation. In GA, mutation is a source of
changes the entire value of a chromosome. Through the                        variability and too great a mutation rate results in less efficient
mutation operator the search space is explored by looking for                evolution, except in the case of particularly simple problems.
better points. The process continues until the population                    Hence, mutation should be used sparingly because it is a
converges to the global maximum or another stop criterion is                 random search operator; otherwise, with high mutation rates,
reached [9].                                                                 the algorithm will become little more than a random search.
                                                                             Moreover, at different stages, one may use different mutation
                                                                             operators. At the beginning, mutation operators resulting in
                 IV. GENETIC OPERATOR                                        bigger jumps in the search space might be preferred. Later on,
                                                                             when the solution is close by a mutation operator leading to
   In each generation, the genetic operators are applied to
                                                                             slighter shifts in the search space could be favored [10][18].
selected individuals from the current population in order to
create a new population. Generally, the three main genetic
operators of reproduction, crossover and mutation are                             V. EVALUATE THE PROCESS USING FITNESS
employed. By using different probabilities for applying these                                  FUNCTION
operators, the speed of convergence can be controlled.
Crossover and mutation operators must be carefully designed,                   A. Objective function
since their choice highly contributes to the performance of the                The most crucial step in applying GA is to choose the
whole genetic algorithm.                                                     objective functions that are used to evaluate fitness of each
    A. Reproduction                                                          chromosome. Some works use performance indices as the
    A part of the new population can be created by simply                    objective functions. The objective functions are Mean of the
copying without change selected individuals from the present                 Squared Error (MSE), Integral of Time multiplied by Absolute
population. Also new population has the possibility of selection             Error (ITAE), Integral of Absolute Magnitude of the Error
by already developed solutions.                                              (IAE), and Integral of the Squared Error (ISE)[8][11].
    There are a number of other selection methods available and
                                                                                                      W                    W
it is up to the user to select the appropriate one for each process.                                 1
                                                                                                          (e(t))2dt ITAE
                                                                                                     t ³0                  ³ t e(t)dt
                                                                                           MSE
All selection methods are based on the same principal i.e.                                                                 0                (5)
giving fitter chromosomes a larger probability of selection.                                     W                   W
                                                                                                          2                    2
Four common methods for selection are:                                                     ISE   ³ e(t) dt
                                                                                                 0
                                                                                                              ITSE   ³ te(t) dt
                                                                                                                     0
    1. Roulette Wheel selection
    2. Stochastic Universal sampling                                            B. The fitness values
    3. Normalized geometric selection                                           The PID controller is used to minimize the error signals, or
    4. Tournament selection                                                  we can define more rigorously, in the term of error criteria: to
And author uses Roulette Wheel selection.                                    minimize the value of performance indices mentioned above.
   B. Crossover                                                              And because the smaller the value of performance indices of
   New individuals are generally created as offspring of two                 the corresponding chromosomes the fitter the chromosomes
parents (i.e., crossover being a binary operator). One or more so            will be, and vice versa, we define the fitness of the
called crossover points are selected (usually at random) within              chromosomes as (6) [11][18].
the chromosome of each parent, at the same place in each. The
parts delimited by the crossover points are then interchanged                                                         1                     (6)
                                                                                          Fitness value
between the parents. The individuals resulting in this way are                                                 Performanc
                                                                                                                        e index
the offspring. Beyond one point and multiple point crossover,
                                                                       386
                                            World Academy of Science, Engineering and Technology 47 2008
              VI. PROPOSED NEW METHODS                                          input of linear congruential generator.
   This paper presents an advanced auto tuning PID controller                        (ฌ) The mechanism of linear congruential generator is
                                                                                represented as (8).
 for RO plant to search the optimal control gain parameters kP ,
 kI , kD  with improved GA. The searching steps of the                                       Xi   ( aX i 1  c ) mod m           ;i   1, 2 ,3 L   (8)
 proposed optimal PID controller are shown as below. The                                    0  m,    a  m,    c  m,       X0  m
 improved GA has new random generator and objective
                                                                                   Where X 0 the initial value that selected at random. Random
                                                                                value is that X 1 divided by m [16] [17]. This method can
                                      kP
                                                                                expand the period of random function effectively if the
                                      kI
                                      kD
                                                                                condition satisfies. As a result, the output value is improved
                                                                                random number.
                                                                                     (ญ) Return the final value to GA.
                                                                                   The newly designed random number generator gives more
Fig. 3 schematic of auto tuning PID controller based on improved GA             reliable random generator than normally using conventionally
                                                                                one.
 function.
                                                                                   B. New objective function
   A. New random generation                                                        In control engineering, Mean of the Squared Error (MSE),
                                                                                Integral of Time multiplied by Absolute Error (ITAE), Integral
                                                                                of Absolute Magnitude of the Error (IAE), and Integral of the
                                                                                Squared Error (ISE) are used as objective function of GA
                                                                                universally. However in the study use of new objective
                                                                                function is attempted for RO plant, which is Root Mean Square
                                                                                Error (RMSE) represented as in (9).
                                                                                                                W
                                                                                                               1
                                                                                                                    (e(t ))2 dt
                                                                                                               t ³0
                                                                                                      R MSE                                        (9)
       Fig. 4 schematic of proposed hybrid random generator
 Fig 4 is the structure of new hybrid random generator.
                                                                                  Fig. 5 shows the schematic diagram of application of new
    Generally, GA is constructed on the basis of probability
                                                                                hybrid random number generating method and objective
 using random function. Conventional GA has used random
 function in the MATLAB or C language library. However more
 reliable random functions are required for better performance
 of GA.
    This study proposes more pureness and longer period of
 random number generation for GA. The steps are listed below.
      (ช) Call the random generator function to make random
 values during GA processing.
      (ซ) Get a first random number from Cauchy distribution
 function method, which is represented as (7).
              F ( p, x0 , J )   x 0  J tan[ S ( p  0 . 5 )]       (7)
    p is random value between 0 and 1, x 0 is the location
 parameter, specifying the location of the peak of the
 distribution and J is the scale parameter which specifies the
 half width at half maximum. Set as x 0 =0, J =1 generally and it
 is called ‘standard Cauchy distribution’ [15]. In this paper set
 these values as random from 0 to 1. So probability density
 function always changes when GA program is called for
 random generator function. The output from Cauchy
                                                                                         Fig. 5 flow chart of the improved Genetic Algorithm
 distribution is the expanded value between 0 and 1 and the
                                                                          387
                                        World Academy of Science, Engineering and Technology 47 2008
function for GA.
      The improved GA work in this paper as follows.                                                                                          Step Response
                                                                                                              1.6
      (ช) The initial population tribes are filled with                                                                                                         Ziegler Nichols tuned controller
                                                                                                                                                                Conventional GA tuned controller
                                                                                                              1.4
individuals that are generally created at random. Sometimes,                                                                                                    Improved GA tuned controller
the individuals in the initial population are the solutions found                                             1.2
by some method determined by the problem domain. In this                                                       1
paper, we gave random values to these initial populations. But
                                                                                                  Amplitude
                                                                                                              0.8
their ranges limited around the values. The ranges of PID                                                     0.6
values are rationally chosen by arbitrary and it is true that the
                                                                                                              0.4
limitation will influence the results of the GA search; it is
intended to obtain more stable, efficient and accurate solutions.                                             0.2
      (ซ) Every generation is applied RO plant, which was                                                      0
                                                                                                                    0        5           10           15             20             25             30
described by PID parameters and produced a group of errors                                                                                     Time (sec)
that calculated the RMSE value from transient to steady state.                  Fig. 7 step response of improved GA tuned controller vs. Ziegler
      (ฌ) Each individual in the current population is evaluated                                     Nichols tuned controller
using the objective function.
                                                                                                                                   GAs converged to final values
      (ญ) If the termination standard [i.e., the generation                                  15
                                                                                                                                                                                         Improved GA
                                                                                                                                                                                         Conventional GA
number > preset number] is met, the best solution (i.e., PID
                                                                                       Kp
                                                                                             10
gain parameters) is returned.
      (ฎ) From the current population, individuals are selected                              5
                                                                                                  0                     50               100                  150               200                250
based on the previously computed fitness values. A new                                       6
population is formed by applying the genetic operators (i.e.,                           Ki   4
reproduction, crossover, mutation using random generator) to                                 2
these individuals.                                                                           0
                                                                                                  0                     50               100                  150               200                250
      (ฏ) Actions starting from step (ซ) are repeated until the                              25
termination standard is satisfied, which is called a                                         20
                                                                                       Kd
generation.[18]                                                                              15
                                                                                             10
                                                                                                  0                     50               100           150                      200                250
                                                                                                                                            Generations
                 VII. SIMULATION RESULTS
  Recently the most widely used RO plant has its control                    Fig. 8 response trends upon improved GA converging through generation
system utilizing empirically determined parameters. The
simulation concept is shown in Fig. 4, where the GA and PID                confirm the effectiveness of the proposed method. Parameters
                                                                           are set for GAs in the study is as in Table1.
                                                                                It can be seen that improved GA tuned PID controller
                                                                           reveals shorter settling time. Moreover the overshoot is
                                                                           considerably lower than the those obtained via the conventional
                                                                           GA tuned controller and Ziegler Nichols tuned controller. The
                                                                           comparison of the performances using improved GA based PID
                                                                           tuned controller, conventional GA based PID tuned controller
                                                                                                                                              TABLE 2
Fig. 6 simulink of auto tuning PID controller based on improved GA                                                           PERFORMANCE COMPARISION
control action are implemented in the MATLAB                                        Item                                Improved GA                                 GA                       Ziegler Nichols
environment[12][13].                                                          Peak amplitude                                     1.19                               1.5                                 1.58
     In this section, numerical simulation is conducted to                    Overshoot (%)                                       19                                49.9                                58.1
                             TABLE I                                         Rising time (sec)                                   0.966                          0.755                                   1.29
                       GAS PARAMETER SETTING
                                                                             Settling time (sec)                                 5.12                               6.92                                14.9
          Parameter                      Value                                  Final value                                       1                                  1                                   1
    Selection method                 Roulette wheel                                P gain                                    6.71275                          10.73984                                   6
    Population size                       80
                                                                                   I gain                                    0.0172                            3.2230                                   1.91
    Generation size                       220
    Crossover probability                65%                                      D gain                                 11.48921                             14.36576                                  4.74
    Mutation probability                 0.1%
    Ranges of PID gain                -1000~1000
    values                                                                 and Ziegler Nichols method are made as shown in Table 2.
                                                                     388
                                                 World Academy of Science, Engineering and Technology 47 2008
                                                                                        [16] Stephen K. Park and Keith W. Miller. Random number generators: Good
                                                                                             ones are hard to find. CACM, 31(10):1192–1201, 1988.
                                                                                        [17] Donald E. Knuth. “Deciphering a linear congruential encryption,”. IEEE
                            VIII. CONCLUSION                                                 Transactions on Information Theory, IT-31(1):49–52, January 1985.
                                                                                        [18] T. K. Teng, J. S. Shieh and C. S. Chen, “Genetic algorithms applied in
   This paper demonstrated how an improved GA can be used
                                                                                             online autotuning PID parameters of a liquid-level control system,”
for the optimal control of RO plant via computer simulation. A                               Transaction of the Institute of Measurement and control 25, 5 (2003),
new GA method based on hybrid concept of Cauchy                                              pp.433~450
distribution, linear congruential generator and simultaneous
using of RMSE type objective function to design a controller
for RO plant is presented. Much more improved performance
of proposed GA tuned controller than the conventional ones
has been revealed in terms of overshoot and settling time etc.
Real time implementation of the proposed method is under way.
Also at the same time implementation of micro controller based
on the new method in commercially low cost is being sought.
Although GA needs lot of computation, its real time realization
of the idea will be performed via physical experiment.
                            ACKNOWLEDGMENT
  This research was supported by a grant (C106A152000106A
085700200) from Plant Technology Advancement Program
funded by Ministry of Construction & Transportation of
Korean government
                                 REFERENCES
[1]    UNESCO (2004, may 11). Water for - water for life – the united nations
       world      water     development       report.    [Online].     Available:
       http://www.unesco.org/water/wwap/wwdr/ex_summary/
[2]     M.S. Mohsen, 0.R AI-Jayyousi, “Brackish water desalination: an
       alternative for water supply enhancement in Jordan’’, Desalination,
       vol.124, p~163-174, Nov.1999
[3]    A. Maurel, “Desalination of sea Water and brackish water,” in Proc. Of
       seminar on water managemen6 strategies in Mediterranean countries
[4]     F. G. Shinskey, Process Control System: Application, Design and Tuning.
       McGraw-Hill, 4th ed, 1996
[5]     K. J. Astrom and B. Wittenmark, Adaptive Control. Addison Wesley, 2nd
       ed., 1995.
[6]    A. Visioli, “Tuning of PID controllers with fuzzy logic,” Proc. Inst. Elect.
       Eng. Contr. Theory Applicat., vol. 148, no. 1, pp. 1–8, Jan. 2001.
[7]    R. A. Krohling and J. P. Rey, “Design of optimal disturbance rejection
       PID controllers using genetic algorithm,” IEEE Trans. Evol. Comput., vol.
       5, pp. 78–82, Feb. 2001.
[8]    Zwe-Lee Gaing, “A Particle Swarm Optimization Approach for Optimum
       Design of PID Controller in AVR System,” IEEE TRANSACTIONS ON
       ENERGY CONVERSION, VOL. 19, NO. 2, pp.384~391, 2004.
[9]    Dionisio S. Pereira, “Genetic Algorithm Based System Identification and
       PID Tuning for Optimum Adaptive Control,” International Conference
       on Advanced Intelligent Mechatronics, Monterey, California, USA, 24-28
       July, pp.801~806, 2005
[10]   Ian Griffin, “On-line PID Controller Tuning using Genetic Algorithms,”
       Dublin City University, 2003
[11]   T O.Mahony, C J Downing and K Fatla, “Genetic Algorithm for PID
       Parameter Optimization: Minimizing Error Criteria,” Process Control and
       Instrumentation 2000 26-28 July 2000, University of Stracthclyde,
       pp.148~153
[12]   C. R. Houck, J. Joines. and M.Kay, “A genetic algorithm for function
       optimization: A Matlab implementation,” ACM Transactions on
       Mathematical Software, 1996.
[13]   Chipperfield, A. J., Fleming, P. J., Pohlheim, H. and Fonseca, C. M., A
       “Genetic Algorithm Toolbox for MATLAB,” Proc. International
       Conference on Systems Engineering, Coventry, UK, 6-8 September, 1994
[14]   D. E. Goldberg, “Genetic Algorithms in Search, Optimization, and
       Machine Learning,” Addison-Wesley Publishing Co., Inc., 1989
[15]   Wikipedia, http://en.wikipedia.org/wiki/Cauchy_distribution
                                                                                  389