1. Introduction
Robots are widely used in welding production. Although this has improved productivity, there are some common problems, one of which is the poor path planning of spot welding robots on welding workstations [Reference Zhuang, Du and Wu1]. In practice, the path planning for spot welding robots is developed by the relevant process personnel based on their own experience, and the robot is given task instructions using online teaching which is tedious. Therefore, it is important to use algorithms to plan a reasonable welding path. The mainstream path planning algorithms include artificial potential field method, ant colony algorithm, RRT algorithm, and particle swarm algorithm [Reference Zhu and Yang2, Reference Liang and Mao3, Reference Lavalle4, Reference Zhu, Chen and Xu5]. Path planning for robot motion has been studied both at home and abroad. Christian Wurll presents results from the Karlsruhe University on path planning for a six-degree-of-freedom robot, which discretely stratifies Cartesian space to calculate distances and uses the A* search algorithm to achieve finding the shortest distance between multiple weld points, but the setting of its valuation function can seriously affect the quality and efficiency of the solution [Reference Wurll and Henrich6]. Pei Chengsong proposed an improved cuckoo search algorithm based on compact and parallel techniques. This algorithm can better deal with the problem of 3D path planning, but there are still problems such as insufficient accuracy and long paths [Reference Pei, Jeng and Shu7]. Liu Lisang proposed a new fusion algorithm of jump-A* algorithm and dynamic window approach to meet the performance requirements of global optimization and path smoothness, but the algorithm takes more time [Reference Liu and Yao8]. Ma Haonan used improved artificial potential field method to overcome the shortcoming of local minima and realized the path planning of the dual-manipulator system, but the algorithm cannot overcome the issue of unreachable target points [Reference Ma, Zhang and Li9]. Zhang Zhen used the RRT algorithm based on constraint sampling to plan the path of the robot arm, which improved the search efficiency and smoothed the trajectory, but the algorithm cannot obtain the shortest path [Reference Zhang, Li and Dong10]. XW Wang analyzed and compared the characteristics of the genetic algorithm and the particle swarm algorithm, and the simulation results showed that both algorithms could be used to solve small-scale path planning in welding tasks. Finally, A combination of the genetic algorithm and the particle swarm algorithm was proposed, which had the effect of avoiding the algorithm from falling into a local optimum [Reference Xue, Yang and Rui11]. Wang Jiahai analyzed the actual welding process and compared the convergence speed and optimization accuracy of simulated annealing, the ant colony algorithm (ACS), and the genetic algorithm and proved that the ACS is more effective than the others [Reference Wang12]. Lin Juguang used the traditional ant colony algorithm to plan the welding path of the body-in-white base plate, and the simulation results in DELMIA showed that the optimized path was more efficient than the traditional path, but in-depth study of the ant colony algorithm was not carried out [Reference Ling and Chen13]. It is found that combining other algorithms with the ant colony algorithm or introducing adaptive strategies can improve the adaptability and effectiveness of the ant colony algorithm [Reference Chen and Liu14, Reference Zhang and Chen15, Reference Xu, Luo and T.16, Reference Jia and Li17].
The ant colony algorithm shows strong superiority over other algorithms in terms of its global search capability and good robustness, but the performance of its algorithm is influenced by initial parameters [Reference Yang18, Reference Blum19]. In this paper, particle swarm algorithm is proposed to train the initial parameters of the ant colony algorithm to obtain the optimal initial parameters for improving the solution quality and efficiency, and the influence of the initial parameters of the ant colony algorithm on the algorithm itself is analyzed. Finally, MATLAB is used to conduct simulation to verify the feasibility and superiority of the improved algorithm.
2. Implementation of the ant colony algorithm
The ants secrete pheromone as they walk which acts as a message transmitter, and other ants can sense the strength of the pheromone as they pass by and use it to guide themselves [Reference Kazharov and Kureichik20].
2.1. Rules for the movement of ants between solder joints
The corresponding mathematical model is developed for the spot welding path planning problem based on the ant colony algorithm. Let the number of ants in the whole ant population be $m$ and the number of solder joints is $n$ . The distance between solder joint $i$ and solder joint $j$ is $d_{ij}\!\left(i,j=1,2,\ldots,n\right)$ , and the pheromone concentration of the path between solder joint $i$ and solder joint $j$ is $\tau _{ij}\!\left(t\right)$ . The ants are placed at different solder joints at the initial moment, and the pheromone concentration on all connected paths between solder joints remains the same $\tau _{ij}\!\left(0\right)=\tau _{0}$ .Then, devising a probability function for the ant’s choice between the different solder joints $p_{ij}^{k}\!\left(t\right)$ denotes the probability of an ant choosing at moment $t$ from solder joint $i$ to solder joint $j$ .
where $\eta _{ij}\!\left(t\right)$ – The degree of expectation that ant from the solder joint i to j the weld point, as a heuristic function
$allow_{k}$ – The set of all solder joints to be processed, k = 1,2…, n
$\alpha$ – Pheromone importance factor
$\beta$ – Significance factor of the heuristic function
$\rho$ – Degree of volatility of pheromones.
2.2. Pheromone updates program design
When the ant has traversed all the solder joints once, the concentration of information connecting the individual solder joints to each other is
where $\Delta \tau _{ij}^{k}$ – The k ant adds pheromones to the solder joint i and solder joint pheromone added to the channel
$\Delta \tau _{ij}$ – All ants in the incremental pheromone release on the channel between the solder joints
$\Delta \tau _{ij}^{k}$ is calculated by the following method.
where $Q$ – The total amount of pheromones released by the ant in one cycle
$L_{k}$ – The total length of the path traveled by the first ant.
2.3. Objective function and implementation steps
In the path planning of the spot welding industrial robot, the order of access to $n$ process points, which is $V=\left\{v_{1},v_{2},v_{3},\ldots v_{n}\right\}$ , is $T=\left\{t_{1},t_{2},t_{3},\ldots t_{n}\right\}$ , where $t_{i}\in V,i=\left(1,2,3,\ldots,n\right)$ , and the corresponding three-dimensional spatial coordinates of $t_{i}$ is $\left(x,y,z\right)$ . The objective function is the distance of the spot welding robot gun movement, whose mathematical expression is
where L is a closed path to access all solder joints.
Figure 1 shows the flow chart of the program structure of the basic ant colony algorithm, and the basic steps of the algorithm are as follows:
-
1. At the beginning of the calculation, the relevant parameters are initialized, the ant colony model (number of ants) $m$ , the pheromone factor $\alpha$ , the importance factor of the heuristic function $\beta$ , the volatility factor of the information system $\eta$ , the total number of pheromone constants $Q$ , the maximum number of iterations $iter\_ max$ , and the initial value of the iterations $iter=1$ .
-
2. Increasing the number of iterations.
-
3. Initializing the taboo table and placing the ant’s current location in the taboo table.
-
4. Number of ants $k=k+1$ .
-
5. Calculation of the transfer probability function $p_{ij}^{k}\left(t\right)$ .
-
6. Modifying the contraindication form.
-
7. Continuing with the fourth iteration step if the current number of ants is less than the total number of ants, otherwise, continuing updating the pheromone.
-
8. The loop ends and the result of the calculation is output when the number of iterations $iter\_ max$ is reached. The forbidden table is reinitialized and the loop continues if it is less than the number of iterations.
3. Improvement of ant colony algorithm based on particle swarm idea
The ACO shows strong robustness and good search capability in dealing with TSP problems but has some limitations. The solution performance of the ACO mainly depends on the pheromone factor $\alpha$ and the heuristic function factor $\beta$ , which are usually determined through extensive experiments or manual experience. To avoid the problem of long solution time or poor solution quality due to improper parameter selection, this paper adopts a strategy of applying particle swarm ideas to optimize the $\alpha$ and $\beta$ parameters of the ant colony algorithm. The particle swarm algorithm can quickly approximate the optimal solution [Reference Min, Ge and Zhang21], which provides a reasonable basis for the selection of parameters. Thus, it improves the solution performance of the ant colony system. Figure 2 shows the flow chart of the improved ant colony algorithm, and the basic steps of the algorithm are shown as above.
3.1. Particle update program
The particle swarm algorithm originates from the foraging behavior of a flock of birds [Reference Tang, Xiang and Pang22], in which each bird is one of the particles in the process of searching for food. In a $D$ dimensional target search space, provided that there are $m$ particles, the coordinate position of the $i$ particle in the search space is $X_{i}=\left(P_{i}^{1},P_{i}^{2},\ldots,P_{i}^{D}\right)$ , each particle is a potential solution of the objective function and will be brought into the requested objective function to obtain the adaptation value of each particle, and the particle’s local optimal position is noted as $P_{i}=\left(P_{i}^{1},P_{i}^{2},\ldots,P_{i}^{D}\right)$ . The velocity of the $i$ particle is $V_{i}=\left(v_{i}^{1},v_{i}^{2},\ldots v_{i}^{D}\right)$ .
The particle is updated continuously at its location using the following equation.
where $i=1,2,\ldots, m;$ $d=1,2,\ldots,D;\; \omega \geq 0$ is the inertia factor. The acceleration constant is $c_{1}\geq 0, c_{2}\geq 0$ . $r_{1}$ and $r_{2}$ are a random number in the range [0, 1]. $\lambda$ is the constraint factor for the purpose of velocity control of the particle. In addition, $v_{i}^{d}\in \left[-v_{\max }^{d},v_{\max }^{d}\right]$ , the maximum velocity of the particle flying $V_{i}$ , is limited by the maximum velocity. The maximum velocity is indicated by $\left(v_{\max }^{1},v_{\max }^{2},\ldots v_{\max }^{D}\right)$ . When the velocity of a particle in one dimension exceeds $v_{\max }^{d}$ , the velocity of that dimension is limited at this point $v_{\max }^{d}$ . The condition of termination of the iteration is that the set maximum number of iterations is reached or the particle population is searched for the optimal solution at the moment to satisfy the minimum permissible error of the objective function.
3.2. Improvement and implementation of ant colony algorithm
3.2.1. Algorithm improvement scheme
First, the certain number of particles are initialized with the coordinates of the particles in two-dimensional space $\left(\alpha,\beta \right)$ . Each position of a particle is a potential target solution for parameter optimization. The corresponding parameters of each particle are fed back to the ant colony algorithm. The individual particle adaptation values are counted according to the objective function to determine the degree of superiority or inferiority of the particles. Then, the positions and velocities of the particles are updated according to Eqs. (5) and (6), and the iteratively updated particles call the ant colony algorithm again to measure the adaptation values of the particles. The above steps are cycled until the number of iterations reaches 20 or when the difference between the optimal solutions of two adjacent generations of particles is less than $\sigma$ , terminating the cycle. The optimal particle position $P_{\mathrm{g}}\!\left(\alpha,\beta \right)$ is the optimal initial parameter in the ant colony algorithm.
3.2.2. Improved algorithm design
-
1. Initial particle swarm parameter design
In this paper, the solution variables are two dimensional. In this two-dimensional target search space, the particle swarm is initialized by setting the initial particle coordinate values to random.
The initial position and velocity of the $i$ particle are
(7) \begin{equation} p\!\left[i\right]\!\left[j\right]=r_{1}\times \left(x_{\max }-x_{\min }\right)+x,j\in \left[0,1\right] \end{equation}(8) \begin{equation} V\!\left[i\right]\!\left[j\right]=r_{2}\times x_{\max },j\in \left[0,1\right] \end{equation}where $r_{1}$ and $r_{2}$ are the random numbers of the variation of the range $\left[0,1\right]$ .Set the values of the basic particle swarm parameters as follows:
\begin{equation*} \left\{\begin{array}{l} \textit{number}=40\\[5pt] \textit{generation}=20\\[5pt] x_{min}=0.5\\[5pt] x_{max}=10.0\\[5pt] v_{min}=0\\[5pt] v_{max}=1.0\\[5pt] \omega =0.8\\[5pt] c_{1}=2\\[5pt] c_{2}=2\\[5pt] \sigma =0.001 \end{array}\right. \end{equation*}where $\textit{number}$ is the size of the particle swarm and taken 20–40 as a general value. The 30 particles are sufficient for most problems, but the 100–200 particles are needed for special puzzles. $\textit{generation}$ is the number of iterations. $c_{1}$ and $c_{2}$ are the acceleration constants, representing the weight of the particles’ own experience and social experience, respectively. $\omega$ is the inertia factor, which defines the particle’s flight range. The larger the flight range, the stronger the global search ability, unfortunately, the weaker the local search ability. $x$ is the random variable and is determined by the direction of the dimensional space in which the particle is placed. The velocity range $\left[v_{\min },v_{\max }\right]$ and position range $\left[x_{\min },x_{\max }\right]$ of each particle place a limit on how far the particle can be transferred and reduce the spatial extent of the particle initialization.Each position of particle represents a set of parameters for the ant colony algorithm.
(9) \begin{equation} \left\{\begin{array}{l} \alpha =p\!\left[i\right]\left[0\right]\\[5pt] \beta =p\!\left[i\right]\!\left[1\right] \end{array}\right. \end{equation} -
2. Design of other initial parameters of the ant colony
For the TSP problem, it is generally accepted that the ant cycle system model is the more reasonable of the three models of the ant colony algorithm (ant quantity system, ant density system, and ant cycle system). The solder joints are given as $n$ , the number of ants is set as $\mathrm{m}=n/2$ in the ant colony algorithm, and the pheromone constant $Q=10$ and the iterations of the ant colony algorithm are set as 30.
-
3. Feedback of initial particle values to the ACS
In the random initialization of particles brought into the ant colony algorithm, the objective function is defined according to the TSP problem-solving objective. The adaptation value of each particle is calculated according to the objective function to determine the merit of the current position of the particle. The adaptation value determines the high quality of the combination of parameters it represents.
-
4. Particle information and optimal solution information update scheme
Update the velocity and position of the particle according to the following equation.
(10) \begin{equation} v\!\left[i\right]\!\left[j\right]=\omega \times V\!\left[i\right]\!\left[j\right]+c_{1}\times r_{3}\times \left(pbest_{i}-p\!\left[i\right]\!\left[j\right]\right)+c_{2}\times r_{4}\times \left(gbest_{i}-p\!\left[i\right]\!\left[j\right]\right) \end{equation}(11) \begin{equation} p\!\left[i\right]\!\left[j\right]=p\!\left[i\right]\!\left[j\right]+v\!\left[i\right]\!\left[j\right] \end{equation}In Eq. (10), $r_{3}$ and $r_{4}$ are random numbers in the range $\left[0,1\right]$ . The first term of the velocity update is the memory term of the particle, indicating that the update direction is influenced by the velocity magnitude and direction of the last location. The second part is the particle’s own experience part, indicating that the particle has been to the point where the adaptation value is optimal. The third part represents the influence brought by the social experience of the particle, reflecting the mutual learning ability between the particles. The superposition of these three components causes the effect of the particles automatically finding the optimal parameters.
The velocity of the particle in two dimensions is updated according to Eq. (5). The updated particle continues to call the ant colony algorithm, which calculates the adaptation value of each particle according to the objective function in the ant colony algorithm to determine the superiority of the particle. Updating the local optimal position and the global optimal position of the particle, and then cycling this process.
-
5. Iteration termination conditions
The algorithm is terminated when the difference between the adaptation values of two consecutive generations of particles does not exceed $\sigma$ or the number of particle swarm update iterations exceeds 20. The final two-dimensional coordinates of the particle with the best adaptation value are the optimal parameters of the ant colony algorithm.
4. MATLAB simulation test and result analysis
In this paper, the algorithm is programmed in MATLAB to verify the effectiveness of optimist the parameters of the ant colony algorithm. First, extensive experiments are conducted to analyze the parameters $\alpha$ and $\beta$ values and combinations on the performance of the algorithm. Then, the proposed new algorithm is used to find the combination of high-quality parameters.
Table I shows the output of the simulation process for the 39 weld joints on the body-in-white side surrounds. X, Y, and Z represent the position information of the weld joints in the table. $Roll,\textit{Pitch},Yaw$ are the Euler angles of the weld joint coordinate system. $Roll$ represents the angle of rotation of the weld joint coordinate system around the Z-axis in the XOY plane. $\textit{Pitch}$ represents the angle of rotation of the YOZ around the X-axis, and $Yaw$ represents the angle of rotation of the XOZ around the Y-axis in the reference coordinate system.
The distribution of solder joints in three dimensions is shown in Fig. 3.
Holding all other parameter constant, $m=75,vol=0.2,Q=10$ as an example, to illustrate $\alpha$ and $\beta$ have a huge impact on the performance of the algorithm. Fixing one of α and β and varying the value of the other, the relationship between parameter variation and optimal path distance can be derived.
As shown in Fig. 4, it is seen that the pheromone importance degree factor $\alpha \lt 1$ in the ant colony algorithm has a huge impact on the convergence and solution quality of the algorithm when the other parameters of the current algorithm are fixed. The comprehensive solution performance of the algorithm is better when $\alpha \in \left[0.5,2.5\right]$ . The influence of the heuristic function importance degree factor $\beta$ is more obvious in the ant colony algorithm on the convergence speed of the algorithm. The comprehensive performance of the algorithm is better when $\beta \in \left[0,2\right]$ . The influence of the pheromone factor and the heuristic function factor on the algorithm was equally evident when the ant colony size $m$ , pheromone volatility factor $vol$ , and constant factor $Q$ were other values.
Table II shows the improved algorithm to find the six sets of $\alpha$ and $\beta$ quality combinations of particles and path lengths.
In order to compare the solution performance of the algorithm before and after optimization, the values of $\alpha$ and $\beta$ and their combinations are set to random, and path planning is performed with random initial parameters. Table III shows the path lengths obtained using the six sets of random initial parameters.
The average path length obtained by the six sets of initial parameters after optimization is 10,357.7509 mm, and the average distance of the six groups of path lengths obtained by the algorithm before optimization is 10,830.8394 mm. The path distance before optimization is reduced by 473.0885 mm compared with that after optimization, which indicates that the solution quality of the algorithm after optimization has been improved.
A set of parameters $\alpha =1.1108,\beta =5.5596$ , which obtained from the particle swarm training, is fed back to the ant colony algorithm, the path order as the planning results of the ant colony algorithm is obtained as follows:
12 32 31 30 19 18 17 16 15 14 13 11 10 9 8 7 6 5 4 3 2 28 37 21 22 23 38 36 29 1 20 33 39 35 34 24 25 26 27 12.
The path is a closed one, as shown in Fig. 5, with the start and end points being the robot’s operating origin, which corresponds to the actual working conditions of the robot. The minimum distance of the path is 10,356.9353 mm.
Figure 6 shows six sets of algorithm convergence curves for the improved ant colony algorithm and pre-modified ant colony algorithm for path planning under different parameter. The blue lines are optimized combination of parameters, and the red lines are random combination of parameters.
The average number of iterations for convergence of the ant colony algorithm for path planning before the improvement is 45, while the average number of iterations for convergence of the improved ant colony algorithm is 17, which is reduced by more than 50%. Importantly, the improved ant colony algorithm can obtain shorter path than traditional ant colony algorithm. The average time of traditional ant colony algorithm for path planning is 5.52 s, but the average time of improved ant colony algorithm for path planning is 4.33 s.
5. Conclusion
-
1. This paper analyzes the principles of ant colony algorithms and particle swarm algorithms, establishes a mathematical model for the spot welding path planning problem, designs a pheromone update scheme, and establishes an objective function.
-
2. Improve the ant colony algorithm by using the particle swarm algorithm to modify the pheromone factor $\alpha$ in the ant colony algorithm and heuristic function factor $\beta$ to avoid the disadvantage of relying on manual experience to select the parameters.
-
3. MATLAB was used to analyze the extent of the pheromone factor $\alpha$ and the heuristic function factor $\beta$ on the path planning algorithm.
-
4. The improved algorithm was used to plan the path for spot welding. The average path length obtained from the improved six sets of initial parameters was 10,357.7509 mm, which was 473.0885 mm less than the path distance planned by the unimproved algorithm. The improved algorithm had a higher quality solution.
-
5. The convergence analysis of the algorithm shows that the average number of iterations was 17 when the improved algorithm converges. The average time of improved ant colony algorithm for path planning was 4.33 s. The improved ant colony algorithm had fewer iterations and running time.
Author contributions
Yuesheng Tan conceived the study and formulated the overarching research aims. Jie Ouyang and Zhuo Zhang designed the study, designed computer program, analyzed data, and wrote the article. Yinglun Lao and Pengju Wen revised the article and conducted data gathering.
Financial support
This work was supported by National Nature Science Foundation of China (grant number: 51705022).
Conflicts of interest
None.
Ethical considerations
None.