# Research on a PSO-H-SVM-Based Intrusion Detection Method for Industrial Robotic Arms
## 3 Intrusion Detection Method and Response Mechanism
### Particle Swarm Optimization Algorithm  
Particle swarm optimization (PSO) is an iteration-based algorithm in which particles have only two attributes, velocicit and position. Each particle gradually moves towards the position of the optimal solution during each iteration until all particles have completed the iteration and the optimal solution is found [40]. Assuming that the space of solutions is an n-dimensional space, then each particle is considered as a candidate solution to this n-dimensional search space, and each particle has memory. During each iteration, the particle updates the optimal position based on the calculated fitness value, and also updates the global optimal position based on the optimal positions of all particles in the particle swarm [41]. Assuming that there are m particles forming a particle swarm in an n-dimensional target search space, the iterative formulation of the algorithm is as follows:  
\[\mathrm{V_{i}^{g+1}}=\omega\cdot\mathrm{V_{i}^{g}+C_{1}\cdot rand_{1}\cdot \left(\mathrm{pbest_{i}^{g}-X_{i}^{g}}\right)+C_{2}\cdot rand_{2}\cdot\left( \mathrm{gbest^{g}-X_{i}^{g}}\right)} \tag{1}\]  
\[\mathrm{X_{i}^{g+1}}=X_{i}^{g}+V_{i}^{g+1} \tag{2}\]  
where, \(\mathrm{V_{i}^{g}}=(\mathrm{v_{i1}},\mathrm{v_{i2}},\cdots,\mathrm{v_{in}}),i= 1,2,\cdots,\mathrm{m}\) is the velocity of the ith particle in the gth generation of the particle swarm; \(\mathrm{X_{i}^{g}}=(\mathrm{x_{i1}},\mathrm{x_{i2}},\cdots,\mathrm{x_{in}}),i= 1,2,\cdots,\mathrm{m}\) is the position of the ith particle in the gth generation of the particle swarm; \(\omega\) is a non-negative number and is the inertia weight; \(C_{1}\) and \(C_{2}\) are learning factors, also known as acceleration constants, representing the importance of the particle optimum and the global optimum; \(\mathrm{rand_{1}}\) and \(\mathrm{rand_{2}}\) are random numbers between 0 and 1; \(\mathrm{pbest_{i}^{g}}\) is the historical optimum solution of the ith particle in the gth generation of the particle swarm; and \(\mathrm{gbest^{g}}\) is the global optimum solution in the gth generation of the particle swarm.  
The parameter \(\omega\) in the algorithm mentioned above is the inertia weight, and the size of this parameter affects the local and global search capability of the algorithm. When the inertia weight is set relatively large, the algorithm has good global search capabilities and does not easily fall into the local optimum solution, but it is likely to miss the optimal point, resulting in oscillation around the optimal value; when the inertia weight is set relatively small, the algorithm has good local search capabilities, which can improve the accuracy of the solution, but it easily falls into local optimum. [PERSON] et al. [42] proposed the linear decreasing inertia weight (LDIW) method, and applied it in experiments to achieve better results. The formula of the LDIW method is as follows:  
\[\omega^{g}=\ \omega_{\mathrm{max}}-\frac{\mathrm{g}-(\omega_{\mathrm{max}}- \omega_{\mathrm{min}})}{\mathrm{g}_{\mathrm{max}}} \tag{3}\]  
where, \(\omega^{g}\) is the value of the inertia weight when the algorithm is updated to the gth generation; \(\omega_{\mathrm{max}}\), \(\omega_{\mathrm{min}}\) are the maximum and minimum values of the inertia weight, respectively; \(g\) is the current iteration step number; and \(\mathrm{g}_{\mathrm{max}}\) is the maximum iteration step number.  
In the optimization process of the algorithm, the particle swarm is first initialized; then the fitness values of all particles are calculated according to the fitness function and compared, and the individual optimal solution and the global optimal solution are updated if they are better; secondly, the current inertia weight \(\omega\) is updated according to the LDIW method, and the velocity and position of the particles are updated using the current inertia weight value. Finally, the iteration ends when the end condition is satisfied and the optimal solution is solved.