# Genetic Algorithm Based PID Controller Tuning Approach for Continuous Stirred Tank Reactor

Authors: A. Jayachitra; R. Vinodha
Journal: Advances in Artificial Intelligence
 (2014)

---

## Abstract

Genetic algorithm (GA) based PID (proportional integral derivative) controller has been proposed for tuning optimized PID parameters in a continuous stirred tank reactor (CSTR) process using a weighted combination of objective functions, namely, integral square error (ISE), integral absolute error (IAE), and integrated time absolute error (ITAE). Optimization of PID controller parameters is the key goal in chemical and biochemical industries. PID controllers have narrowed down the operating range of processes with dynamic nonlinearity. In our proposed work, globally optimized PID parameters tend to operate the CSTR process in its entire operating range to overcome the limitations of the linear PID controller. The simulation study reveals that the GA based PID controller tuned with fixed PID parameters provides satisfactory performance in terms of set point tracking and disturbance rejection.


---

## Body

## 1. Introduction

PID controllers are still widely used in 90% of industries, since no other advanced control schemes such as model predictive control, internal model control (IMC), and sliding mode control (SMC) match the simplicity, clear functionality, applicability, and ease of use provided by this controller [1]. PID controller tuned at a particular operating point will not provide a satisfying response when there exists deviation in the process operating range [2]. Hence, soft computing based PID controller tuning is widely proposed by the researchers during the last few decades [3–7].CSTR process exhibits typical nonlinear and time varying behaviour where control of the parameter reactor concentration with few computation steps is a challenge to the researchers. Therefore, it becomes essential to use powerful heuristic algorithms like GA to tune the PID parameters, thereby achieving good set point tracking and disturbance rejection control in the chemical system CSTR. Vinodha et al. have designed three control schemes for nonlinear CSTR process such as extraction of PID controller parameters based on artificial intelligence, model predictive controllers using the weighted sum of the output from local predictive controllers, and multiple model PID controllers [8]. The presence of parameter uncertainty in nonlinear systems like CSTR has been controlled by designing the nonlinear predictive adaptive controller (NPAC) and a nonlinear disturbance observer (NDO) in literature [9] and the proposed compensation method improves system tracking accuracy and robustness. Prakash and Senthil formulated a nonlinear observer based model predictive controller (NMPC) based on fuzzy Kalman filter (FKF) and augmented state fuzzy Kalman filter (ASFKF) for CSTR process [10]. A model based control scheme (F-NMPC) reduces the number of computations needed and is considered as an alternative to analytical model based control scheme as discussed in [11, 12].A partial state feedback controller has been proposed to achieve the global set point tracking control of CSTR [13]. Indirect adaptive control based pole placement and adaptive general predictive control (GPC) methodologies are used to estimate and control parameters of CSTR which has been reported by Delbari et al. [14]. Shopova and Vaklieva-Bancheva have introduced in detail a genetic algorithm called BASIC, designed to deal with various engineering optimization problems [15]. The self-organizing GA optimization method has been used for evolving PID controller parameters to avoid premature convergence and to achieve good optimization performance [16]. Krohling and Rey have discussed a method to design an optimal disturbance rejection PID controller based on genetic algorithms for solving the constrained optimization problem in a servo motor system [17]. Kumar et al. have described the design of GA based controller for a bioreactor model that outperformed Ziegler Nichols and Skogestad’s tuned controller in terms of overshoot and undershoot as well as disturbance rejection and set point tracking [18]. A modified genetic algorithm has been reported [19] to obtain the optimal PID controller parameters for different process types. Fuzzy gain scheduling has been used to determine the controller parameter transition policy for the dynamic plant [20].Nagaraj and Murugananth have discussed PID tuning using soft computing based controller, improving the performance of process in terms of time domain specifications, set point tracking, and regulatory changes [21]. In the work of Chang, PID controller has been designed using an artificial bee colony algorithm for an unstable and nonlinear CSTR chemical system [22]. Wang and Jin have determined state feedback linearization control method for nonminimum phase characteristics of CSTR system [23]. Singh and Sharma have proposed a fractional order PID controller with a PSO approach, providing better servo and regulatory response [24]. The combined PID control tuning by coupling the gain-phase margin method with genetic algorithm has been applied for position control in a servo system [25]. A virtual feedback control has been implemented to control the state variables using extended Kalman filter (EKF) in the feedback path using particle swarm optimization technique for CSTR process [7]. In our proposed work to depict the nonlinearity of CSTR process, the differential equation model is used. The methodology proposed is the design of global GA tuned PID values constrained at individual optimum values ISE, IAE, and ITAE and weighted combination of objective functions considered to operate the plant in the entire operating range.Organization of the paper is presented as follows. Section2 presents the proposed control approach and Section 3 describes the CSTR plant. Introduction to genetic algorithm is provided in Section 4 and Section 5 includes the simulation results of CSTR process for both servo and regulatory cases. Finally, Section 6 concludes how GA based PID controller gives better performance with minimum computation steps to achieve optimized PID control of the CSTR plant in a wide range.


## 2. Proposed Control Approach

A PID controller is a combination of a proportional, an integral, and a derivative controller, integrating the main features of all three. A simplified block diagram of control approach followed in the work is shown in Figure1.Figure 1
Structure of PID controller.From Figure1, it is inferred that the objective of the work is to tune the PID gains with minimum error between the set value and actual concentration value, where e is a difference between the desired output r and actual output y, u is the PID control law, and parameters Kc, TI, and Td are the proportional gain and integral and derivative times, respectively. Commonly employed error criteria to achieve optimized PID tuning values are integral square error (ISE), integral absolute error (IAE), and integrated time absolute error (ITAE), respectively, and are formulated as given in (1), (2), and (3), respectively. From the block diagram, it is clear that a weighted combination of ISE, IAE, and ITAE [4] is used as an objective function to obtain PID parameters through genetic algorithm. Consider
(1)ISE=∫0∞et2dt,(2)IAE=∫0∞etdt,(3)ITAE=∫0∞tetdt.
The objective function J used in genetic algorithm is defined as
(4)JKc,TI,Td=w1ISE+w2IAE+w3ITAE.
The PID control law utilized in velocity form is given in
(5)uk=Kcek-ek-1+TTIek+TdTek-2ek-1+ek-2+uk-1.
One or a weighted combination of these criteria is employed to achieve optimized parameter tuning of PID controller. It is generally accepted that weighted indices are more appropriate than individual performance indices as reported in [3–6].


## 3. Description of CSTR Process

The first principles model of the continuous stirred tank reactor and the operating point data as specified by Pottman and Seborg [26] and design procedure described [27] has been used in the simulation studies. In the process considered for simulation study (shown in Figure 2), an irreversible, exothermic reaction A → B (Reactant A of Concentration CAf is converted to Product B of Concentration CA) occurs in a constant volume reactor that is cooled by a single coolant stream qc. The steady state operating specifications are given in Table 1.Table 1
Steady state operating data of CSTR process.
Process variable
Normal operating conditions
Measured product concentration (CA)
0.0989 mol/lit
Reactor temperature (T)
438.7763 K
Coolant flow rate (qc)
103 lit/min
Process flow rate (q)
100.0 lit/min
Feed concentration (CAf)
1 mol/lit
Feed temperature (Tf)
350.0 K
Inlet coolant temperature (Tcf)
350.0 K
CSTR volume (V)
100 lit
Heat transfer term (hA)
7 * 105 cal/(min·k)
Reaction rate constant (k0)
7.2 * 1010 min−1
Activation energy term (E/R)
1 * 104 K
Heat of reaction (−ΔH)
2 * 105 cal/mol
Liquid density (ρ, ρc)
1 * 103 g/lit
Specific heats (Cp, Cpc)
1 cal/(g·k)
Fouling coefficientφh(t)
1
Deactivation coefficientφc(t)
1Figure 2
Schematic of CSTR process.The fundamental dependent quantities for the reactor are the total mass of the reacting mixture in the tank, mass of chemicalA in the reacting mixture, and total energy of the reacting mixture in the tank.The mass balance on componentA is
(6)dCAdt=qVCAf-CA-k0CAexp⁡-ERTφct.
The reactor energy balance, assuming constant volume, heat capacity Cp, density ρ and neglecting changes in potential and kinetic energy is given in equation (7). Consider
(7)dTdt=qVTf-T+-ΔHk0CAρCpexp⁡-ERTφct+ρcCpcρCpqcV1-exp⁡-hAqcρCpφhtTcf-T.
The linearized transfer function model of the CSTR process formulating CA as a control variable takes the form specified in (8) with δ and ωn being damping factor and undamped natural frequency, respectively. Consider
(8)CAsqcs=ωn2kps2+2δωns+ωn2.
The model gives a drastic variation in δ as the operating concentration varies. The variations are mentioned in Table 2. Hence, it is observed that PID parameters [1], designed for a particular operating point, are not suitable to control the process globally. Therefore, there is a need to motivate an insight into the heuristic algorithm that satisfies with the fixed PID parameters, constrained to certain objectives.Table 2
Variation inδ and ωn with respect to concentration.
Concentration (CA)
Damping factor (δ)
Frequency (ωn)
0.0792
0.66
3.94
0.0822
0.62
3.83
0.0851
0.58
3.74
0.0882
0.55
3.65
0.0915
0.50
3.54
0.0949
0.46
3.45
0.0985
0.42
3.35
0.1023
0.38
3.25
0.1062
0.34
3.16
0.1104
0.29
3.04
0.1147
0.24
2.95
0.1196
0.20
2.84
0.1241
0.15
2.74


## 4. Genetic Algorithm

Genetic algorithm is a random search method that can be used to solve nonlinear system of equations and optimize complex problems. GA uses probabilistic transition rules instead of deterministic rules and handles a population of potential solutions known as individuals or chromosomes that evolve iteratively. Each iteration of the algorithm is termed a generation. The evolution of solutions is simulated through a fitness function and genetic operators such as reproduction, crossover, and mutation [28]. Genetic algorithm as illustrated in Figure 3 is typically initialized with a random population. This population (mating pool) is usually represented by a real-valued number or a binary string called a chromosome. The performance of the individual is measured and assessed by the objective function, which assigns each individual a corresponding number called its fitness.Figure 3
Flow diagram of genetic algorithm.The fitness of each chromosome is assessed and a survival of the fittest strategy is applied. In this work, the error value is used to assess the fitness of each chromosome. There are three main operations in a genetic algorithm: reproduction, crossover, and mutation. The sequences of operations involved in GA are described in Figure3.Genetic Algorithm StepsStep 1.
Initialize the parameter with a population of random solutions, such as crossover rate, mutation rate, number of clusters, and number of generations. Determine the coding mode.Step 2.
Compute and evaluate the value of the fitness function.Step 3.
Proceed with crossover and mutation operation and make up the new cluster.Step 4.
Repeat Step2, till the best value is obtained.


### 4.1. Coding and Decoding

Genetic algorithms work with a population of strings or chromosomes, instead of considering parameters directly. Hence, to solve our problem, the controller parameter vector should be coded to a string called chromosome. For convenience and simplicity, the binary coding method is chosen. Based on the binary coding method, every element of the parameter vector is coded as a string of length, which consists of zeros and ones for the desired resolution.


### 4.2. Fitness

Fitness is a measure to evaluate the suitability of a chromosome. By the principle of survival of the fittest, a chromosome with higher fitness value has a higher probability of contributing one or more offspring in the next generation. By employing genetic algorithm, the performance criterion is related to fitness function and optimal PID parameters are derived by minimizing an objective, which inculcates a weighted combination of IAE, ISE, and ITAE.


### 4.3. Reproduction

Reproduction is a basic operator of genetic algorithm. It is operated on the basis of the survival of the fittest. In each generation, the chromosome of the current population is reproduced or copied into the next generation, according to the reproduction probabilityPri, which is defined in
(9)Pri=Fiθ∑i=1PlFiθ,
where Pl is the population size.


### 4.4. Crossover

Reproduction directs the search of genetic algorithm towards the best individuals. Crossover operation is performed to exchange the information between any two chromosomes via probabilistic decision in the mating pool and to provide a mechanism to mix chromosomes with the splice point.


### 4.5. Mutation

In genetic algorithms, however, the gene pool tends to become more and more homogeneous as one better gene begins to dominate after several generations and leads to premature convergence of nonoptimal solution. To overcome this undesirable convergence, the third genetic operator mutation is introduced in genetic algorithm with appropriate probability. Mutation is an occasional alternation of the gene from zero to one or from one to zero with the mutation point determined uniformly at random.Genetic Algorithm Based PID Tuning. It is summarized as follows. GA initially generates a random population, which is implemented with small population size in order to allow the controller to be optimized and converge at a faster rate. The initial population is set by encoding the PID parameters Kc, TI, and Td into binary strings known as a chromosome. The fitness of each chromosome is calculated by converting its binary string into real value which represents the PID parameters. Each set of PID parameters is passed to PID controller. The complete response of the system for each PID parameter value and its initial fitness value is computed using individual cost functions like ISE, IAE, and ITAE a weighted combination of these three cost functions. This process will go through Steps 2 and 3 until the end of the generations where the best fitness value is achieved. The ultimate aim of GA is to seek global PID values (Kc, TI, and Td) with minimum fitness value to operate the CSTR plant in the entire range. The details of GA parameters used in the simulation are shown in Table 3.Table 3
Parameters used in genetic algorithm.
Parameter
Type/value
Maximum generations
100
Population size
20
Encoding
Binary
Selection
Uniform
Crossover
Single point crossover
Mutation
Uniform


## 4.1. Coding and Decoding

Genetic algorithms work with a population of strings or chromosomes, instead of considering parameters directly. Hence, to solve our problem, the controller parameter vector should be coded to a string called chromosome. For convenience and simplicity, the binary coding method is chosen. Based on the binary coding method, every element of the parameter vector is coded as a string of length, which consists of zeros and ones for the desired resolution.


## 4.2. Fitness

Fitness is a measure to evaluate the suitability of a chromosome. By the principle of survival of the fittest, a chromosome with higher fitness value has a higher probability of contributing one or more offspring in the next generation. By employing genetic algorithm, the performance criterion is related to fitness function and optimal PID parameters are derived by minimizing an objective, which inculcates a weighted combination of IAE, ISE, and ITAE.


## 4.3. Reproduction

Reproduction is a basic operator of genetic algorithm. It is operated on the basis of the survival of the fittest. In each generation, the chromosome of the current population is reproduced or copied into the next generation, according to the reproduction probabilityPri, which is defined in
(9)Pri=Fiθ∑i=1PlFiθ,
where Pl is the population size.


## 4.4. Crossover

Reproduction directs the search of genetic algorithm towards the best individuals. Crossover operation is performed to exchange the information between any two chromosomes via probabilistic decision in the mating pool and to provide a mechanism to mix chromosomes with the splice point.


## 4.5. Mutation

In genetic algorithms, however, the gene pool tends to become more and more homogeneous as one better gene begins to dominate after several generations and leads to premature convergence of nonoptimal solution. To overcome this undesirable convergence, the third genetic operator mutation is introduced in genetic algorithm with appropriate probability. Mutation is an occasional alternation of the gene from zero to one or from one to zero with the mutation point determined uniformly at random.Genetic Algorithm Based PID Tuning. It is summarized as follows. GA initially generates a random population, which is implemented with small population size in order to allow the controller to be optimized and converge at a faster rate. The initial population is set by encoding the PID parameters Kc, TI, and Td into binary strings known as a chromosome. The fitness of each chromosome is calculated by converting its binary string into real value which represents the PID parameters. Each set of PID parameters is passed to PID controller. The complete response of the system for each PID parameter value and its initial fitness value is computed using individual cost functions like ISE, IAE, and ITAE a weighted combination of these three cost functions. This process will go through Steps 2 and 3 until the end of the generations where the best fitness value is achieved. The ultimate aim of GA is to seek global PID values (Kc, TI, and Td) with minimum fitness value to operate the CSTR plant in the entire range. The details of GA parameters used in the simulation are shown in Table 3.Table 3
Parameters used in genetic algorithm.
Parameter
Type/value
Maximum generations
100
Population size
20
Encoding
Binary
Selection
Uniform
Crossover
Single point crossover
Mutation
Uniform


## 5. Simulation Results

Simulation using genetic algorithm based PID controller for a CSTR plant, including different performance indices such as ISE, IAE, and ITAE separately and a weighted combination of these three functions, is carried out for both servo and servo regulatory cases. In all simulation runs, the CSTR process is simulated using the nonlinear first principles model given by (6) and (7) and the true state variable (concentration) is computed by solving the nonlinear differential equation using Matlab 7.0. The controller saturation limit between 97 and 109 lit/min is considered with initial conditions given by qc=103 lit/min, CA=0.0989 mol/lit, and T=438.77 K and the sampling time of about 0.083 sec is selected for all the simulation studies. The range of PID parameters considered for the simulation is given in Table 4.Table 4
PID parameter range.
PID parameters
K
c
T
I
T
d
Minimum value
0
0
0
Maximum value
60
5
2


### 5.1. Servo Performance of CSTR Process

The set point variations as shown in Figure4(a) have been introduced for assessing the tracking capability of the proposed PID controllers utilizing ISE, IAE, and ITAE separately and a weighted combination of these three functions as objective functions. The weights associated with combined objective function are w1=0.4, w2=0.2, and w3=0.4. From the response, it is observed that all the controllers are able to track the variation in the reactor concentration when the set point concentration is changed from 0.0989 mol/L to 0.1245 mol/L, 0.1245 mol/L to 0.0885 mol/L, and 0.0885 mol/L to 0.0989 mol/L. Weighted GA based PID controller settles faster in all set point transitions. The variation in the controller outputs is presented in Figure 4(b). The performance measures like percentage peak overshoot and settling time are calculated for various objective functions as shown in Table 5. Further, it is evident that the coolant flow rate variation is found to be smooth in all the controllers (refer to Figures 4 and 5).Table 5
Performance measures under various cost functions.
Error measures
Sampling instants
25 : 150
151 : 275
276 : 350
Overshoot (%)
Settling time (samples)
Overshoot (%)
Settling time (samples)
Overshoot (%)
Settling time (samples)
ISE
36.22
32
0
20
0
20
IAE
1.03
55
9.8
19
5.1
19
ITAE
13.5
50
2.3
19
1
18
Combined
1.53
23
0
18
0
18Servo response of CSTR process. (a) Process output. (b) Controller output.
(a)
(b)Servo regulatory response of CSTR process. (a) Feed temperature. (b) Process output. (c) Controller output.
(a)
(b)
(c)Table5 implies that a weighted combination of cost functions like ISE, IAE, and ITAE gives a better reduction in percentage peak overshoot and settling time compared to using ISE, IAE, and ITAE separately. Overshoot is negligible, both for ISE and for combined cost functions when concentration set point is changed from 0.1245 mol/L to 0.0885 mol/L and 0.0885 mol/L to 0.0989 mol/L.


### 5.2. Servo Regulatory Performance of CSTR Process

Simulation studies have been carried out to demonstrate the disturbance rejection capability of the CSTR process at nominal and shifted operating point in the presence of change in the feed temperature. A step change in the inlet temperature of magnitude 2 K (from 350 K to 348 K) has been introduced at the 100th sampling instant and maintained at up to 200th sampling instant (refer to Figure5(a)).From 100th sampling instants to 150th sampling instants of Figure5(b), it can be inferred that the controllers utilizing ISE, IAE, and ITAE separately and a weighted combination of these three functions as objective functions are able to reject the disturbance quickly and bring the reactor concentration back to the nominal value of the set point. The flow rate variation of the controllers is shown in Figure 5(c).When disturbance persists, a step change in the set point has been introduced at the 150th sampling instant. It can be inferred that all the controllers are able to maintain the concentration at the specific set point, as shown in Figure5(b). This part of the simulation shows that the controllers are capable of rejecting the disturbance, also at shifted operating points.Similar observation has been obtained by disturbing the process and by varying the feed concentration as shown in Figure6(a). The controllers utilizing ISE, IAE, and ITAE separately and a weighted combination of these three functions as objective functions are able to reject the disturbance quickly and bring the reactor concentration back to the nominal value of the set point as shown in Figure 6(b). The flow rate variation of the controllers is shown in Figure 6(c).Servo regulatory response of CSTR process. (a) Feed concentration. (b) Process output. (c) Controller output.
(a)
(b)
(c)Simulation study has been carried out by providing the disturbances feed temperature and feed concentration simultaneously as shown in Figures7(a) and 7(b). For combined disturbance also, GA based PID controllers with various error goals have given satisfactory performance as shown in Figure 7(c). The respective flow rate variation of the controllers is shown in Figure 7(d).Servo regulatory response of CSTR process. (a) Feed temperature. (b) Feed concentration. (c) Process output. (d) Controller output.
(a)
(b)
(c)
(d)


## 5.1. Servo Performance of CSTR Process

The set point variations as shown in Figure4(a) have been introduced for assessing the tracking capability of the proposed PID controllers utilizing ISE, IAE, and ITAE separately and a weighted combination of these three functions as objective functions. The weights associated with combined objective function are w1=0.4, w2=0.2, and w3=0.4. From the response, it is observed that all the controllers are able to track the variation in the reactor concentration when the set point concentration is changed from 0.0989 mol/L to 0.1245 mol/L, 0.1245 mol/L to 0.0885 mol/L, and 0.0885 mol/L to 0.0989 mol/L. Weighted GA based PID controller settles faster in all set point transitions. The variation in the controller outputs is presented in Figure 4(b). The performance measures like percentage peak overshoot and settling time are calculated for various objective functions as shown in Table 5. Further, it is evident that the coolant flow rate variation is found to be smooth in all the controllers (refer to Figures 4 and 5).Table 5
Performance measures under various cost functions.
Error measures
Sampling instants
25 : 150
151 : 275
276 : 350
Overshoot (%)
Settling time (samples)
Overshoot (%)
Settling time (samples)
Overshoot (%)
Settling time (samples)
ISE
36.22
32
0
20
0
20
IAE
1.03
55
9.8
19
5.1
19
ITAE
13.5
50
2.3
19
1
18
Combined
1.53
23
0
18
0
18Servo response of CSTR process. (a) Process output. (b) Controller output.
(a)
(b)Servo regulatory response of CSTR process. (a) Feed temperature. (b) Process output. (c) Controller output.
(a)
(b)
(c)Table5 implies that a weighted combination of cost functions like ISE, IAE, and ITAE gives a better reduction in percentage peak overshoot and settling time compared to using ISE, IAE, and ITAE separately. Overshoot is negligible, both for ISE and for combined cost functions when concentration set point is changed from 0.1245 mol/L to 0.0885 mol/L and 0.0885 mol/L to 0.0989 mol/L.


## 5.2. Servo Regulatory Performance of CSTR Process

Simulation studies have been carried out to demonstrate the disturbance rejection capability of the CSTR process at nominal and shifted operating point in the presence of change in the feed temperature. A step change in the inlet temperature of magnitude 2 K (from 350 K to 348 K) has been introduced at the 100th sampling instant and maintained at up to 200th sampling instant (refer to Figure5(a)).From 100th sampling instants to 150th sampling instants of Figure5(b), it can be inferred that the controllers utilizing ISE, IAE, and ITAE separately and a weighted combination of these three functions as objective functions are able to reject the disturbance quickly and bring the reactor concentration back to the nominal value of the set point. The flow rate variation of the controllers is shown in Figure 5(c).When disturbance persists, a step change in the set point has been introduced at the 150th sampling instant. It can be inferred that all the controllers are able to maintain the concentration at the specific set point, as shown in Figure5(b). This part of the simulation shows that the controllers are capable of rejecting the disturbance, also at shifted operating points.Similar observation has been obtained by disturbing the process and by varying the feed concentration as shown in Figure6(a). The controllers utilizing ISE, IAE, and ITAE separately and a weighted combination of these three functions as objective functions are able to reject the disturbance quickly and bring the reactor concentration back to the nominal value of the set point as shown in Figure 6(b). The flow rate variation of the controllers is shown in Figure 6(c).Servo regulatory response of CSTR process. (a) Feed concentration. (b) Process output. (c) Controller output.
(a)
(b)
(c)Simulation study has been carried out by providing the disturbances feed temperature and feed concentration simultaneously as shown in Figures7(a) and 7(b). For combined disturbance also, GA based PID controllers with various error goals have given satisfactory performance as shown in Figure 7(c). The respective flow rate variation of the controllers is shown in Figure 7(d).Servo regulatory response of CSTR process. (a) Feed temperature. (b) Feed concentration. (c) Process output. (d) Controller output.
(a)
(b)
(c)
(d)


## 6. Conclusion

In this paper, GA based PID controller tuning has been designed and applied to CSTR process. From the simulation studies, we infer that optimized controller parameters obtained by implementing this algorithm with a weighted combination of ISE, IAE, and ITAE as cost indices have achieved satisfactory set point tracking and disturbance rejection in the entire operating range of the CSTR process.



---

*Source: 791230-2014-12-23.xml*