# Research on Coal Structure Prediction Method Based on Genetic Algorithm-BP Neural Network
## 3 Materials and Methods
### Genetic Algorithm (GA)  
In order to solve the problem of BP neural network structure and parameter selection, a genetic algorithm (GA) is introduced into the BP neural network. GA is an evolutionary algorithm based on natural selection and genetic mechanism, which is used to solve complex optimization problems and search problems. Genetic algorithms search in the solution space to find the optimal or approximately optimal solution by imitating the biological evolution process (such as natural selection, crossover, mutation, etc.). By optimizing the BP neural network through GA, the BP neural network can converge to the global optimal solution faster, improve the training speed of the network, and effectively avoid problems such as it being easy to fall into the local optimal value and a long training time [38, 39, 40, 41]. The specific steps of GA optimization of the BP neural network are as follows [42]:  
(1) Population initialization. A population is randomly generated, and each individual represents all the weights and biases of a BP neural network. These weights and biases are usually encoded as a one-dimensional vector of real numbers. Figure 6: Schematic diagram of BP neural network. (2) Fitness function selection. The fitness is usually expressed as the inverse of the mean squared error, that is, the smaller the error, the higher the fitness. The fitness function is expressed as:  
\[fitness=\frac{m}{\left(x-y\right)^{2}} \tag{2}\]  
where \(m\) represents the number of samples; \(x\) represents the model prediction result; and \(y\) represents the label data. (3) Selection. The selection operation is mainly based on the fitness of individuals, and the roulette wheel selection is used in this paper. The basic principle is that the selection probability of each individual is proportional to its fitness, and individuals with high fitness are more likely to be selected. First, the total fitness is calculated; then, the fitness of each individual is calculated and, finally, selection is made based on the fitness of the individual, and the selected individual will be used as the parent individual. (4) Crossover. The selected parent individuals are crossed to generate new offspring individuals. The method used in this paper is single-point crossover, which selects a crossover point from two parent individuals and then exchanges the genetic parts after the point. This produces two new offspring individuals. (5) Mutation. The mutation operation is performed on the offspring individual, randomly changing a part of the gene (parameter). In this paper, point mutation is used, where the genes of individuals (in this paper, the parameters of individuals) will be randomly changed with a certain probability, thus introducing diversity and helping the algorithm to jump out of local optima. (6) Population update. The old population is replaced with the newly generated offspring individuals to form a new generation of population. (7) Check termination conditions. It is judged whether the termination condition is satisfied (whether the maximum number of iterations is reached or the fitness function value is no longer significantly improved). If it is satisfied, the algorithm is terminated and the result is output. Otherwise, the second step is returned to for the next generation of iteration. (8) Output the optimal parameters. The individual with the highest fitness is decoded into the weights and biases of the BP neural network, and these parameters are used to initialize the BP neural network. The BP neural network is optimized by GA and, finally, two hidden layers are used; the number of neurons in each hidden layer is 28 and 56, respectively. ReLU is one of the most commonly used activation functions in neural networks. Its definition is simple, but it performs exceptionally well in practical applications, and it is especially widely used in deep learning.