Selective LASER melting part quality prediction and energy consumption optimization

Selective LASER Melting (SLM) popularity is increasing because of its ability to quickly produce components with acceptable quality. The SLM process parameters, such as LASER power and scan speed, play a significant role in assuring the quality of customized SLM products. Therefore, the process parameters must be tuned appropriately to achieve high-quality customized products. Most existing methods for adjusting the SLM’s parameters use multiple inputs and one or two outputs to develop a model for achieving their desired quality. However, the number of the model’s input and output parameters to be considered can be increased to achieve a more comprehensive model. Furthermore, energy consumption is also a factor that should be considered when adjusting input parameters. This paper presents a multi-inputs-multi-outputs (MIMO) artificial neural network model to predict the SLM product qualities. We also try to combine training data from different sources to achieve a more general model that can be used in real applications by industries. The model inputs are LASER power, scan speed, overlap rate, and hatch distance. Moreover, four critical product quality measures: relative density, hardness, tensile strength, and porosity, are used as the model’s outputs. After finding a proper model, an energy optimization method is developed using the genetic algorithm in this paper. The objective of the optimization is to minimize the energy consumption of SLM manufacturing with a less compromised output quality. The results of this study can be used in the industry to decrease energy consumption while maintaining the required quality.

Selective LASER Melting (SLM) popularity is increasing because of its ability to quickly produce components with acceptable quality. The SLM process parameters, such as LASER power and scan speed, play a significant role in assuring the quality of customized SLM products. Therefore, the process parameters must be tuned appropriately to achieve high-quality customized products. Most existing methods for adjusting the SLM's parameters use multiple inputs and one or two outputs to develop a model for achieving their desired quality. However, the number of the model's input and output parameters to be considered can be increased to achieve a more comprehensive model. Furthermore, energy consumption is also a factor that should be considered when adjusting input parameters. This paper presents a multi-inputs-multioutputs (MIMO) artificial neural network model to predict the SLM product qualities. We also try to combine training data from different sources to achieve a more general model that can be used in real applications by industries. The model inputs are LASER power, scan speed, overlap rate, and hatch distance. Moreover, four critical product quality measures: relative density, hardness, tensile strength, and porosity, are used as the model's outputs. After finding a proper model, an energy optimization method is developed using the genetic algorithm in this paper. The objective of the optimization is to minimize the energy consumption of SLM manufacturing with a less compromised output quality. The results of this study can be used in the industry to decrease energy consumption while maintaining the required quality.
Keywords: additive manufacturing, selective LASER melting, artificial neural network, genetic algorithm, energy consumption optimization (Some figures may appear in colour only in the online journal) * Author to whom any correspondence should be addressed.
Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.

Introduction
Additive manufacturing (AM) connects melted materials to produce items from a computer-aided design (CAD) model [1]. AM technologies are rapidly growing due to their manufacturing speed and flexibility [2]. Selective LASER melting (SLM) is one of the most popular AM methods for fabricating metal parts with high precision and acceptable surface finish [3]. The SLM product quality depends on the values of input parameters such as LASER power, scan speed, overlap rate, and hatch distance. Accordingly, fine-tuning those parameters can help achieve a customized design with desired quality and high precision. Failure to tune those parameters properly can result in unacceptable product quality. Besides, in AM technologies, especially SLM printing, energy consumption is higher than in traditional manufacturing processes such as casting [4]. High energy consumption in SLM printing is not desired for modern manufacturing when green technologies are getting more attention [5,6]. Therefore, it is also essential to properly select manufacturing parameters such as LASER power to minimize power consumption.
Many researchers have tried investigating the AM process's output quality to improve the final product's quality [7,8]. Some studies have used experimental observations to investigate the relationship between the SLM printers' input and output parameters. For example, Majeed et al investigated the influence of heat treatment on the product's relative density and porosity [9]. Their research aims to investigate the impact of process settings and heat treatments on the densification and porosity of AlSi10Mg parts manufactured using SLM. Peng et al studied how process parameters, including LASER power, scan speed, and overlap rate affected part quality, electrical energy consumption, and energy effectiveness [10]. Some other researchers have used analytical [11,12] and finite element models (FEM) [13,14] to simulate the 3D printing process and predict the printer's output quality. Simulation-based methods are not always feasible, especially when it is not straightforward to develop an analytical/FEM simulation model of the AM process [15]. In such cases, statistical methods, such as response surface (RS) regression, have been used in the literature [16][17][18]. Most of the mentioned studies face problems in providing an accurate model when facing complicated systems (for example, nonlinear systems) or when multiple quality factors are desired to be predicted through the output quality prediction process.
Machine learning (ML)-based methods have been used to develop a quality prediction model for SLM printers [19,20]. Specifically, knowing that the artificial neural network (ANN) model is a well-known prediction tool for identifying complex relationships between input and output results, it has received an increasing demand in the field of modeling AM process during the recent decade [21]. Moreover, when the relationships of the input-output parameters are not well understood via physics-based models, this approach has shown an acceptable performance in predicting the output parameters [22]. Chowdhury et al studied the application of an ANN model to predict thermal deformation in manufactured parts in the AM process [23]. They claimed that the ANN model resulted in a significant improvement in part accuracy. Ding et al used an ANN model to predict the dimension of a weld bead in arc-welding-based AM for aluminum alloy. Using this model, they found the optimal operational parameters for the welding process [24,25]. Mehrpouya et al applied the ANN models to predict the influence of the operational parameters in various LASER materials processing for metals and polymers [26]. In a particular study, they have developed a prediction model using ANN for optimizing the operational parameters in the AM using NiTi alloy. The model showed an excellent agreement between the predicted values and the experimental data [27]. Another important aspect of SLM technology is its energy consumption. SLM manufacturing, as a modern manufacturing method, is supposed to be a cleaner procedure as compared to traditional methods. They use less raw material and less coolant material; however, their energy usage and emission exceed the traditional manufacturing processes, as shown in table 1 [4]. Many researchers used the energy consumption rate to analyze AM energy consumption characteristics. Sreenivasan et al developed an energy consumption rate for evaluating SLM's sustainability from three perspectives [28]. Meteyer et al presented the SLM process energy and material consumption model and life cycle inventory data for life cycle energy consumption analysis [29]. Baumers and Martin (2012) proposed a method for analyzing the shape complexity of AM practically while also considering construction time, energy flows, and costs [30]. Nelson et al investigated the SLM process and created a one-dimensional thermal model to predict the amount of LASER energy needed to melt the 3D printer raw material [31]. They investigated how LASER scan speed, LASER power, powder size, and powder bed temperature affected the growth of melted layers, among other parameters. Yardimci et al investigated the two main parts of the SLM process: melting and extruding the molten material and deposition and solidification of the extruded material on the part platform and estimated the energy transfer engaged in the second part [32]. They created analytical and numerical models to solve the energy equation and tested them on a test example. Bellini et al analyzed the flow dynamics in an FDM machine's liquefier [33]. They examined three approaches: the power law for Newtonian fluids, a transfer function, and experimental results for calculating the force and power required to extrude the molten material through the liquefier.
A very important aspect of the quality prediction model in AM-based products is the ability to control process parameters to minimize energy consumption while producing the AM product. Huang et al also presented a framework for assessing the overall changes in life cycle primary energy and greenhouse gas emissions related to SLM technologies using a predictive modeling framework [34]. Burkhart and Aurich provided a methodology for predicting AM's environmental impact during the life cycle of the equipment [35]. To reduce energy consumption, some researchers have optimized the AM process parameters. Griffiths et al proposed a waste weight, part weight, energy consumption, and production time-based part optimization experimental design method for AM [36]. The results suggest that the desired response can be obtained by optimizing AM manufacturing parameters and balancing output responses such as waste and production time [36]. Peng et al investigated how to reduce power consumption while maintaining quality by configuring process parameters. The results showed that employing SLM to manufacture parts may save 27.8% of the power while maintaining quality requirements [10]. Qin et al applied data-driven modeling of AM energy consumption and suggested a new deep learning-driven particle swarm optimization (DLD-PSO) method to maximize AM energy usage. They discovered that DLD-PSO is superior to classical particle swarm optimization because it has a faster convergence time and uses less energy [37]. Ma et al proposed a quantitative energy consumption prediction model based on energy units and optimized the energy using the genetic algorithm (GA) for optimal process parameters [38].
Regarding the reviewed literature, producing an AM product from a customized design, i.e. custom output qualities while minimizing energy consumption, need to be further studied. In this sense, this study aims to develop a MIMO quality prediction model for an SLM printer using an optimized neural network to predict four quality measures given four inputs, which helps the manufacturers achieve their custom designs with required qualities through fine-tuning the input parameters of the 3D printer (LASER power, scan speed, overlap rate, and hatch distance). In addition, the study suggests a method to optimize energy consumption with minimum compromising product quality measures (that are relative density, hardness, tensile strength, and porosity). The proposed prediction model and optimization are not limited to SLM, and they can also extend to deal with other AM applications. This paper is extracted from a master's thesis stored at the University of Manitoba's Institutional Repository [39].
This paper is organized as follows. Section 2 introduces the AM process to be modeled, materials used for printing, important parameters and how they have been measured, and also the description of the datasets. Section 3 presents the methodology used for the proposed quality prediction modeling. The accuracy and validity of the proposed prediction modeling are discussed, followed by a sensitivity analysis. Section 3 introduces the proposed method for energy consumption optimization. The parameters considered for the optimization model are discussed. The inputs and outputs of the GA and their roles in solving the optimization model are presented. Concluding remarks are presented in section 5.

Introduction of the SLM printer and datasets
SLM is one of the most popular AM methods for fabricating metal parts with high precision, density, and surface finish [3,7]. In addition, due to certain metallurgical circumstances during the SLM process, such as fast solidification, directional heat flux, and temperature gradient, SLM fabricated parts have higher tensile strength, hardness, and density than traditionally manufactured objects, allowing ultrafine microstructures to form inside the final pieces by using different alloys [40].
Solid components, honeycomb structures, porous structures, thin-walled parts, and other types of parts can be made with SLM in a variety of materials, including titanium alloys, steel, and nickel alloys [5][6][7]. Aluminum alloys have sparked much interest in the SLM technique. AlSi10Mg is a classic cast alloy that is commonly used in die-casting. The automotive and aerospace industries widely use this alloy because of its excellent strength, weldability, hardenability, and mechanical qualities [41]. The LASER melts the alloy powder layerby-layer to prepare a high-quality product until the model is completed.
The chamber of an SLM machine is filled with metal powder. Then a coater blade spreads the metal powder in thin layers across the substrate or builds a plate. A high-powered LASER then selectively melts the powdered material to fuse a 2D slice of the part. One layer's height then lowers the build plate, and the roller delicately spreads another coating of new powder across the surface. The process repeats until the part is complete. The entire procedure that takes place inside the machine in a controlled environment is shown in figure 1. The part can then be removed from the machine once it is completed. First, SLM pieces must be removed from the build plate, which accomplishes with a bandsaw often. The supports must be removed then. It can be time-consuming and challenging because the support material is the same as the part material. In addition, the sintered pieces have a rough surface finish that may require post-processing, depending on the needs. It is common for machine parts to achieve acceptable tolerances and finish fine features, surfaces, and holes.
There are many parameters to be tuned during an SLM process and several output parameters to consider for output quality assessment. We have considered four inputs which are LASER power, scan speed, overlap rate, and hatch distance, and four critical outputs, which are relative density, hardness, tensile strength, and porosity, as the model's training data. In the next two sections, these parameters are explained in detail.

Input parameters
As mentioned, there are various parameters to be tuned for running an SLM process. Those parameters are most critical and can significantly change the output quality. It is important to know the process parameters and understand their role in the SLM process so that in the model training and energy optimization, we can consider the required limitations for each parameter. We take four important parameters as our model's inputs. Those four parameters that are LASER power, scan speed, scan speed, and hatch distance, are explained as follows.
2.1.1. LASER power. LASER power is an important parameter reflecting the energy absorption of powder in the melting process. When the power is not tuned properly high, the powder melts irregularly, resulting in unfused defects and pores in the product. On the other hand, when the LASER power becomes too high, the extra heat cannot be transferred in time, resulting in the easy occurrence of over-burning [42].

Scan speed.
During the SLM sintering process, a higher scan speed results in a smaller size of the molten pool, which leads to a change in the flow of the molten pool and a changing the final quality. At the same time, the droplets in the molten pool are easy to splash, and the microstructure, un-fused defects, and gas holes are easy to occur in the microstructures when an unsuitable scanning speed is used for the printing process. Therefore, in order to achieve a uniform and dense solidified structure, a proper scan speed is vital.

Hatch distance.
The hatch distance strongly influences the surface quality and relative density of the SLM parts. The distance between the centers of one beam and the center of the following beam is used to measure it. The distance between the hatches is related to the rate of production. If it is high, the LASER will take less time to scan the layer. However, if it is low, many scannings will be required to complete the entire layer. Therefore, a smaller hatch distance is required for making a thin layer. To have a large hatch distance, a large LASER spot size is required. Otherwise, there remains a gap between two consecutive scans resulting in porous products. Higher LASER power is required to provide the necessary LASER energy for processing with more significant spot sizes. It means that the maximum hatch distance obtained in a given SLM system is limited [43]. Because the parts are created layer-by-layer, and each layer is manufactured track-by-track, the hatch spacing determines the final density and building speed [4,5]. After comparing the other process parameters, increasing the hatch distance resulted in a higher building speed. However, increasing the hatch distance further results in defective materials melting and excessive porosity. As a result, research efforts are focused on establishing the impact of hatch distance and the melting/solidification method to obtain optimum SLM-processed components [44].

Overlap rate.
The overlap rate is represented by a percentage, and it indicates the areas influenced by repeated melting with the LASER beam and the hatch distance. The local heat input caused by the high-energy LASER beam leads to a high-temperature gradient during the SLM process, which causes high residual stresses and undesired thermal deformations. It even leads to failure to manufacture some parts [45]. The island scanning strategy proved to be a helpful method for reducing residual stress due to the decreased scanning length [6]. However, an overlap region between the islands ensured the close metallurgical bonding of the materials between the islands. The existence of the overlap region can be seen to have a significant influence on parts fabricated by SLM. Previous research showed a vital effect on selective LASER melted characteristics such as surface quality and forming defects [46]. The hatch distance controls the overlap rate of the following tracks, and due to the different overlaps, some sections were irradiated by repeated LASER scans and melted twice. The overlap is required to avoid porosity creation at the scan's boundaries [45].
Besides fine-tuning the mentioned parameters, the utilized SLM powder material is also essential for producing a good product. The final product can suffer different defects such as porosity, voids, powder residue blocking channels, contamination, cracking, deformations, etc. Therefore, product output parameters testing is essential to ensure defect-free parts and meet the production requirements. The output quality parameters that are used in this study are described in the next section.

Output parameters
Manufacturers usually opt for several output quality factors to test the AM product's quality. In this study, we have mainly focused on relative density, hardness, tensile strength, and porosity to measure the properties of products, as those parameters can properly represent the intended quality in most situations [9]. Understanding those parameters is also important as we must use the output quality parameters in the future to define an effective objective function for energy optimization with a minimum trade-off of the final quality.

Relative density.
The ratio of a product's density to the density of a reference substance is known as relative density. It has generally been estimated with respect to water. It is a term that's often used in modern science to establish whether a specific product substance is denser than a reference product. For instance, if the relative density is less than one, the material is less dense, but if the relative density is equal, then the two substances have equal mass. The characteristics of porosity, irregular shape, and fragility result in a high possibility of grain crushing, which further affects the stress-strain behavior and strength of the product. Wang et al address the influence of relative density on the particle breakage of non-uniform grading coral sand by 45 one-dimensional compression tests [47]. Majeed et al aim to study the effect of process parameters and heat treatments such as T4 (solution heat treatment) and T6 (artificial aging) on the densification and porosity of AlSi10Mg parts built by SLM to increase the densification and reduce the porosity of the manufactured products [9].

Hardness.
Hardness is the capability of a product to resist deformation, which is tested by a standard test, which measures the resistance of the surface to indentation. The most common hardness tests are the shape or kind of indent, the size, and the amount of load applied. The hardness numbers are on an arbitrary, non-dimensioned scale, with higher numbers denoting harder surfaces [48]. Hardness testing is frequently the most effective method of ensuring that parts will survive and work as intended. As a result, hardness testing is now an essential aspect of the quality assurance process. To fulfill high-performance requirements, producing fasteners for the aerospace and automotive industries requires a greater focus on quality and material selection. Hardness testing is typically the best way of ensuring that components will function successfully in their intended application.

Tensile strength.
Tensile testing is commonly used to assess the mechanical properties of metals and alloys. The tensile test gives a fundamental understanding of how metals and alloys respond to mechanical loads. When stressed to failure in a tensile test, most structural metals and alloys fracture via ductile processes. Coalescence or a combination of microvoids forms the fracture surface. The coalescence process is influenced by strain rate, test temperature, and microstructure, and under certain conditions (lower temperature, for example), the fracture may change from ductile to brittle processes. Such transitions may limit the alloy's utility and may be detected by strength measurements [49]. Therefore, the tensile test may require interpretation, and interpretation requires a knowledge of the factors that influence the test results.

Porosity.
According to ASTM definitions, there are two types of porosity. Apparent porosity refers to porous defects that occur accidentally in a well-prepared structure and on the AM product's surface. The porosity typically controls the physical properties, such as size, dimensions, shape, and architecture, manufactured by a controlled fabrication process. In recent years, the effect of porous defects on essential mechanical properties like stiffness, strength, and toughness has been extensively studied computationally and experimentally in AM products [50]. Pores can be found in AM-processed products at three critical locations: the excessively rough surface, the sub-surface, and amid deposited layers. The AM process determines the quantity and distribution of air pores in AM-produced products. The mechanical performance of parts produced by powder bed (PBF) and filament extrusion-based AM techniques is mainly affected by porosity. As a result, porosity significantly impacts printed products' quality and reliability, and eliminating or minimizing these adverse effects becomes very important in real-life implementations [51].

Datasets used for model training
A proper dataset is an important factor in any ML-based modeling problem. This research focused on building a quality prediction model and an energy consumption optimization framework for SLM manufacturing, as metal printing AM technologies are expensive and time-consuming. Thus, there are not much data available in the literature to represent the change in output quality parameters versus the changes in input parameters. As there is not much data available for SLM in the existing studies, we have put two different datasets together to develop the prediction model. We have used the best available dataset with the maximum measured inputs and outputs in the existing literature. In this research, sets of four inputs and four outputs were reported from the SLM experiment done by Majeed et al and Peng et al [9,10]. Both these studies used the same experimental and acquisition system. Majeed et al investigated the influence of heat treatment on the product's relative density and porosity [9]. The purpose of their research is to investigate the impact of processing settings and heat treatments like T4 (solution heat treatment) and T6 (artificial ageing) on the densification and porosity of AlSi10Mg parts manufactured using SLM. Peng et al studied how process parameters, including LASER power, scan speed, and overlap rate affected part quality, electrical energy consumption, and energy effectiveness [10]. Merging the reported measurements in [9] and [10] provided us with the most extensive available data in the literature to perform our modeling. As all the settings in those two studies are the same, we directly combined the data without any changes. Moreover, to ensure our model is as inclusive as possible, we have included data from both datasets in training, validation and testing. Combining measured data from those two mentioned studies provides us with twenty-seven experiments to be used for the model development. We will optimize an ANN model to fit these data best.
The experimental data used in this study are presented in table 2. The data includes twenty-seven experiments where four inputs and four outputs were measured in SLM experiments done by Majeed et al and Peng et al [9,10]. We have merged the experimental results in those two studies as they have used exactly the same experimental settings. It is noted that although we have merged the data from those two published studies to enhance the accuracy of our model, more data is needed to increase the ANN reliability and accuracy for generic applications. As it can be seen from the table, and based on the explanation of the dataset, the LASER power range is selected between 320-400 Watts. This range is chosen as higher LASER powers may burn the products, and lower power may cause miss-melting, which reduces the quality. Moreover, the scan speed range is chosen to be 600-900mms −1 to avoid splashes or gas holes. The overlap range is also selected to be in the range of 0.25-0.35 to make sure of removing the space between two scanning. For the Hatch distance, as it can directly affect product density and surface quality, a wide range is considered in the experiments. Also, for the outputs, Archimedes' principle is used to measure the relative density. Tensile strength is measured using Instron electromechanical universal testing machine, and a Leco AMH 43 automatic hardness tester is used for the hardness measurement. The porosity of the samples is also measured using Archimedes' method and microscopic analysis of samples.
In the next section, the dataset introduced in table 2. Will be used to find a multi-input multi-output model for the SLM process.

AM part quality prediction
This section presents the model works correctly and interprets the developed model repeatedly. The model developed in this chapter will be used to optimize energy consumption.

Methodology
The relationship between the process input parameters and output quality measures can be complicated and nonlinear; in such cases, ANN has shown an acceptable performance, and it is being used in this research. Moreover, ANN is often used when the relationship between the variables is uncertain, as in the SLM process [11]. In order to use the ANN efficiently, different NN structure optimization, have been used such as Scikit, Pytorch Lightning, and Keras Tuner. For example, Scikit provides a number of different NN approaches for data preprocessing, feature selection, and model selection. PyTorch Lightning provides a high-level interface for building and training complex deep NN models, with built-in features for distributed training, and Keras Tuner offers a variety of optimization techniques, including random search, hyperband, and Bayesian optimization, to help find the best set of hyperparameters for a given neural network architecture. In this study, we optimize the number of ANN's hidden layers and the number of neurons in each hidden layer using the GA. The GA can offer advantages when searching a large space of potential NN architectures, or when trying to find a globally optimal or near-optimal solution.
The ANN comprises many interconnected neurons arranged in layers (input layer, hidden layers, output layer). The ANN-based model used in this study consists of twentyseven data points represented by {X,Y}, where x i is the input vector representing four parameters that are LASER power, scan speed, overlap rate, and hatch distance, and y i is the output vector representing four output parameters that are LASER power, scan speed, overlap rate, and hatch distance.
The hidden layer is implemented with a sigmoid activation function given below, where b 1 j represents the bias at the hidden layer and ω 1 ji denotes the weight connecting the j-th hidden neuron with the i-th input.
The neurons receive information from the neurons in the previous layer and produce the output with the activation function. Each connection between two adjacent layers has an associated weight, representing its relative importance to other connections. Additionally, a bias term with a trainable value is attached to the nodes of hidden layers and output layer and serves as an intercept term. Finally, the output layer uses a linear function, as in equation (2), where b s is the bias of the output neuron and ω s j represents the weight connecting the j-th hidden neuron to the output. In this study, samples are divided into three groups, 70% for training, 15% for validation, and 15% for testing. Significant differences in the values of the four investigated process parameters of the inputs and the four output quality factors can be seen in table 2. This large difference in the range of those parameters can result in an imbalance in the connection weights and can decrease the model's accuracy. For example, the range of LASER power is 320-400 W, whereas the overlap rate range is 0.25-0.35. These differences will affect the neural network accuracy. Therefore, all inputs and outputs are normalized in the range [0, 1] to improve the model's accuracy.
After normalization, a backpropagation algorithm called gradient descent with momentum is used to solve the ANN model. The values of weights and bias terms were updated with the following equations [52]: where k denotes the iteration number, m k+1 and m k refer to the momentum terms while ω k+1 and ω k refer to the connections weights in two successive iterations k + 1 and k, γ means the momentum factor, η gives the learning rate, and E represents the loss function. The iterative process stops when the predetermined maximum number of iterations is reached or satisfies the accuracy requirement. The training process optimizes the values of the weights and bias terms of the ANN model. Moreover, in this study, to make a more accurate model with less error for different datasets, the number of hidden layers and the number of neurons in each hidden layer are also optimized using a GA. The optimization algorithm has two decision variables which are hidden layers and the number of neurons in each hidden layer. To obtain the proper values for these parameters, the GA's objective function is the mean squared error (MSE) as represented in equation (6). The MSE represents the ANN's prediction accuracy, where y i represents the target output, y i denotes the output predicted by the model, and m is the size of the dataset. The steps of GA-based optimized ANN for developing the quality prediction model are as follows: Step 1 Generate the initial population. In this research, the population is represented as a set of hidden layers and the number of neurons in each hidden layer.
Step 2 Create the ANN model and calculates the objective function (equation (6)).
Step 3 Check the stopping criteria. In this study, the stopping criterion is 1000 generations and 1000 maximum stall generation. Additionally, the average relative change in the best MSE value over maximum stall generations needs to be less than or equal to 1 × 10 −6 .
Step 4 Generate new populations if the stopping criteria are not met. (There are three fundamental operations involved in generating new populations using GA that are selection, crossover, and mutation [53]). Step 5 Replace the old population (hidden layers and number of neurons in each hidden layer) with the best offspring population for the next generation. Figure 2 represents the final ANN setting resulting from the abovementioned optimization framework.

Prediction modeling results
The quality prediction model results and performance analysis are presented in this section. The GA optimization involves four decision variables, namely x 1 , x 2 , x 3 and x 4 . The first three variables, x 1 , x 2 , and x 3 represent the number of neurons of the hidden layers 1, 2, and 3, respectively, while x 4 represents the number of hidden layers (x 4 has a range of 1-3 in our algorithm; so maximum, there are three hidden layers). The initial population is randomly generated within the search space domain (for example, [7,5,6,3] is the initial population for generating figure 3). If the fourth variable, x 4 equals three, all other variables, x 1 , x 2 and x 3 , are used in the algorithm, whereas for x 4 less than three, some other variables are neglected in the algorithm (e.g. x 4 = 1 means there is only one hidden layer, and only x 1 is used to represent the number of neurons of that hidden layer, and x 2 and x 3 are ignored in the algorithm).
The objective function, MSE given in equation (6), is calculated by the neural network for each population, and the resulting MSE value represents the population's prediction accuracy. The lower the MSE value, the higher the prediction accuracy, and it is used to determine a population's survival and ability to create offspring for the next generation. In Table 3. Function parameters of GA.

Parameters Value
Maximum generation 10 000 Maximum stall generation 5000 Population size 100 Crossover fraction 0.9 Function tolerance 1e-6 each generation, the set of hidden layers and the number of neurons in each hidden layer with the best prediction accuracy are chosen using the universal stochastic sampling selection method. The crossover process involves creating a new set of populations for the next generation by crossing the information of the old population, where a set of hidden layers and neurons switch their values to create a new population set. The mutation process involves applying a uniform mutation operator to create small random changes in the hidden layers and neurons and generate a new population. The old population is replaced with the best offspring population for the next generation, and the weights are chosen using the Bayesian regularization backpropagation algorithm. The main GA parameters used in our optimization are presented in table 3. The explained loop continues until the stopping criterion is met and the fitness reaches to a minimum desired value. When running the GA, the best and mean fitness values are important indicators of the algorithm's performance and convergence. The best fitness value represents the fitness of the best solution found so far during the GA's execution. This value indicates the quality of the best solution in the current population and how well it satisfies the fitness function. As the algorithm progresses, the best fitness value should improve over time, and ideally, it should converge to the global optimum of the problem being solved. The mean fitness value represents the average fitness of all the solutions in the current population. This value gives an indication of the overall quality of the population and how well it satisfies the fitness function. As the algorithm progresses, the mean fitness value should improve over time, reflecting the evolution of the population towards better solutions. In general, a GA is considered to have converged when the best fitness value no longer improves significantly over several generations or when it reaches a predefined threshold. At the same time, the mean fitness value should also converge toward a stable value that is close to the optimal fitness value. The convergence of both the best and mean fitness values indicates that the GA has found a good solution to the problem being solved. The performance of our optimization process can be found in figure 3 where after 350 generations, the best fitness does not improve significantly and the mean fitness value becomes stable. Moreover, to illustrate how the decision variables (number of neurons and the number of layers) evolve with iterations, the evolution of decision variables with iterations of the GA is presented in table 4. After 350 generations, the decision variables do not change anymore, which is the optimal solution.
As mentioned in the methodology section, the data set used for the ANN is divided into three groups (training, testing, and validation). The model provided the error of each group. The MSE of each group is shown in table 5. The overall error represents the model's prediction accuracy using the whole data set. In order to compare the performance of our proposed algorithm, with some other well-known NN architectures, a comparison of our method's accuracy and seven other ML algorithms is also presented in the appendix. Moreover, in this study, to validate the model's prediction accuracy, we have conducted overfitting and regression analysis. The results of the ANN model were compared with the experimental data.   Figure 4 provides the prediction trends of the samples for relative density, hardness, tensile strength, and porosity. The xaxis of the plot shows the sample number, and the y-axis represents the four product quality measures. Figure 4 shows the predicted results from the model fit closely with the experimental results.
Moreover, figure 5 shows the performance progress of the ANN training algorithm. The plot specifies the iteration during which the validation performance was at its lowest. If the test curve had climbed significantly before the validation curve increased, then it is possible that some overfitting might have occurred. Overfitting happens when a model is very accurate on the training data but will most likely be inaccurate on the testing data. Generally, when overfitting happens, the model learns the noise in the training data instead of the actual relationships between variables. Figure 5, does not reveal obvious overfitting, showing the model's acceptable performance.
Finally, toward investigating our model's validity, figure 6 shows the regression analysis of the ANN model. The following regression plots display the network outputs with respect to targets for training, validation, test, and overall sets. The targets are represented by the dashed lines in each plot. The solid line represents the best-fit linear regression line between outputs and targets. The R-value represents the relationship between the outputs and the targets. If R = 1, the outputs and targets have a perfect linear connection. There is no linear relationship between outputs and targets if R is close to zero. The training data indicates a decent fit for the trained model. Moreover, R values are high in the validation and test results. Therefore, the validation and test data also have a decent fit. Besides, The R-value for the whole data is 0.94107, which reflects a good fitting of the model. Moreover, in order to better evaluate the performance of the trained ANN, the mean absolute error (MAE), and mean bias error (MBE) are calculated. MAE is usually used to calculate the errors' average magnitude where their sign is not considered. Low values of MAE demonstrates a better prediction accuracy for the model. MBE is also determined using the target output and the network's output when the signs of the error are also considered. The MBA is usually used to evaluate the average model bias which can show if the data is overestimated or underestimated. Too high (positive) and too low MBE values (negative) should be avoided. Equations (7) and (8) are presenting the formulations for calculating MAE and MBE respectively [54,55], In the above equations,ŷ i and y i are the ANN output and target output respectively. The calculated MAE for the developed model is 0.076 and the calculated MBE is 0.009 both showing an acceptable model performance. The MBE also shows that the fitting is almost normal and there is no significant overfitting or underfitting in the model. Moreover, to check the validity of the GA solution, we have used multiple runs with different initial conditions and parameters to check the consistency of the obtained solutions. After this check, the same solution is obtained repeatedly, which can be an indication of reaching a global optimum. Next, in order to better understand the developed model and to better interpret the information we can get from the model, a sensitivity analysis is presented.

Sensitivity analysis
Sensitivity analysis is usually used to determine the input variables' contribution and their importance in manufacturing. Two algorithms called connection weights and Garson's Algorithm have shown an acceptable performance for the AM applications [56], and they are also used in our study. Those algorithms are briefly explained in this section, followed by their results for our model.

Garson's algorithm.
Garson's algorithm is an algorithm being proposed for partitioning the ANN weights to determine the relative importance of each input variable in the network. Garson's algorithm measures the impact of the coefficient based on input-hidden (W) and hidden-output (V) connection weights of the ANN, and the i-th input factor of k-th output sensitivity coefficient. In Garson's algorithm, p (p = 1, 2, …, P) represents the sensitivity coefficient calculated with the p-th input sample value, as shown in the formula below [57], where, i, j, k, respectively, refer to the input layer, hidden layer, and output layer of neurons; w ij are the connection weights between the input layer and the hidden layer neuron, similarly w jk is the connection weights between the hidden layer and output layer neurons, n is the total number of input layer neurons, m is the total number of hidden layer neurons.

Connection weights method.
The connection weight method uses the following equation [56]: where w xy refers to the input-hidden connection weight and v yz is the hidden-output layer connection weight. As can be seen from Garson's method and connection weights method, the weights calculated in the ANN model are being used in both algorithms to find the importance of the input parameters. Figures 7 and 8 presents the results of connection weights and Garson's Algorithm respectively. The bar chart indicates the impact of the input parameters, and the pie chart presents the percentage of the impact of each input for production. Both algorithms confirm that the scan speed is the most important input parameter in the SLM process and hatch distance became the second-best parameter. The sensitivity analysis results enable AM users to make decisions regarding their engineering needs and decide on the specifications of the AM machines they are going to use. In this section, a prediction model based on four inputs and four outputs is developed. In the next section, the developed model will be used to optimize the energy consumption of the modeled SLM printer.

Energy consumption optimization
This chapter presents an energy consumption optimization model. First, the optimization model's details, such as the objective function, constraints, and decision variables, are described. Then, the results obtained from the optimization process are presented and discussed.

Objective function
Multiple energy consumption models have been developed using some process parameters such as LASER power and  Ciurana et al [62] a D: the LASER spot diameter. b t: layer thickness during a single scan. scan speed. Some of the most common models to represent energy consumption are presented in table 6. Where in table 6, LASER power, scan speed, and hatch distance are represented by P, v, and H, respectively. The energy is denoted by E.
From the equations represented in table 6, it is seen that among different parameters used for representing energy consumption, LASER power, scan speed, and hatch distance are more common. Despite the equations represented in table 6, researchers are still exploring more parameters to efficiently control product qualities and energy consumption. Among the available energy consumption models based on process parameters, Peng et al [10] presented one of the most comprehensive published energy consumption models. They have developed a power acquisition system using NI data acquisition and LEM voltage and current sensors [10]. The total energy consumed in their assessed SLM process includes coating energy and building energy. The coating energy is affected by the number of layers, which is determined by build height and layer thickness. Building energy is responsible for the behavior of grain growth and the quality of the fabricated parts. The energy consumption model developed by Peng et al is as follows: where P L represents the LASER power, P A denotes auxiliary LASER power that is a constant (2423 W), n is the number of working LASER that is 2, and ρ p means density. In this study, we are using the model presented in equation (11), as it includes more process parameters and has been validated experimentally. Peng et al reported the lowest energy consumption of 352.4 MJ Kg-1 in their studies, but they did not present any optimization methods for energy consumption.

Decision variables
In our optimization problem, the SLM process input parameters that are introduced in sections 2 and 3 are the decision variables. The variables are chosen here based on the sensitivity analysis performed in the previous section and their importance and effects on energy consumption. LASER power is the primary source of energy consumption. More LASER power means more energy usage. Scanning speed plays a vital role in product quality. A slow scanning speed results in the powder melting properly, which will build a good product at the cost of increased energy consumption. Hatch distance plays a vital role in the surface roughness and relative density of the product. However, if the hatch distance is set high, the LASER needs less time to scan the layer, resulting in reduced energy consumption.

Constraints
As mentioned, SLM is a multi-layers manufacturing process, and processing parameters' range of variation for the multiple layers can be selected based on well-connected tracks in a single layer. In single-track fabrication, excellent consolidation is characterized when the range of LASER power is 320-400 W, and the scan speed is 600-900 mm s −1 . The singletrack surface becomes unstable when the scan speed exceeds 1100 mm s −1 or the LASER power becomes less than 300 W. Better energy efficiency for a single track implies generating a continuous regular straight line with lower LASER power and higher scan speed. However, it may result in unstable and inconsistent tracks at a certain level because the powders cannot consume enough energy to melt entirely, causing the balling effect. The hatch distances of stable single tracks range from 70.9 mm to 116.4 mm. Moreover, when the overlap rate is less than 0.2, the SLM fails to achieve a good interconnection within nearby tracks. In addition to the mentioned input ranges, four quality measures are also considered as optimization constraints to make our model more effective for real industrial applications. The corresponding quality measurements of relative density, hardness, tensile strength, and porosity are also reported in the study by Peng et al [10] and are taken as the minimum requirements of the qualities of our optimization process. The constraints in our optimization are given below: Laser power and scan speed need to be positive integer value.

Optimization process
Considering the introduced objective function, decision variables and their ranges and the constraints on the quality measures, an optimization algorithm is needed to find the optimal values. We have used the GA with the maximum generation and maximum stall generations of 100, as the convergence rate has shown to be fast enough to converge before the 100th iteration. Moreover, to maintain the diversity of the population and avoid premature convergence, 5% of the population was chosen as the elite, which will go directly to the next generation. The chromosomes created by the crossover process are more likely to be better than the parent chromosomes, and that is why the probability of crossover was chosen at 70%. Additionally, a high mutation rate increases the probability of searching more areas in the search space. Therefore, the mutation rate was chosen large enough to avoid local minimums; it is chosen at 6%. At last, the function tolerance is 1 × 10 −6 , which means the algorithm will stop when the average relative change in the best energy consumption value over maximum stall generations is less than or equal to 1 × 10 −6 . Figure 9 shows the flowchart of energy optimization using GA. The steps involved in the flowchart are given below.

Energy consumption optimization results and discussion
The results of the GA optimization to minimize the energy consumption are presented in figure 10. The x-axis represents the generation number in the plot, and the y-axis represents the fitness function value that is the energy consumption. From the optimization, the optimal value of the decision variables is achieved. Table 7 shows the optimal values of the decision variables that are achieved after the GA optimization. Figure 11 presents the variables' values before and after the optimization. From figure 11, it can be seen that the LASER power is significantly reduced. LASER power consumes the most amount of energy during manufacturing. Because of its reduction, the energy consumption reduced considerably after the optimization. The scan speed, hatch distance, and density are inversely proportional to the energy consumption. If they increase, energy consumption will decrease. Scan speed almost remains the same before and after the optimization. With more scan speed, the track of the layer becomes unstable, which will affect the product quality. That is why the scan speed stopped at 899 mm s −1 . Besides, the hatch distance is increased from 94.1 to 116.2 because the hatch distances depend on LASER power and scan speed. If LASER power decrease and scan speed increase, hatch distance will increase, and on the opposite, it will decrease. As the LASER power decreased significantly and scan speed did not reduce so much, the hatch distance increased. Finally, the density is improved to 2.64 gcm −3 . With higher scan speed, hatch distance, and lower LASER power, the product quality can also be improved, which is seen here because the track surface remains stable within this range, which helps to improve product density.
Peng et al [10] reported that the energy consumption of an SLM produce product is 352.20 MJ kg −1 in their study. After our optimization, the energy consumption was reduced to 260.83 MJ kg −1 , a reduction of 26% when maintaining the quality. It is noted that this reduction is compared with the best setting presented in Peng et al [10], which reduced the energy consumption of the process by up to 28%. Figure 12 shows the energy consumption difference before and after the optimization.
It should also be noted that regarding the comparisons made in figures 11 and 12, after our optimization framework, the scan speed decreases by 0.11%, which directly increases the manufacturing required time. However, as the LASER power falls in using our model, the cooling process also takes less time which can compensate for that delay. Moreover, the 26% decrease in LASER power consumption can roughly save 500 USD a month (160 h of operation) based on the average North American electricity rate. That saving, when it becomes large scale, can significantly help the industry reduce production costs.
Moreover, the potential impact of the presented energy optimization on the 3D printing industry is significant, and  can lead to cost savings, improved sustainability, increased efficiency, and practical implementation of energy-efficient strategies, as the presented energy optimization strategies can be implemented relatively easily as most of the process parameters are tunable in modern 3D printers. These improvements can be integrated into existing 3D printing workflows without major modifications or additional costs. As the 3D printing industry continues to grow and evolve, optimizing energy use will become increasingly important for both economic and environmental reasons.  Figure 11. Comparison of decision variables before and after the optimization.

Conclusion
A quality prediction model using experimental data and an energy consumption optimization method for SLM printing is presented in this paper. First, data gathered from two datasets have been combined with being used for ANN modeling.
Then, the ANN model is developed and evaluated using overfitting and sensitivity analysis. Regarding the validation and regression analyses, the developed model was shown to be proficient in predicting SLM products qualities such as relative density, hardness, tensile strength, and porosity based on four crucial process parameters: LASER power, scan speed, hatch distance, and overlap rate. Furthermore, a GA has also been applied to determine the optimal number of hidden layers and the number of neurons in each hidden layer based on minimum MSE to reduce the model's error. The model's results show a fit between the predicted values and the experimental dataset with an accuracy of 98.8%, which proves the model's effectiveness in predicting the SLM product's qualities. Moreover, the sensitivity analysis found that scan speed is the most influential parameter on the final product's quality. Using the developed quality prediction model, an energy consumption optimization model is also developed to minimize the SLM printing's energy consumption considering input parameters' ranges of variation and output parameters' required qualities. After the optimization, the energy consumption is reduced by 26% compared to the previous study performed by Peng et al without compromising the output qualities. The framework presented in this paper is general and is not limited to SLM, and it can also be extended to other AM technologies. Moreover, the proposed prediction model is conducted based on a limited dataset, and it can be further improved if more data are available for future industrial applications.

Data availability statement
All data that support the findings of this study are included within the article (and any supplementary files).

Appendix. Comparison of different methods
The optimization was performed using the neural network's method individually. Gradient descent with momentum (GDM) backpropagation provided the best prediction accuracy among them. Figure A.1 shows the MSE of different NN methods where the x-axis shows the MSE value and the y-axis shows the NN methods.