# Application of Machine Learning for Bulbous Bow Optimization Design and Ship Resistance Prediction
## 2 Materials and Methods
### Improved Whale Algorithm for Predicting Optimal Resistance  
Metaheuristic optimization algorithms perform excellently when dealing with complex nonlinear problems. For the mapping relationship between the spherical bow dimensions and ship resistance constructed by the CBR model, they can obtain the minimum ship resistance and the corresponding spherical bow dimensions. The whale optimization algorithm (WOA) [27], inspired by the hunting behavior of humpback whales, continuously updates the positions of individual whales to identify an optimal solution. This algorithm is distinguished by its minimal number of parameters, ease of implementation, and adaptability. The search process was categorized into three stages:  
(1) Enveloping the prey. Assuming that the position of the best whale individual in space is \(X^{*}\) and that the other individuals move toward it to encircle the prey, the change in the individual's position \(X\) at the next moment can be expressed as follows:  
\[X(t+1)=X^{*}(t)-AD \tag{12}\]  
\[D=\left|\right.CX^{*}(t)-X(t)\left|\right. \tag{13}\]  
\[A=2 ar_{1}-a \tag{14}\]  
\[C=2r_{2} \tag{15}\]  
where \(D\) is the distance between the individual and the prey, \(t\) is the current number of iterations, \(A\) and \(C\) are computational coefficients, \(r_{1}\) and \(r_{2}\) are random numbers between 0 and 1, and the value of \(a\) is determined by the number of iterations, decreasing from 2 to 0 linearly. (2) Bubble net attack. Bubble netting, a predatory behavior unique to whales, involves expelling bubbles to deter prey through spiral swimming. It can be represented by the following two mathematical models: contraction encirclement and spiral position update. In contraction encirclement, the process is analogous to the surrounding prey in the model, with the range of parameter A modified from \((-a,a)\) to \((-1,1)\). In the bubble net assault, the whale selects the contraction encirclement and spiral position update with a chance of 50%, represented as follows:  
\[X(t+1)= \begin{cases}X^{*}(t)-AD,p<0.5\\ X^{*}(t)+D\varepsilon^{bl}\cos(2\pi l),p\geq 0.5\end{cases}  \tag{16}\]  
where \(p\) is a random number between 0 and 1, \(b\) is a logarithmic spiral shape constant, and \(l\) is a random number between \(-1\) and \(1\). (3) Search predation. To ensure the sufficiency of the search and avoid becoming trapped in local optima, the WOA updates the positions based on the relative positions of the whale individuals. Its mathematical model is as follows:  
\[D=\left|\,\mathrm{C}X_{rand}(\,t\,)-X(\,t\,)\right| \tag{17}\]  
\[X(t+1)=X_{rand}(\,t\,)-AD \tag{18}\]  
where \(X_{rand}(\,t\,)\) denotes a randomly selected whale location when \(A\geq 1\). From the above principle, it can be seen that the whale algorithm calculates the coefficient \(A\leq 1\) when the linear parameter \(a\) decreases to 1. At this time, the algorithm no longer carries out a stochastic search, which leads to the inability to find the global optimal solution. Therefore, parameter \(a\) is improved to a nonlinear convergence factor \(\epsilon\), which enables the algorithm to adaptively adjust the convergence speed according to the current iteration state. This is conducive to the balance between global exploration and local exploitation, and its updated formula is as follows:  
\[\epsilon=2\sin(\frac{\pi}{2}+\frac{\pi t}{2T_{max}}) \tag{19}\]  
where \(T_{max}\) is the maximum number of iterations. The steps of the improved WOA algorithm are listed in Algorithm 1.