Investigation of a Multitasking System for Automatic Ship Berthing in Marine Practice Based on an Integrated Neural Controller

: In this article, a multitasking system is investigated for automatic ship berthing in marine practices, based on artiﬁcial neural networks (ANNs). First, a neural network with separate structures in hidden layers is developed, based on a head-up coordinate system. This network is trained once with the berthing data of a ship in an original port to conduct berthing tasks in di ﬀ erent ports. Then, on the basis of the developed network, an integrated mechanism including three negative signs is linked to achieve an integrated neural controller. This controller can bring the ship to a berth on each side of the ship in di ﬀ erent ports. The whole system has the ability to berth for di ﬀ erent tasks without retraining the neural network. Finally, to validate the e ﬀ ectiveness of the proposed system for automatic ship berthing, numerical simulations were performed for berthing tasks, such as di ﬀ erent ports, and berthing each side of the ship. The results indicate that the proposed system shows a good performance in automatic ship berthing.


Introduction
When moving towards a berth at a low speed, ship dynamics become highly nonlinear; therefore, the maneuverability of the ship is decreased significantly. To ensure that ship berthing occurs safely and properly, the states of the ship, such as the position, ship heading, and ship speed, must be controlled simultaneously and appropriately by the rudder and propeller. In marine practice, because of the nonlinear character of ship dynamics at low speeds, the maneuvering process of ship berthing is usually conducted by three steps: course changing, deceleration, and engine stopping. Because artificial neural networks (ANNs) have the ability to model any multiple input-multiple output nonlinear systems, they are commonly applied to learn and to imitate the actions of the human brain during the stages of ship berthing.
Based on the advantages of neural networks, they have been used not only as centralized controllers, but also as identifiers to approximate unknown functions in dynamic systems. In automatic ship berthing, Yamato et al. (1990) [1] was the first researcher to use ANNs as a main controller, but changed their approach to the expert theory for ship berthing (Yamato et al., 1991) [2]. In that study, the inputs of the ANN included the ship position, ship heading, and ship speed, and the outputs of the controller consisted of the rudder and propeller. Later on, a multi-variable neural network was proposed by Zhang et al. (1997) [3] for ship berthing. In that work, an online training process for the network was considered via the feedback of the ship state, and the control signals were used to control the rudder and the propeller.
In 2001, Im and Hasegawa (2001) [4] proposed a parallel controller with two neural networks in a hidden layer. Numerical simulations showed that the results of ship berthing obtained by the proposed controller were better than those obtained by a centralized network. To solve ship berthing under strong winds and currents, two neural network identifiers were added to the main controller to estimate the sway velocity and the yawing rate under strong disturbances (Im and Hasegawa, 2002) [5]. These values are additionally used to correct the rudder angle and the propeller. Subsequently, selective neural networks were proposed by Im (2007) [6] for ship berthing to bring the ship into the berth from any point around the berthing area. Meanwhile, a neural controller with an adaptive interaction algorithm for online training was applied in the research of Nguyen (2007) [7]. In this work, a predetermined route for ship berthing was considered and the proposed neural controller regulated the ship heading and ship speed to track that route.
To generate consistent teaching data for training a neural controller, the studies by Ahmed and Hasegawa (2012), Ahmed and Hasegawa (2013) and Ahmed and Hasegawa (2014) [8][9][10] proposed a nonlinear programming language and a virtual window; the ANN controller was then verified for ship berthing with no disturbance cases. In 2018, Im and Nguyen (2018) and Nguyen et al. (2018) [11,12] proposed neural controllers for an automatic ship berthing based on head-up coordinate system, where relative bearing and distance are introduced to the inputs of the network. The advantage of these studies is the use of the information mentioned in navigational practice for automatic ship berthing. Recently, Zhang et al. (2019) [13] considered an adaptive neural control for the auto-berthing of a ship under unknown ship dynamics and in unknown environment, but the actuators are difficult to apply to marine ships. Meanwhile, an efficient neural network approach with feature selection and a genetic algorithm was proposed by Shuai et al. (2019) [14] for ship docking. In addition, a deep learning algorithm was applied for automatic ship berthing by Lee et al. (2019) [15].
With the advances in marine technology, auxiliary devices such as the side thruster and tugboat have been applied to assist ship berthing. By incorporating these devices for ship berthing, the studies of Tran and Im (2012) [16] and Ahmed and Hasegawa (2014) [17] developed a neural network controller and a PD (proportional-derivative)-ANN controller to regulate the rudder angle, propeller revolution, bow thruster, and tugboat signals for automatic ship berthing. Based on an adaptive back-stepping technique, Park and Kim (2014) [18] suggested a control law for a cruise ship, considering the uncertainty of wind disturbance. This system can control the lateral force of a ship with a crabbing motion. However, this system has a drawback, in that the ship's motion in the longitudinal direction is assumed to be zero. On the other hand, Nguyen (2019) and Nguyen and Im [19,20] introduced fuzzy controllers for ship berthing in near areas of the berth. These systems can control the ship into the berth without any conditions, unlike previous studies.
By using other approaches, such as a sliding mode control- Bui et al. (2011) [21], model prediction control- Mizuno et al. (2012) [22] and Li et al. (2020) [23], optimal control- Mizuno et al. (2015) and Maki et al. (2019), [24,25] and fuzzy logic- Liao et al. (2019) [26], the automatic control systems were also considered for ship berthing. Compared to ANN, it is difficult to realize the stages of ship berthing as human brain when using these approaches.
Although the aforementioned studies have achieved significant results in applying the ANN to automatic ship berthing problems, none of them consider a multitasking system for ship berthing without retraining the network. To use ANN controllers, as in previous studies, for different tasks of ship berthing, the neural network structure needs to be trained again by new teaching data. This is too time-consuming, costly, and complex for the control system.
To overcome the above mentioned limitations, a multitasking system based on ANNs is developed in this study to conduct different tasks of automatic ship berthing in marine practice, without retraining the network structure. First, a neural controller with separate structures in hidden layers is developed based on the parameters of a head-up coordinate system. This neural controller is trained once with the berthing data of a ship in an original port to conduct the berthing tasks for different terminals, as well as different ports. Second, on the basis of the developed controller, an integrated mechanism, including three negative signs, is linked to achieve an integrated neural controller. This controller has the ability to berth from each side of the ship in different ports. The main contributions of this study can be summarized as follows: • The multitasking system for automatic ship berthing is proposed based on an integrated neural controller to carry out different tasks without retraining the neural network structure.

•
The ship can be automatically controlled by the proposed system to berth in different terminals as well as different ports. • The proposed system can control the ship into the berth on each side of ship in the original port as well as different ports.

•
Compared to other approaches, the proposed system is applicable for marine practices because the ANN has the ability to learn and perform the berthing stages as a human brain.
Finally, to validate the effectiveness of the proposed system for automatic ship berthing, the numerical simulations were performed for berthing tasks, such as different ports, and on each side. The results showed that this proposed system effectively performs automatic ship berthing.

Kinematic Model
To express the ship motion with respect to time, the kinematics of the ship need to be considered in two coordinate systems [27]: the earth-fixed frame (O-ηξ) and the body-fixed frame (G-xy). Normally, the motion of the marine vehicle is represented in six DOFs (degree of freedoms), however, for a surface ship, the components of ship motion in the heave, pitch, and roll axes are neglected, as shown in Figure 1. The relationship between the two coordinate systems is represented by Equation (1).
. ψ = r where u, v r are the surge, sway, and yaw velocity, respectively, determined in the body-fixed coordinates system; Ψ is the ship heading.
Mathematics 2020, 8, x FOR PEER REVIEW 3 of 24  The multitasking system for automatic ship berthing is proposed based on an integrated neural controller to carry out different tasks without retraining the neural network structure.  The ship can be automatically controlled by the proposed system to berth in different terminals as well as different ports.  The proposed system can control the ship into the berth on each side of ship in the original port as well as different ports.  Compared to other approaches, the proposed system is applicable for marine practices because the ANN has the ability to learn and perform the berthing stages as a human brain.
Finally, to validate the effectiveness of the proposed system for automatic ship berthing, the numerical simulations were performed for berthing tasks, such as different ports, and on each side. The results showed that this proposed system effectively performs automatic ship berthing.

Kinematic Model
To express the ship motion with respect to time, the kinematics of the ship need to be considered in two coordinate systems [27]: the earth-fixed frame (O-ηξ) and the body-fixed frame (G-xy). Normally, the motion of the marine vehicle is represented in six DOFs (degree of freedoms), however, for a surface ship, the components of ship motion in the heave, pitch, and roll axes are neglected, as shown in Figure 1. The relationship between the two coordinate systems is represented by Equation (1).

= cos − sin = sin + cos
(1) = where u, v r are the surge, sway, and yaw velocity, respectively, determined in the body-fixed coordinates system; Ψ is the ship heading.

Ship Dynamic Model
For ship berthing, a third-order degree of freedoms (3-DOFs) model must be employed to express the dynamics of the ship on the surge, sway, and yawing axes in the body-fixed coordinate system. In this study, the Maneuvering Modeling Group (MMG) model was used to represent the ship motion in the berthing process, where the hydrodynamic forces and moments acting on the

Ship Dynamic Model
For ship berthing, a third-order degree of freedoms (3-DOFs) model must be employed to express the dynamics of the ship on the surge, sway, and yawing axes in the body-fixed coordinate system. In this study, the Maneuvering Modeling Group (MMG) model was used to represent the ship motion in the berthing process, where the hydrodynamic forces and moments acting on the ship were divided into modular components such as the hull, rudder, and propeller. The motion equation of the ship based on the MMG model is presented as follows: where the subscripts H, P and R denote the components of hull, propeller, and rudder, respectively. The components of the hydrodynamic forces and moments acting on the ship hull are shown in Equation (3), which is proposed by Kijima (1990) [28].
where X βr , X uu , . . . ., N ββr , and N βrr are the hydrodynamic coefficients investigated by the method of the authors (Kijima (1990)) [28]; L, d, U, r and β are the ship's length, the ship's draft, its total velocity, its yaw velocity, and the ship's drift; ρ is the density of water. The hydrodynamic force due to the propeller and the propeller thrust force proposed by Kijima (1990) [28] can be considered as follows: The hydrodynamic forces and moments obtained by the rudder can be represented via the work of Kijima (1990) [28] as follows: In order to control the ship's motion in the berthing process, the actuators including the rudder angle (δ) and the propeller speed (rps) were regulated simultaneously. For the numerical simulation, the training ship (named SAENURI) of Mokpo National Maritime University was used as the model ship. The particulars of this ship are shown in Table 1. The hydrodynamic coefficients predicted by the Kijima model are presented in Table 2.

Dynamic Feature in Ship Turning
When the ship's rudder is turned to each side to alter the ship heading, there is a change in the ship dynamic velocities. The surge velocity (u) is similar in both cases. Meanwhile, the values of the sway velocity (v) and the yaw rate (r), when the ship heading alters to the starboard side, are approximate to those in case of the port side. Additionally, the sign of (v r) in the whole starboard turn is opposite with those in the port turn process. The expression and illustration of this feature are shown as Equation (7). This characteristic is used to propose a mechanism integrated for the controller. With this mechanism, a neural controller can be applied for berth-approaching on each side even if the controller is only trained by the teaching data to berth from one side.
r port −r starboard where u port , v port , and r port are the surge velocity, sway velocity, and yaw velocity, respectively, when the ship turns to the port side; u starboard , v starboard , and r starboard are the surge velocity, sway velocity, and yaw velocity, respectively, when the ship turns to the starboard side.

Head-Up Coordinate System
A head-up coordinate system was introduced by Im and Nguyen [11] to consider two new inputs for a neural controller instead of using the parameters including the geographical coordinates (η, ξ) and ship heading (Ψ) like in previous studies. Two parameters proposed in the head-up coordinate system, as illustrated in Figure 2, consist of the relative bearing (Ψ REL ) and the distance from the ship to the berth (D). Based on these inputs, the rudder (δ ord ) and propeller (rps) are determined properly by the neural controller. In combination with the distance to the imaginary line (d 1 ) and the remaining distance to the berth (d 2 ), four parameters (Ψ REL , D, d 1 and d 2 ) are found in this coordinate system.

= ∠ ,
where is defined as the directional angle (in degrees) from the ship heading to a straight line drawn from the ship , to the berth ( , ), and is the angle between the vector and the vector .

Concept of a Multitasking Ship Berthing System Based on ANN
In theory, an ANN has no ability to determine the control signal well when the initial inputs entered for the network are entirely different from those considered in the teaching data. This means that the ANN controller cannot work when the initial conditions of the inputs are different from those in the teaching data. In the previous studies, the inputs of the teaching data always contain the geographical coordinates of the ship (η1, ξ1). Because the geographical coordinates of the ship (η1, ξ1) in the trained port are always different from those (η2, ξ2) in other ports, the ability of the ANN to perform different tasks of ship berthing is limited. To overcome that problem, we use two parameters: relative bearing (ΨREL) and distance from the ship to berth (D).
Second, it assumes that teaching data including the ΨREL1, D1, d1(1), d2(1), u1, v1, r1, δord and rps are obtained, in which the ship approaches the berth from the port side. Because the dynamic feature of the ship on the port side is different to that of the starboard side, the trained neural networks in previous studies, as well as in the first part of this research, cannot berth from the starboard side of the ship. To solve this problem, an integrated mechanism with three negative signs is linked to the main controller to achieve an integrated neural controller where two negative signs are added to the velocities (u and v), and one negative sign is connected to the rudder angle. For the starboard side, where the initial conditions of inputs (ΨREL3, D3, d1(3), d2(3), u3, v3, r3) are similar to those of the port side (ΨREL1, D1, d1(1), d2(1), u1, v1, r1), the integrated neural controller can berth successfully based on the changing of the signs of velocities (u, v) and the rudder angle (δord), as illustrated in Figure 4. To simulate the ship motion, Equations (1) and (2) are employed to obtain the ship states with respect to time. In every case, the ship dynamics (u, v, r) and parameters (d 1 , d 2 ) are originally kept, and a data converter is suggested to transform the ship states (η, ξ, Ψ) into inputs considered as (Ψ REL , D) in the head-up coordinate system for the proposed controller. The formula of the data converter is shown as in Equation (8).
where ψ REL is defined as the directional angle (in degrees) from the ship heading to a straight line drawn from the ship S η ship , ξ ship to the berth B(η berth , ξ berth ), and λ is the angle between the vector → BS and the vector → BA.

Concept of a Multitasking Ship Berthing System Based on ANN
In theory, an ANN has no ability to determine the control signal well when the initial inputs entered for the network are entirely different from those considered in the teaching data. This means that the ANN controller cannot work when the initial conditions of the inputs are different from those in the teaching data. In the previous studies, the inputs of the teaching data always contain the geographical coordinates of the ship (η 1 , ξ 1 ). Because the geographical coordinates of the ship (η 1 , ξ 1 ) in the trained port are always different from those (η 2 , ξ 2 ) in other ports, the ability of the ANN to perform different tasks of ship berthing is limited. To overcome that problem, we use two parameters: relative bearing (Ψ REL ) and distance from the ship to berth (D).
First, in the original port, teaching data consisting of the Ψ REL1 , D 1 , d 1(1) , d 2(1) , u 1 , v 1 , r 1 , δ ord, and rps are generated to train an artificial neural network. This neural network is applied as a main controller, and is a basis to construct an integrated neural controller. In other ports, where the initial conditions of inputs (Ψ REL2 , D 2 , d 1(2) , d 2(2) , u 2 , v 2 , r 2 ) are similar to those (Ψ REL1 , D 1 , d 1(1) , d 2(1) , u 1 , v 1 , r 1 ) achieved in the teaching data of the original port, the trained ANN can calculate the rudder angle (δ ord ) and propeller speed (rps) to bring the ship into the berth successfully, as illustrated in Figure 3.   Second, it assumes that teaching data including the Ψ REL1 , D 1 , d 1(1) , d 2(1) , u 1 , v 1 , r 1 , δ ord and rps are obtained, in which the ship approaches the berth from the port side. Because the dynamic feature of the ship on the port side is different to that of the starboard side, the trained neural networks in previous studies, as well as in the first part of this research, cannot berth from the starboard side of the ship. To solve this problem, an integrated mechanism with three negative signs is linked to the main controller to achieve an integrated neural controller where two negative signs are added to the velocities (u and v), and one negative sign is connected to the rudder angle. For the starboard side, where the initial conditions of inputs (Ψ REL3 , D 3 , d 1(3) , d 2(3) , u 3 , v 3 , r 3 ) are similar to those of the port side (Ψ REL1 , D 1 , d 1(1) , d 2(1) , u 1 , v 1 , r 1 ), the integrated neural controller can berth successfully based on the changing of the signs of velocities (u, v) and the rudder angle (δ ord ), as illustrated in Figure 4.

Artificial Neural Network Trained by Teaching Data in the Original Port
In this section, a neural network of multi-layer perception (MLP) was selected for the ANN controller, which had seven inputs including the Ψ REL , d 1 , v, r, u, D, and d 2 , and two outputs consisting of the rudder angle (δ ord ), and the revolution rounds (rps). The structure of the network was divided into two separate parts in a hidden layer, as illustrated in Figure 5a.
In this section, a neural network of multi-layer perception (MLP) was selected for the ANN controller, which had seven inputs including the ΨREL, d1, v, r, u, D, and d2, and two outputs consisting of the rudder angle (δord), and the revolution rounds (rps). The structure of the network was divided into two separate parts in a hidden layer, as illustrated in Figure 5a.
As shown in Figure 5b, a berthing ship's maneuver parameters were used to generate teaching data, and then a data converter was applied to collect the parameters in a head-up coordinate system. A back-propagation technique with a training function of the Levenberg−Marquardt algorithm was applied to train the ANN and to obtain weights and thresholds. The objective of training is to minimize the mean square error (MSE) between the outputs of the network and the desired outputs provided by the teaching data. The training of the ANN was installed as an off-line mode to learn directly the samples in teaching data. The number of nodes in each layer of the network is assumed to be m, n and p. The teaching data consist of samples expressed in the following form: {q1, l1}, {q2, l2},…{qi, li}, where qi and li are the inputs of the network and the target outputs, respectively. The input vector of the ANN is denoted as The output of each node at the hidden layer (Hn) can be written as follows: A tansig-function was chosen as a transfer function at the hidden layer, the details of which are as follows: where f1 is a transfer function at the hidden layer and netn is an input at the n-th node of the hidden layer. Wnm and bn are the weights on the link from node n to node m and the threshold of the hidden layer (Hn). As shown in Figure 5b, a berthing ship's maneuver parameters were used to generate teaching data, and then a data converter was applied to collect the parameters in a head-up coordinate system. A back-propagation technique with a training function of the Levenberg−Marquardt algorithm was applied to train the ANN and to obtain weights and thresholds. The objective of training is to minimize the mean square error (MSE) between the outputs of the network and the desired outputs provided by the teaching data. The training of the ANN was installed as an off-line mode to learn directly the samples in teaching data.
The number of nodes in each layer of the network is assumed to be m, n and p. The teaching data consist of samples expressed in the following form: {q 1 , l 1 }, {q 2 , l 2 }, . . . {q i , l i }, where q i and l i are the inputs of the network and the target outputs, respectively. The input vector of the ANN is denoted as The output of each node at the hidden layer (H n ) can be written as follows: A tansig-function was chosen as a transfer function at the hidden layer, the details of which are as follows: where f 1 is a transfer function at the hidden layer and net n is an input at the n-th node of the hidden layer. W nm and b n are the weights on the link from node n to node m and the threshold of the hidden layer (H n ). Similarly, the output of each node at the output layer (O P ) is written as Equation (11) O A satlin-function is employed as the active function at the output layer, and the detail of this function is as follows: where the f 2 and net p are a transfer function at the output layer and an input at the p-th node of the output layer, respectively. W pn and b p are the weights on the link from node p to node n and the threshold of output layer (O p ). The goal function (MSE) to train the ANN is represented as follows: The back-propagation technique, which is a gradient descent algorithm, is applied when the network weights are moved along the negative of a gradient of a performance function. Then, the Levenberg-Marquardt algorithm is used to approach the second-order training speed without computing the Hessian matrix as required in a quasi-Newtonion method. When the performance function has the form of a sum of squares, then the Levenberg-Marquardt algorithm uses the following approximation for the Hessian matrix in order to follow a Newton-like update: where W contains of all weights of the network, J is the Jacobian matrix, I is the identity matrix. After the training process of an ANN, the control signals and ship states are determined by the following equations δ ord(t+1) , rps t+1 where f MMG is a function denoted for the MMG model. This procedure is carried out continuously during the berthing process of a ship. In this study, a MATLAB Neural Network Toolbox, where varieties of training functions with different basic algorithms are available to train the network, is used to train the proposed controller, and to simulate the automatic ship berthing. The Levenberg−Marquardt algorithm is one of the training functions, and it is easy to get the syntax of this algorithm in MATLAB.
With the rapid advance of science, technology and theories, such as machine learning methods, deep learning methods, etc., have been developed deeply and widely to carry out advanced tasks with help from artificial intelligence. For automatic ship berthing, a MLP neural network is commonly used to learn the teaching data and to imitate the actions of a human brain in performing the stages of ship berthing. In this study, the purpose is to construct a MLP-based ship berthing system without retraining the structure of the neural network; therefore, other approaches, such as a long short-term memory network (LSTMN), recurrent neural network (RNN), convolutional neural network (CNN), and so on, will be investigated in the future.

Integrated Neural Controller
The proposed ANN controller was trained in the original port, where the ship approaches to the berth on her port side with the initial conditions of a ship at starting time as (Ψ REL1 , d 1(1) , v 1 , r 1 , u 1 , D 1 , d 2(1) , δ 1 , rps 1 ). Figure 6 shows the structure of a multitasking berthing system and integrated neural controller for different tasks for automatic ship berthing. The proposed ANN controller was trained in the original port, where the ship approaches to the berth on her port side with the initial conditions of a ship at starting time as (ΨREL1, d1(1), v1, r1, u1, D1, d2(1), δ1, rps1). Figure 6 shows the structure of a multitasking berthing system and integrated neural controller for different tasks for automatic ship berthing. Figure 6. The structure of the multitasking berthing system and the integrated neural controller.
Generally, the ship states (ΨREL(t) d1(t), vt , rt, ut, Dt, d2(t)) are used to find out the rudder angle (δt+1) and revolution speed (rpst+1) in next time by Equation (15). Besides that, Equation (15) can be rewritten in the following form where fANN and gANN are operators denoted as separate outputs of the integrated neural controller.
For the second task (as shown in Figure 4), when the ship berths from its starboard side with initial states similar to those in the teaching data, the integrated controller with three negative signs calculates the rudder angle and the revolution speed continuously to berth from its starboard side.
From the inputs such as the ΨREL1, D1, d1(1), d2(1), u1, v1, and r1, the rudder angle (δ2) and the revolution speed (rps2) at second time are determined as the outputs of the controller. To approach the berth, the rudder angle (δ2) needs to be altered oppositely to that angle in the teaching data, as in Figure 7. Besides that, the ship dynamics of the starboard side (−v2, -r2) are also opposite to that of the port side (as shown in Equation (7)); therefore, it is necessary to invert the sign of these states (−v2, -r2 δ2) for a successful berthing. To achieve successful ship berthing on each side, three negative signs For the first task (as shown in Figure 3), the integrated neural controller calculates the rudder angle and the revolution speed continuously to control the ship into the berth. From the inputs such as the Ψ REL1 , d 1(1) , v 1 , r 1 , u 1 , D 1 and d 2(1) , the rudder angle and the revolution speed at second time are determined. The new rudder angle (δ 2 ) and revolution speed (rps 2 ) make the ship motion dynamics change from the ship states (Ψ REL1 , d 1(1) , v 1 , r 1 , u 1 , D 1 , d 2(1) ) into new ones (Ψ REL2 , d 1 (2) , v 2 , r 2 , u 2 , D 2 , d 2(2) ).
Generally, the ship states (Ψ REL(t) d 1(t) , v t , r t , u t , D t , d 2(t) ) are used to find out the rudder angle (δ t+1 ) and revolution speed (rps t+1 ) in next time by Equation (15). Besides that, Equation (15) can be rewritten in the following form where f ANN and g ANN are operators denoted as separate outputs of the integrated neural controller.
For the second task (as shown in Figure 4), when the ship berths from its starboard side with initial states similar to those in the teaching data, the integrated controller with three negative signs calculates the rudder angle and the revolution speed continuously to berth from its starboard side.
From the inputs such as the Ψ REL1 , D 1 , d 1(1) , d 2(1) , u 1 , v 1 , and r 1 , the rudder angle (δ 2 ) and the revolution speed (rps 2 ) at second time are determined as the outputs of the controller. To approach the berth, the rudder angle (δ 2 ) needs to be altered oppositely to that angle in the teaching data, as in Figure 7. Besides that, the ship dynamics of the starboard side (−v 2 , -r 2 ) are also opposite to that of the port side (as shown in Equation (7)); therefore, it is necessary to invert the sign of these states (−v 2 , -r 2 δ 2 ) for a successful berthing. To achieve successful ship berthing on each side, three negative signs are linked to this controller where two of them are added in front of the inputs (v r), and another is placed behind the output (δ), as illustrated in Figure 6. Similarly, the integrated neural controller determines the control signals for all the steps to approach the berth from its starboard side by the following equations Mathematics 2020, 8, x FOR PEER REVIEW 11 of 24 determines the control signals for all the steps to approach the berth from its starboard side by the following equations

Numerical Simulation and Result
In this section, numerical simulations were carried out in the MATLAB environment to verify the effectiveness of the multitasking system for automatic ship berthing. First, the teaching data are generated to train the integrated neural controller in the original port with the initial states of the ship by the maneuvering process, in which the ship approaches to the berth from its port side. Then, the proposed neural controller is simulated to perform different tasks without the retraining process of an ANN.
For the simulation, the geographical coordinates of all the ports with a latitude and longitude need to be normalized to a non-dimensional form. Because the non-dimensional forms of these ports were different, these ports were entirely different. The geographical coordinates of the ports and the ship position were normalized into the non-dimensional form. Generally, input variables are transformed into the non-dimensional form by following Equation [27].

Numerical Simulation and Result
In this section, numerical simulations were carried out in the MATLAB environment to verify the effectiveness of the multitasking system for automatic ship berthing. First, the teaching data are generated to train the integrated neural controller in the original port with the initial states of the ship by the maneuvering process, in which the ship approaches to the berth from its port side. Then, the proposed neural controller is simulated to perform different tasks without the retraining process of an ANN.
For the simulation, the geographical coordinates of all the ports with a latitude and longitude need to be normalized to a non-dimensional form. Because the non-dimensional forms of these ports were different, these ports were entirely different. The geographical coordinates of the ports and the ship position were normalized into the non-dimensional form. Generally, input variables are transformed into the non-dimensional form by following Equation [27].
where L is the length of the ship; g is the gravitational acceleration; η , ξ , D , d 1 , d 2 , u , v , r , and ψ REL are the longitude, latitude, distances, velocities, and relative bearing in non-dimensional form, respectively.

Teaching Data Generation and Training of ANN in the Original Port
As shown in Figure 8, the teaching data generated in the original port consist of six cases of maneuvering patterns which are conducted to bring the ship into the berth. The range of latitude is from −2 to 8, and the range of the longitude is from −2 to 10. Normally, the ship berthing is considered as a successful process when the ship reaches the berth within 0.2 m/s and the ship's heading is parallel to the berth. As shown in Figure 8, the teaching data generated in the original port consist of six cases of maneuvering patterns which are conducted to bring the ship into the berth. The range of latitude is from −2 to 8, and the range of the longitude is from −2 to 10. Normally, the ship berthing is considered as a successful process when the ship reaches the berth within 0.2 m/s and the ship's heading is parallel to the berth.
The initial states of the ship in the original port include the ship position, ship heading, ship velocities, and the rudder and propeller speeds as the following set: η1/L, ξ1/L, Ψ1, u1, v1, r1, rps, δord. By using the data converter, these states are transformed into the ΨREL, D/L, d1/L, d2/L, u1, v1, r1, rps, and δord, which are used to train the neural network. In the berth maneuvering process, all the time series of the teaching data are recorded.
In this research, six initial states of the ship in the original port were examined: (8, 6, 250, 1.5, 0, 0, 0.75, 0), (8, 6, 210, 1.5, 0, 0, 0.75, 0), (8, 4, 220, 1.5, 0, 0, 0.75, 0), (8, 4, 250, 1.5, 0, 0, 0.75, 0), (8, 2, 240,  1.5, 0, 0, 0.75, 0), and (8, 2, 270, 1.5, 0, 0, 0.75, 0). The corresponding teaching data had the following initial conditions, respectively: (16.9, 10, 2.9, 9.6, 1.  Before training the ANN, a min−max normalization is applied to normalize all the variables of the teaching data for the range (from 0 to 1) which ensures the convergence of the training algorithm for the ANN. The rule of the min−max normalization is represented as the following equation where xi = (x1,..., xn) are the elements of data; zi is the corresponding normalized data; max(x) is the maximum value of xi; min(x) is the minimum value of xi. For the training, the parameters for the structure of the ANN are shown as in Table 3. The result of training of ANN is presented as Figure 9. The initial states of the ship in the original port include the ship position, ship heading, ship velocities, and the rudder and propeller speeds as the following set: η 1 /L, ξ 1 /L, Ψ 1 , u 1 , v 1 , r 1 , rps, δ ord . By using the data converter, these states are transformed into the Ψ REL , D/L, d 1 /L, d 2 /L, u 1 , v 1 , r 1 , rps, and δ ord , which are used to train the neural network. In the berth maneuvering process, all the time series of the teaching data are recorded.
In this research, six initial states of the ship in the original port were examined: (8, 6, 250, 1.5, 0, 0, 0.75, 0), (8, 6,  The teaching data were normalized into values between 0 and 1 to train the ANN controller. Before training the ANN, a min−max normalization is applied to normalize all the variables of the teaching data for the range (from 0 to 1) which ensures the convergence of the training algorithm for the ANN. The rule of the min−max normalization is represented as the following equation where x i = (x 1 , . . . , x n ) are the elements of data; z i is the corresponding normalized data; max(x) is the maximum value of x i ; min(x) is the minimum value of x i . For the training, the parameters for the structure of the ANN are shown as in Table 3. The result of training of ANN is presented as Figure 9.  . Figure 9. The result of training the ANN with teaching data in the original port.
After training, the detail of the data, such as the teaching data, testing data, and validation, are synthesized as shown in Table 4. Table 4. The list of teaching data/validation data/testing data.

Type of Data
Amount Teaching data 06 (as shown in Figure 8) Validation data 06 (03 cases are presented in Figure 10) Testing data 05 (cases are tested for initial conditions which are different to those in teaching data)

Verification of the Integrated Neural Controller for the Original Port and Different Ports
For this task, berthing simulations were carried out for the original port, a different port, and two terminals of a real port. After training, the detail of the data, such as the teaching data, testing data, and validation, are synthesized as shown in Table 4. Table 4. The list of teaching data/validation data/testing data.

Type of Data Amount
Teaching data 06 (as shown in Figure 8) Validation data 06 (03 cases are presented in Figure 10) Testing data 05 (cases are tested for initial conditions which are different to those in teaching data) 6, 250, 1.5, 0, 0, 0, 0.75), the rudder was turned to −10 degrees and the propeller was reduced. The second case started with (8, 4, 250, 1.5, 0, 0, 0, 0.75), the controller brought the ship into berth safely.
In the third case, the ship states started with the initial conditions (8, 2, 270, 1.5, 0, 0, 0, 0.75), and the controller performed the actions to bring the ship into berth. The results showed a good performance of this controller in the original port.

Verification of the Integrated Neural Controller for the Original Port and Different Ports
For this task, berthing simulations were carried out for the original port, a different port, and two terminals of a real port.
As shown in Figure 10, all cases were successful in the original port where the ship approaches to the berth within 0.2 m/s and is also parallel to the berth. These results proved the learning ability of an ANN from teaching data. Figure 10 indicates the three cases of simulation. In the first case, the ship states started with (8, 6, 250, 1.5, 0, 0, 0, 0.75), the rudder was turned to −10 degrees and the propeller was reduced. The second case started with (8, 4, 250, 1.5, 0, 0, 0, 0.75), the controller brought the ship into berth safely. In the third case, the ship states started with the initial conditions (8, 2, 270, 1.5, 0, 0, 0, 0.75), and the controller performed the actions to bring the ship into berth. The results showed a good performance of this controller in the original port.
The different port was validated for the proposed system, in which the range of latitude is from 2 to 12, and the range of the longitude is from −15 to −2. The ship headings in all cases in this simulation were also different to those in the original port.
The results of the automatic ship berthing in a different port are presented in Figure 11. In the first case, the ship started with the initial state of (−13.5, 4, 70, 1.5, 0, 0, 0, 0.75); the rudder was turned to −10 degrees and the propeller was reduced. The second case started with the initial state of (−13.5, 6, 70, 1.5, 0, 0, 0, 0.75), and the controller brought the ship into berth. In the third case, the ship started with the initial conditions of (−13.5, 8, 80, 1.5, 0, 0, 0, 0.75), and the rudder angle was turned to +05 degrees to bring the ship into berth. The results show a successful berthing of the ship in the different port which is entirely different to the original port's geographical coordinates. The different port was validated for the proposed system, in which the range of latitude is from 2 to 12, and the range of the longitude is from −15 to −2. The ship headings in all cases in this simulation were also different to those in the original port.
The results of the automatic ship berthing in a different port are presented in Figure 11. In the first case, the ship started with the initial state of (−13.5, 4, 70, 1.5, 0, 0, 0, 0.75); the rudder was turned to −10 degrees and the propeller was reduced. The second case started with the initial state of (−13.5, 6, 70, 1.5, 0, 0, 0, 0.75), and the controller brought the ship into berth. In the third case, the ship started with the initial conditions of (−13 .5, 8, 80, 1.5, 0, 0, 0, 0.75), and the rudder angle was turned to +05 degrees to bring the ship into berth. The results show a successful berthing of the ship in the different port which is entirely different to the original port's geographical coordinates. Figure 11. Automatic ship berthing in the different port.To verify the proposed controller for a real port, the ship was simulated for the automatic berthing in the Gamcheon area of Busan Harbor, To verify the proposed controller for a real port, the ship was simulated for the automatic berthing in the Gamcheon area of Busan Harbor, where two other terminals were applied. These terminals are named No.4 Wharf and No.6 Wharf, as shown in Figure 12. The range of the latitude is from 35 • 2 N to 35 • 5 56" N, and the longitude is from 128 • 58 E to 129 • 2 36" E. The results of ship berthing in these two terminals are synthesized in Figure 13. where two other terminals were applied. These terminals are named No.4 Wharf and No.6 Wharf, as shown in Figure 12. The range of the latitude is from 35°2′N to 35°5′56′'N, and the longitude is from 128°58′E to 129°2′36′'E. The results of ship berthing in these two terminals are synthesized in Figure  13.  In the first section of the numerical simulation, the integrated neural controller controlled the ship into the berth automatically, but the results were only achieved when the ship approached the berth from its port side. In this section, numerical simulations for ship berthing are performed for when the ship approaches from its starboard side.
In previous studies, the controllers must be retrained by a new teaching data to berth while the integrated neural controller with three negative signs in the ANN structure can control the ship into the berth from its starboard side, without retraining the ANN. Simulations are also applied in the original port, the different port, and two terminals of a real port. where two other terminals were applied. These terminals are named No.4 Wharf and No.6 Wharf, as shown in Figure 12. The range of the latitude is from 35°2′N to 35°5′56′'N, and the longitude is from 128°58′E to 129°2′36′'E. The results of ship berthing in these two terminals are synthesized in Figure  13.  In the first section of the numerical simulation, the integrated neural controller controlled the ship into the berth automatically, but the results were only achieved when the ship approached the berth from its port side. In this section, numerical simulations for ship berthing are performed for when the ship approaches from its starboard side.
In previous studies, the controllers must be retrained by a new teaching data to berth while the integrated neural controller with three negative signs in the ANN structure can control the ship into the berth from its starboard side, without retraining the ANN. Simulations are also applied in the original port, the different port, and two terminals of a real port.

Verification of Integrated Neural Controller for Berth Approaching on Each Side
In the first section of the numerical simulation, the integrated neural controller controlled the ship into the berth automatically, but the results were only achieved when the ship approached the berth from its port side. In this section, numerical simulations for ship berthing are performed for when the ship approaches from its starboard side.
In previous studies, the controllers must be retrained by a new teaching data to berth while the integrated neural controller with three negative signs in the ANN structure can control the ship into the berth from its starboard side, without retraining the ANN. Simulations are also applied in the original port, the different port, and two terminals of a real port.
As shown in Figure 14, the automatic ship berthing is conducted for the original port, in which the ship position and ship heading at the starting time in all cases in this simulation are symmetrical to those in teaching data. The time history shows that the rudder angles, the sway velocity and yaw rate are the opposite to those in teaching data. In the first case, the ship states started with (−8, 6, 110, 1.5, 0, 0, 0, 0.75); the rudder was turned to +10 degrees and the propeller was reduced. The second case started with (8, 4, 110, 1.5, 0, 0, 0, 0.75), and the controller brought the ship into berth safely. In the third case, the ship started with the initial conditions of (8, 2, 100, 1.5, 0, 0, 0, 0.75), and the controller performed the actions to bring the ship into berth. The results showed a good performance of this controller for berthing in the original port. As shown in Figure 14, the automatic ship berthing is conducted for the original port, in which the ship position and ship heading at the starting time in all cases in this simulation are symmetrical to those in teaching data. The time history shows that the rudder angles, the sway velocity and yaw rate are the opposite to those in teaching data. In the first case, the ship states started with (−8, 6, 110, 1.5, 0, 0, 0, 0.75); the rudder was turned to +10 degrees and the propeller was reduced. The second case started with (8, 4, 110, 1.5, 0, 0, 0, 0.75), and the controller brought the ship into berth safely. In the third case, the ship started with the initial conditions of (8, 2, 100, 1.5, 0, 0, 0, 0.75), and the controller performed the actions to bring the ship into berth. The results showed a good performance of this controller for berthing in the original port.
In Figure 15, the automatic ship berthing carried out for the different port, in which the ship position and ship heading at starting time in all cases in this simulation were different to those in the original port. In the first case, the ship started with an initial state of (3, 4, 290, 1.5, 0, 0, 0, 0.75), the rudder was turned to +10 degrees and the propeller was reduced. The second case started with (3, 6, 290, 1.5, 0, 0, 0, 0.75), and the controller brought the ship into berth. In the third case, the ship started with the In Figure 15, the automatic ship berthing carried out for the different port, in which the ship position and ship heading at starting time in all cases in this simulation were different to those in the original port. In the first case, the ship started with an initial state of (3, 4, 290, 1.5, 0, 0, 0, 0.75), the rudder was turned to +10 degrees and the propeller was reduced. The second case started with (3, 6, 290, 1.5, 0, 0, 0, 0.75), and the controller brought the ship into berth. In the third case, the ship started with the initial conditions (3, 8, 280, 1.5, 0, 0, 0, 0.75), and the rudder angle was turned to +10 degrees to bring the ship into berth. The results presented a successful berthing into the different port, which is entirely different from the original port with regards to its geographical coordinates.
Mathematics 2020, 8, x FOR PEER REVIEW  18 of 24   initial conditions (3, 8, 280, 1.5, 0, 0, 0, 0.75), and the rudder angle was turned to +10 degrees to bring the ship into berth. The results presented a successful berthing into the different port, which is entirely different from the original port with regards to its geographical coordinates. Figure 15. Automatic ship berthing in the different port from the starboard side. Figure 16 showed the results of ship berthing at No. 4 Wharf: the ship approached this terminal from the starboard side. All the cases showed that the proposed neural controller performs well at berthing for both approach sides.  Similarly, Figure 17 indicated the results of ship berthing at No. 6 Wharf. The results of this simulation were successful for the starboard side. In this section, numerical simulations were carried out to validate the effectiveness of the multitasking berthing system of the ship based on the integrated neural controller without In this section, numerical simulations were carried out to validate the effectiveness of the multitasking berthing system of the ship based on the integrated neural controller without retraining the ANN structure. The results indicated that the proposed controller performs well at conducting different tasks related to ship berthing problems. In the future, the author will continue to develop this system considering different tasks, such as combining it with an automatic collision avoidance system, berthing the ship in a restricted depth, and so on.

Conclusions
In this study, a multitasking system for automatic ship berthing was proposed based on an integrated neural controller without the retraining stages of an ANN to carry out the different tasks of ship berthing. An integrated neural controller is a combination of an artificial neural network and integrated mechanism. By using the proposed system, the ship can be controlled automatically for different ports and from both berth-approach sides without retraining the controller structure. Compared to previous studies, this system does not demand the retraining of ANN; therefore it saves time and cost when performing different tasks of ship berthing. In the future, the complex effect of disturbances, such as the wind, current, and waves, will be also investigated for this system. This study uses applicable approaches to perform real experiments of automatic ship berthing at scale for ships in the future.
Funding: This research received no external funding.

Acknowledgments:
The author thanks the editors and the anonymous reviewers for their constructive comments, which helped us to improve the manuscript.

Conflicts of Interest:
The authors declare no conflict of interest.

ANN Artificial Neural Network Wnm
Weight on the link from node n to node m Wpn Weight on the link from node p to node n bn Threshold of hidden layer (Hn)