# Federated Learning for Maritime Environments: Use Cases, Experimental Results, and Open Issues
## 4 FL-Aided Fuel Consumption Prediction
### Runtime and Time Complexity Considerations  
The computation complexity of an algorithm can be considered as the amount of the resources needed to accurately execute it from both computation time (_time complexity_) and memory storage requirements (_space complexity_) perspectives. Since space complexity was analyzed in the previous section, this subsection gives an comparative overview of the time complexity characterizing each of the schemes used in this work. Table 3 reports the practical training and inference runtime required for each scheme to run. Notably, the runtime required for training purposes is required only one time (and usually before the real operation of the model), and, once the model is trained, it can--almost effortlessly--be inferred multiple times (inference requires only some arithmetic operations). \begin{table}
\begin{tabular}{c c c} \hline \hline
**Metric** & **Federated Learning (FL)** & **Centralized Learning and Inference (CLI)** \\ \hline \(A_{norm}\) (\(a.u.\), 0–1) & 0.89 & 1 \\ \hline GoF (\(a.u.\), 0–1) & 0.85 & 0.94 \\ \hline MAE (kW ) & 13.3 & 11.9 \\ \hline MSE (kW\({}^{2}\)) & 171.6 & 132.2 \\ \hline MAPE (\%) & 12.7 & 8.8 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Comparison between FL and CLI performance. Figure 7: MEP validation curves for the actual, CLI-predicted, and FL-predicted values. Apart from this, Table 3 tabulates the theoretical time complexity of the compared methods considering worst-case scenarios. To this end, time complexity was quantified as the overall and worst-case numbers of iterations performed by each algorithm, as a function of the input size \(n\) and other learning hyper-parameters using the _big O notation_ as \(\mathcal{O}(f(n))\). We used the following notations for defining the time complexity of both the training and inference phases: \(n\) is the number of the input data rows available for each local model for training, \(n^{\prime}\) is the number of the input data rows per local model for inference, \(F\) is the number of input features, \(N_{H}\) is the number of hidden neural units of single-agent models, \(N_{H}^{\prime}\) is the number of hidden neural units of the centralized model, \(N_{O}\) is the number of the output neural units, \(E\) is the number of local training epochs of the single-agent model, \(E^{\prime}\) is the number of local training epochs of the centralized model, \(N\) is the number of the local ship agents, \(R\) is the number of the aggregation rounds performed at the central location (e.g., cloud), \(\psi\) is the total number of weights averaged at each aggregation round, \(f_{GD}(\cdot)\) is the cost for performing a single GD step (including feedforward and back-propagation steps), and \(f_{FF}(\cdot)\) is the cost for performing a single feedforward step. The CLI training uses all the training samples from all ships, and thus it has \(N\cdot n\) training rows in total. Considering \(E^{\prime}\) number of epochs for training the CLI model, the time complexity is \(\mathcal{O}(E^{\prime}\cdot f_{GD}(N\cdot n,F,N_{H}^{\prime}))\). The FL algorithm operates according to the following sequence: At each global round, data held on each local agent are either passed row-by-row (Gradient Descent--GD) or split into several batches (Stochastic Gradient Descent--SGD) according to a predefined batch size; each row/batch is passed as a whole to train the local model and an epoch is completed once every row/batch is used for learning. Finally, after multiple epochs, each agent sends the adjusted weights to the server, which then computes the average weights across all agents and distributes it back to them. Thus, assuming the worst case of row-by-row gradient calculation (i.e., the GD case), the data rows are accessed \(n\) times per epoch, whereas \(E\) epochs are performed for each of the \(R\) global aggregation rounds. The cost function \(f_{GD}(n,F,N_{H})\) is encountered at every epoch, and it includes the cost for the feedforward passing and back-propagation passing of all \(n\) samples.