## 3 Description of the Method  
### Particle Swarm Optimization  
The PSO is a derivative-free iterative stochastic optimization algorithm based on swarm theory and observation of social behavior of animals, e.g., bird flocks or fish school [24]. This method suits our purpose, because we will not know the energy consumption function and we do not try to construct it for our particular case of the Universal Robot robotic arm (model UR3)-Figure 2.  
The population contains candidate solutions, called particles. Particles are initialized with random positions that correlate with a solution to the problem. Each particle has a random velocity vector defining its movement through a solution space. The individual particle then dynamically adjusts its velocity and searches the solution space according to its own movement experience, the same as the best solution from the rest of the population. All of the particles are grouped into a swarm and cooperate on finding the best solution within the search space. In our work, we use the PSO algorithm with cognitive and social components. The particle positions in our method serve as control points. The solution space is defined as a \(J\)-dimensional area containing a population of \(I\) particles. The particle \(i\) is then located at the position \(X_{i}=x_{i1},x_{i2},\ldots,x_{ij}\) with a velocity \(V_{i}=v_{i1},v_{i2},\ldots,v_{ij}\). In each iteration of the PSO algorithm, the particle updates its position and then moves randomly towards its best-known position (\(L_{i}\)), denoted as \(L_{i}=l_{i1},l_{i2},\ldots,l_{ij}\) and to the best position known in the swarm \(G_{best}=g_{1},g_{2},\ldots,g_{j}\). Particle positions are calculated as the addition of the actual velocity to the previous position:  
\[X_{i}^{t+1}=X_{i}^{t}+V_{i}^{t+1} \tag{1}\]  
Equation (2) shows the computation of the particle velocity:  
\[v_{ij}^{t+1}=w*v_{ij}^{t}+c_{1}r_{1}[l_{ij}^{t}-x_{ij}^{t}]+c_{2}r_{2}[g_{j}^{ t}-x_{ij}^{t}] \tag{2}\]  
where \(v_{ij}^{t}\) is the velocity of particle \(i\) in dimension \(j\) at time \(t\). The inertial weight \(w\) influences the velocity from the previous iteration to control the exploration and exploitation of the search space. A small \(w\) urges the particle to exploit the area in its near position, while a high value prevents the particle from being stuck in a local minimum [25]. Figure 2: Block diagram of the proposed algorithm. Values \(r_{1}\) and \(r_{2}\) are independent random numbers from a uniform distribution over a range from 0 to 1. The constants \(c_{1}\) and \(c_{2}\) affect the acceleration that pulls the particle to the best position from the particle memory and the best-known particle position from the swarm. In other words, \(c_{1}\) influences the cognitive part of the particle, representing primitive thinking. The constant \(c_{2}\) takes part in social behavior and it represents the cooperation among particles. Various recommendations about the values of \(c_{1}\) and \(c_{2}\) exist. Some authors recommend values over the range from 0 to 1, and the sum of \(c_{1}\) and \(c_{2}\) is less than or equal to 1 [26; 27]. [PERSON] and others [25; 28] use inertial weight in Equation (3) to show that particles have convergent trajectories, even for values of \(c_{1}\) and \(c_{2}\) higher than 1. [PERSON] et al. [29] proposed PSOs with a new comprehensive learning strategy (CLPSO), where each dimension of a particle learned from just one particle best historical information, while each particle learned from a different particles best historical information for different dimensions. \[w>\frac{1}{2}(c_{1}+c_{2})-1 \tag{3}\]  
By [PERSON], cyclic or divergent particle trajectories may occur when Equation (3) is not satisfied [25]. Other researchers [30] drew similar conclusions. The termination criterion for basic PSO is reaching a specific generation, the designated value of \(G_{best}\), or its saturation.