# Parallel Hybrid Particle Swarm Algorithm for Workshop Scheduling Based on Spark
## 3 Parallelized Hybrid Particle Swarm Algorithm Based on Spark
### Parallel Hybrid Particle Swarm Algorithm
In the case of local[N] mode, the optimal plans for the assembly scheduling of parts, components and products are obtained, respectively, {E1, G1, F1, D1, G2, D2, F2, B1, F3, C1, F4, A1, H1, A2, E2, C2, B2, A3, D3, H2, H3, G3, B3, D4, H4, B4, C3, E3}; {X1, X2, Y1, Y2, Y3, Y4, X3}; {Q3, Q1, Q1, Q3, Q2, Q4, Q4}; the total completion time is 15,508 s. Using the immune genetic algorithm IA [15], the total completion time is 15,679 s. Using the PSO algorithm, the total completion time is 15,660 s. Figure 3 shows the evolution curve of this algorithm. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Process** & **Q1** & **Q2** & **Q3** & **Q4** \\ \hline



\hline \hline \end{tabular}
\end{table} 
Table 4: Product final assembly process and time. In this paper, the parallel hybrid particle swarm optimization (PHPSO), IA and PSO algorithms are set to the same number of iterations of 50. \(\mathrm{C_{best}}\) is the optimal value of the operation, \(\mathrm{A_{ver}}\) is the average value of the operation and the relative deviation of the value dev [28]. Among them, dev1 is the comparison between PHPSO and IA and dev2 is the comparison between PHPSO and PSO. If dev is positive, the solution obtained by the compared algorithm is better. If dev is negative, the solution obtained by PHPSO is better. Table 5 shows algorithm comparison. It can be seen from Table 5, that PHPSO finds the optimal value within 50 iterations of running time and the IA and PSO algorithms cannot find the optimal solution, indicating that the PHPSO algorithm has a good ability to find the optimal solution. The average value obtained by PHPSO in 50 iterations is smaller, indicating that the algorithm has a strong global search ability, avoiding the limitation of the algorithm that is easy to fall into the local optimum and the algorithm has strong convergence. The parallel hybrid particle swarm optimization algorithm is compared with immune genetic algorithm IA and PSO. A stand for IA or PSO algorithms. The comparison results of the largest completion time of parts-, components- and product-assembly workshops are shown in Table 6. The deviation obtained by the hybrid particle swarm algorithm solution and the IA solution is

\[Dev=[(A-C_{PHPSO})/C_{PHPSO}]\times 100\% \tag{7}\] \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multicolumn{2}{c}{**PHPSO**} & \multicolumn{3}{c}{**IA**} & \multicolumn{3}{c}{**PSO**} \\ \hline \(\mathrm{C_{best}}(/s)\) & \(\mathrm{A_{ver}}(/s)\) & \(\mathrm{C_{best}}(/s)\) & \(\mathrm{A_{ver}}(/s)\) & \(\mathrm{C_{best}}(/s)\) & \(\mathrm{A_{ver}}(/s)\) & \(\mathrm{dev_{1}}(\%)\) & \(\mathrm{dev_{2}}(\%)\) \\
15,508 & 15,526.92 & 15,688 & 15,734.38 & 15,660 & 15,682.4 & \(-1.16\) & \(-0.98\) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Algorithm comparison. Figure 3: Algorithm evolution curve. From Table 6, we can see that the PHPSO algorithm used in this article has a better solution than the GA algorithm and the PSO algorithm in the parts workshop and product-assembly workshop. Through the analysis of the results, the parallelized hybrid particle swarm optimization algorithm can achieve overall optimization. ### Computing Performance

To test the parallelization performance of the hybrid particle swarm algorithm, set the population to 20 and the number of iterations to 40. Compare the running time of algorithm serialization and algorithm parallelization. The tested data are as follows: when the number of products is 7, the ratio of products is [2:1:2:2]; when the number of products is 10, the ratio of products is [2:3:2:3]; when the number of products is 14, the ratio of products is [3:4:5:2]. Compared with the running time of algorithm parallelization and algorithm serialization, the computing speed is greatly improved by 2-4 times. As the number of products input increases, the speed increases more obviously, reflecting the advantage of the Spark platform in processing a large amount of data. The running time of the algorithm is shown in Figure 4 below.