## 3 Method
### The Particle Swarm Optimization  
An optimization algorithm is a method to find the maximum or minimum of a given function. For the contact problem of Figure 4, the objective function is shown in Equation (26), where \(I\) corresponds to the perimeter of the deformed body, and \(I_{or}\) corresponds to the body perimeter before applying the load. The algorithm varies the NURBS control points that define the bodies, and the contact zone is assumed to be a straight line (Figure 6).  
\[I_{or}-I=0 \tag{26}\]  
There is a wide variety of optimization algorithms, but those algorithms based on nature stand out. For example, the genetic algorithms, the particle swarm optimization, the ant colony optimization,  
Figure 5: Flowchart to analyze contact with the proposed IGA-BEM.  
Figure 6: Contact zone and control points.  
and the differential evolution, among others. In this paper, the particle swarm algorithm was chosen because it is easy to implement and has fast convergence [30].  
The PSO is inspired by how animal herds behave. The flowchart of this method is shown in Figure 7. The first step is to set the population size or \"swarm\" (\(N_{swarm}\)). Each \"individual\" of the community has a set of optimization variables or design variables that represent their position (\(X\)). These elements move in the solution space by adjusting their speeds (\(V\)). However, the individual speed depends on their previous position and speed values. Moreover, it depends on the best individual location (\(L\)) and the best position of all individuals (\(G\)). The algorithm runs until the maximum number of iterations (\(N_{i}\)) is reached. The last best global position values correspond to the design optimized variables.  
The function to be optimized is the initial perimeter of the bodies, and the design variables are the control points (\(B\)) that are outside of the contact zone. The next position \(X_{i}\) and velocity \(V_{i}\) values of each particle are calculated by using Equations (27) and (28), respectively, where the best particle position is \(L_{i}\), and the best position of all particles is \(G_{N}\).  
\[V_{i+1}=C_{1}V_{i}+C_{max}rand(0,1)(L_{i}-X_{i})\ +C_{max}rand(0,1)(G_{N}-X_{i}), \tag{27}\]  
\[X_{i+1}=X_{i}+V_{i} \tag{28}\]  
To update the best local and global values, the function to be optimized must be analyzed. This means the perimeter of the body for each \(X_{i}\) value must be calculated. The elements of \(X_{i}\) are the new control points. If the perimeter is higher or less than the original, then a penalization is applied by adding or subtracting an amount from the obtained perimeter value, Equations (29) and (30), where k represents a proportional constant to the difference between the value of \(I\) and \(I_{\sigma}\). To update the best local position, \(L_{i}\), the penalized \(I\) is compared with the best saved local perimeter; if the new \(I\) value is better than the saved, the best local position \(L_{i}\) is updated. The same procedure is done to update the best global location.  
\[if\ I>I_{\sigma}\Rightarrow I=I+abs(kl) \tag{29}\]  
\[if\ I<I_{\sigma}\Rightarrow I=I-(kl) \tag{30}\]  
Figure 7: Flowchart of PSO.