## 6 Discussion
### Optimization Analysis
Due to the complexity of the optimization problem, the global minimum is achieved eventually in iteration number 992. When the number of iterations is set to 20,000 at a power of \(p\) = 0.47 MW, the global minimum is finally achieved in iteration number 13,119. However, the reduction in required peak power when the number of iterations is set to 20,000 versus 1000 iterations is 0.00074%. Figure 11 shows the relationship between peak power reduction and the number of iterations when the ship's daily energy needs are 1.82 MW. It has to be pointed out that the stated power represents realistic daily energy needs. In this case, the greedy algorithm preferentially favors the ship with the highest energy needs while disconnecting all others from the shore connection. As the difference in the charging power ratio is expressed, the minimum was achieved in the first iteration, while the achieved reduction is 24%. Figure 10: Convergence history when the energy needs of “Ferry 6” is equal to 0.48 MW. Figure 9: Convergence history when the energy requirements of “Ferry 6” are equal to 0 MW. The output of this optimization problem is a reduction in the peak power required to charge a certain number of ships. The effect of the optimization depends on the number of ships, their energy needs, and mostly the sailing schedule. Figure 8 shows the required number of iterations to achieve the minimum of the function while adhering to all constraints. Additionally, the efficiency of the optimization is analyzed, as shown in Figure 12. A correlation can be detected in relation to the required number of iterations. When the optimization results are predictable, i.e., less demanding, a significant reduction in peak power is achieved in a short time with a small number of iterations. On the other hand, when the values of the energy requirements are equalized with a large number of iterations, a relatively small reduction in the required power is achieved. For example, when the daily energy needs of \"Ferry 6\" are 0.48 MW, 992 iterations are needed to achieve a total peak power reduction of 0.76%. When the daily energy needs of \"Ferry 6\" are between 0.4 MW and 0.6 MW, a large number of iterations are required to achieve a small reduction in the charging power of the group of ships. The reason for this is that several different consumers with similar energy needs are connected to the charger at the same time. On the contrary, when the daily energy needs of \"Ferry 6\" are 1.82 MW, one iteration is required to reduce the peak power by 24%. In the case of the transition of ferries to electric propulsion, it is necessary to provide a shore connection that meets the energy needs at the most unfavorable moment when the  
Figure 11: Convergence history when the energy needs of “Ferry 6” is equal to 1.82 MW. Figure 12: Dependency of power reduction in relation to the daily energy needs of “Ferry 6”. demand is at the highest. A model was created using the PSO and a greedy algorithm to reduce the required peak power. The model can be adjusted so that the objective function is the charging price, which depends on the price of electricity at a certain period of the day. Furthermore, this model can be used as a tool for the optimization of various transport, energy, and production processes. Also, technical aspects and limitations are not considered when optimizing the peak load following the repetitive navigation profile of the ships. Namely, for charging the entire fleet of ships to be feasible, all docks should have sufficient power connections. However, this research assumes that the mentioned requirement is fulfilled. PSO was used in work [40] to reduce the peak loads of the shore network in the case of charging shipboard ESSs. The optimization was achieved by using shore-based battery ESS. Further, the model created in the MATLAB/Simulink software (R2023b Update 5) package shows that the application of land-based ESS is more profitable than investments in the infrastructure of the shore power grid.