# B-Spline Curve Fitting of Hungry Predation Optimization on Ship Line Design
## 4 Key Parameter Settings  
There are four key parameters of the HPA:  
(1) Population size \(W\), which determines how many individuals find the optimal solution in the population size at the same time. (2) Internal knot rate \(\lambda\): The range of \(\lambda\) depends on the number of given data points, usually select interval [0, 0.5], which can be reduced with the increase of data points. The \(\lambda\) is different for each individual. (3) Error threshold \(E\), which ensures that the error value of the final fitted curve is less than \(E\). (4) Iteration number \(Max\_iter\), which determines the number of iterations of the whole optimization process, iterates to the \(Max\_iter\) time and outputs the current optimal solution. In previous studies [17; 18; 19; 20; 21; 22], the population size and iteration number have been based on different fitting models and fitting error thresholds, relying on intuitive experience or multiple attempts to give appropriate values, which is troublesome and time consuming. This section takes two continuous semicircle models with radius 1 as an example, as shown in Figure 6. We further explore the impact of population size, iteration number and error threshold on curve fitting effect, and give the setting formula of population size and iteration number. Figure 6: Two continuous semicircles. Radius: 1. The population size determines the number of parallel solution paths. When the iteration number _Max_iter_ is 20 and the error threshold \(E\) is 0.1, the population size \(W\) is set to 10, 20 and 50, respectively; the fitting result is recorded as shown in Figure 7.  
The inner knots of Figure 7a are 0.4328 and 0.5771, and the fitting accuracy is 0.0186. The inner knots of Figure 7b are 0.4612 and 0.5376, and the fitting accuracy is 0.0207. The inner knots of Figure 7c are 0.4076 and 0.5924, and the fitting accuracy is 0.0169. It can be seen from Figure 7 that the fitting result with \(W=20\) is worse than \(W=10\) in this experiment. The setting of the iteration number affects the step size of each iteration. The more the iteration number, the more carefully the algorithm searches. However, when the iteration number is large enough, increasing the iteration number will have little effect on the curve fitting accuracy. Besides, a large iteration number will improve the operation time of the algorithm. When the error threshold \(E\) is 0.1, multiple experiments are carried out by changing the population size \(W\) and iteration number _Max_iter_. The results are shown in Figure 8.  
As shown in Figure 8a, _Max_iter_ is 20. When \(W\) is 10 and 20, the result fluctuates greatly, and the fluctuation is relatively small when \(W\) is 30. In Figure 8b, \(W\) is 20, and the fluctuation is small after 30 iterations. The setting of the error threshold determines the fitting accuracy of the B-spline curve. The HPA algorithm can better implement the B-spline curve with the least number of control points when the error threshold is satisfied. Set \(W\) to 30, _Max_iter_ to 20 and set \(E\) to 0.1, 0.01 and 0.001, respectively; the fitting results are shown in Figure 9.  
Figure 8: Fluctuation of curve fitting accuracy when (**a**) _Max_iter_ is 20 and \(W\) varies from 10 to 100, and when (**b**) \(W\) is 20 and _Max_iter_ varies from 10 to 50. Figure 7: Influence of population size \(W\) on curve fitting, (**a**) \(W=10\), (**b**) \(W=20\) and (**c**) \(W=50\). The least-squares fitting accuracies of Figure 9a-c are 0.0207, 0.0016, and 0.0004, respectively. It can be seen from the results that as \(E\) decreases, the final curve fitting result is getting better, and more control points are required. Adjust \(E\) from 1 to 0.0001, and the change of inner knot number required for the fitted curve, which is shown in Figure 10.  
The optimization algorithm in the field of B-spline curve fitting is to solve the extremum problem, and the solution is a number of interrelated decimals arranged in ascending order from 0 to 1.