## 3 Algorithm Design
### BP Neural Network
#### 3.2.2 Structure Design of BP Neural Network  
The current study establishes one hidden layer in a BP neural network structure. Each time the SoC value is estimated, the battery temperature \(T\) at time \(k+1\), the Kalman gain matrix \(\mathbf{P}_{k}\), and the SoC state value difference \(\Delta\hat{\mathbf{x}}_{k+1}(=\hat{\mathbf{x}}_{k+1}-\hat{\mathbf{x}}_{k})\) estimated via the EKF algorithm at time \(k\) and time \(k+1\) are input into the trained neural network model, and the SoC estimation error \(\Delta SoC_{k+1}\) is taken as the output to remove the estimation error \(\Delta SoC_{k+1}\) from the estimated value \(\hat{\mathbf{x}}_{k+1}\). Finally, the estimated value \(SoC_{k+1}\) of the SoC quantity of a state at time \(k+1\), namely, \(SoC_{k+1}=\hat{\mathbf{x}}_{k+1}+\Delta SoC_{k+1}\), is obtained (see Figure 4 below). Let \(m,\ n\), and \(s\) in Figure 4 equal the quantity of nodes in the input layer, hidden layer, and output layer; \(i,\ j\), and \(l\) denote the input layer, hidden layer, and output layer, with \(i,\ j\), and \(l\) neurons in each case. In this paper, the number of input layer nodes is \(m=3\), the quantity of output nodes is \(s=1\), and the quantity of hidden layers of the BP neural network may be determined via a trial-and-error method; the common formula is \(n=\sqrt{m+s}+a\) (where \(a\) is the constant within the range from 1 to 10) [30]. After many simulation tests, when the quantity of hidden layer nodes is \(n=7\), the network prediction accuracy is higher, and the convergence speed is faster. \(w_{ij}^{1}\) and \(w_{ji}^{2}\) denote the weights that travel from the \(i\)-th input layer node to the \(j\)-th hidden layer node in addition to the \(j\)-th hidden layer node to the \(l\)-th output layer node in the network, respectively. The \(j\)-th nodes across the network in the hidden layer contain a threshold of \(b_{j}^{1}\); meanwhile, the \(l\)-th nodes across the network in the output layer have a threshold of \(b_{l}^{2}\). Figure 4: Specific structure and parameter diagram of BP neural network. According to the quantity of nodes in each layer determined in this paper, from the input layer to the hidden layer, the weight matrix equals \(\mathbf{W}^{1}\), and the threshold matrix equals \(\mathbf{B}^{1}\). The weight matrix from the hidden layer to the output layer equals \(\mathbf{W}^{2}\), and the threshold matrix equals \(\mathbf{B}^{2}\). The input vector equals \(\mathbf{X}\), the output vector equals \(\mathbf{Y}\), the expected output vector equals \(\mathbf{O}\), the hidden layer output value vector equals \(\mathbf{V}\), the hidden layer error value vector equals \(\mathbf{U}^{1}\), and the output layer error value matrix equals \(\mathbf{U}^{2}\), as shown in Equations (11) and (12)  
\[\mathbf{W}^{1}=\left[ \begin{array}{cccc}w_{11}^{1}&w_{12}^{1}&\cdots&w_{17}^ {1}\\ w_{21}^{1}&w_{22}^{1}&\cdots&w_{2n}^{1}\\ w_{31}^{1}&w_{32}^{1}&\cdots&w_{37}^{1}\end{array} \right]\,,\,\mathbf{B}^{1}= \left[ \begin{array}{c}b_{2}^{1}\\ \vdots\\ b_{7}^{1}\end{array} \right]\,,\,\mathbf{W}^{2}=\left[ \begin{array}{c}w_{21} ^{2}\\ w_{21}^{2}\\ w_{71}^{2}\end{array} \right]\,,\,\mathbf{B}^{2}=\left[b_{1}^{2}\right] \tag{11}\]  
\[\mathbf{X}=\left[ \begin{array}{c}\alpha_{1}\\ \alpha_{2}\\ \alpha_{3}\end{array} \right]=\left[ \begin{array}{c}T\\ \mathbf{K}_{k}\\ \Delta\hat{x}_{k+1}\end{array} \right]\,,\,\mathbf{Y}=\left[\theta_{1}\right]= y\,,\,\mathbf{O}=\left[\phi_{1}\right]\,,\,\mathbf{V}=\left[ \begin{array}{c} \delta_{1}\\ \delta_{2}\\ \vdots\\ \delta_{7}\end{array} \right]\,,\,\mathbf{U}^{1}=\left[ \begin{array}{c}u_{1 }^{1}\\ u_{2}^{1}\\ \vdots\\ u_{7}^{1}\end{array} \right]\,,\,\mathbf{U}^{2}=\left[u_{1}^{2}\right] \tag{12}\]  
where we also obtain \(\mathbf{V}=g_{1}(\mathbf{W}^{1^{\prime}}\mathbf{X}+\mathbf{B}^{1})\) and \(\mathbf{Y}=g_{2}(\mathbf{W}^{2^{\prime}}\mathbf{V}+\mathbf{B}^{2})\). The activation functions for the hidden layer and the output layer in each case are \(g_{1}(\cdot)\) and \(g_{2}(\cdot)\), and the two activation functions can be the same.