## 3 Methodology
### Optimization of the Bezier Curve Degree Using GA  
Once the coordinates of the points and \(CSF_{\text{dig}}\) values of the graphite nodule contours are obtained, then these points that are defined by the set \(\mathbf{A}=\{a_{0},a_{1},a_{2},...,a_{k}\}\) with a points number of \((k+1)\) must be approximated by some type of curve in order to reduce the errors caused by the discretization process. In this work, it was decided to use approximations by Bezier curves as these generate smooth curves and are currently used in different applications [19; 31; 32]. However, there is a wide possibility of degrees to be used for generating Bezier curves; therefore, it requires an optimization strategy that simplifies the selection of the optimal degree, \(n_{\text{opt}}\), of the Bezier curve for each of the graphite nodules contours. The optimization algorithm that is used in the present work was implemented in the MATLAB software and is based on genetic algorithms. The diagram of the steps that were followed to implement the optimization method can be seen in Figure 5.  
First, an initial set (population) containing a given number of different Bezier curves degrees (individuals) is generated, these individuals are selected randomly from a given range of Bezier degrees, where each individual represents a potential solution of the optimal degree of the Bezier curve that best fit the micro-scale model of the nodule \(i\), which is being analyzed. Then, the Bezier curves are generated for each of the proposed degree in the initial set, and for each individual, the relative error, \(E_{\text{r}}\), is computed as:  
\[E_{\text{r}}=\frac{\left|CSF_{\text{dig}}-CSF_{\text{est}}\right|}{CSF_{\text {dig}}} \tag{3}\]  
where \(CSF_{\text{dig}}\) is the circular shape factor obtained digitally (image processing), and \(CSF_{\text{est}}\) is the estimated shape factor for each of the individuals of the Bezier degrees population randomly generated.  
Figure 5: General scheme of the Bézier curves optimization.  
The relative error, \(E_{\rm r}\), represents the performance of each Bezier degree (fitness of the individual). According to each of the \(E_{\rm r}\) that are obtained, the initial population is reordered, this corresponds to the elitist selection of the individuals, leaving in the first place the Bezier curve degree whose \(E_{\rm r}\) is the lowest (best fitness), and lastly the Bezier curve degree with the highest \(E_{\rm r}\) (worst fitness). Once the degrees with the best performance have been selected, a new population is generated, which will be evaluated in the next iteration of the evolutionary process. The generation of this population will be done by using the cross over operation between the best individuals (those who have the lowest \(E_{\rm r}\)), whereas the individuals with the highest \(E_{\rm r}\) will be replaced using the mutation operator. It should be noted that during the elitist selection, the best degree that is obtained will be kept in the highest position (during re-ordering), and will only be replaced if a degree of curve with a better fit is found in a following iteration. This will guarantee the curve degree evaluation to its optimal value. The algorithm ends when the relative error, \(E_{\rm r}\), obtained for the Bezier curve degree at the highest position is less than the termination criterion, which is the desired relative error, \(E_{\rm rd}\). It is important to mention that the proposed models do not have the aim to converge to the \(CSF_{\rm dig}\) values, because if the proposed curves had the same \(CSF_{\rm dig}\) values, it would be repeating the same errors that were produced by the discretization process, for this reason is that the termination criterion is the \(E_{\rm rd}\) value instead of \(CSF_{\rm dig}\), which function is to give a tolerance factor to produce smooth curves in the proposed models.