## 2 Optimization Methodology
### Methodology of Optimization Process in Trajectory Planning and Contour Tracking  
The DE optimization method works as robust alternative meta-heuristic algorithm. DE algorithm consists of four steps, the first is the initialization step, the second is the mutation step, the third is the crossover step and the fourth is the selection step. In the first step initialization of population \(NP\) with \(D\) as a parameter is carried out. Each individual is symbolized as \(x_{i,g}=[x_{i,j}^{1},x_{i,j}^{2},\ldots,\ x_{i,j}^{D}]\), where \(i\) = [1, 2, \(\ldots\) \(\ldots\) \(\ldots\) \(\ldots\) \(\ldots\), NP], \(g=[1,2,\ldots\)\(\ldots\)\(\ldots\)\(\ldots\)\(\ldots\), \(g_{max}]\) and \(g_{max}\) is the maximum generation and \(X_{max}\), \(X_{min}\) are the upper and lower search bounds imposed on the population. The initialization of the \(i\)-th individual is generated according to the following equation:  
\[x_{i,0}^{j}=x_{min}^{j}+rand(0,1)*(X_{max}-X_{min}) \tag{15}\]  
In the second step, mutation of each individual is generated and hence a new mutated vector is produced. There are many strategies to mutate the individual, in this study \"DE/rand/1\" is adopted such that:  
\[v_{i,g}=x_{r1,g}+F.\left(x_{r2,g}-x_{r3,g}\right) \tag{16}\]  
where \(v_{i,g}\) is the \(i\)-th element in the mutated vector. \(F\) is a scaling factor which lies between 0 and 1. The indices \(r_{1}\), \(r_{2}\) and \(r_{3}\) are randomly selected from \(i\). After the mutation step, the crossover step is performed in order to generate the trial vector. In this step, the new mutated vector (which is the target vector) should have the same properties of the trial vector. There are two basic crossover schemes of DE which are the binomial recombination and the exponential recombination [28]. In this study, binomial recombination is used in DE algorithm as performed in (17). \[u_{ij,k+1}=\left\{ \begin{array}{l}w_{ijk}\ if\ l>CR\ AND\ j\
eq R\\ v_{ijk+1}\ if\ l\leq CR\ OR\ j=R\end{array} ,\ j=1,\ldots,D\right. \tag{17}\]  
where \(CR\) is the crossover probability, \(j_{rand}\) is a randomly selected index to confirm that trial vector has at least one property of the mutated vector. Finally, in the selection step, three fitness functions are individually used to determine whether the trial vector is converted into a target vector. The selection operation is characterized in (18):  
\[x_{i,g++1}=\left[ \begin{array}{l}u_{i,g}\ if\ f\left(u_{i,g}\right)\leq f \left(x_{i,g}\right)\\ u_{i,g}\ if\ f\left(x_{i,g}\right)<f\left(u_{i,g}\right)\end{array} \right] \tag{18}\]  
where _f(x)_ is a fitness function. Trajectory planning can be treated as an optimization problem, that is, calculating the global minimum of \(U\), from the initial configuration \(\theta_{initial}\). One of the simplest methods used to solve this problem is through the gradient. In this study, the negative gradient of \(U\) can be considered as a force acting on the robot; that is, it is directly related to the movement of the joints [29]. In general, the \(U\) field is an additional field in which one part constitutes the attraction, and the other part constitutes the repulsion, as given in (10). The resultant force of artificial potential field that should be applied to the robot is given in (11). The real action of the potential field for the planar manipulator is obtained by the sum of each force in its respective direction [27]. \[F(x,y)=F_{xya}(x,y)+F_{xyo}(x,y)+F_{xyr}(x,y) \tag{19}\]  
Equation (19) is used as an evaluation function to perform the simulation of the DE algorithm. This equation is minimized to find the best strength of the potential field from which the values of the parameters \(k_{r},k_{a}\) and \(k_{o}\) have to be determined. For the collision-free trajectory of the UR5 manipulator, cartesian coordinate system is adopted. The generated path must avoid collision with circular obstacles having equal size. The scenario of the simulation is formed by the start point of the robot, the obstacle, and the end point of the robot.