## 4 Genetic Algorithm Optimization
### Fitness Function Definition  
The fitness function is the main concern for the development of the GA and its definition establishes the expected output of the algorithm. For this research, this function was defined as a function that evaluates the lowest power consumption, the shortest machining time and an acceptable surface roughness among others. Equation (9) defines the fitness function for this genetic algorithm optimization. This equation is a summation of goal functions \(g_{i}\), which evaluate power consumption, machining time, surface roughness, etc. Furthermore, each \(g_{i}\) function is weighted by a constant \(\omega_{i}\), which allows the adjustment of the importance of each \(g_{i}\) function. \[fitness=\sum_{i}\omega_{i}\cdot g_{i} \tag{9}\]  
The goal function, \(g_{1}\), described in Equation (10), evaluates the power consumption ratio in the turning process. This function uses Equation (11) to evaluate the theoretical power consumption, \(P\)[20]. Furthermore, the \(P_{net}\) constant is the total available power in the machine (introduced in Table 5). The constant \(\gamma\) allows for the consideration of the friction losses in the transmission motor [20] although this constant is equal to 1 for this research. Equation (12) shows the cutting force, \(F_{c}\), as a function of the specific cutting force, \(K_{c}\), related to the working material, depth of cut (_ap_rec_) and feed rate (_fn_rec_) [25]. It is important to note that the specific cutting force, \(K_{c}\), is a parameter that was also introduced in Table 5.  
\[g_{1}=\frac{\gamma\cdot P_{net}}{P} \tag{10}\]  
\[P=\frac{v_{c}\cdot F_{c}}{6\times 10^{4}} \tag{11}\]  
\[F_{c}=K_{c}\cdot ap\_rec\cdot fn\_rec \tag{12}\]  
The goal function, \(g_{2}\), described in Equation (13), defines the machining time ratio, which relates the tool life to the machining time. The tool life, \(T_{life}\), is a tool supplier parameter, which defines the approximate tool life for a tool-insert. The machining time is an objective variable evaluated in Equation (14). This defines the machining time in the turning process with a certain group of cutting parameters. Equation (15) presents the spindle speed, \(n\), as a function of the cutting velocity, \(v_{c}\) and the current machining diameter, \(D\). It is important to note that \(n\) varies according to \(D\). Thus, for each machining pass (diameter decreasing), the spindle speed increases. \[g_{2}=\frac{T_{life}}{T_{m}} \tag{13}\]  
\[T_{m}=\frac{L_{m}}{fn\_rec\cdot n} \tag{14}\]  
\[n=\frac{v_{c}\times 1000}{\pi\cdot D} \tag{15}\]  
The goal function, \(g_{3}\), defined in Equation (16), relates the maximum surface roughness, \(R_{a\_max}\), to the theoretically reached surface roughness, \(R_{a}\). The parameter \(R_{a\_max}\) is a working specification of material that defines the maximum allowed roughness. \(R_{a}\) is an objective variable defined in Equation (17), which estimates the surface roughness for a certain finishing operation [20]. \[g_{3}=\frac{R_{a\_max}}{R_{a}} \tag{16}\]  
\[R_{a}=\frac{125\cdot fn\_rec^{2}}{REmm} \tag{17}\]The goal function, \(g_{4}\), defined in Equation (18), relates the objective variable, \(d_{euclidean}\), to the parameter \(Th_{d}\) (threshold distance). The variable \(d_{euclidean}\) is obtained by Equation (19). This equation calculates the Euclidean distance between the features \(x_{i}\) and \(y_{i}\), which are defined by the suggested GA tool-insert features and the \(n\)th tool-insert in the dataset, respectively. Table 5.0  
Table 5.1  
The goal function, \(g_{5}\), shown in Equation (20), evaluates the spindle speed ratio, which is used in the turning process. This objective function relates the maximum spindle speed of the machine to the theoretical spindle speed reached in the turning process. Table 5.2  
The goal function, \(g_{6}\), shown in Equation (21), evaluates the suitability range for a certain insert grade. This function assesses if a suggested grade is more appropriate for a specific application area compared to other solutions.