A Route Planning Method using Neural Network and HIL Technology Applied for Cargo Ships

.co.in A Route Planning Method using Neural Network and HIL ░ ABSTRACT - This paper presents the development of a method to find optimal routes for cargo ships with three criteria: fuel consumption, safety, and required time. Unlike most previous works, operational data are used for the studies. In this study, we use data collected from a hardware-in-loop (HIL) simulator, with the plant model being a 3D dynamic model of a bulk carrier designed and programmed from 6 degrees of freedom (6-DOF) equations that can interact with forces and moments from the environmental disturbances. The dataset generated from the HIL simulator with various operating scenarios is used to train an artificial neural network (ANN) model. This predictive model then combines the A* algorithm, weather forecast data, ship parameters, and waypoint coordinates to find the optimal routes for ships before each voyage. The test results show that the proposed method works reliably, helping to improve fuel efficiency and enhance the safety of the ships.

Shipping is the cheapest transportation method between countries and continents.Fuel prices are rising now, but fuel cost is the most expensive factor in operating a ship, accounting for up to 70% of the total cost of ship operation.Moreover, to comply with the International Convention for the Prevention of Pollution from Ships (MARPOL) of the International Maritime Organization (IMO) under Annex MEPC.328(76), revised in 2021, solutions to improve fuel efficiency are an issue that many researchers in this field are interested in.
There are many solutions to improve fuel efficiency for ships.Building optimal routes for ships before each voyage based on weather forecast data is a solution that brings high efficiency and low cost.Over the years, there have been many studies related to this issue.
The goal of the work [1] is to find the optimal route such that the main engine (ME) speed is the smallest.The authors use the Journée algorithm to estimate the travel time and the Newton-Raphson method to find the minimum ME speed.The study [2] uses a modified Dijkstra algorithm to find the shortest distance with the convention that the shortest distance is the distance the ship travels in the shortest time.The ship speed is estimated based on speed reduction curves.
The research [3] proposes to build a method to find the safe route for the ships based on Dijkstra and the genetic algorithm.The literature [4], [5] uses the Dijkstra algorithm to find the shortest path in a grid of nodes.The weights between any pair of nodes will be proportional to the distance between those two nodes and the added resistance to the ship.The work [6] builds software based on the Promethee method, which is a multicriteria decision support method.The criteria consist of fuel consumption, transit time, or environmental pollution.The study [7] uses an operational dataset recorded over a year of a 17,500 DWT cargo ship combined with the A* algorithm to find out the route with the smallest total propulsion forces.Just like in the literature [4], [5], the studies [8]- [10] also use the RAO to calculate the necessary weights used for the algorithms, such as dynamic programming algorithm in the works [9], [10] to find the route.The study [11] uses Dijkstra algorithm, and the cost function is calculated using the SPI index.The research [12] uses an algorithm that combines genetic algorithms and swarm optimization algorithms to find the route with the choice of three criteria: safety, fuel economy, and required time.The literature [13] uses the multi-objective ant colony algorithm to find the optimal route.Meanwhile, the studies [14]- [17] all use the A* algorithm, in which the research [14] uses a machine learning model from the data of the automatic identification system (AIS) combined with weather data to calculate travel speed, literature [15], [16] combine the A* algorithm and a wave prediction model to find the optimal route.In addition, the work [17] combines A* and a fuel consumption prediction model from the operational data.
The above studies show that many works have used Dijkstra and A* algorithms combined with other methods to find the cost function, such as using the RAO, genetic algorithms, dynamic programming algorithms, etc.However, in most of these works, the data are primarily historical operational data such as noon reports or AIS data.These data are often incomplete (mainly no data on current speed and current direction) or not large enough (for ships that have not been in service for a long time or newly built ships), not to mention the large sampling time (usually once a day), using these incomplete datasets will reduce the accuracy and reliability of route finding algorithms.
Therefore, this study proposes a method to find optimal routes for ships with three criteria before each voyage.The proposed method uses the dataset generated from a HIL simulator, ANN model, and A* algorithm.Unlike most previous studies, the dataset created from the HIL simulator instead of past operating data fully includes the three main turbulence components affecting the ship: waves, wind, and current, which will help improve the accuracy and reliability of the route-finding algorithm.Furthermore, the novelty of this method is that it can be applied to ships where data is collected over a short time or some necessary data is missing, especially ships that are not authorized to use past operational data for security and defence reasons in Vietnam.

Research Framework
Figure 1 displays the fundamental research framework.In step 1, we will build a HIL simulator based on the ship's technical profile, the 6-DOF equations of motion, and mathematical models of environmental disturbances and propulsion systems.A dataset similar to the operational data of the real ship with various operating scenarios will be generated from that HIL simulator.
Step 2 shows the construction of the proposed algorithms.The built ANN model combined with the coordinates of the starting waypoint, the destination waypoint, and the coordinates of the obstacles (if any) will be the input variables for algorithm 1 to find the optimal fuel route.Besides, from the optimal found route and the required time, the appropriate ME speed will be recommended by algorithm 2.

Data Preparation 2.2.1. The HIL Simulator
This study uses a HIL simulator to build a dataset to replace operational datasets.In particular, the plant model built is a 3D dynamic model.Meanwhile, the controller is a trajectory controller built by MATLAB/Simulink software.The 3D dynamic model is built based on the 6-DOF equations of motion and the ship's technical profile.These equations are commonly used in ship motion control studies as follows [18]: where  denotes the position and orientation vector; () J  is a transformation matrix;  is the body-fixed linear and angular velocity vector; To build the 3D dynamic ship, we use Unity software, which is specialized software in 3D graphics simulation and processing.
The shape and dimensions of the real ship (the real ship used in this study is a bulk carrier named The Prosperity) are designed into a 3D model as an FBX file to be imported into the Unity software.The 3D ship will then be assigned the Rigidbody property so that it can have physical interactions with its surroundings.In addition, the software modules (C# language) are also programmed to assign corresponding objects.More details on the construction and testing of this model can be found in the work [19].

Figure 1: Research framework
When building the HIL simulator, in addition to the 3D dynamic model, a real-time fuel consumption calculation model is also built based on the interpolation method and semi-empirical formulas.This model has been presented in detail in research [20].
Figure 2 shows the built HIL simulator.Block 1 contains the Control PC, which acts as an actual controller.Meanwhile, Block 2 consists of the 3D PC running a 3D dynamic model as a plant model.These two blocks are communicated with each other via an ethernet cable with the OPC Client/Server protocol.

Data Preparation
Firstly, we make the following assumptions to limit the scope of the study: • The ship's draft is 14.429 m (laden); • The ship is on an even keel (the draft of the ship is equal fore and aft); • Waves are generated entirely by the wind; • Wind speed and wave height are programmed according to the Beaufort scale of the World Meteorological Organization (WMO) [21].
The input variables will be varied to create different scenarios to build the dataset.Specifically, there are five input variables, Meanwhile, the output variables include fuel consumption and sailing time.Therefore, we get a dataset with 3456 cases.In all test cases, the ship controlled by a PID controller goes through the same sample route.

A* Search Algorithm
A* is a computer science algorithm commonly used in pathfinding and graph traversal.As A* crosses the map, it follows a track of the lowest known heuristic cost, keeping an arranged priority queue of consecutive track nodes along the path [22].
The basic principle of this method depends on the following equation: Where x is the current node on the map, and g(x) is the actual cost from the starting node to the current node x.Meanwhile, h(x) is the heuristic function that estimates the cost from the current node x to the destination node, and h(x) is admissible if ∀x: Where * () hx is the actual cost from node x to the destination node.
Thus, before building algorithms to find the optimal route for the ship, we need to do the following:   Like the [2], [4] studies, to implement the A* algorithm, it is first necessary to create a moving graph for the ship.We know that the shortest distance between any two waypoints on Earth is an arc on the great circle.Therefore, based on the coordinates of starting waypoint WP0 and destination waypoint WPg, this study proposes to build a moving graph for ships that is a curved grid, as shown in figure 3.For any waypoint like WPn, there are three directions to travel from WPn to WPp, WPq, or WPr.

Building the Curved Grid
Meanwhile, with waypoints located on Edge 1 and Edge 4, such as WPu, there is only one direction of travel from WPu to WPv.
In particular, the shortest distance between any two waypoints is calculated according to the Haversian formula.For example, the shortest arc length WPn WPq D − between any two points, WPn and WPq, will be calculated using equation ( 4). .
Where R is Earth's radius and c is a coefficient calculated as the following equations: . tan( , ( )) sin ( / ) cos .cos.sin( / ) Therefore, the estimated cost when the ship moves from WPn to WPq will be calculated as follows: Where FC unit is the fuel consumed per nautical mile in calm sea conditions to satisfy equation ( 3).

The ANN Model for Predicting Fuel Consumption and Sailing Time
The proposed prediction model is a multilayer perceptron (MLP) trained by the back-propagation method with five inputs and two outputs corresponding to the number of inputs and outputs of the built dataset.According to many studies, the number of hidden layers and neurons of the hidden layer will depend on each different dataset.Therefore, the authors trained the neural network with 30 models with different numbers of hidden layers and neurons with training parameters shown in table 1.When testing trained 30 models with the testing dataset, the network model with one hidden layer and 30 neurons in that hidden layer is the model with the smallest mean absolute percentage error (MAPE) of only 1.031%.The structure of this ANN model contains one input layer (five neurons), one hidden layer (30 neurons), and one output layer (two neurons), as shown in figure 4.

The Objective Function
The proposed algorithm will minimize the objective function as follows: : Where h(WPn) is the estimated fuel consumption to go from WPn to WPg, and g(WPi) is the actual fuel consumption to reach waypoint (i) from its parent waypoint (i-1).
The h(WPn) values will be taken from the matrix H, which will be calculated based on the curved grid and Harvesin formula as equation (6).Meanwhile, the g(WPi) values will be taken from the matrix G, which will be calculated using the proposed ANN model, the weather forecast data, and the distance between adjacent waypoints.

The proposed algorithms
This section proposes two algorithms to create an optimal route with three criteria: fuel economy, safety and required time.algorithm 1 will find the optimal fuel route based on the A* algorithm and ANN model with the ME speed of 70 rpm.Initially, the OPEN and CLOSED list will be created.The OPEN list is used to record all waypoints that need to be considered to find the optimal route.Meanwhile, the CLOSED list is a list that stores waypoints that we no longer need to review.Algorithm 1 will start by finding neighboring points with WP0 until the last neighboring point WPg to satisfy equation (7).
Specifically, algorithm 1 will execute from line 1 to line 24.
Initially, the OPEN list only includes WP0, so WPn==WP0 and WP0 will be added to the CLOSED list.Then, algorithm 1 will find all neighbors WPx of WPn (line 8).If WPx belongs to the OPEN list or CLOSED list, it will proceed from line 10 to line 15.Meanwhile, if WPx does not belong to either of the lists above, it will be added to the OPEN list (line 17).For each such WPx, the algorithm will calculate the actual fuel consumption g(WPx) based on matrix G (line 19) and the estimated fuel consumption h(WPx) based on matrix H (line 20), as mentioned in section 2.3.4.
In addition, in the case of WPx located in dangerous areas with a risk of collision, g(WPx) will be assigned to infinity.Therefore, algorithm 1 will find routes that are both optimal for fuel consumption and safe, avoiding the risk of collision, if any.Details of algorithm 1 are shown as pseudocodes in table 2. ... In Scenario 2, the recommended route is Route 3, which saves 4.01% of fuel compared to the case where the ship sails through the shortest route -Route 4 (similar to Route 2, but Route 4 has the effect of current).If the ship follows Route 5 as suggested in Scenario 1, it will consume 2.52% more fuel than Route 3 (Route 5 is similar to Route 1 but has the effect of current).
Scenario 3 has weather conditions like Scenario 2, but some waypoints are not allowed to enter (waypoints 53, 54, 62, and 63).Algorithm 1 suggests Route 6.This route saves 3.97% of fuel compared to the case where the ship sails through Route 4, but this route consumes more fuel when running through Route 3 by 0.045%.The extra cost compared to Route 3 is minimal while the ship has sailed through a safer route, avoiding the risk of a dangerous collision.
Table 4 also shows that the largest error between the fuel consumption forecast data by the ANN model and the data when running the 3D model is 2.26% with a heavy sea.Compared with fuel forecasting models in other works, such as work [25], this error is not large and completely acceptable.
Coriolis and Centripetal matrix, () A C  is the hydrodynamic Coriolis and centripetal matrix, G is a constant matrix, () D  is the damping matrix, E  and  are environmental and propulsion forces and moments, respectively.

Figure 4 :
Figure 4: Structure of the ANN model More details about this model, the HIL simulator, and the generated dataset are presented in the research [23].