Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 8, No. 3, 2024 90 Simulation Application of BPNN‐PID Controller with Improved Ant Colony Algorithm in Temperature Control System Cong Gao, Mingge Sun, Xiaolong Guo, Yinggang Li, Xingke Zhang School of Information and Control Engineering, Jilin Institute of Chemical Technology, Jilin City, Jilin Province 132022, China Abstract: Aiming at the nonlinear and hysteresis of PID controller in temperature control, this paper proposes a BPNN-PID control scheme with improved ant colony algorithm, and uses MATLAB to simulate and compare experiments. The results show that compared with the traditional ant colony algorithm control and BPNN control methods, the improved system has higher precision and better anti-interference ability in temperature control, and has higher practical application value. Keywords: Hysteresis; Ant Colony Algorithm; BPNN-PID Control; Temperature Control. 1. Introduction Electric heating furnaces are widely used as equipment for industrial heat treatment. In order to achieve temperature control, the traditional principle of feedback control is used. The temperature sensor is used to obtain the actual measurement data, and after comparing with the predetermined temperature, it is controlled by adjusting the heating power of the controller to keep the temperature in the furnace near the set value during the use of PID. Compared with other control schemes, the traditional PID control scheme is relatively simple and feasible, and is often used in the control system with low precision. However, the hysteresis of temperature regulation and model parameters may be affected by changes in the environment and temperature in the furnace, making it impossible for traditional PID controllers to achieve accurate parameter adjustment [1]. It may cause overshoot or oscillation of the system, resulting in failure to meet the requirements of actual industrial production. In recent years, in order to improve the performance of temperature control system, many experts and scholars are committed to applying various advanced control algorithms to temperature control. The control concept of literature [2] et al. is to optimize and adjust the initial weight of BPNN by applying ant colony algorithm, and then adjust the PID parameters by using the optimized BPNN controller, and finally precisely control the temperature of the main steam. In literature [3], by combining genetic algorithm with BP neural network, the control system has faster response characteristics and better dynamic characteristics, which has certain popularization value for the control of industrial furnaces. Literature [4] et al. proposed a fermentation control scheme based on BPNN controller as the main body, and BPNN was used to adjust the output parameters of PID controller, thus improving the performance. In the temperature control system of electric heating furnace, ant colony algorithm and BP neural network algorithm are used to realize the control. During the implementation of the control system, in order to increase the response speed of the system, the ant colony algorithm's state transition rules and pheromone update rules are improved, which helps to improve the generalization and approximation characteristics of BP neural network and dynamically adjust the PID parameters. In the actual operation process, it is necessary to use the experience of PID parameter tuning to optimize some conflicting data, so as to improve the accuracy of temperature control. 2. Introduction to Electric Heating Furnace Control System The box-type resistance furnace is taken as the controlled object, and the system structure is shown in Figure 1. To set a target temperature, the real-time temperature in the electric heating furnace is detected by the measuring transmitter and transmitted to the controller. By comparing the real-time temperature with the target temperature, the deviation generated generates a control signal, and then transmitted to the voltage regulator module for heating power adjustment, so as to achieve temperature control. 调压模块 电加热炉 ( )y t e Voltage regulator module Electric heating furnace Measuring transmitter Controller ( )r t ( )y t   Figure 1. Structure of electric heating furnace system In the actual control system application, Siemens S7-1500 is used as the core controller of the system, the unidirectional thyristor voltage regulator module is used as the actuator, and the K-type thermocouple and intelligent temperature 91 transmitter module are used as the measuring transmitter to control the temperature of the electric heating furnace by adjusting the output power of the electric heating element. 3. Ant Colony Algorithm to Optimize BPNN-PID Controller The temperature control of electric heating furnace mainly uses PID control method, which is simple and easy to realize, and can achieve high control precision for the controlled object of accurate model. However, the temperature characteristics of electric heating furnaces are difficult to control because of their complexity, such as time variability and hysteresis. The conventional PID controller is difficult to satisfy the effect. In this paper, BPNN-PID electric heating furnace control scheme optimized by improved ant colony algorithm is adopted. The system mainly consists of three components: At the beginning, ant colony algorithm is used to optimize the initial weight of BPNN controller; Next, the BPNN controller continuously adjusts its own weight parameters; Finally, the parameters of PID controller and sum are adjusted. 3.1. BPNN Controller Adjusting the parameters of PID controller is an important step to achieve the ideal control effect. However, the traditional PID controller cannot adapt itself to the change of the operating condition of the controlled system [5], which directly affects the performance of the control system. ( )r t  Executive mechanism Controlled object Measuring transmitter e u BPNN-PID controller ( )y t Figure 2. BPNN-PID control system structure block diagram Firstly, the temperature transmitter is used to obtain the deviation e after the superposition of the preset  r t and the unit negative feedback  y t . As the input of the BPNN- PID controller, the neural network is used to continuously adjust the weight parameters, optimize and adjust the three parameters of the PID output in real time, and apply the optimized parameters to the electric heating furnace to meet the expected requirements. 3.1.1. Introduction to BPNN Controller The BPNN controller structure used in this study is a 3-5-3 network with three input nodes [6] corresponding to set value  r t , process value  y t , and deviation ( )e k . At the same time, it also includes three output nodes, which are suitable for the proportional coefficient pK , the integration time iK , and the differential time dK of the PID controller. The detailed structure is shown in Figure 3. With this network, the parameters of PID controller can be adjusted adaptively. Figure 3. BPNN structure diagram 3.1.2. BPNN-PID Control Algorithm The traditional PID controller works by adjusting the parameters of pK , iK and dK . To make the temperature system have a good closed-loop control performance [7], PID control algorithm adjusts the output of the controller according to the difference between the output of the execution object and the expected value. BPNN controller is mainly divided into forward propagation type and back propagation type of error neural network. Forward propagation is used to deal with classification and regression problems. Back propagation is a method to adjust BPNN controller by calculating gradient [8], and transfer errors from output layer to hidden layer and input layer to update network weights and thresholds. Forward propagation is used to calculate the output of the network, while back propagation is used to adjust the parameter deviation so that the network can better optimize the output effect. 1. Forward propagation network BPNN input layer function: (1) ( )jO x j ( 1,2,3)j  (1) In the formula, x is the input layer neuron. BPNN hidden layer input function: 3 (2) (2) (1) 1 ( ) * ( )i ij j i net k W O k   (2) BPNN hidden layer output function: (2) 2( ) [ ]i iO k f net k ( )( ) ( 1,2 5)i   (3) The hidden layer weight coefficient of BPNN can be expressed as (2) ijW , and the upper corner marks (1) , (2) and (3) respectively represent the input layer, hidden layer and output layer of the neural network. The Sigmoid function is usually chosen as the activation function to activate the output of the hidden layer neurons: ( ) tanh( ) ( ) / ( )x x x xf x x e e e e     (4) 92 BPNN output layer input function: 5 (3) (3) (2) 1 ( ) * ( )l li i i net k W O k   ( 1,2,3)l  (5) In the formula: (3) liW The coefficient represents the weight of the output layer of BPNN, and the activation function of the output layer selects the non-negative Sigmoid function: ( ) 1/ 2(1 tanh( )) /x x xg x x e e e    (6) BPNN output layer output function: (3) (3)( ) [ ( )]l lO k g net k ( 1,2,3)l  (7) In formula (7): (3) 1 ( ) pO k K , (3) 2 ( ) iO k K , (3) 3 ( ) dO k K . 2. error backpropagation network Expected error performance index criterion: 2( ) ( ( ) ( )) / 2E k r k y k  (8) By using the method of gradient descent, the expected error can be minimized. BPNN output layer weight learning: (3) (3) (2) (3)( ) ( ) ( 1)li i i liW k O k W k       (9) In the formula:  is the learning efficiency,  makes the inertia coefficient, and (3) i is to reduce the error signal of the weight of the output layer in the process of backpropagation: (3) (3)( ) ( ) sgn [ ( ) ( 1)] '( ( )) ( )i l y k e k e k e k g net k u k       (10) BPNN implicit layer weight learning: (2) (2) (1) (2)( ) ( ) ( 1)i j i j i jW k O k W k       (11) (2) i is to reduce the backpropagation error signal of the hidden layer weight: 3 (2) (2) (3) (2) 1 '{ ( )} ( )i i l i f net k Wli k     ( 1,2 5)i   (12) 3.2. Ant Colony Algorithm Controller Ant colony algorithm mimics ant foraging behavior and is an intelligent optimization method. In the process of searching for food, the algorithm will make positive feedback adjustment according to the concentration of pheromone [9], that is, ants will tend to choose the path with higher pheromone concentration, and ants will constantly release pheromone on the road through the state transfer rule. This regulatory mechanism increases the pheromone concentration on the better path and decreases the pheromone concentration on the worse path, so that the ants eventually choose the higher concentration path for food. This algorithm draws on the regulation mechanism of pheromone during ant foraging and is used to solve optimization problems such as path planning and task scheduling. By simulating ant behavior, ant colony algorithms can find global optimal solutions or near- optimal solutions. 3.2.1. State Transition Rule When selecting the next node to reach, ants will take into account the length of the path and the concentration of pheromone, and the corresponding formula of state transition rule is as follows: [ ( )] [ ( )] [ ( )] [ ( )] 0( ) { , i j j is s t t t tk ij kP t j allowed            (13)  is the pheromone heuristic factor;  Expectation heuristic factors; ( )i j t represents the information volume between nodes i and j . ( )j t represents the heuristic function; kallowed is the node that goes to the next place. 3.2.2. Pheromone Update Rules After all ants walk a path, they will iteratively process the remaining pheromones on the path and update them according to formula (14) : 1 ( ) (1 ) ( ) ( ) ( ) ( ) { i j i j ij m k ij ij k t n t t t t               (14)  is the pheromone volatilization coefficient and ( )k ij t is the pheromone increment during the cycle. 3.2.3. Improvement of Ant Colony Algorithm The core of ant colony algorithm mainly includes two elements: state transition rule and pheromone update rule [10]. In order to improve the effect of the algorithm, these two elements need to be optimized. In the traditional state transition rule, the idea of "search hot zone" is introduced [11], which sets the ant nest and food as two rectangular vertices, thus delineating a special search area. The part of the ant that connects the nest to the food, called the hot zone, was significantly more likely to be successful than the ants outside it. The state transition rule also introduces the importance of search as a weight, so the probability of the ant moving to the next node is: (15) In terms of pheromones, specific analysis should be made according to the distribution characteristics of pheromones [12]. The improved pheromone update rules of the traditional ant colony algorithm cannot meet the control requirements, so the traditional pheromone rules can be modified to achieve dynamic adjustment, and can be updated according to the convergence of the algorithm at different time points. The global pheromone rules are updated as follows: ( ) 2 / (1 ) ( ) ( , ), ( , )bs ij ij ij bst n t t t n i j T             (16) Local pheromone update rules: ( 1) (1 ) ( )ij ijt t     (17) In the formula, bsT is the optimal path of ant colony in the search process, and  is the adaptive variable. When 1  , the effect of formula (16) is strengthened, the effect of formula (17) is weakened, and the effect is opposite when 1  . 93 3.2.4. Improved Ant Colony Algorithm BPNN-PID Controller The structure block diagram of BPNN-PID control system optimized by improved ant colony algorithm is shown in Figure (4). ACO PID controller ( )r t ( )y tiKpK dK BPNN controller Improved pheromone update rulesImproved state transition rules  Executive mechanism e Controlled object u Figure 4. Structure block diagram of BPNN-PID control system optimized by improved ant colony algorithm In Figure 4, ( )r t represents the preset value and ( )y t is the real-time temperature of the electric heating furnace. By applying the improved ant colony algorithm to adjust the weight of BP neural network, a new controller is formed. Compared with the traditional ant colony algorithm, the state transition rule and pheromone update rule are strengthened. By performing optimization operations in the weights of BP neural network, the optimal weights can be found to minimize the system error. This control process mainly consists of two parts: one is to use the traditional PID controller for closed- loop control and parameter correction of the control object; the other is to use the neural network to adjust the PID parameters online according to the current operating state of the control object, so as to maintain the optimal operating state of the control system. The parameters in the PID controller correspond to the output value of the BP neural network, and the weight is adjusted by the self-learning ability of the neural network and the improved ant colony algorithm to make the control system reach a stable state. 4. Simulation Results and Analysis 4.1. Build Model In order to deal with the characteristics of nonlinearity and lag, a hybrid modeling method combining mechanism analysis and experimental identification is adopted to analyze the control system principle of the box-type resistance furnace. Firstly, the electric heating mechanism is analyzed and the model is established based on the law of conservation of energy. Then the parameters of the model are identified by analyzing the open-loop step response characteristics, and the mathematical model is represented by the combination of first-order inertia and pure hysteresis. The transfer function is shown in formula (18): ( ) 1 sK G s e Ts   (18) The time constant of the inertia link is expressed by T , the amplification factor isK , and the delay time of the lag link is expressed by  , whereT =2744,K =12.5, =30. 4.2. Step Response Characteristic Analysis In order to verify the effect of the control algorithm, PID, BPNN-PID, ACO-PID and improved ACO-BPNN-PID controllers are simulated respectively to observe the dynamic response characteristics, and pulse interference is added at appropriate positions to simulate the disturbance of the heating furnace under external action in actual conditions. The anti-interference ability of various control algorithms [13] is tested, and the results are presented in the form of response curve in Figure 5. Figure 5. Step response curve of the system 94 In the simulation results shown in FIG. 5, after the system responds, the overmodulation of PID controller is about 23%, that of BPNN-PID controller is about 10%, and that of ant colony algorithm controller is about 2%. The three control schemes approach the equilibrium in the 2500s, and the improved ant colony algorithm significantly reduces the adjustment time of BPNN-PID controller with fast response. The speed was increased. In order to test the response characteristics of the controller, a step disturbance with an amplitude of -0.1 is set at the time point of 4000s to compare the resistance to interference under various control methods. The specific data comparison is shown in Table 1 and Table 2. Table 1. Comparison of step response characteristic data Control mode PID BPNN-PID ACO-PID Improved ACO-BPNN-PID Overshoot/ % 22.8 10.3 2.1 0.1 Adjust time /s 2363 996 715 678 Rise time /s 308 252 479 308 Table 2. Comparison of characteristic data of interference action Control mode PID BPNN-PID ACO-PID Improved ACO-BPNN-PID overshoot /% 11.7 6.3 7.8 3.3 Adjust time /s 1026 940 1024 905 PID controller produces a large overshoot and takes a long time to reach stability, BPNN-PID and ACO-PID produce relatively less overshoot, and the recovery time is shorter than PID controller. Compared with traditional control controller schemes, the improved ACO-BPNN-PID controller has better performance and stronger anti-interference ability. The recovery time is fast. 5. Conclusion In the working process of electric heating furnace, the temperature variation trend will show some changes such as nonlinear and hysteresis. Based on the traditional control scheme, an intelligent algorithm is proposed to optimize the BPNN-PID controller by improving the ant colony algorithm. Simulation software is used to simulate each control scheme, observe the characteristic response curve of each control scheme, and conduct comparative experiments. The simulation results show that, the improved ant colony algorithm optimized BPNN-PID controller scheme has obvious improvement in anti-interference and can meet the practical engineering needs. References [1] Zhou Xin, Zhou Qi-Xiang, Yang Xu, et al. Design and Application of Temperature Servo Control System for Resistance Furnace [J]. Journal of Jilin University of Chemical Technology,20,37(7):45-48. [2] Wang Qiuping, Ma Chunlin, Xiao Lingling, et al. Application of Ant Colony Algorithm to Optimize BP Neural Network in Main Steam Temperature Control [J]. Chemical Automation and Instrumentation,2013,40(7):834-837. [3] QIONG WANG, XIAOKAN WANG. Parameters Optimization of the Heating Furnace Control Systems Based on BP Neural Network Improved by Genetic Algorithm[J]. Journal on Internet of Things, 2019,2(2):75-80. [4] Jiang Meixian, Wang Zhenshui, Wu Guoxing, et al. Control model and simulation of rice wine pre-fermentation temperature based on BPNN [J]. Journal of Zhejiang University of Technology,20,48(6):620-626. [5] Su Gang, Liu Hao, Qiao Junfeng, et al. Predictive adaptive PID control Method for Temperature system [J]. Journal of Jilin University (Information Science Edition),2022,40(1):1-6. [6] Wang Xiaoyu, Yan Yuwei. PLC Design and Implementation of BP Neural Network Electric Heating Temperature Control System [J]. Automation & Instrumentation, 201,36(12):24-28. [7] Xiong Chang-Jiong, Wang Chun-Rong, Xia Erdong. Research on Temperature Control of Heating Furnace Based on Improved PID Algorithm [J]. China Equipment Engineering, 2022 (12): 101-102. [8] Liang Hai-tao, Zhang Chun-yu, Chen Wei. Research on temperature control of tea strip machine based on BP neural network PID control [J]. Journal of Xinyang Agriculture and Forestry College,2021,31(2): 107-112. [9] Fu Xin, Li Jing. Ant colony algorithm [J]. Silicon Valley, 2012 (3):183-183. [10] Sun Y, Dong W ,Chen Y .An Improved Routing Algorithm Based on Ant Colony Optimization in Wireless Sensor Networks[J].IEEE Communications Letters,2017:1-1 [11] Zhou Jianxin, Huang Jianxiong. Temperature control of PIDNN heating furnace based on improved ant colony immune algorithm [J]. Sichuan Metallurgy,20,42(3):22-26. [12] Yu Menghan. Research on Optimal Combustion Control Strategy of Continuous Steel Rolling Heating Furnace [D]. North China University of Science and Technology,2022. [13] Yang Yi, Tiger Grace. BP Neural Network PID Controller based on S function and Simulink Simulation [J]. Electronic Design Engineering,2014,22(4):29-31,35.