# Research of Flexible Assembly of Miniature Circuit Breakers Based on Robot Trajectory Optimization
## 3 Robot Kinematic Modeling
### Improved PSO Algorithm  
This paper seeks the optimal trajectory by an improved particle swarm optimization (PSO) algorithm with the objective function of time. Suppose that in a \(D\)-dimensional search space, a population \(X=(X_{1},X_{2},\cdots,X_{n})\) composed of \(n\) particles, where the \(i\)-th particle is represented as a \(D\)-dimensional vector \(X_{i}=(x_{i1},x_{i2},\cdots,x_{in})^{T}\), which represents the position of the \(i\)-th particle, i.e., a potential solution. The fitness corresponding to each particle position \(X_{i}\) can be calculated by the objective function. The velocity of the \(i\)-th particle is \(V_{i}=(V_{1i},V_{i2},\cdots,V_{iD})^{T}\), the individual extreme value is \(P_{i}=(P_{i1},P_{i2},\cdots,P_{iD})^{T}\), and the population extreme value of the population is \(P_{g}=(P_{g1},P_{g2},\cdots,P_{gD})^{T}\). In each iteration, the particle updates its speed and position by extreme values of the individual and the group, as shown below:  
\[V_{it}^{k+1}=\omega V_{it}^{k}+c_{1}r_{1}(P_{id}^{k}-X_{id}^{k})+c_{2}r_{2}(P_ {gd}^{k}-X_{id}^{k}) \tag{9}\]  
\[X_{it}^{k+1}=X_{id}^{k}+V_{id}^{k+1} \tag{10}\]  
where \(\omega\) is the inertia weight, \(d=1,2,\cdots,D\), \(i=1,2,\cdots,n\), and \(k\) are the current iteration times; \(V_{id}\) is the particle velocity; \(c_{1}\) and \(c_{2}\) are acceleration factors (non-negative constants); \(r_{1}\) and \(r_{2}\) are random numbers (distributed within \([0,1]\)). To prevent the blind search of particles, the position \(X_{id}^{k}\) is within \([-X_{\max},\)\(X_{\max}]\), and the speed \(V_{id}^{k}\) is within \([-0.1\cdot X_{\max},\)\(0.1\cdot X_{\max}]\). The key of PSO with the quintic polynomial interpolation is to obtain the optimal time \(x_{id}^{k}\) by selecting the independent variables for particle optimization. This paper performs optimization in the search space of time \(t_{1}\), \(t_{2}\), and \(t_{3}\) by reducing the number of search dimensions of the particle swarm to three to avoid complex mapping relations in the derivation. Meanwhile, multi-optimization is with the fitness switch function are applied to improve the converge speed. Time-optimal optimization iteration is performed after the kinematic constraints are met. The fitness function is described as follows:  
\[f(t)=min(t_{1}+t_{2}+t_{3}) \tag{11}\]  
\[ \begin{array}{l}s.t.\max\{\big{|}V_{j1}\big{|}\big{\}}\leq V_{\max}\\ \max\{\big{|}V_{\prime 2}\big{|}\big{\}}\leq V_{\max}\\ \max\{\big{|}V_{\prime 3}\big{|}\big{\}}\leq V_{\max}\end{array}  \tag{12}\]  
where \(V_{j1}\), \(V_{j2}\), \(V_{j3}\), and \(V_{\max}\) are the real-time speed and maximum speed limits of the \(i\)-th joint, respectively. This paper introduces multi-optimization mechanisms into the PSO algorithm. In the multi-optimization process, a conditional judgment optimization mechanism based on the fitness switch function is proposed, and the corresponding fitness switch function is established according to the result of the particle fitness. Therefore, the result is judged, compared and optimized according to the fitness switch function. The improved PSO process in this article is shown in Figure 9.  
Compared with the standard particle swarm optimization process, this paper introduces two optimization processes in the standard PSO algorithm to form a multi-optimization mechanism. A conditional decision mechanism based on a fitness switch function in the multi-optimization process, As shown in Figure 9. On one hand, after  
Figure 9: Improve PSO process. initializing the particle swarm and determining the basic parameters, the interpolation period of the initialized particles is selected according to the constraints to prevent the initial randomness which reduce the optimization efficiency. Therefore, the rationality of each initial particle can be guaranteed; on the other hand, after the particle fitness, the current individual extreme value and the group extreme value are determined, a fitness switch function that quickly finds the optimal is used to select the particles.