## 2 Materials and Methods
### Computational Procedure  
Manufacturers and researchers are interested in finding the best relationship between input(s) and output(s) with the aim of predicting and controlling the final quality of a process saving time and costs. This is usually accomplished by using empirical models. However, the choice of the best one is a challenging task that is not straightforward because of the very high number of possibilities, especially when dealing with data affected by dispersion due to both process and measurement variability. For this reason, in this work, a genetic algorithm (GA) is proposed and implemented in order to find the best empirical model (see Equation (1)) and, therefore, for the global optimization of the laser hardening process presented in this work in terms of the number of cycles until failure (\(N_{GA}\)). The choice of this evolutionary-based method is due to the ability to handle the optimization of many variables in a robust and efficient way [32; 33; 34; 35]. \[N_{GA}(P,Ss)=k_{0}+\sum\
olimits_{i=1}^{N_{T}}\Bigl{(}k_{i}\cdot P^{\alpha_{ i}}\cdot S\delta^{\beta_{i}}\Bigr{)}. \tag{1}\]  
Given a defined number of terms \(N_{T}\), Equation (2) represents a generic regression model in which \(\alpha_{i}\) and \(\beta_{i}\) are optimized using the proposed GA, while the empirical coefficients \(k_{i}\) and the constant term \(k_{0}\) are obtained with standard linear regression. Figure 5 reports the procedure of the proposed algorithm as it is typically implemented: it consists of four steps, i.e., initialization, selection, crossover and mutation [36]. In this case, the crossover and mutation operators are used in parallel, in order to emphasize the gains in performance that can be achieved from the concurrent application of operators with different and complementary roles [37]. Furthermore, two other important concepts are the genetic encoding of the parameters and the formulation of the fitness function, which are explained in the following Figure. Figure 4: Wöhler curve for the untreated samples. The implementation of the genetic algorithm starts with the definition of a fixed number of chromosomes, which represent, in this case, one of the possible regression models. At the beginning, chromosomes are encoded and therefore represented in terms of a string of bits, octal numbers, hexadecimal numbers, values, etc. [38]. In this study, real value encoding is adopted, in which every chromosome is represented in terms of a set of real values. The main advantage of this scheme is given by the direct representation of the parameters and by the fact that it avoids any intermediate encoding and decoding steps [32]. In particular, each term of the model:  
\[C_{i}=P^{\alpha_{i}}.S_{S}\beta^{i_{i}}, \tag{2}\]  
is encoded using two independent genes, i.e., the powers of the variables that constitute each term \(\alpha_{i}\) and \(\beta_{i}\), \(i=1,\ldots,N_{T}\), with \(\alpha_{i},\ \beta_{i}\in Q\), where \(Q\) is a discrete set of real values representing all the possible considered exponents for the model. Finally, the coefficients of the regression model (\(k_{i}\), \(i=0,\ldots,N_{T}\)) are evaluated using a standard linear regression. The initial population of models is generated by assigning to each gene a random value within the chosen range. The fitness of this population is evaluated by the fitness function, which is built according to the target of the study, thus returning a specific value for the variable of interest:  
\[f=\text{rms}(N_{GA}(P_{i},S_{i})-N_{E}(P_{i},S_{i})),\ i=1,\ldots,c, \tag{3}\]  
where rms represents the root mean square operation, \(N_{GA}(P_{i},S_{i})\) is the result obtained by applying the models of the initial population for the specific combination of parameters \(i\), \(N_{E}(P_{i},S_{i})\) is the corresponding experimental measure and \(c\) is the number of combinations. The aim of the genetic algorithm is to find the best regression model which minimizes the fit value \(f\).