# Metaheuristic and Heuristic Algorithms-Based Identification Parameters of a Direct Current Motor
## 3 Optimization Algorithms
### Implementation of Metaheuristic Algorithms  
The parameters used for the development of the algorithms are described here. Much of the optimization is based on a good selection of search parameters that govern the search for acceptable solutions to the problem in question. The same \"fitness function\" was applied to each metaheuristic algorithm for a fair comparison. This equation was based on the inverse of the Euclidean distance, as shown in Equation (13), where \(I_{s}\) is the estimated current, \(I\) is the actual current, \(\omega_{s}\) is the estimated angular velocity, and \(\omega\) is the actual angular velocity. It should be noted that this function is applied to each iteration of the metaheuristic algorithms. \[Fitness=\frac{1}{\sqrt{\sum(I-I_{s})^{2}+\sum(\omega-\omega_{s})^{2}}} \tag{13}\]  
Figure 6: The flowchart of the Genetic Algorithm. The MSE was used as an error evaluation criterion; see Equation (14). This function measures the average of the differences between the real and predicted values and allows us to penalize the largest differences to obtain a more robust model where, if there are large deviations, we can obtain a good approximation of the results. Since the DC motor is a system of differential equations with two variables, both must be included in the error estimate. That is why the fitness function must consider the MSE in current and speed. Since they are two different variables, the Euclidean distance is used to associate them. This statistical method will be used to analyze performance in the parametric estimations of the DC motor. The result will be a percentage of error in each vector of the five parameters [R, L, K, B, J]. It is important to highlight that the error function selected can affect the behavior of the metaheuristic algorithm. In addition to the MSE error, some other error functions have shown similar performance [44; 45]; for example, the Integral Squared Error (ISE), the Integral Absolute Error (IAE), the Integral of Time multiplied by the Absolute Error (ITAE), and the Integral of Time multiplied by the Square Error (ITSE). Studying the effects of these error functions is beyond the scope of this manuscript. \[MSE=\frac{1}{N}\sum_{i=1}^{N}(y_{i}-\hat{y}_{i})^{2} \tag{14}\]  
This method results in an error calculated by adding the actual values minus the estimated values squared and divided by the number of parameters. The optimization offered by metaheuristic algorithms depends on the iterations, since the algorithm produces a more optimal solution in each iteration. However, if many iterations are used, the algorithm will require a higher computational cost. For this work, the number of iterations is a fixed parameter aiming for a good performance in both computational cost and parametric estimation, obtaining a good balance between effectiveness and efficiency. The iterations used were 100 for each program. The range of limits (upper and lower) determines the search space for each motor parameter. The limits adjust each range proportionally to the magnitude of the parameter. Varying these limits increases or reduces the search space. Although an infinite number of values can be selected, it is not essential, as long as the nominal value is within the search range. Thanks to this, the algorithm has a defined search space, where it begins to evaluate random values in search of the most appropriate solution. Mutation and creating a new population are performed within the limits of the GA. In the case of GWO and Jaya, new search agents within the range are checked in each iteration, guaranteeing that the search for all algorithms is performed within the limits. The ranges selected for this work must be positive since, by definition, any parameter takes negative values. On the other hand, the final selection of values is based on the typical values expected for this type of motor. For example, investigations such as refs. [30; 46] have successfully searched for values in this range in similar DC motors.