# A Scheduling Algorithm for Multi-Workshop Production Based on BOM and Process Route
## 5 Implementation of Scheduling Algorithm for Multi-Workshop Production  
The complex constraints between products and processes need to be considered in the optimization of complex product scheduling, which requires the parallel ability of the algorithm. When the product structure is deep and there are many kinds of products, the process network is more complex, and the parallelism requirement for the solution algorithm is higher. Particle swarm optimization (PSO) is a kind of optimization method based on iteration, which makes individuals accumulate experience continuously through group cooperation, so as to realize the search for the optimal value. Compared with GA and ACO algorithms, the PSO algorithm does not depend on specific problems and has a fast convergence speed. The ACO algorithm has a slow convergence speed, and the search process can easily stagnate due to the consistency of individual solutions. The scheduling of complex products needs to deal with a huge process network diagram, and the algorithm needs to have high search efficiency, so it is not considered to use the ACO algorithm. The GA algorithm, like the PSO algorithm, belongs to the family of bionic algorithms and has parallel search characteristics. PSO particles can preserve the historical experience characteristics and have a certain memory ability, while the experience of the GA algorithm will be destroyed with a change in population. In addition, due to the complex constraints of the process network model, it is difficult to use GA to construct the appropriate coding and operator, which will also affect the efficiency of the algorithm. The PSO algorithm does not have this problem. Therefore, after comprehensive consideration, we select the PSO algorithm to solve the complex product scheduling problem. Since complex product scheduling is a complex optimization problem with multiple constraints and extrema, the standard particle swarm algorithm is prone to premature and low solution accuracy. In this paper, an improved particle swarm algorithm is proposed, which changes the direction and speed of the particles through recombination, improves the diversity of the population, and prevents the algorithm from prematurely converging. In addition, by setting the dynamic inertia weight, the global search ability of the algorithm is improved. In the standard particle swarm algorithm, the initial particle swarm is generated randomly, and the optimal solution is obtained through continuous iteration. After each iteration, the individual extremum and global extremum are updated by the fitness value, and the velocity and position are updated according to the equation. As shown in Equations (19) and (20):  
\[V_{i,j}^{t+1}=\omega V_{i,j}^{t}+c_{1}r_{1}(P_{i,j}-X_{i,j}^{t})+c_{2}r_{2}(g_ {j}-X_{i,j}^{t}) \tag{19}\]  
\[X_{i,j}^{t+1}=V_{i,j}^{t+1}+X_{i,j}^{t} \tag{20}\]  
\(X_{i,j}^{t}\) and \(V_{i,j}^{t}\) represent the position and velocity of the \(i\)-th (\(i=1,\,2,\,3,\,\ldots,\,\,\)n) particle in the \(j\) dimension (\(j=1,\,2,\,3,\,\ldots,\,\,\)m) after the \(t\)-th (\(t=1,\,2,\,3,\,\ldots,\,\,\)T) iteration; \(P\) represents the optimal value of the \(i\)-th particle in the \(j\)-th dimension; \(\omega\) represents the inertia weight, which decreases linearly with the increase in iteration time, and the convergence effect is better when \(\omega\) is between 0.8 and 1.2; \(g\) is the global optimal value; \(c1\) and \(c2\) represent learning factors; \(r1\) and \(r2\) represent random numbers that obey random distribution in the interval \((0,\,1)\).