## 3 Design and Simulation of BP-PID-Smith Based Controller for pH Regulation System
### Design of BP-PID-Smith Prediction Compensator  
Because the pH control system in this paper is a large time-delay system, and the traditional PID control is easily affected by time-delay, it cannot be optimized and adjusted according to the overall changes of the system. Therefore, this paper combines BP neural network with traditional PID control, designs a predictive compensator based on BP-PID-Smith, reduces the impact of time delay on the system, improves its learning efficiency by optimizing PID controller parameters, and realizes the parameter tuning of the control system. The structure of the PID control system based on the BP neural network is shown in Figure 8.  
Figure 7: Simulation model of pH regulation system based on PID-Smith prediction compensation. The structure consists of a conventional PID and a BP neural network. The conventional PID realizes the closed-loop feedback control of the controlled object, and the BP neural network finally obtains the optimal PID control parameters of the system by continuously updating iterations according to the system state and learning algorithm. The neural network structure in Figure 8 is shown in Figure 9 below. The neural network consists of an input layer, an implicit layer, and an output layer, in which the input layer contains three neurons, and the inputs are \(r(k)\), \(y(k)\), and \(e(k)\); to reduce the complexity of the system and improve the learning efficiency, the number of neurons in the implicit layer is set to five; the output layer contains three neurons, and the outputs correspond to the three parameters of the PID controller, \(K_{p}\), \(K_{i}\), and \(K_{d}\), respectively. A neural network structure based on 3-5-3, where the input layer inputs are:  
\[O_{j}{}^{(1)}=x(j)\ \ \ \ \ (j=1,2,\ldots,M) \tag{33}\]  
\(M\) is the number of neurons in the input layer. The implicit layer inputs and outputs are:  
\[net_{i}{}^{(2)}=\sum_{j=0}^{M}w_{ij}{}^{(2)}O_{j}{}^{(1)} \tag{34}\]  
\[O_{i}^{(2)}(k)=f\Big{(}net_{i}^{(2)}(k)\Big{)}\ \ \ \ (i=1,2,\ldots,Q) \tag{35}\]  
Figure 8: Structure of PID control system based on BP neural network. Figure 9: Optimization of PID parameters based on BP neural network. where \(Q\) is the number of neurons in the hidden layer and \(w_{ij}^{(2)}\) is the hidden layer connection weight, \(f(x)=\tanh(x)=\frac{e^{x}-e^{-x}}{e^{x}+e^{-x}}\). The output layer inputs and outputs are:  
\[net_{l}{}^{(3)}(k)=\sum_{d=0}^{Q}w_{li}{}^{(3)}O_{i}{}^{(2)}(k) \tag{36}\]  
\[O_{l}^{(3)}(k)=g\Big{(}net_{l}^{(3)}(k)\Big{)}\ \ \ \ \ (l=1,2,\ldots,N) \tag{37}\]  
where \(N\) is the number of neurons in the output layer and \(w_{li}^{(3)}\) is the output layer connection weight, \(g(x)=\frac{1}{2}[1+\tanh(x)]=\frac{e^{x}}{e^{x}+e^{-x}}\). The control quantity \(u(t)\) of the PID controller is calculated according to Equation (23), \(K_{p}\), \(K_{i}\), and \(K_{d}\) are \(O_{1}^{(3)}(k)\), \(O_{2}^{(3)}(k)\), and \(O_{3}^{(3)}(k)\) as found in Equation (37). The selected performance metrics have the following functional form:  
\[E(k)=\frac{1}{2}[r(k)-y(k)]^{2} \tag{38}\]  
The gradient descent method is used to continuously and iteratively update the connection weights between the neurons in the neural network so that the error signal decreases in the negative gradient direction. In addition, to speed up the convergence of the BP neural network algorithm and to obtain better dynamic properties, an inertia term is added to obtain a new update of the output layer connection weights when the learning rate is \(\eta\). Figure 7:0  
where \(\alpha\) is the inertia factor. \(\frac{\partial E(k)}{\partial w_{li}^{(3)}}\) can be split into:  
Figure 7:1  
After performing a series of simplifications, the updated output layer connection weights after learning by the neural network are obtained as:  
Figure 7:2  
Figure 7:3  
Similarly, the update of the connection weights of the hidden layer after learning can be obtained as:  
Figure 7:4  
Figure 7:5  
The mathematical model for adding BP neural network is established above.