TPS-Genetic Algorithm for Real-Time Sailing Route Planning based on Potential Field Theory

— Real-time route planning is always a difficulty in maritime traffic. Route planning must take into account the complex meteorological environment. Route planning based on meteorological environment real-time update is the basis of route feasibility. Based on potential field theory, this paper proposes a TPS - Genetic algorithm for real-time route planning of sailing ships. On the basis of genetic algorithm, combined with the characteristics of route planning, the turning point sorting operation is added to improve the calculation efficiency, and further improve the real-time performance of route planning. Simulation experiments are established and compared with A* algorithm. The experimental results show that the potential field theory can accurately express the dynamic changes of Marine meteorology, and the path planned by TPS - Genetic algorithm is more suitable for real-time navigation environment. TPS - Genetic algorithm can be applied to ship navigation system, which can further adjust the potential energy base and plan routes according to the needs of shipping companies.


I. INTRODUCTION
Road traffic belongs to two-dimensional traffic, aviation belongs to three-dimensional traffic. Compared with road traffic and aviation, maritime traffic has its unique characteristics, between two-dimensional and threedimensional [1]. Ships are the main means of transportation on the sea, that is, they have neither the two-dimensional navigation stability of vehicles nor the three-dimensional spatial freedom of aircraft. Therefore, compared with vehicles and aircraft, ships have poor adaptability, which also makes it very important for ships to plan detailed sailing routes before departure. The planned route not only needs to ensure the safety of the ship navigation, but also needs to facilitate the shipping company to estimate the navigation cost, so the route planning is very important for maritime traffic. Route planning is to plan a sailing route of a ship according to the environment of the starting point, destination and sailing waters before the ship embarks [2]. Route planning is mainly divided into three steps: environment construction, environment search, route generation. Accurate mathematical description of navigation environment is the basis of route planning. Route planning algorithm needs to combine ship and environment related information.
Excellent route planning needs to consider ship safety, Marine meteorology, navigation requirements and other constraints.

A. Literature Review
With the installation of Automatic Identification System (AIS) and the establishment of ship data center, a large amount of ship track data contains precious historical navigation information, including longitude, latitude, speed and course. Most scholars extract ship routes from the perspective of AIS data, mainly optimize in AIS data processing algorithm, and extract main ship track points as the main route points of the routes [3]- [6]. Wen et al. [7] integrates DBSCAN with artificial neural network to enable automatic route design between specific ports based on a large amount of AIS data. Zhang et al. [8] used Laplace feature mapping and Gaussian kernel function to compress AIS data, extracted turning points of all ships, and took turning points as the main path nodes of the route. Maritime traffic routes are extracted from a large number of historical AIS data, and historical ship navigation data hidden by AIS data is effectively mined. However, this method has high requirements on the quantity and quality of AIS data, and does not take into account Marine meteorology, ship itself and other practical constraints. Excellent routes need to consider the actual constraints of ship navigation.
At present, with the development of intelligent algorithms, computers can calculate a large amount of data in a short time. Many scholars optimize the intelligent algorithm and apply it to route planning and have made corresponding breakthroughs. A* algorithm is a mature heuristic algorithm applied in route planning, but its calculation results have high requirements for the mathematical description of the environment. Xie et al. [9] proposed the multi-direction A* algorithm, which increased the search directions of A* algorithm from 8 to 20 and selected the area of offshore wind power plants for route planning. The results proved that the algorithm could effectively avoid danger and plan the shortest route. Ant colony algorithm is inspired by the foraging behavior of real ant colonies and can get the calculation results quickly. Liang et al. [10] proposed leader-vertex ant colony optimization algorithm to further condense path nodes and realize real-time route planning. Genetic algorithm (GA) is a computational model of biological evolution which simulates the natural selection and genetic mechanism of Darwin's biological evolution. It is a method to search the optimal solution by simulating the natural evolution process. Tsou et al. [11] combined the genetic algorithm with the International Rules for Collision Avoidance at Sea (COLREGS) and the field of ship safety, and calculated the optimal safety avoidance Angle, navigation recovery time and navigation recovery Angle of the ship collision avoidance path. The algorithm can better realize the ship collision avoidance. Mohammed et al. [12] proposes to use genetic algorithm to solve the capable vehicle routing problem CVRP, which proves that genetic algorithm can effectively solve the multi-dimensional quality problem with high computational load [12]. On the basis of the original genetic algorithm, Chong et al. [13] introduced trigonometric function selection operator, improved the mutation operator, increased the search range in the initial stage of the algorithm, and gradually reduced the search range in the middle and late stage of the algorithm, so as to accelerate the convergence speed of the algorithm, shorten the calculation time, and realize the real-time airline planning.
Marine environment is complex and changeable, and Marine meteorology has great influence on shipping route. Roar et al. analysis of weather and AIS data from 42,000 voyages in the North Pacific between January 2013 and August 2019 shows that meteorological information adds value in claim prediction and that short-term complex interactions between ships and weather conditions affect Marine risk [14]. The Marine environment is dynamic in nature, changing over time due to tidal, weather and environmental constraints. This requires that Marine meteorological environment must be expressed dynamically in environmental description and route planning should be carried out according to real-time meteorological changes [15]. Zhang et al. [16] analyzed AIS data of Ro-PAX vessels operating in the Gulf of Finland during the ice-free period of 13 months, and found that under adverse hydrometeorological conditions, ships operating in a specific region tend to have a lower composite index. Ship route planning must take into account the influence of weather, so that the planned route can be practical. Sen and Padhy [17] propose an application algorithm of ship weather path considering wind current and ship behavior in waves. A weather route algorithm for developing ships is proposed. Various real wave data in the northern Indian Ocean region verify that the algorithm can effectively avoid local stormy weather and other meteorological conditions for the shortest time route in the Arabian Sea and Bay of Bengal [17].
Conforming to the international trend of green shipping, the application of new energy in ships is becoming a trend of auxiliary Marine power. However, the actual effectiveness of new energy sources such as wind and solar is limited by Marine environmental factors, which are mainly related to shipping routes. Ma et al. established a multi-objective optimization model of ship route and ship speed considering ECA (Emission Control Area) regulations to minimize ship transportation costs and emissions [18]. Zhang et al. proposed a route optimization design method for solar sailboat with energy-saving power as the objective function of route optimization. Wind power is the main power of sailboat, because of the particularity of its power, the prediction of sailboat speed is also one of the key points of route planning [19]. Lee et al. [20] proposed a high-fidelity velocity prediction method based on computational fluid dynamics (CFD). An algorithm to predict the attitude and speed of sailing ship is established. The sailboat's speed and Angle vary until it reaches a balance of power at a constant wind speed and Angle. Langbein et al. [21] proposed A long-term route algorithm for autonomous sailboats based on the A* algorithm and realized a significantly shorter calculation time by dynamically adjusting the underlying routing map to integrate changing weather conditions. It works with real wind forecasts.

B. Contribution
According to the above analysis, it is very important to realize real-time route planning based on accurate mathematical description of Marine environment. The structure of the paper is shown in Fig. 1. In this study, the potential field theory based real-time sailing route planning TPS-Genetic algorithm was proposed to effectively solve the problems of environmental expression accuracy and real-time route planning. The main contributions are as follows: 1) The potential field theory in road traffic is used to realize the digital expression of sailing environment. This theory can represent the influence of Marine meteorology on sailing and reflect the dynamics of Marine meteorology. At the same time, the target route can be planned in real time by adjusting the potential energy value according to the demand of the shipping company.  This paper is organized as follows. The second section describes the mathematical model of sailing route planning and potential energy field model in detail. The third section combines the genetic algorithm with the characteristics of sailing course planning, proposes the TPS-Genetic algorithm, and adds the turning point sorting operation on the basis of the initial population to further improve the efficiency of the algorithm. The fourth section explains in detail the implementation steps of potential field theory and TPS-Genetic algorithm in sailing course planning. The fifth section further verifies the feasibility of potential field theory and TPS-Genetic algorithm in real-time sailing route planning through simulation experiments. The sixth section is the summary of the thesis.

A. Digital Charts
Sea navigation is usually carried out by satellite navigation using geographic coordinates, as well as paper or electronic charts. In order to facilitate the calculation, the cartesian coordinate system is established according to the navigation chart, and the longitude and latitude coordinates are expressed as plane coordinates. Considering the observation ability of human eyes and the accuracy of the chart, the horizontal and vertical amplitude of the chart will not exceed 1500 pixels, that is, the figure after digital processing will not exceed 2.25 million pixels. The transformation formula of geometric coordinates and plane coordinates in the figure is shown in (1).
As shown in (1), the relation between a, b, α and β can be simply expressed as: , that is, the difference between the geometric longitude difference and the geographical latitude of any two points in the scope of the map is equal to the difference between the horizontal coordinate of the corresponding plane in the digital map.

B. Speed Explanation
The wind speed data of the navigation area can be obtained directly from the monitoring data of various weather stations. The relationship between true wind speed, ship speed and apparent wind speed is shown in Fig. 2. The apparent wind is shown in (2) and (3).
As shown in (2) and (3), v and θ are the speed and direction of apparent wind, ' and ' are the speed and direction of navigation, and ( and ( is the magnitude and direction of true wind.

C. Objective Function
The purpose of the route scheme is to minimize the time cost of sailing from start to finish. This route planning model is mainly to plan the route with the minimum time cost. It is difficult to time the route directly because offshore wind conditions change quickly. In this paper, the integral method is used to calculate, the whole airline is divided into different sub-sections, and the minimum time cost of sub-sections is calculated respectively. Finally, the time cost of each subsection is accumulated to get the time cost of the whole airline. The mathematical function is given in (4) and (5).

A. Potential Energy Field
In road traffic, Ni. D used the field theory to describe the vehicle driving environment, which could describe the driving environment well from the macro and micro perspectives [22]- [24]. Li et al. [25] proposed the vehicle lane-changing model based on this theory from the micro $ $ & * * perspective, so the application of this theory in road traffic is relatively mature. Similarly, this theory can accurately express the changes of Marine meteorology in the course of ship navigation and plan the navigation route. Liu et al. [26] carried out route planning in the coastal waters of the Yangtze Estuary of China based on potential field theory, which further proved that the theory could be used for ship route planning.
From the perspective of practical navigation: 1) Sailing ships mainly rely on sails to sail with the help of wind, so the change of Marine meteorological environment has a great impact on the route; 2) In the dimension of time and space, Marine meteorological environment changes all the time. The dynamic nature of Marine meteorology directly leads to the need for sailing ships to plan their routes in real time according to meteorological changes. This study mainly explains the mathematical description of potential field theory in Marine meteorology. Wind speed and wind direction are taken as the basis for the potential energy value of wind energy field. Potential energy is a vector value, potential energy size represents wind speed, and potential energy direction represents wind direction. The function model of wind energy field is shown in (6).
As shown in (6), / ( , ) represents the wind potential energy value of point( , ) ( 2 , 2 ) is the position of the center point of the cyclone at t, and the movement function of the center point is 9 2 = ( ) 2 = ( ) , 32 , 42 represent the influence radius of the X-axis and Y-axis of the obstacle in the horizontal plane area at t. b is the tuning coefficient between the function value and the actual wind speed value. The following is an example of a small cyclone whose position varies with time but whose influence radius remains the same. As shown in Fig. 5, from the macroscopic perspective, the change of potential energy field of cyclone can reflect the change of its position and influence range; Microscopic view: A comparison of states A and B shows the potential energy change in the box. The length of the arrow represents the wind speed, and the direction of the arrow represents the wind direction. The potential energy field of the cyclone takes the center of the cyclone as the potential energy center. The closer to the center, the greater the potential energy value is. The physical significance is that the wind speed at this point is higher. As shown in Fig. 4, the cross-section diagram of the central potential energy of the cyclone shows that ' , ' , ( and ( are at different distances from the central point, and their potential energy values are different. ' and ' are on the potential energy equipotential line, so the potential energy values of ' and ' are the same with different directions.
As shown in Table I, the potential energy changes of ' and ' in the wind energy field and at points ( and ( after the change: 3) ' and ' are points at different positions at the same time, and the potential energy values of ' and ' are the same with different directions; 4) ' and ( are points at the same position at different times, and the potential energy values of ' and ( are the same with different directions. As shown in Table  I, the potential energy values of ' , ' , ( and ( are compared.  Similarly, the potential energy of waves and currents in sailing waters is established, and the mathematical model of environmental potential energy considering wind, waves and currents is as (7).
As shown in (7), ; is wind potential energy function, < is wave potential energy function, and E_O is ocean current potential energy function.

B. Data Interpolation
At sea, it is not always possible to accurately measure the wind vector data for each location. Wind data can only be obtained from weather stations, such as individual weather stations or weather buoys. In open water without shelter, the wind field changes more evenly. We can use interpolation method to get the wind vector data of the whole wind field. By querying the wind vector data of the wind field, we can get the map vector range of any point in the wind vector data. In this paper, the distance-weighted inverse interpolation method [27] is used to find the nearest weather station and interpolate the weather station data according to the proportion of regional scale, as shown in (8).
is a constant greater than 0, known as the weighted power index. In this paper = 1.And use , and other auxiliary software to complete the digital processing. As shown in Fig. 3, the number represents the wind speed value at this point, and the curve is the wind speed contour, indicating that the wind speed at the position points on the curve is the same. The wind speed after interpolation can reflect the change trend of wind speed, and the change of wind speed is consistent with the actual situation.

A. Evaluation Function
The purpose of the route plan is to minimize the time for the sailboat from the start to the end points, and the evaluation function is represented by ( ) ), set a probability for each chromosome in the population, the likelihood of the chromosome is proportional to the suitability of other chromosomes in its population, and greater of the adaptability of the chromosome, greater of the likelihood of being selected, calculated is given in (9).
B. Initial Population Set the number of genes is C, the number of populations is N. So, N routes are randomly generated within the range of the digitized chart. There are C inflection points in each chromosome, and then the waypoint is sorted, and the ordered set of turn points is taken as the initial population, as follows: 1) The initial population: P / = { P ! / , P " / , ⋯ , P 0 / , ⋯ , P 1 / } , where P & is the 0th generation, P C & is the ith chromosome of the 0th generation. 2) % / = { /% ! , /% " , ⋯ , /% 2 ⋯ , /% 3 } , Where &) * is the jth turn of the ith chromosome of the 0th generation, and the coordinates is ( /% 2 , /% 2 ).

C. Turn Point Sorting
Since randomly generated turning points are messy, if the random connection starts from the beginning to the end, the effectiveness of the route will be very low, as shown in Fig.  6, so it is necessary to sort randomly generated coordinates. According to the constraints of the previous step, the projection vector size includes all turning points from the beginning to the end, as shown in Fig. 7, and is calculated (10), and (11). As shown in (10) and (11)  3 ], from the starting point in turn connected to the end to generate a more reasonable road map in order, as shown in Fig. 8.

D. Selection
Using the roulette selection method, the specific operation is: 1) For each chromosome ) , calculate the cumulative probability ) , calculated using (12).

E. Crossover
Using a single point of cross, the specific operation is: 1) First define the cross probability in the population + , the population of expected value for the * + chromosomes will be cross-operation; 2) To determine the parent of the crossed operation, repeat the following procedure from = 1 to = ; 3) Generate a random number r from [0,1], and if r < + , choose ) HG as a parent, ' HG ， ( HG ⋯ , present the parent of the above selection, and randomize them, for 4) When the number of fathers is odd, then randomly remove a chromosome to ensure that the two pairs, use the following ' H # ， ( HG as example explains how to cross the above group; 5) We randomly generate an intersection r between 1 and 22 * , through the exchange of chromosome ! <7 and " &7 of the r to 22 * Genes to form two offspring.

F. Mutation
The specific step is: 1) Define the parameter I as the mutation probability of the genetic system. This probability indicates that there will be an expected value of N * I chromosomes in the population for the mutation operation; 2) Similar with the process of selecting the parent in the crossover operation, repeat the following procedure from = 1 to = ; 3) Generate the random number r from the interval [0,1], and if < I , select the chromosome ) HG as the parent of the mutation, for each selected parent, press the following method Perform a mutation operation; 4) First select a mutation between s and 22 * s, if the point of the gene is 0, then change the gene replaced by 1, if the point of the gene is 1, then the gene will be replaced by 0.

G. Code
Since the horizontal and vertical amplitudes of a chart do not exceed 1500 pixels, the size of all waypoints does not exceed 1500. Since it is 2 = < 1500 < 2 > , it is possible to encode 11-bit binary numbers. As shown in Figure 9, consider converting the x and y coordinates of each turn point /%7 2 after the previous step into binary form, forming a binary sequence of 22 * bits % /7 to complete the chromosome encoding. % /7 represents the binary encoding of chromosome I of generation 0.
The specific step is: 1) Converts the binary number % &7 corresponding to the shortest % & of ) to the decimal plane coordinate set: * is the jth turn of the ith chromosome of the nth generation, and the coordinates are ( H) * , H) * );Similar with the process of selecting the parent in the crossover operation, repeat the following procedure from = 1 to = ; 2) The plane coordinates are converted to the corresponding geographical coordinates, generate a list of sailing routes turn points, the table lists the starting point, the end and the various points of the plane coordinates and geographical coordinates; 3) Connecting the waypoint to a line, which produces the best route for the sailboat.

VI. ROUTE PLANNING FRAMEWORK
As mentioned above, the real-time route planning process of sailing ship based on potential field theory and TPSgenetic algorithm is as follows: 1) Obtain relevant information: wind data of starting point, longitude and latitude of destination, route planning; 2) Wind data of navigable waters are interpolated to obtain uniformly distributed wind vector data; 3) Based on the obtained wind vector data, the wind potential energy field in the waterway area is established; 4) Establish the evaluation function of TPS-Genetic algorithm; 5) The initial population is constructed on the basis of the wind energy field; 6) The initial population was optimized by turning point sequencing; 7) Select, cross and mutate the initial population; 8) Decode the route to get the optimal route. The overall flow chart of airline planning is shown in Fig.10.

A. Select the Route Planning Area
The experiment design: Taking the 28-foot conventional keel sailing ship as the research object, the open water area of the East China Sea was selected as the route planning area, and the potential energy field of the navigation area was established based on the realtime meteorological data of the area. The route planning was carried out by TPS-Genetic algorithm and the feasibility of the route planning was verified by combining with the actual electronic chart.
The route planned by TPS-Genetic algorithm and A* algorithm is compared to verify whether the route planned by TPS-Genetic algorithm is more consistent with the reality.
A 28-foot conventional keel sailboat [28], [29] was used as a simulation vessel in the east China Sea (122°40′E，27°30 ′N) to (124°55′E，29.0°N) virtual environment. As shown in Fig. 11, the route planning area is an open area without obstacles in the black box area, and the sea breeze change in this area will not be affected by obstacles.
The electronic chart shows that the average water depth of this area is 349 m, which fully meets the draft of the sailing ship. Therefore, the selected area is the ideal area for sailing route planning. Five weather stations are evenly distributed in the sea area planned for shipping routes to monitor Marine wind data in real time. As shown in Table II, the conversion between latitude and longitude coordinates of starting point, end point, weather station and plane coordinates. The wind monitoring data of each weather station are shown in Table III. The algorithm of route planning is realized by Surfer and MATLAB platform and verified by experiment.

B. Potential Energy Field is Constructed
The distance is 1000 m × 1356 m. The wind vector data of the whole sea area is calculated by interpolation, and the Potential energy field is established. In order to verify the feasibility of the planned route, the simulation study takes electronic chart [30] as the base diagram, and the potential energy field is represented by the arrow, the direction of the arrow represents the potential energy, and the length and color of the arrow represent the potential energy value, as shown in Fig. 12.

C. TPS -Genetic Algorithm
Since the distance is 149.6 nautical miles, the number of turning points C (number of genes) is 15, and the number of populations (number of chromosomes) is 70.
The initial population is shown in Fig. 13, obviously, the disordered main population is inefficient. A large number of initial populations that do not meet the requirements of route planning in the initial population will increase the algorithm solving time, so it is necessary to further optimize the initial population to improve the efficiency of the algorithm and achieve the purpose of real-time route planning.
Turn point sorting operation is carried out for the above initial population, and the sorted population is shown in Fig. 14.
The optimized populations are in line with the characteristics of route planning, and the number is significantly reduced, greatly shortening the calculation time of the algorithm.
The maximum number of iterations of the algorithm is set as 400. After chromosome coding, selection, crossover and variation, when the iteration reaches about 150 generations, the population fitness gradually stabilizes to the next value, indicating that the population has converged. The fitness and evolution algebra are shown in Fig. 15.    After the path is decoded, % &7 is converted to decimal plane coordinates, which are then converted to geographic coordinates according to the formula. The generated waypoints are connected to a straight line, and the generated binary points are converted to decimal plane. The optimal route of sailing ship is shown in Table IV. The route consists of starting point, ending point and 15 route nodes.
As shown in Fig. 16, the planned route is combined with the observation of electronic chart and wind potential field. It can be seen that there is no upwind section in the planned route, and the steering direction of each path node is reasonable, and the Angle difference between the route direction and wind direction of each sub-road section is reasonable.

D. Algorithm Contrast
Genetic algorithm is an evolutionary algorithm, and its calculation speed can reach the real-time route planning. TPS-Genetic algorithm optimizes the initial population on the original basis, improves the efficiency of the algorithm, and further improves the real-time performance of the algorithm. Under the TPS-Genetic algorithm and A * algorithm, comparing the planning route as shown in Fig. 17, the green route planning routes by TPS -Genetic algorithm, the red route planning routes by A * algorithm, route planning area of the wind in the north by east between 10° to 20°, TPS -Genetic algorithm is more in line with the planning route navigation planning the waters of the wind.
As shown in Table V, the route planned by TPS-Genetic algorithm and A* algorithm consists of 16 route segments. The length and route time of each route segment are listed in the table. Although TPS-Genetic algorithm is 29.156km longer than A* algorithm in route length, the route time is reduced by 1.04h. As shown in Fig. 18 and 19, in Rs1, Rs2 and Rs16 sections, the voyage time of TPS-Genetic algorithm is much lower than A* algorithm. The comparison of the length and time consumption of each airline shows that although the length of some flight segments planned by TPS-Genetic algorithm is longer than that of A* algorithm, the sailing time is shorter. To sum up, the route planned by TPS-Genetic algorithm is more in line with the wind direction and more conducive to sailing.

VIII. CONCLUSION
In this study, a TPS-Genetic algorithm for real-time route planning was proposed based on potential field theory, and the feasibility of the algorithm was verified by simulation experiments. It not only provides a good reference for realtime navigation planning in open water, but also applies potential field theory to the mathematical description of Marine meteorological environment. Firstly, in the mathematical description of sailing environment, the potential energy field theory of road traffic is used, which can accurately express the change of Marine meteorological environment and the influence of Marine meteorological on sailing route planning. Secondly, combined with the characteristics of route planning, this study proposes the TPS-Genetic algorithm, which adds turning point sorting operation to the initial population to further improve the calculation efficiency of the algorithm and realize real-time route planning based on meteorological data. Compared with A* algorithm, the feasibility of TPS-Genetic algorithm is further verified.
Ship navigation system has been widely used in ships and become an essential tool for ship navigation. TPS-Genetic algorithm can be used as the core algorithm of route planning in navigation system to realize real-time route planning of Marine meteorological data.

A. About the Potential Energy Field
In this study, the concept of potential energy field is introduced to realize the mathematical description of Marine environment, and gauss model is used as a function model. However, in the actual sea breeze mathematical expression, a single function model cannot meet the mathematical description of Marine meteorology, so the next step is to find a more accurate function model to cover the meteorological environment. Wind, current and waves are taken as the main factors in route planning. In the next step, more microlimiting factors such as ship draft, obstacles and other ships will be considered to further improve the accuracy of route planning.

B. About the Solving Algorithm
In this study, by combining the characteristics of route planning and Genetic algorithm, the TPS-Genetic algorithm was proposed by adding the initial solution to the steering point sorting operation. Compared with A* algorithm, the effectiveness of the proposed algorithm is verified. The sorting rule in the simulation experiment applies to the case that the wind direction change between the starting point and the ending point is less than 90°.When the wind direction changes by more than 90° or the wind field is eddy, the sorting rules of the initial navigation points need to be changed. TPS-Genetic algorithm can be further applied to the autonomous route planning system of unmanned ship, and the Real-time route planning of unmanned ship can be realized combined with the automatic control of sail and rudder, thus further promoting the development of unmanned ship.