## 3 LSTM Network Optimized by GA
### Genetic Algorithm  
The GA is usually a biological scientific algorithm that simulates [PERSON]'s theory of biological evolution by a computer, proposed by [PERSON] [32] in 1975. In the genetic evolution of populations in the GA, it is found that chromosomes are used as the main carrier of population inheritance, and with the help of a variety of random operations--gene selection, gene crossover, and gene mutation--a new solution set population is constantly evolving. According to the value of individual fitness and the selection function, the optimal population individual can be selected, which is the optimal solution of the optimization problem in the GA. In this paper, the GA is used to optimize the key hyperparameters of the LSTM network and the powerful global random search ability of the GA is adopted to obtain the optimal combination of the number of neurons and the learning rate in the LSTM network. The basic idea is as follows:  
(1) Chromosome coding  
The number of hidden-layer neurons and the learning rate in the LSTM network are taken as the initialization objects of the GA, and chromosome coding is carried out in the form of real-number coding. The interval range of hidden-layer neurons is set to [2; 40], and the interval range of the learning rate is set to [0.001-0.1]. (2) Fitness function  
The fitness function is applied to determine which individuals in the population can perform next-generation genetic operations. According to differing individual fitness, the \"survival of the fittest\" is used for screening individuals. The selection-of-fitness function directly affects the performance of the optimized network by the GA and then affects the performance of prediction. This paper mainly constructs the fitness function based on the overall fit between the estimated value and the true value of the ship navigation position. In order to make the network parameters obtained by the GA more suitable for the LSTM model and improve the generalization ability of the model, the AIS data are divided into training samples and test samples. The training samples are utilized for LSTM network training. After reaching the limit of the number of iterations, the training sample output value and test sample output value of the LSTM network are obtained. Then the individual fitness function is defined as:  
\[fitness=0.5\times\frac{1}{\gamma}\sum_{j=1}^{J}\left(\widetilde{\boldsymbol{y} }^{j}_{t}-\boldsymbol{y}^{j}_{t}\right)^{2}+0.5\times\frac{1}{K}\sum_{k=1}^{K }\left(\widetilde{\boldsymbol{y}}^{k}_{v}-\boldsymbol{y}^{k}_{v}\right)^{2} \tag{9}\]  
where \(\widetilde{\boldsymbol{y}}^{j}_{t}\) and \(\widetilde{\boldsymbol{y}}^{k}_{v}\) are the predicted value of the training sample and the predicted value of the test sample, respectively, and \(\boldsymbol{y}^{j}_{t}\) and \(\boldsymbol{y}^{k}_{v}\) are the actual value. The error of the test sample directly reflects the prediction effect of the model; therefore, the fitness function \(fitness\) includes not only the fitting error of the training sample but also the verification error of the test sample. In the experiment, the error of the training sample and the error of the test sample are given the same weight, which is 0.5, and the sum of the two multiplied with the weight is used as the fitness function of the model. (3) Selection operator, crossover operator, and mutation operator  
The selection operator selects individuals with better adaptability as parents in the current population and passes genetic information to the offspring. Here, the tournament selection algorithm is used as the GA selection strategy. This selection strategy has the characteristics of efficient algorithm execution rate and easy implementation, and its algorithm complexity is much lower than other selection strategies and is easy to parallelize. It is not easy to fall into the local optimal individual during the selection process and does not require sorting the fitness values of all individuals. The crossover operator takes the shuffle crossover algorithm.