A New Approach to Optimize the Relative Clearance for Cylindrical Joints Manufactured by FDM 3D Printing Using a Hybrid Genetic Algorithm Artiﬁcial Neural Network and Rational Function

: Nowadays, FDM technology permits obtaining functional prototypes or even end parts. The process parameters, such as layer thickness, building orientation, ﬁll density, type of support, etc., have great inﬂuence on the quality, functionality and behavior of the obtained parts during their lifetime. In this paper, we present a study concerning the possibilities of obtaining certain values for clearance in revolute joints of non-assembly mechanisms manufactured by FDM 3D Printing. To ensure the functioning of the assembly, one must know the relationship between the imposed and measured clearances by taking into account the signiﬁcant input data. One way is to use the automat learning method with an artiﬁcial neuronal network (ANN). The data necessary for the training, testing, and validation of ANN were experimentally obtained, using a complete L 27 Taguchi experimental plan. A total of 27 samples were printed with different values of the following parameters: the inﬁll density, the imposed clearance between the shaft and the hole, and the layer thickness. ANN architecture corresponds to the Hecht–Kolmogorov theorem. Genetic algorithms (GA) were used for the optimization of the output. The Neural Network Toolbox from MATLAB was used for training the network and a hybrid tool genetic algorithm artiﬁcial neural network (GA-ANN) was used to minimize the value of the absolute relative clearance (arc). The minimum value of the absolute relative clearance established by GA-ANN was 0.0385788. This value was validated experimentally, with a relative difference of 4%. We also introduced a rational function to approximate the correlation between the input and output parameters. This function fulﬁlls some frontier conditions resulted from practice. In addition, the function may be used to establish the designed clearance in order to obtain an imposed one.


Introduction
The technology of rapid prototyping has rapidly evolved and has found use in many industries, such as the automotive industry, aerospace, electronics, and medicine, to create prototype products and complex mechanisms [1,2]. Parts with shapes that are difficult or even impossible to be manufactured by conventional technologies are easily obtained by 3D printing. However, rapid prototyping technologies do not represent a general solution for any product-manufacturing problem. Aside from its advantages as a safe and simple technology, including the freedom in design, wide range of materials, affordable price, and ease of use, FDM also has some disadvantages, such as poor accuracy for small parts and fine details when the parts are manufactured as an assembly. In the case of 3D printing non-assembly mechanisms, the process parameters and assembly clearances must be chosen accordingly [3][4][5]. It is currently possible to create a wide range of mechanisms using additive manufacturing (AM), ranging from the traditional types of multi-part mechanisms to non-assembly mechanisms [5]. There are some disadvantages of nonassembly mechanisms. In designing the traditional mechanism, the choice in material and the production process may be optimized for each part, as they are all separately manufactured. For non-assembly mechanisms, all parts are manufactured, using the same process and often using the same material. Usually, one or more post-processing steps are required, such as removing the backing material or polishing the surfaces. In particular, removing the backing can be a long, time-consuming process.
Non-assembly mechanisms must be functional. This has led to the shift from design to fabrication and assembly to design for additive manufacturing (DFAM) [6][7][8][9][10][11][12]. In this case, the main objective of the design activity is no longer to ensure the assembly of the mechanisms but to ensure the functionality of non-assembly mechanisms. Research in the field of DFAM has focused mostly on the design of the shape of the parts, which has led to the obtaining of some topologically optimized models. However, as fully functional assemblies requiring few or no assembly operations can be manufactured through AM, DFAM methodologies are needed to address the design of the assembly [6,7].
The tolerance and clearance analysis can predict the effects of part deviations on the assembly characteristics [13][14][15]. It has been shown that the clearance and materials play a key role in the design of non-assembly mechanisms. Ensuring the functionality of the product depends on the choice of clearance between the elements of the assembly. The clearance depends on the required joint performance and print resolution, i.e., it must be small enough to ensure the performance of the joint (avoiding instability, vibration etc.) but large enough to prevent the welding of components during the manufacturing process [6,[16][17][18].
Depending on the geometries of the parts, the values of the clearances necessary for the functionality of the non-assembly mechanism are different. The recommended values are as follows: 0.2 mm using an Object Eden 350 V machine [18], 0.2 mm and 0.05 mm (with additional changes in the shape of the assembly) by using FDM [19], and 0.4 mm by using a Stratasys F370 machine [3].
New methodologies have been developed to ensure the functionality of the nonassembly mechanisms through a statistical analysis of tolerance by considering geometric deviations and clearance [1,3,6,20,21]. The methodology presented in [1] was applied on an eight-bar non-assembly mechanism. The clearance of the kinematic joints was set at a value equal to 0.4 mm. The validation of the methodology was performed by applying it to an eight-bar planar mechanism. Another developed methodology allows non-assembly mechanisms to be arranged automatically, minimizing the support material quantity and printing time. The integration of CAD software allows automatic optimization by taking into account a pre-selected machine. The method was applied to a 3RRR planar mechanism and it turned out that optimizing the orientation of individual moving parts could significantly reduce printing time and support material quantity [21]. In [20] is presented a novel methodology for the statistical tolerance analysis of non-assembly mechanism motion with consideration of joint clearance.
The methodology proposed in [6] aims to design products the components of which are at their minimum dimensions; the methodology consists of three main steps: -Functional analysis, which is designed to describe the functionality of the product and to understand both the relationships between the product and its environment, as well as the relationships between components; -Detailing the control structures of the components; -Designing the geometries of the parts.
The accuracy of the parts influences the functionality of the assembly [22]. There are currently no recommendations regarding the accuracy of individual parts or nonassembly mechanisms obtained by FDM because it is strongly influenced by the machine used for the manufacturing process; moreover, there are only predictive empirical models obtained under certain conditions. Thus, tolerances may be established considering the process parameters. These empirical models automatically learn the relationship between Processes 2021, 9, 925 3 of 13 input and output quantities based on a previously collected training dataset, usually experimentally [23][24][25][26][27][28][29].
The neural networks must be trained with known experimental data. The experimental data used for the training of the networks must be representative. During the training phase, sufficient knowledge must be transferred to the neural network in order to estimate the output data so that they can also be used in those cases in which the artificial neural network has not been directly trained. There is no single way in which one can determine how much data are needed to train a neural network. In the literature are presented some approaches that consider the training of the artificial neural network, using experimental plans (factorial or otherwise) [30,31].
The configuration of a neural network can take a long time, the trial-error method having to be used to find the artificial neural network for a given problem [32].
The chosen input parameters must be significant. Preliminary experiments are performed for this purpose. Thus, to identify the relationship between the input and output data, preliminary studies are performed, through which the samples printed by FDM are measured to establish the dimensional accuracy. Subsequently, the results are evaluated in order to analyze their influence on the geometric accuracy of FDM printed parts.
Frequently, the chosen input parameters are layer thickness, raster angle, air gap, raster width, build orientation, number of contours, contour width, and printing speed [26].
It is difficult to adjust the parameters of the AM process because they may exert a major influence on the printed parts and the performance of subsequent products. It is also very difficult to establish a relationship between the input and output parameters by using traditional numerical and analytical models. Currently, the method of machine learning using neural networks is a valid way to perform complex model recognition and regression analysis, without the need to build and solve mathematical models. The neural network is the most widely used model due to the large dataset currently available, strong computing power, and sophisticated algorithm architecture [33,34].
Significant process parameters (layer thickness, building orientation, fill density, and the number of contours) are optimized in order to increase the dimensional accuracy of the parts obtained by (FDM). Hybrid statistical tools, such as the response surface method (RSM), artificial neural network (ANN), and artificial neural network genetic algorithm (ANN-GA) in MATLAB, are used for training and optimization. Mathematical models have been established, which allow the establishment of an indirect correlation between different FDM process parameters and dimensional accuracies. The developed models were experimentally validated [24,25].
In this paper, empirical predictive models are presented, using an artificial neural network and genetic algorithm for determining the clearance joint of non-assembly mechanisms manufactured by FDM based on the chosen process parameters and the clearance initially imposed. Subsequently, this information can be used to know the value of the clearance that must be imposed in order to obtain the required clearance.
A novel approach presented in this paper consists in the application of a hybrid tool genetic algorithm artificial neural network (GA-ANN) to minimize the value of the absolute relative clearance of a joint of a non-assembly mechanism obtained on an M200 Zortrax 3D printer.
Another approach presented in this paper is using a rational function depending on certain parameters and which has the properties that it asymptotically tends to the imposed clearance when the last one is enough large, vanishes for small values of imposed clearance, and has a null slope at a critical value at which the obtained clearance start to increase from the zero value.

Materials and Methods
The study on the influence of design and process parameters on the quality of the assembly of pieces manufactured by FDM 3D Printing was conducted with the aid of non-assembly parts. The samples for the tests were designed using Catia V5 software and were realized by the FDM 3D printer Zortrax M200, using Z-ABS material. The shape and dimensions of the sample are presented in Figure 1.
The experimentation methodology was designed to achieve the influence of input parameters on the measured clearance that was calculated from the difference in the dimensions of the pieces realized by 3D printing.
increase from the zero value.

Materials and Methods
The study on the influence of design and process parameters on the quality of the assembly of pieces manufactured by FDM 3D Printing was conducted with the aid of nonassembly parts.
The samples for the tests were designed using Catia V5 software and were realized by the FDM 3D printer Zortrax M200, using Z-ABS material. The shape and dimensions of the sample are presented in Figure 1.
The experimentation methodology was designed to achieve the influence of input parameters on the measured clearance that was calculated from the difference in the dimensions of the pieces realized by 3D printing. In order to realize pieces by FDM, the following values were used: for the parameter infill density, three values, namely, 60% (low density), 80% (high density), and 100% (solid); and for the layer thickness, the values between 0.14 and 0.29 mm (also three values). In the case of the second input parameter, the Catia V5R19 software was used to design a cylindrical non-assembly fit with a nominal size of ∅20 mm. To obtain different values for the clearance, the diameter of the incorporated piece (shaft type) was kept constant at a value of 20 mm, and the diameter of the incorporating piece (hole type) was varied, being designed at a value equal to 20 mm plus the value of the imposed clearance. By design, the pieces were positioned in such a way that during their manufacturing process, the imposed clearance was uniformly distributed in any direction. A variation of the imposed clearance between 0.8 and 2.0 mm was desired; hence, the dimensions of the samples are those shown in Table 1.  In order to realize pieces by FDM, the following values were used: for the parameter infill density, three values, namely, 60% (low density), 80% (high density), and 100% (solid); and for the layer thickness, the values between 0.14 and 0.29 mm (also three values). In the case of the second input parameter, the Catia V5R19 software was used to design a cylindrical non-assembly fit with a nominal size of ∅20 mm. To obtain different values for the clearance, the diameter of the incorporated piece (shaft type) was kept constant at a value of 20 mm, and the diameter of the incorporating piece (hole type) was varied, being designed at a value equal to 20 mm plus the value of the imposed clearance. By design, the pieces were positioned in such a way that during their manufacturing process, the imposed clearance was uniformly distributed in any direction. A variation of the imposed clearance between 0.8 and 2.0 mm was desired; hence, the dimensions of the samples are those shown in Table 1. Each input parameter (infill density, imposed clearance, and layer thickness) was varied over three levels, and their values are shown in Table 2. The experimental plan used in this paper was the Taguchi type 3 3 one, so 27 experiments were conducted.
After the 3D-printing process, each sample was measured in several directions corresponding to the angles equal to 0 • , 45 • , 90 • , and 135 • , the measurements were repeated several times and the results were averaged, as shown in Figure 2. Each sample was measured using a Zeiss Contura G3 coordinate measuring machine (with an accuracy of 1 µm) and CALIPSO software. Because the accuracy of 0.1 mm was used for the imposed clearance, it was considered that the accuracy for the measured clearance is equal to 0.01 mm. The experimental plan used in this paper was the Taguchi type 3 3 one, so 27 experiments were conducted.
After the 3D-printing process, each sample was measured in several directions corresponding to the angles equal to 0°, 45°, 90°, and 135°, the measurements were repeated several times and the results were averaged, as shown in Figure 2. Each sample was measured using a Zeiss Contura G3 coordinate measuring machine (with an accuracy of 1 μm) and CALIPSO software. Because the accuracy of 0.1 mm was used for the imposed clearance, it was considered that the accuracy for the measured clearance is equal to 0.01 mm. A genetic algorithm (GA) is used to evaluate a given objective function, using a random population within a specified range for the input parameters.
Based on the data presented in Table 3, an ANN was trained, using the input and output data sets as follows: an input matrix (27 × 3) and an output vector (27 × 1). The Neural Network Toolbox of MATLAB was used.
A multilayer perceptron (MLP) based on feed-forward ANN was used to construct the predictive model. The network consists of an input layer, a hidden layer, and an output layer. The inputs for ANN were the infill density, imposed clearance between the shaft and the hole, and layer thickness.  A genetic algorithm (GA) is used to evaluate a given objective function, using a random population within a specified range for the input parameters.
Based on the data presented in Table 3, an ANN was trained, using the input and output data sets as follows: an input matrix (27 × 3) and an output vector (27 × 1). The Neural Network Toolbox of MATLAB was used.
A multilayer perceptron (MLP) based on feed-forward ANN was used to construct the predictive model. The network consists of an input layer, a hidden layer, and an output layer. The inputs for ANN were the infill density, imposed clearance between the shaft and the hole, and layer thickness.  The output is the absolute relative clearance (arc) defined as a ratio presented in Equation (1).
The connections between inputs, hidden layer, and output were transposed into weights (w) and biases (b), which are considered parameters of the artificial neural network.
The sigmoid tangent function was chosen for the activation of the ANN, and the type of the network was feedforward backpropagation. For the training of the ANN, 70% of the datasets were selected; 15% datasets were used for testing and another 15% for validation.
A value toward zero of the correlation coefficient indicates that there is no relationship between the inputs and outputs, and a value very close to 1 indicates a very good correlation.
The already trained network was used as an objective function by GA, which seeks to minimize the objective function.
The intervals for the three input parameters were [0.6; 0.8; 0.14] and [1; 2; 0.29]. The architecture of the network used in this study consisted of the following: three input neurons, corresponding to the input parameters; one output neuron, corresponding to the output parameter; and seven neurons on the hidden layer, empirically chosen, shown in Figure 3.  Using the "Levenberg-Marquardt" backpropagation algorithm, the ANN was trained. The training process is an iterative one. For this study, 7 iterations were performed for the training of the network.
At the end of the training process, in the window "Train Network" the values for R 2 and the MSE (mean square error) are displayed, shown in Figure 4. Using the "Levenberg-Marquardt" backpropagation algorithm, the ANN was trained. The training process is an iterative one. For this study, 7 iterations were performed for the training of the network.
At the end of the training process, in the window "Train Network" the values for R 2 and the MSE (mean square error) are displayed, shown in Figure 4.
Using the "Levenberg-Marquardt" backpropagation algorithm, the ANN was trained. The training process is an iterative one. For this study, 7 iterations were performed for the training of the network.
At the end of the training process, in the window "Train Network" the values for R 2 and the MSE (mean square error) are displayed, shown in Figure 4.

Mathematical Modeling
The mathematical modeling of the clearance as a function of the imposed clearance (further on denoted by ), layer thickness (further on denoted by ), and infill density (further on denoted by ) requires the selection of a candidate function that depends on three variables.
Usually, this function is selected as a polynomial one, a higher degree of the polynomial implying a higher precision. The coefficients of the selected polynomial are obtained by using the least squares method. The significant problems with such a polynomial function are at least the following: (i) the values of this function may be negative in some intervals; (ii) the function does not linearly tend to infinite when the imposed clearance tends to infinite; (iii) the clearance starts to grow from zero when the imposed clearance increases over a limit; and (iv) the slope of clearance has to be zero at that critical value when the clearance starts to have non-zero values. Practically, when the imposed clearance is sufficiently great, the resulted clearance is approximately equal to the first one. Moreover, if the imposed clearance is small enough, the obtained clearance is equal to zero. Considering these remarks, it results that the candidate function must not be a polynomial in the variable .
As candidate function, we choose the following simple one:

Mathematical Modeling
The mathematical modeling of the clearance as a function of the imposed clearance (further on denoted by x), layer thickness (further on denoted by y), and infill density (further on denoted by z) requires the selection of a candidate function that depends on three variables.
Usually, this function is selected as a polynomial one, a higher degree of the polynomial implying a higher precision. The coefficients of the selected polynomial are obtained by using the least squares method. The significant problems with such a polynomial function are at least the following: (i) the values of this function may be negative in some intervals; (ii) the function does not linearly tend to infinite when the imposed clearance tends to infinite; (iii) the clearance starts to grow from zero when the imposed clearance increases over a limit; and (iv) the slope of clearance has to be zero at that critical value when the clearance starts to have non-zero values. Practically, when the imposed clearance is sufficiently great, the resulted clearance is approximately equal to the first one. Moreover, if the imposed clearance is small enough, the obtained clearance is equal to zero. Considering these remarks, it results that the candidate function must not be a polynomial in the variable x.
As candidate function, we choose the following simple one: f (x, y, z) = (x−x 0 ) 2 x+b × a 22 y 2 z 2 + a 21 y 2 z + a 20 y 2 + a 12 yz 2 + a 11 yz + a 10 y + a 02 z 2 + a 01 z + a 00 , where x 0 is the minimum value of the imposed clearance under which the obtained clearance is zero, while b, a 22 , a 21 , a 20 , a 12 , a 11 , a 10 ,a 02 , a 01 , a 00 are the parameters which must be determined. The expression of the function f (x, y, z) given by Equation (2) is valid if and only if x ≥ x 0 ; otherwise, we put f (x, y, z) = 0. One may observe the following: lim x→∞ f (x, y, z) x = a 22 y 2 z 2 + a 21 y 2 z + a 20 y 2 + a 12 yz 2 + a 11 yz + a 10 y + a 02 z 2 + a 01 z + a 00 , (3) that is, this limit does not depend on x, and the following is true: Processes 2021, 9, 925 8 of 13 The parameters of the function f (x, y, z) will be determined using the least square method. To do that, we define the error function by the following expression: in which n is the number of experiments, x i , y i and z i are the values used in each experiment, while v i is the real values obtained in the experiment, i = 1, n. Let us denote by h 1 (x) and h 2 (y, z) the following functions: h 2 (y, z) = a 22 y 2 z 2 + a 21 y 2 z + a 20 y 2 + a 12 yz 2 + a 11 yz + a 10 y + a 02 z 2 + a 01 z + a 00 , which implies f (x, y, z) = h 1 (x)h 2 (y, z). One may write the following: where p is a generic parameter. It results as follows: and the system given by the least square method and which must be solved reads as follows: that is a nonlinear system of ten equations with ten unknowns. We denote by F(x, y, z) the vector function given by the following: our system becoming F(x, y, z) = 0, while the function F(x, y, z) has ten components. The system is solved using the gradient method for which the vector of the ten unknowns at a certain step p + 1 has the following expression: where and J is the following Jacobi matrix: Moreover, we have the following: The iterative process stops when x (p+1) − x (p) < ε, with ε = 10 −3 , the norm of a matrix A with m lines and n column being given by the following:

Results and Discussion
The training process was validated when a value of overall R 2 (0.985) was obtained. Figure 5 presents the values of R 2 of training, testing, validation, and the value of the overall R 2 . The iterative process was stopped when the validated MSE started to increase as shown in the mean square error plotted in Figure 6. The best obtained validation performance was 0.0013063 at epoch 7. The iterative process was stopped when the validated MSE started to increase as shown in the mean square error plotted in Figure 6. The best obtained validation performance was 0.0013063 at epoch 7. The iterative process was stopped when the validated MSE started to increase as shown in the mean square error plotted in Figure 6. The best obtained validation performance was 0.0013063 at epoch 7. The values of the specific GA parameters were the following: population size = 10, crossover fraction, crossover probability = 0.8, uniform mutation, mutation probability = 0.01. After 52 iterations, the optimized conditions were obtained, shown in Figure 7. The value for absolute relative clearance (arc) was 0.0385788 for the following values of the input parameters: 0.737 for the infill density, 1.674 for the imposed clearance, and the value of 0.209 for the layer thickness as shown in Table 4. The values of the specific GA parameters were the following: population size = 10, crossover fraction, crossover probability = 0.8, uniform mutation, mutation probability = 0.01. After 52 iterations, the optimized conditions were obtained, shown in Figure 7. The value for absolute relative clearance (arc) was 0.0385788 for the following values of the input parameters: 0.737 for the infill density, 1.674 for the imposed clearance, and the value of 0.209 for the layer thickness as shown in Table 4.    In order to verify and validate the results obtained by GA, a new sample was realized with the following parameters (which can be chosen on the 3D printer, with values close to the optimal ones): 0.7 for the infill density, 1.7 for the imposed clearance and the value of 0.19 for the layer thickness. In this situation, the measured value for absolute relative clearance (arc M ) was 0.041 for an estimated value for absolute relative clearance (arc E ) with rained network equal to 0.0394. The relative difference between arc M and arc E , arc M −arc E arc M * 100, was about 4%. Using the expression (Equation (2)) for the function f , one gets the following values presented in Table 5. Table 5. The values of the coefficients in Equation (2).

Conclusions
This paper presents the influence of design parameters on the geometrical parameter, that is, the absolute relative clearance in the revolute joints of the non-assembly mechanisms manufactured by FDM 3D Printing.
The methods used in this paper are the method of automat learning with the aid of the artificial neural network and the construction of a simple rational function, which links the following input parameters: imposed clearance, layer thickness, and infill density to the output parameter (absolute relative clearance):

•
Using the hybrid tool GA-ANN, the minimum value for absolute relative clearance (arc) was 0.0385788, obtained for the following values of the input parameters: 0.737 for the infill density, 1.674 for the imposed clearance, and 0.209 for the layer thickness. This value was validated experimentally with a relative difference of 4%. • Using the rational function, one obtains the following best values: 0.725 mm for the clearance, 0.28 for the layer thickness, and 0.9 for the infill density when x 0 = 0, the imposed clearance being equal to 0.8 mm; for x 0 = 0.3 the best choice is defined by 1.860 mm for the clearance, 0.28 for the layer thickness and 0.9 for the infill density, the imposed clearance being equal to 2.0 mm.

•
The rational function may also offer the values of the input parameter when a certain clearance is required. For instance, if one requires a clearance equal to 1.1 mm, assuming that x 0 = 0, then one may select the following values: 1.6 mm for the imposed clearance, 0.15 for the layer thickness, and 0.6 for the infill density, the obtained clearance being equal to 1.101 mm.

•
Similarly, for x 0 = 0.3 and a required clearance equal to 1.6 mm, the selected values are as follows: 1.8 mm for the imposed clearance, 0.28 for the layer thickness, and 0.8 for the infill density, while the obtained clearance reads 1.591 mm.
Using the artificial intelligence tools, ANN and the GA-ANN hybrid instrument, it was possible to train an artificial neural network able to establish the absolute relative clearance values for different values of the input parameters, being useful in designing of the revolute joints of the non-assembly mechanisms manufactured by FDM 3D Printing, from Z-ABS.