## 3 Orthogonal Experiments and Grey Relational Analysis
### Neural Network Genetic Algorithm Function Optimization
#### 4.3.1 BP Neural Network Construction  
BP neural network is a type of multilayer feedforward neural network trained according to the error backpropagation algorithm [11]. It consists of an input layer, hidden layers, and an output layer, possessing excellent multi-dimensional function mapping capabilities without the need to construct complex mathematical models. Currently, there is no suitable mathematical model for the engine hood model discussed in this paper; hence, the choice  
Figure 5: Optimization flowchart.  
of the BP neural network is used to construct the mapping relationship between process parameters and targets. Studies have shown that neural network models with biases, at least one S-shaped hidden layer, and one linear output layer can approximate any rational function [18]. According to the description in the literature [19], multiple hidden layers can improve the fitting effect, prediction accuracy, and generalization ability of neural networks. This is particularly effective in handling the complexity and uncertainty of data, especially when there are few data samples. Therefore, a double hidden layer network structure was adopted for function approximation.  
The number of nodes in the input layer was determined using the number of input variables, and the number of nodes in the output layer was determined using the prediction target. The number of nodes in the hidden layer is determined using Equation (13). Through repeated experiments, it was found that when the number of nodes in both hidden layers is set to nine, the error rate is minimized.  
\[Z=\sqrt{i+j}+a,a\in[0,10] \tag{13}\]  
In the equation, \(i\) and \(j\) represent the number of nodes in the input and output layers, respectively.  
In the hidden layer, let \(F(x)\) be the mapping relationship of the activation function. The _Lossig_ function was chosen as the activation function for the hidden layer, and the _Purelin_ linear function was used for the output layer. The formula for the _Lossig_ function is as follows:  
\[F(x)=\frac{1}{1+e^{-x}} \tag{14}\]  
The formula for the _Purelin_ linear function is as follows:  
\[F(x)=x \tag{15}\]  
Based on repeated trials, other parameters of the BP neural network were set as follows: 100 iterations, the learning rate of 0.1, and the training target error of 0.001. In the MATLAB software environment, using the blank holder force and die clearance as input variables and \"maximum thickening rate\" and \"maximum thinning rate\" as prediction targets, a 2-9-9-1-2 neural network model was constructed, as shown in Figure 6.  
In this model, 21 sets of sample data are used for training and nine sets for prediction, with the prediction results shown in Table 7.  
During the prediction phase, the maximum average error rate of the part was 2.22%, and the minimum average error rate was only 0.67%. Based on this analysis, the average error rate during the prediction phase was well below 5%, indicating that the network model has a high predictive accuracy for such problems.  
Figure 6: BP neural network model.