## 3 BP Prediction Model of First Weighting Based on the Genetic Algorithm (GA)  
It is necessary to optimize the BP neural network because the volatility of the network is relatively large and it is easy to fall into a locally optimal solution. GA is a domain-independent problem-solving technique, which encodes the problem into a chromosome composed of genes and generates a chromosome representing the solution to the problem through a continuous process of selecting, crossing, and mutating the chromosome. The GA operates on the chromosome code and isolates the characteristics of the problem itself, so it has wide adaptability. At the same time, since the algorithm operates in parallel from multiple initial points, the search process is free from convergence to a local extremum. The GA implements the search process through groups, making it different from a single-point search and easy to parallelize, thus improving the efficiency of the algorithm [30; 31]. Therefore, this paper uses a genetic algorithm to optimize the BP network and establish a GA-BP network model. The operational flow of the GA-BP algorithm is shown in Figure 5.  
The optimization of the BP neural network by GA mainly includes determining the structure of the BP neural network and optimizing the weights, thresholds, training, and prediction of the model. Since the optimization of the genetic algorithm is the initial weight and threshold of the BP neural network, as long as we know the topological structure of a neural network, we can determine the number of optimization parameters of the genetic algorithm, to determine the coding length of population individuals. The process of genetic algorithm includes the population initialization, fitness function, selection operator, crossover operator, and mutation operator [32; 33].  
Figure 4: Comparison of the first roof weighting interval.  
(1) Population initialization  
Through individual binary coding, each individual is represented by a binary string. The network structure of this paper is 12-15-1, so the number of weights and thresholds is listed in Table 3.  
(2) Fitness function  
In this paper, to make the residual difference between the predicted and actual value as small as possible, the sum of the absolute errors between the predicted and actual value of the predicted sample is selected as the output of the objective function.  
\[F=\sum_{i=1}^{n}abs(y^{\prime}_{i}-y_{i}), \tag{14}\]  
where \(n\) is the number of network output nodes, \(y^{\prime}_{i}\) is the predicted value, and \(y_{i}\) is the true value.  
(3) Operator selection  
Random ergodic sampling is adopted as the selection operator. A roulette wheel is used to select a pair of individuals; the two individuals compete and the one with the highest fitness is selected.  
Figure 5: The flowchart of the GA-BP algorithm.  
\begin{table}
\begin{tabular}{c c c c} \hline
**Link Weights between the Input** & **Thresholds of the** & **Link Weights between the Hidden** & **Thresholds of** \\
**Layer and the Hidden Layer** & **Hidden Layer** & **Layer and the Output Layer** & **the Output Layer** \\ \hline
180 & 15 & 15 & 1 \\ \hline \end{tabular}
\end{table}
Table 3: The number of weights and thresholds.  
\[p_{i}=\frac{F_{i}}{\sum\limits_{i=1}^{n}F_{i}}, \tag{15}\]  
where \(n\) is the number of individuals in the population, \(F_{i}\) is the fitness function value of the \(i\)th individual, and \(p_{i}\) is the probability that the \(i\)th individual will be chosen.  
(4) Crossover operator  
The simplest single-point crossover is adopted as the crossover operator. In the individual code string, only one intersection point is randomly selected, and the coding parts of two pairs of individuals are exchanged at that point.  
(5) Mutation operator  
The mutation operator produces some mutated genes with a certain probability, and the mutated genes are selected randomly. If the selected gene code is 1, it becomes 0; otherwise, it becomes 1. Table 4 shows the parameters of the genetic algorithm.