A Co-operative Hybrid Model For Ship Motion Prediction

Dynamic models of ships have been widely used for model-based control and short-term prediction in the past. Identifying the parameters of such models has mainly been done through scaled model tests, full scale tests or computational fluid dynamics software. This is a challenging task due to the many aspects that influence the ship dynamic behaviour and thus one would expect a certain degree of mismatch between the actual motion of the ship and the modelled behaviour. The mismatch in the dynamic model may be due to unmodelled effects, but also the lack of measurements of waves and ocean current. To make up for the discrepancies the authors propose to create a co-operative hybrid model consisting of the dynamic model and a neural network, where the neural network predicts the acceleration error of the dynamic model. The approach is tested on real data originating from the Research Vessel (RV) Gunnerus performing a shutdown of thrusters during stationkeeping. The subsequent task is to predict the propagation of position and heading while drifting due to wind, wave and current forces. Comparing the motion of the real ship and the modelled ship, shows the improved prediction accuracy of the hybrid model.


Introduction
Short-term ship motion prediction, ranging in prediction interval length from a few seconds to one minute, has implications for a variety of applications such as takeoff and landing of unmanned aerial vehicles and helicopters Yang (2013), ship crane operations From et al. (2010) Küchler et al. (2011), maneuvering Perera (2017 and quiescent period prediction Dannenberg et al. (2010) Giron-Sierra and Esteban (2010). The main motivating factors for all these applications of ship motion prediction are safety and efficiency. If the uncertainty of the future motion is reduced, the ship operator can make informed decisions on how to proceed with an operation. Helicopter landing may be timed to coincide with a period of relatively low heave motions or a trajectory that may interfere with surrounding vessels or stationary objects may be discovered at an early stage and corrective measures can be implemented.
The motion of a ship at sea is dictated by the hydrodynamic properties of the ship, environmental disturbances like wind, wave and ocean current and thruster forces. Typically, the wind is the only measurable environmental state, which leaves the wave impact and current impact on the model unmeasured. Probably, this is why many researchers have turned to data-based modelling for predicting ship motion. It allows for fitting models based on informative features from recently sampled ship motion data. If the ship is performing Dynamic Positioning (DP), meaning that it maintains a steady position, or performs low-speed ma-neuvering using thrusters, observers have been developed that filter out the wave-induced oscillatory motion and estimate the apparent force caused by a combination of wave drift force and ocean currents Fossen and Perez (2009). However, they depend on information about the sea state and requires that the ship is actively controlled.
In this paper we investigate the benefit of combining a dynamic model with a data-based model for predicting the future position and heading of a ship. The dynamic model is identified through scaled model experiments and describes the motion of the ship in 3 degrees of freedom (DOF): longitudinal/lateral motion and rotation about the vertical axis of the ship Hassani et al. (2015). Forces due to wind and thrusters are accounted for as well. But, due to lack of knowledge of wave and current impact on the ship and inherent model fidelity limitations, the model output will not describe the 3 DOF motion of the real ship perfectly. Thus, based on a limited set of recent data to perform model parameter adaptation, the data-based model corrects the dynamic model on an acceleration level. In this way, the general trends in future motion may be outlined by using existing knowledge, leaving the data-based model with less of a challenge in predicting the residuals of the original model.
Hybrid modelling, using an identified model of a process along with a data-based model to amend its deficiencies, has been explored in the past van de Ven et al. (2007). Albeit, with a focus of improving parameter estimates of a partially known model. The present study focuses on compensating the predictions made by a model which is assumed to be complete, but lacking information about the complete environmental disturbances Skulstad et al. (2021).
When the ship is automatically controlled, either for stationkeeping or trajectory tracking under normal operating conditions, the assumption is that the ship will maintain its desired motion state and therefore no prediction is needed. Therefore, the case study presented in this paper shows the use of predictions during a power failure situation. While power failures during stationkeeping operations is unlikely due to power plant and thruster redundancy for ships involved in critical operations, the consequences may be severe. Often such operations take place close to other ships or offshore structures or during deployment of seabed installations. Being able to predict the future position and heading during such a failure could provide the ship operator with valuable information on whether or not to carry out the operation, and thus enhances the quality of the pre-operation risk analysis. This insight might also be of use in decision-making for autonomous ships where a failure requires a proper response based on the future trajectory of the ship Blindheim et al. (2020).

Related work
Ship motion prediction models range from completely transparent kinetic models Triantafyllou et al. (1983), through kinematic models Perera (2017) to regression models Brandsaeter and Vanem (2018) and black-box Machine Learning (ML) models Yin et al. (2017). Each domain has their own strengths and weaknesses. Applying a kinetic model to prediction requires knowing the parameters that go into the model. This may be performed using scaled model experiments Hassani et al. (2015) or specialized hydrodynamic computer programs. It is challenging to determine all the parameters of the models to a satisfactory accuracy van de Ven et al. (2007) covering all the various speed regimes and environmental conditions a vessel may encounter. However, the relations between measured data and future motion are explicit and defined by functions describing forces that are derived using well-established theory Fossen (2011).
Kinematic models disregard the forces induced by a ship moving on the surface of the ocean and apply only the relation between acceleration/velocity and heading to get positions. A complete method of estimation and prediction of vessel trajectories is presented in Perera (2017). An extended Kalman filter was used to estimate the states of a kinematic ship maneuvering model. Estimated states were then applied to determine navigation vectors, which were input to a vector product-based prediction method for calculating future positions and heading.
ML offers a way of modelling the ship behaviour without explicitly identifying parameters that relate environmental disturbances, ship state and thruster forces to future ship states Li et al. (2017). However, this comes at the cost of model transparency and the requirement of having sufficiently rich data such that the data-based model is able to generalize to new inputs. An online approach to ship roll angle prediction was presented in Yin et al. (2017). They applied an adaptive sliding window to include relevant recently sampled data which best describe the time-varying dynamics of the ship. The Radial Basis Function (RBF) Neural Network (NN) used in their study was updated in a sequential manner. A similar sequential RBF network was used for multi-step predictions in relation to predictive control of a ship's course in Yin et al. (2010). Recently, recurrent networks have also been used for predicting roll/pitch angles and heave motion Zhang et al. (2020) Duan et al. (2019) and horizontal motion Skulstad et al. (2019). Support vector regression (SVR) models represent an alternative to NNs for creating data-based predictive models Li et al. (2016). By recognizing that the roll angle exhibits a periodic term when exposed to waves, Li et al. combined a periodogram estimation method with a SVR model to predict the roll angle up to 15 seconds ahead Li et al. (2019). Comparison against pure SVR and NN models showed the benefit of including such a hybrid prediction scheme. The periodicity seen in the time series of ship roll and pitch angle and heave motion may also be handled by decomposition of the signals using e.g. empirical mode decomposition Hong et al. (2019) Duan et al. (2015b). For such an approach each mode is related to a predictive model, such as the SVR, and the individual predictions are merged to form the prediction of the original signal.
The Autoregressive (AR) method makes use of only the history samples of a certain state and is an efficient way of obtaining predictions a few seconds ahead From et al. (2010). Optimized parameters may be obtained through a recursive least squares method Ma et al. (2006). The AR method is efficient, but it is a linear method which is limited by the assumption of having a stationary time series Duan et al. (2015a). To overcome these limitations Yang et al. applied the Bayes Information Criteria to select the model coefficient size and also implemented a factor that reduced the impact of the most distant samples Yang (2013).
The performance of data-based methods, such as ML and AR, heavily depend on the amount and relevance of the training data with respect to the data used during the prediction stage. And, given a certain training dataset containing relevant and sufficient amount of data, the training time can not be determined up front Takami et al. (2021). Predictors that apply a priori information about the ship dynamics, such as identified maneuvering models, face fidelity issues due to the abundance of operational conditions that influence on the dynamics of the ship. The deficiencies of the two modelling domains makes combining models from the two a natural choice. Training efficiency of the data-based predictor may be enhanced by predicting residual errors in the dynamic model predictions. And those residual predictions may be used to account for the previously mentioned fidelity issues Skulstad et al. (2021).

Ship motion predictors
In this section predictors that apply a priori information about the components of the system will be introduced. In a scenario where data is scarce and the event that triggers the prediction is seldom seen, purely data-based predictors will have limited information to perform successful predictions.

Model-based predictor
A purely model-based ship motion predictor embeds the models of the environment impact on the ship, thruster forces and the hydrodynamic models of the ship hull. This is visualized in Figure 1.
In combination these models output the total force exerted on the ship hull and these forces are converted to accelerations through the known mass matrix of the ship, shown in eq. (1).
In the above equation the ship velocity relative to current is given as ν T denotes the components of the current velocity in the coordinate frame of the ship. The current velocity is presumed irrotational in this case. M RB and M A are the rigid body and added mass matrices of the ship. Coriolis and centripetal forces are included through C A (ν r ) and C RB (ν), linear damping through D and nonlinear damping through D n (ν r ). Forces generated by the three thrusters are given as τ c , while the environmental forces due to wind and waves are given by τ wi and τ wa , respectively. τ wa and ν c are unknown and will therefore not be considered further as inputs to the dynamic model. The block named Model-based predictor in Figure 1 contains these models. Integrating the accelerations once yields the predicted propagated velocities,ν t+1 , given in the coordinate frame of the ship. A rotation by the heading angle to obtain velocities relative to North and East, followed by a second integration results in predicted positions and heading,η t+1 .
At the beginning of the prediction interval the thrusters are each fed with their respective most recent sample from the thrusters, u 0 , where the subscript 0 signifies the start of the prediction interval. For the azimuth thrusters this corresponds to an azimuth angle and a Revolutions Per Minute (RPM) command, and for the tunnel thruster an RPM command. During a power failure the thrusters do not actively produce force. The only force they induce on the ship is due to moving through the water at a non-zero velocity. These values are updated based on the predicted ship velocities.
Thruster forces are acquired through the execution of hydrodynamic models created by the manufacturer of the thrusters. The individual thrust outputs depend on the control commands issued by the motion Figure 1: Model-based predictor controller as well as the ship speed and is valid for the 4 quadrants of operation given in Table 1 Smogeli (2006).  (2006)).
The ship used in this study has three thrusters: one bow tunnel thruster and two main azimuth thrusters at the stern. Converting their individual, local, thrust force into a combined force acting in the centre of gravity of the ship requires the 3x3 thrust configuration matrix shown in eq. (2). s(·) and c(·) are abbreviations of the sine and cosine functions.
The tunnel thruster cannot rotate and thus produces positive or negative thrust, T tn , along the lateral axis of the ship at a distance l tx from the ship's centre of gravity. Azimuth thrusters may rotate and the angles for the port and starboard thruster are α p and α s , respectively. Their individual thrust, T pa and T sa , is applied at locations (l px ,l py ) and (l sx ,l sy ) relative to the ship's centre of gravity.
Wind related variables are also unknown for future time instances, so the values sampled at the prediction interval start is used (V w,0 and β w,0 ). The resulting estimated force, τ wi , given in the coordinate frame of the ship is shown in eq. (3).
The wind force coefficients C X , C Y and C N depend on the relative wind direction, γ rw , and they are typically derived using either computational fluid dynamics software or wind tunnel tests Hassani et al. (2015).
In addition to the force coefficients the model requires air density, ρ a , relative wind velocity, V rw , area of the ship's frontal and lateral projection, A F w and A Lw , and the overall length of the ship, L oa . To perform multi-step predictions the equation of motion, given in eq. (1), is solved for the acceleration, ν. Integration according to Figure 1 allows for feeding back the velocities. Repeating this process gives predicted accelerations, velocities, positions and heading at future time instances.

Hybrid model predictor
In the hybrid model the dynamic model is applied as described in section 3.1, while a data-based model aims to predict the discrepancy in the acceleration of the model-based predictor. Discrepancies will always be present due to the complex environment in which the ship operates. In the present study the discrepancies also come from not having measurements or estimates of the ocean current, such that the dynamic model may account for these forces. The training scheme is shown in Figure 2.
The objective of the NN predictor is to predict ∆ν t+1 =ν t+1 −ν t+1 , whereν t+1 is the actual acceleration of the ship andν t+1 is the acceleration predicted by the model-based predictor. For each sample in the Historical data of Figure 2, the model-based prediction of the surge, sway and yaw acceleration one second ahead is compared against the true acceleration one second ahead. This yields the targets for the supervised training procedure of an ensemble of feedforward NNs. Ensembles are applied in order to average the effect of random weight/bias initialization in the individual NNs. A subset of all the available inputs, shown as X tr,t in Figure 2, is extracted according to the feature selection procedure described in Section 3.3. The available features also include virtual sensors in the form of states predicted by the model-based predictor and the NNs (see Figure 2). This results in the input training data, X tr,t . Figure 2 shows the application of the hybrid predictor when used to output predictions of the future north/east position and heading angle. The modelbased predictor initially receives the following, most recently sampled, data: • Position and heading, η 0 , relative to the North East Down coordinate frame.
• Linear and angular velocities, ν 0 , given in the coordinate frame of the ship.
• Thruster control commands, u t . These remain constant throughout the prediction interval.
Executing the model-based predictor results in predictions of acceleration, velocity and position at one second ahead of the prediction interval start time. These predictions are passed to the Sensors block for potential use as input features to the NNs at subsequent steps. Then an input vector is drawn from the set of available sensor data according to the feature selection scheme. A predicted acceleration discrepancy is output by a forward pass over the data-based predictor to get ∆ν t+1 . Summing the predicted acceleration discrepancy and the model-based predicted accelerations yields the corrected acceleration, which is propagated through integrators to achieve the predicted position and heading angle at one second ahead of the initial time instance. This process is repeated 60 times for a one minute prediction interval. A motivating factor for selecting an iterative multistep prediction strategy, as opposed to directly predicting the complete future acceleration discrepancy vector, lies in the nature of the process that generates the training data. When the ship is actively controlled the control commands change as fast as 1 Hz. This limits the temporal validity of the acceleration predictions made by the model-based predictor, which is used to generate supervised training data for the NNs. The NN structure applied in this paper is a regular feedforward network consisting of two layers of 20 units applying a hyperbolic tangent activation function. The output layer has three units and applies linear activation functions.

Feature selection and extraction
Selecting features that contain useful information for predicting a certain target value is beneficial in terms of generalization ability of the NNs, reducing computational burden and providing a more interpretable model. In this paper this is achieved by first acknowledging that as the model-based predictor performs multi-step predictions, only the position and heading and the respective velocities will be propagated/updated. Thus, features such as roll and pitch angle, their velocities, and wind direction and velocity remain constant throughout the prediction interval. Also, the control commands to thrusters remain constant as they do no longer contribute to actively control the ship's position and heading. By this intuition, only the position, heading and their velocities and accelerations will provide current information about the motion of the ship within the prediction interval. From this subset, which contains features that are dynamic in the prediction interval, the model-predicted longitudinal, lateral and rotational speed and accelerations were selected as input to the data-based predictor along with the previously predicted acceleration discrepancy, ∆ν t . The NNs thereby assume an auto-regressive form with exogenous inputs.

Case study
In this section the performance of the predictors are compared in a scenario where the ship operator turns off the active dynamic positioning controller. The scenario was conducted outside the port of Trondheim, Norway, and the purpose was to mimic a power failure event. The analysis, training and application of the predictors is carried out based on historical data, i.e. not onboard the ship in real time.

Data and ship model
The ship used in this case study is the Research Vessel (RV) Gunnerus shown in Figure 3. It is equipped with two azimuth thrusters at the stern and one bow tunnel thruster and has an overall length of 36.25 m.
The data used for the case study presented in this section was collected during a shutdown of the active dynamic positioning control, leaving the vessel to drift freely due to forces incurred by current, wind and waves. The sea state during the data collection was estimated by the ship operator to correspond to a sea state of 2 on the Beaufort scale. Prior to executing the simulated shutdown of dynamic positioning control, the ship performed low-speed maneuvering and stationkeeping for 50 minutes, sampling data at 1 Hz from thrusters, ship motion data, wind direction and wind speed.

Results
Since the parameters of the ship-and thruster models have been derived through tests using scaled model experiments and computational fluid dynamics software they describe the dynamic behaviour of the overall system well. Applying the models as-is therefore yields a reasonably accurate set of predicted future position and heading. Figure 4 shows the velocities predicted every second from the point of failure to the prediction horizon end at 60 seconds ahead of time. The performance of the model-based predictor is sensitive to initial velocities and heading. To mitigate the effect of noisy velocity measurements, seen as red lines in Figure 4, on the model-based predictions, a sliding window average of 3 seconds was applied to the heading and velocities input at the start of each prediction interval. A larger discrepancy is seen for the surge velocity predicted by the dynamic model, which indicates that either wave/ocean current-induced forces, or model discrepancies are present. The smooth output from the model-based predictor, in addition to reliably propagating its predictions, has the added effect of smoothing the output of the hybrid predictor (see Figure 5). Figure 5 shows the acceleration prediction made by the two predictors over the course of the first predic-  tion interval, starting from the time of failure. The closer proximity of the hybrid predicted acceleration to the mean acceleration, given in red, shows the positive effect of adding the acceleration prediction compensation. By running multiple prediction intervals, successively incrementing the start of the interval with one second, the average prediction errors may be discerned. In Table 2, average values of the first 5 and 20 successive, post failure, prediction intervals are given. Due to the nature of ML algorithms, requiring data for inference which is similar to that seen in training, the predictions made on data sampled some time after the failure may not be valid. This is caused by the ship drifting and thus obtaining higher velocities relative to the low-speed and stationkeeping operation from which the training data was sampled. This is reflected by the degradation in performance of the hybrid predictor rel-  Table 3). If a set of data covering a larger dynamic range was pre-recorded, the validity of the hybrid predictions may be extended beyond what is shown in this paper. Unlike the hybrid predictor, the average error of the model-based predictor decreases as the prediction interval start time is propagated (see Table 2). This is attributed to the fact that as the ship drifts the transient accelerations, caused by the sudden loss of stationkeeping control, decrease. When the ship no longer has active stationkeeping capabilities, it drifts northwards for this specific case. This is shown in Figure 6 where the black dashed lines of the figure show the trajectory of the first 5 prediction intervals of the hybrid predictor, while the dash-dot lines show the corresponding model-based predictions. Averages of the 5 trajectories are given as red circles (hybrid model) and red crosses (dynamic model). The initial speed direction for the first prediction interval is given by the black arrow. Variations in the predicted trajectories are mainly due to the advancing prediction interval start time, which yields varying initial speeds. The average of the trajectories shown in Figure 6 clearly show the benefit of including the acceleration corrections.
The measured wind direction and speed for the cor-   Figure 7: Actual wind speed and direction relative to north (0 degrees). The direction is to be interpreted as "coming from ".
responding time interval are shown in Figure 7. The mean direction is roughly 157 degrees. Thus, wind effect induces forces on the hull consistent with the drifting northward trajectory. However, the ship also moves slightly due east, which is not consistent with the wind direction. Thus, due to the modest wave height, current is the remaining factor that may lead to this trajectory.

Conclusion
A hybrid predictor was constructed and its predictive performance was tested on data from a real scenario mimicking a power failure during dynamic positioning. The NN models providing acceleration corrections to the model were shown to substantially improve the accuracy of the overall motion predictions for such a case. However, as the ship drifts freely due to wind and current, it eventually attains speeds outside of the range of the data that was used to train the NNs. This limits the validity of such corrective predictions to a short time span after experiencing such a failure. In the case study presented in this paper a good match between the predicted position and heading compared to the actual position and heading was seen for the first 10, 60-second, prediction intervals. The proposed approach may be transferred to more general purpose prediction scenarios. However, the accuracy of this method, for scenarios where future thruster commands may not be deduced at the time of prediction start, will be reduced. This is due to the influence of commands, not yet known to the predictor.