Research on Ship Collision Avoidance Path Optimization Based on Particle Swarm Optimization and Genetic Algorithm

: With the increasingly busy shipping routes, ship collision accidents occur from time to time. In order to avoid ship collision, the research on ship collision avoidance decision has become a research hotspot. For a long time, many experts and scholars have been publishing research results on collision avoidance automation and artificial intelligence, in order to avoid or reduce ship collision accidents in the case of large marine traffic flow and complex traffic forms. Based on the previous research, considering the economic and safety requirements of ship collision avoidance, and based on particle swarm optimization algorithm, genetic algorithm and nonlinear programming theory, this paper establishes the optimization model of ship collision avoidance path planning. Combined with specific cases, the simulation analysis is carried out under the three collision avoidance situations of ship head-on, crossing and overtaking. The simulation results show that the convergence speed of particle swarm genetic hybrid optimization algorithm is fast, ship collision avoidance path is smooth, and path distance and steering angle is small. The optimal path of ship collision avoidance can meet the requirements of economy and safety at the same time, and the effectiveness and operation efficiency of the algorithm have been significantly improved.


Introduction
With the more and more frequent trade between countries in the world, ship maritime transportation has become an international transportation industry. At present, most countries in the world use maritime transportation for bulk import and export goods, and the maritime routes are very busy. At the same time, with the development of marine science and technology, the ship tonnage is getting larger and larger, and the ship speed is getting faster and faster, which increases the possibility of marine collision accidents. In order to avoid ship collision, the research on ship collision avoidance decision has become an important topic in the navigation industry [1][2][3]. For a long time, many experts and scholars have been publishing research results on collision avoidance automation and artificial intelligence, in order to avoid or reduce ship collision accidents in the case of large marine traffic flow and complex traffic forms. After years of development, the research in this field has gradually changed from the traditional analysis based on mathematical theory to the path planning analysis with intelligence and discipline diversity, and the academic research results in related fields are constantly enriched [4][5][6].
Based on the fuzzy logic algorithm, the decision-making model of ship navigation collision avoidance operation is given by means of computer simulation. Some scholars also evaluate the ship collision risk, obtain the learning samples by using the fuzzy theory, take the DCPA (distance of the closure point of approach) and TCPA (time to the closure point of approach) of each target as the input and the ship collision risk index as the output, and apply the back propagation neural network to make multi-attribute decision [7,8]. In addition to the safety decision-making of ship collision avoidance, some scholars also apply the grey theory prediction model to predict the next movement direction between each target and the relative ship according to the ship movement situation and collision avoidance opportunity in the ship collision avoidance decision-making, taking the nearest encounter distance and time as the prediction parameters [9,10]. In recent years, researchers began to introduce artificial intelligence technology into the field of collision avoidance, using neural network, fuzzy theory and genetic algorithm to study the problem of collision avoidance, and then opened the research field of software computing automatic collision avoidance, which is different from the pure mathematical model. At the same time, some scholars put forward the development analysis of collision avoidance technology and path planning for ships in close encounter at sea, and used multi-objective optimization algorithm to search for the route planning of the best route [11][12][13].
Based on the above research, it can be found that the current research on ship collision avoidance has entered the systematic mode from the mathematical mode, from the expert system to the fuzzy neural network, artificial intelligence and decision support system, and has obtained a more valuable mathematical model in all aspects. However, most of the current path planning research on ship collision avoidance decision-making is based on the perspective of detection algorithm, and the optimization algorithm has problems such as premature convergence. Therefore, based on particle swarm optimization algorithm and genetic algorithm, this study establishes a ship collision avoidance path planning model, which is verified by simulation cases, which overcomes the problems of premature convergence of optimization algorithm, in order to provide scientific and reasonable theoretical support for the above collision avoidance decision-making.

Analysis of Ship Collision Avoidance Path
According to the comprehensive literature analysis [14], the avoidance ship has begun to take avoidance action before being infringed in the ship field. The ship area is a collection of safe distances, so the minimum distance between the ship and the straight ship after taking action is the ship area. However, due to the frequent jumping of heading data, this study, based on the phased characteristics of avoidance behavior, instead takes the nearest distance point C between the two ships as the center, and divides the fixed time area before and after the nearest point into three sections (as shown in Figure 1): Section AB is the section where the dangerous area is found, and the original heading is maintained at this time, which is defined as the initial heading; BD section is the area where the ship performs avoidance action, which is defined as avoidance heading; After other ships pass safely, the original course shall be restored at point D, and DE segment shall be defined as the restored course. When the average heading difference between BD section and AB section is greater than 10° and the error between AB section and DE section is within 3°, it indicates that avoidance action has been taken.
It can be seen from the diagram of ship collision avoidance path in Figure 1 that the course within a fixed time before and after the nearest distance point C from other ships is the new course of collision avoidance path. In order to determine the course of avoidance and the DCPA and TCPA of avoidance, the course values within 2 min before and after point C are taken as the average in this study; Take the heading value before the collision avoidance action time point of the original heading section AB as the average; In the DE section of restoring the original course, because the recovery time will be shorter than the avoidance action time in the previous section, the selection of the average course time can be shorter than the whole collision avoidance time area.

Conditions Determination of Ship Collision
The system uses the DCPA and TCPA values set by the user as the basis for judging whether there is a collision risk and when to start implementing collision avoidance measures. When the current DCPA value of two ships is less than the DCPA value set by the user and TCPA is greater than zero, it means that the two ships continue to move forward in this direction, otherwise there will be a risk of collision. In case of collision crisis, when the current TCPA value of the two ships begins to be less than the TCPA value set by the user, the collision avoidance measures shall be implemented. When the current TCPA value of two ships starts to be less than zero, it means that they have left the closest point between the two ships and there is no collision risk. According to the analysis diagram of ship collision avoidance path in Figure 1, the judgment conditions of ship collision risk are given, as shown in Table 1. Table 1. Determination conditions of ship collision risk.

Collision condition Relative bearing or true bearing
Head-on The bearing of the headline of the ship relative to the other ship is -6° ~ +6°, and the bearing of the headline of the other ship relative to the ship is -6° ~ +6° Left crossing The bearing of the headline of the ship relative to the other ship is 0° ~ +90°, and the bearing of the headline of the other ship relative to the ship is 0° ~ -90°

Right crossing
The bearing of the headline of the ship relative to the other ship is 0° ~ -90°, and the bearing of the headline of the other ship relative to the ship is 0° ~ +90° Left overtaking The bearing of the ship is the heading (the other ship) +112.5°~180°, and the headline of the ship is greater than (less than) 0°~90° from the other ship

Right overtaking
The bearing of the ship is the heading (the other ship) -112.5°~180°, and the headline of the ship is greater than (less than) 0°~90° from the other ship

Overview of Particle Swarm Optimization and Genetic Algorithm
The main concept of particle swarm optimization (PSO) is derived from the animal group behavior theory and inspired by the observation of the collective action of birds and fish groups. When they act collectively, they can make the whole group move in the same direction through the special way of transmitting information between individuals, so as to seek the best interests of the group. The algorithm first generates an initial particle swarm, and each particle is a solution to the problem. In the particle swarm search space, each particle has its own speed, evolves and modifies according to previous experience and group behavior, and gradually approaches the optimal solution [15]. Genetic algorithm (GA) is an optimization algorithm based on the concept of biological genetic evolution. The genetic algorithm randomly selects such a concept, and then uses the random mutation evolution method to optimize the required conditions as the basis for judging ship collision. This method can more effectively search for new optimization problems in a known space and find the optimal solution. Its core principle is Darwin's theory of evolution, the fittest survive and the unfit eliminate [16].
Although particle swarm optimization (PSO) algorithm has fast convergence speed, when PSO solves the optimization, all particles move to the particle with the best fitness value during the search, resulting in the gradual reduction of particle diversity, so that particles often can not jump off the local optimal solution. Therefore, scholars have proposed a dynamic particle swarm optimization algorithm combined with genetic algorithm PSO-GA). In the process of solving the optimal solution by particle swarm optimization, they combine genetic algorithm. When specific conditions are met, the particles and their displacement velocity are copied and put into the mating pool. With mating, mutation and other mechanisms as interference, the particles can get rid of the local optimal solution and get the global optimal solution. Compared with the traditional particle swarm optimization algorithm, this hybrid algorithm has faster convergence speed and good clustering quality. On the basis of considering the advantages and disadvantages of the above two algorithms, the multi-objective optimization solution is integrated, so as to quickly search and break away from the local optimal solution, construct and optimize the ship path and avoid ship collision.

Coding and Initialization of Collision Avoidance Path
On the collision avoidance path of ships, in order to obtain the key information such as TCPA and DCPA, it is necessary to obtain the environmental information in real time to update the position of ships and the angle of collision avoidance path. Whether in the adjustment of the ship's real-time path or the setting of the initial position, it is necessary to rely on the environmental information to determine the ship's position and avoidance angle. Therefore, the following equation is given in the relationship between the adjustment of the real-time path and the initial position: Where, is the search parameter and is the current location parameter.
Set the number of particles to be generated in space, and then correct the position and speed of path movement through this initial position and speed: Each particle is limited to its maximum moving speed and maximum moving range , so that the speed and movement of particles will not exceed the set range, so that the control particles can be evenly distributed in space.
Where, is the weight coefficient, and the value is 0 < < 1.
Calculate the fitness function of each particle, as described in the following formula: Define the best adaptability parameter ( %&'() ) and the best position ( %&'() ) of each particle: If the individual optimal value ( %&'() ) and the group optimal value ( 0&'() ) are equal, it means that the optimization result has been reached, and the condition can be defined as: If equation (9) is satisfied, skip to the previous step, otherwise the next moving speed of each particle will continue to be updated.
Where, the second part is the cognitive model of the particle itself, the third part is the social model of the particle group, is the original speed of the particle, is the speed of the particle's next movement, 2 and 2 are learning factors, % is the best position of the individual, 0 is the best position of the group, and is the current position of the particle. 1 is the weight value, which we define as: Where 1 and 1 represent the maximum and minimum values of 1 respectively.
Then, genetic algorithm is used to adjust the weight value 1 in particle swarm optimization. First, determine the range of chromosomes and the total number of chromosomes. Calculate the adaptability of each single chromosome, which depends on the replication process or the selected chromosome, and then generate the initial parental chromosome population (< , < ,•••, < ). Calculate the adaptability of each chromosome ( (= ), (= ),••• , (= )). Among all parental chromosomes, based on the level of adaptability, select the chromosomes with the set proportion and number, and then find a pair of chromosomes with the highest adaptability from these chromosomes for mating. Through the cross operation and mutation between chromosomes, a pair of offspring chromosomes are generated. The new offspring chromosomes were added to the new chromosome population. Then repeat step until the total number of chromosomes is equal to the initial total number. The parental chromosomes are replaced by new offspring chromosomes until the termination conditions are met or the goal has been optimized.
Check the particle speed limit again.
Update the position value of each particle at the same time: Where represents the new location to be moved next time.
In the search range, give each particle a limit to update the position value: Finally, the movement mode of the ship's final collision avoidance path is determined according to the nonlinear optimization objective function corresponding to the particle optimal position ( 0&'() ) and the optimal adaptation parameter ( 0&'() ).

Objective Function of Collision Avoidance Path Optimization
In the decision-making process of ship collision avoidance, it is necessary to meet both safety and economic objectives. The safety objectives are mainly determined by DCPA, by setting the minimum DCPA, and the economy is determined by turning amplitude and avoidance mileage. The specific optimization objective function is Where, is the safety objective function value, B CDEF is the nearest distance from the target ship, is the economic objective function value, and is the collision avoidance path mileage, K Is the steering amplitude, @ and G They are the weight coefficients, and the optimization objective function is optimal with the minimum value, so the collision avoidance path has the best safety and economy.

Program Design of Collision Avoidance Path
According to the above PSO-GA algorithm model and optimization objective function, the program design flow of ship collision avoidance path in this study is given, as shown in Figure 2.

Simulation Parameters
In this study, MATLAB software is used for simulation analysis, the simulation platform adopts Intel Core 3.2 GHz processor and a computer with 16 GB memory. Environmental parameters such as wind direction and water density are set as conventional parameters. The parameters of this ship and target ship are shown in Table  2. Combined with the given ship parameters, this study simulates and analyzes the ship collision avoidance in combination with the three situations of head-on, crossing and overtaking. This ship is the coordinate origin, and the target ship information of the three situations is shown in Table 3.

Analysis of Simulation Results
In order to verify the reliability of the collision avoidance algorithm in this study, the three ship collision avoidance situations given in Table 3 are analyzed. With reference to the azimuth distribution and distance of the target ship, the initial parameter values of the collision avoidance situation are given and input into the algorithm program, and the initial operation of the path is carried out based on the perspective of initialization function. At the same time, the hybrid genetic algorithm is used to optimize the ship collision avoidance path. The genetic operator is used to select the initial population, the appropriate function is used to determine the quality of the genetic process, and the global optimization position is obtained. Then the ship collision avoidance path is searched and the optimal collision avoidance operation path is solved.
In the three collision avoidance situations of head-on, crossing and overtaking, the ship can achieve safe and effective avoidance, and the avoidance paths are smooth, that is, the distance between the ship and the target ship changes evenly, which meets the safety requirements in collision avoidance. At the same time, the minimum distance is greater than 5km, It meets the wide avoidance requirements in ship avoidance. At the same time, the target ship in the three collision avoidance cases finally approaches and returns to the initial heading trajectory. The deviation of the trajectory from the original course is not large, which meets the economic requirements of ship avoidance.

Comparative Analysis of Algorithms
It can be seen from the analysis in Figure 3 that the collision avoidance path plan of the algorithm in this study can meet the safety and economic requirements of ship collision avoidance, and the path optimization is good. In order to further verify the effectiveness of the hybrid genetic algorithm in this study, the particle swarm optimization algorithm and genetic algorithm are compared with the algorithm in this study to simulate the three situations of head-on, crossing and overtaking, The number of iterations of simulation and the average optimal value are compared, and the results are shown in Table 4. According to the comparison results in Table 4, it can be seen that under the three collision avoidance conditions of head-on, crossing and overtaking, the algorithm in this study can complete iterations within 25 times, of which the number of iterations under the encounter condition is at least 13 times, which is more than 20 times less than that of particle swarm optimization algorithm and genetic algorithm under the same condition, and the convergence speed of the algorithm has been greatly improved; At the same time, it can be seen from the average optimal value that the average optimal value of this research algorithm in the three collision avoidance situations of head-on, crossing and overtaking is less than that of particle swarm optimization algorithm and genetic algorithm. The convergence of this research algorithm is better, that is, the economy and safety of collision avoidance path are optimal. To sum up, the results further verify the effectiveness and efficiency of the algorithm.

Conclusion
With the continuous improvement of maritime transportation efficiency, ship collision has become one of the important factors affecting maritime transportation safety. The optimization decision analysis of ship collision avoidance path has become a research hotspot. In this study, considering the requirements of ship safety and economy, particle swarm optimization algorithm and genetic algorithm are integrated and applied to the optimization analysis of ship collision avoidance path, so as to construct the optimization model of ship collision avoidance path planning. Combined with specific cases, the simulation analysis is carried out under the three collision avoidance situations of ship head-on, crossing and overtaking. The analysis results show that the particle swarm genetic hybrid optimization algorithm presented in this study has faster convergence speed, smoother ship collision avoidance path, smaller path distance and steering angle, and can meet the economic and safety requirements of ship collision avoidance at the same time. Compared with a single algorithm, it has significant effectiveness and efficiency.