The GA–ACO–BP hybrid algorithm is to integrate the advantages of a genetic algorithm, ant colony optimization and BP neural network technology, design a hybrid genetic–ant colony algorithm, and introduce and optimize the BP neural network.
3.2.1. The BP Neural Network
A BP neural network is a multi-layer feedforward neural network trained according to the error back propagation algorithm. Among all neural network models, the BP neural network algorithm is among the most successful and widely used neural network models. In the process of BP neural network training, the error is compared between the results of each training and the actual results, and then feedback to the middle layer to modify the weights and thresholds, step by step to approach the desired prediction results, which is the core of the BP neural network.
A BP neural network consists of an input layer, a hidden layer, and an output layer. given training set
, Among them,
means input training samples of d indicators,
means input one-dimensional test samples, compare the error ‘e’ between the actual results
and
, and feed it back to the middle layer for error correction. The topology of BP neural network is shown in
Figure 4.
Specific steps are as follows:
Step 1. Initialize the network, input the training set and the test set, and determine the input dimension (
) and the output dimension (
). Initialize the weights V and W between neurons in the input layer, the hidden layer, and the output layer, initialize the output threshold of the hidden layer, and set the learning rate and activation function. The number of nodes in the initial hidden layer is obtained by the empirical formula, and the empirical formula is as follows:
Step 2. Calculate the hidden layer output and the output layer output:
where
represents the input variable,
,
represents the connection weight between the input layer and the hidden layer and the threshold of the hidden layer, the output of the hidden layer is
,
is the number of nodes in the hidden layer and the number of nodes in the output layer, and
f is the hidden layer. Layer activation function;
,
are connection weights and thresholds, respectively.
Step 3. The calculation of the error,
e, is:
is the predicted value and is the actual expected value.
Step 4. Update the weights and thresholds, and update the network connection weights through the prediction error
e.
where
is the learning rate, and then judge whether the iteration has reached the expected value, if not, return to step 2 and cycle again until the training effect reaches the desired effect.
3.2.2. Ant Colony Optimization
Compared with other heuristic algorithms, an ant colony algorithm has strong robustness in solving performance (the basic ant colony algorithm model can be applied to other problems after a little modification) and the ability to search for better solutions, and it can also be well integrated with a genetic algorithm. At the same time, the inland waterway is changeable, the navigation situation of ships is complex, the navigation habits of each waterway are different, and the data characteristics of different regions are different. Therefore, an optimization algorithm that can adapt to various conditions and is sensitive to a small amount of data is needed. Ant colony optimization is a probabilistic algorithm used to find optimization paths. It has the characteristics of distributed calculation, positive feedback of information and heuristic search. It is essentially a heuristic global optimization algorithm in evolutionary algorithms. The general process of the ant colony algorithm is as follows:
Step 1. Initialization. Initialize pheromone and heuristic information; determine initial values of parameters such as population size M, pheromone volatilization coefficient, transition probability constant, and total amount of information released. The optimization in an ant colony algorithm usually takes a lot of time, and by calling the genetic algorithm to select the optimal individual to optimize the distribution of initial pheromone, the speed of ant colony optimization can be greatly accelerated.
Step 2. State transition. In order to avoid too much residual pheromone and drown out the heuristic information, after each ant completes one step or completes the traversal cycle of all
positions, the residual information is updated. Therefore, the amount of information on the path (
) at time
can be adjusted according to the following rules:
Among them,
is the initialization parameter,
is the random value in the [0, 1] interval;
is the pheromone concentration on the path (
) at time
t;
is the information heuristic factor, representing the guidance of the amount of pheromone for the ants to choose the route role;
is the expected heuristic factor, the ant decision is influenced by the path distance information;
is the heuristic function.
When
, pseudo-random proportional selection is used, as follows:
Meaning of parameters in the formula:
: The position point that the ant has not visited yet is the position point that can be traversed next; S: the probability of the ant moving from position to position t at time ; S: temporary A location in the set of unvisited location points; the larger the value of, the greater the probability of going to location (but the actual location in the model is not necessarily the point with the highest probability). For , it means that the location If point n has been visited, the probability of being selected is 0;
The initial ant is randomly in a city, then the set has (n − 1) elements; then the ant goes to the next position according to (n − 1) non-zero probability
values. At this point, the set has (n − 2) elements, and continues to calculate the next target position…, until the set is empty and the ants have traversed all
positions.
Step 3. Fitness calculation. The fitness function is established according to the track prediction problem, and the fitness of each individual is calculated to obtain the current solution. In this paper, the ship track is predicted by the ship dynamic data in the AIS data. Here, we use the mean square error of the track training set and the test set as the fitness function. When the difference between the predicted value and the actual value is the smallest, the fitness function should be the minimum value, indicating that the more accurate the training, the higher the prediction accuracy.
is the individual fitness value, is the true value, is the predicted value.
In the process of optimization, ants will achieve some solutions of poor quality, which will leave pheromones on the path. These pheromones will induce the ants to choose this path, causing them to waste time searching for high-quality solutions. In order to avoid this problem as much as possible, a value needs to be selected as the quality of the solution. If the fitness value is greater than the given value, the high-quality solution is left, and pheromone is generated on the ant search path. If the fitness value is less than the given value set value, it will be eliminated. In this paper, the average value of the fitness values corresponding to all ant search paths in each cycle is used as the judgment condition, as shown in the following formula. The search path of each ant is recorded, and the solution with the best fitness value is left.
Among them, is the average value of the fitness values corresponding to the paths traveled by all the ants, m is the number of ants, and is the fitness value corresponding to the path traveled by the i-th ant.
Step4 Update pheromone. After all the ants complete the path assignment, the path will be updated (pheromone update), and the pheromone on the path will be updated according to Formula (12).
In the formula,
represents the pheromone volatilization coefficient,
represents the pheromone residual coefficient,
represents the total amount of pheromone left by all ants from position
to
, as shown in Equation (13).
In the formula,
represents the amount of pheromone left by ant
when it walks the path
, which can be calculated by Formula (14):
In the formula, is the route distance traveled by ant , and is the total amount of pheromone.
Step 5. Save the path population obtained by the ant search, compare the weights and thresholds of the BP neural network obtained under all the path populations, and make predictions, respectively, to obtain the best network parameters.
3.2.3. The Genetic Algorithm
A genetic algorithm is designed and proposed according to the laws of biological evolution in nature. It is a computational model that simulates natural selection and genetic mechanism to simulate the accidental events of biological evolution. The general process of the genetic algorithm is as follows.
Step 1. Initialization: Set the maximum evolutionary algebra T, set the initial population size N, as the initial population .
Step 2. Fitness calculation. According to the problem to be solved, different fitness functions are formulated. The design of the fitness function will directly affect the performance of the genetic algorithm. In this model, the genetic algorithm and the ant colony algorithm use the mean square error of the predicted value of the BP neural network as the fitness function. The smaller the fitness value is, the more accurate the training is, and the fitness function is as follows.
is the th individual fitness value, is the th true value, is the th predicted value.
Step 3. Select operation: There are many methods for selection operation in a genetic algorithm, the common ones are roulette method, tournament method, etc. In this paper, the selection strategy of the roulette method is used to arrange the pheromone of the ants in ascending order, and the ants with low fitness are subjected to genetic selection and crossover operation, the hybridization probability ratio is 0.8, and the mutation probability ratio is 0.2. Then, the probability of each population stepping into the next link is inversely proportional to its corresponding fitness value, and the probability of an individual being selected
is as follows.
In the formula, is the fitness value of individual , the smaller the fitness value in this paper, the better the training effect.
Step 4. Cross operation: Chromosomes according to the set probability . Perform the crossover operation to group the parent chromosomes into pairs. Assuming the two parent chromosomes are and , the algorithm automatically generates a random value r during the operation. If the value is smaller than the crossover probability , perform the crossover operation on the chromosome and , otherwise, do not implement.
The crossover works as follows:
Among them, are the chromosomes, is a random number between 0 and 1, and are the chromosomes that are regenerated after the parent chromosome is crossed.
Step 5. Mutation operation: The purpose of mutation is to increase the diversity of individuals. Chromosomes are mutated according to the set probability
(0.2). The specific mutation method is as follows: the algorithm automatically generates a random value r during the operation process, and the value is set in advance with the value
. A good mutation probability
is compared, and if
<
, the mutation operation is performed, otherwise it is not performed. Mutation works as follows:
Among them, is the lower bound, and rand is a random number within 0–1.