# Federated Learning for Maritime Environments: Use Cases, Experimental Results, and Open Issues
## 4 FL-Aided Fuel Consumption Prediction
### Runtime and Time Complexity Considerations
Assuming sequential local training rounds for the \(N\) ship models (i.e., each local model is trained one after the other), this results in a time complexity of \(\mathcal{O}(R\cdot N\cdot E\cdot f_{GD}(n,F,N_{H}))\), whereas the average extraction across the local models has a complexity of \(\mathcal{O}(\psi)\) and is performed \(R\) times. Thus, the final complexity of the FL scheme is \(\mathcal{O}(R\cdot N\cdot E\cdot f_{GD}(n,F,N_{H})+R\cdot\psi)\) (assuming sequential training across ships) or \(\mathcal{O}(R\cdot E\cdot f_{GD}(n,F,N_{H})+R\cdot\psi)\) (assuming parallel training across ships). In a similar concept, to train a single-ship model, as only required by the LLMS scheme, the complexity is \(\mathcal{O}(E\cdot f_{GD}(n,F,N_{H}))\). This is basically the time complexity met in the FL scheme as a sub-term to train each agent in each global round, thus making the LLMS training the best \begin{table}
\begin{tabular}{c c c} \hline \hline \multirow{2}{*}{**Scheme**} & **Runtime for Training** & **Runtime for Inference** \\  & **(h:min:s)** & **(s)** \\ \hline CLI & 00:38:43 & 3.58 \\ \hline LLMS & 00:05:19 & 0.61 \\ \hline LLCI & 00:05:21 & 3.34 \\ \hline FL & 00:43:44 & 0.62 \\ \hline \multirow{2}{*}{**Scheme**} & **Time Complexity** & **Time Complexity** \\  & **for Training** & **for Inference** \\ \hline CLI & \(\mathcal{O}(E^{\prime}\cdot f_{GD}(N\cdot n,F,N_{H}^{\prime}))\) & \(\mathcal{O}(N\cdot n^{\prime}\cdot f_{FF}(F,N_{H}^{\prime}))\) \\ \hline LLMS & \(\mathcal{O}(E\cdot f_{GD}(n,F,N_{H}))\) & \(\mathcal{O}(n^{\prime}\cdot f_{FF}(F,N_{H}))\) \\ \hline LLCI & \(\mathcal{O}(E\cdot f_{GD}(n,F,N_{H}))\) & \(\mathcal{O}(N\cdot n^{\prime}\cdot f_{FF}(F,N_{H})\) \\  & \(+N\cdot N_{O})\) \\ \hline FL & \(\begin{array}{c}\mathcal{O}(R\cdot E\cdot f_{GD}(n,F,N_{H})\\ +R\cdot\psi)\end{array}\) & \(\mathcal{O}(n^{\prime}\cdot f_{FF}(F,N_{H}))\) \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Runtime and time complexity per scheme. scheme in terms of time complexity. Finally, the time complexity for training the LLCI scheme is \(N\) times the complexity of LLMS training, i.e., \(\mathcal{O}(N\cdot E\cdot f_{GD}(n,F,N_{H}))\), given that \(N\) single-ship models are required to be trained. If the ships are trained in parallel, the time complexity is \(\mathcal{O}(E\cdot f_{GD}(n,F,N_{H}))\). Regarding the time complexity for inference, given \(n^{\prime}\) input instances, the complexity is derived by computing the product between the input size and the cost for the feed-forward step (plus the cost for averaging the output predictions only in LLCI). Based on the previous analysis, some possible ways to reduce the time complexity can be identified: (i) minimization of the number of communications as the gold standard for reducing the complexity in FL; (ii) instead of standard gradient descent, the use of Stochastic Gradient Descent can reduce the time complexity, as the data rows are accessed in batch groups (and not row-by-row), while ensuring performance convergence; (iii) gradient computation can be parallelizable within each ship agent. Note also that it would be beneficial for each untrained model to start training using the pretrained weights of another model, rather than randomly initializing its weights. The latter solution basically corresponds to transfer learning and can significantly reduce the time complexity in multi-agent and multi-round FL.