Modification of Casting Production Parameters in Order to Obtain Products with the Assumed Parameters with Using Machine Learning

A study was carried out on the possibility of using artificial intelligence in the modification of the casting production process. Proposed solution shows the model for our data and how the changes may affect the cost of metal casting. These activities are the subject of the research described in this article. In the proposed solution, the cost function was added to the prediction model developed and presented by Hazela et al. (J Nanomater, 2022). The data obtained as a result of the model operation were verified using a computer simulation and a physical experiment.


Introduction
The works respond to part of the activities aimed at developing an intelligent IT system supporting the casting production process.The problem solved in the course of the described works was a model enabling the modification of production parameters.In order to develop the model, a review of the literature was carried out, in which the methods used to create models supporting the casting production process were important.In the first study, an approach for the application of machine learning in the prediction and understanding of casting surface-related defects is presented. 1This article is based on actual production data from a medium-sized cast steel and cast iron foundry (one foundry).The results of the work indicate which of the algorithms selected and tested as part of the work allow for the best results in the field of Prediction of Casting Surface Defects, taking into account the incomplete and heterogeneous character of data from the foundry.In publication 2 this article, based on data from a pressure foundry, models were developed to detect three types of defects.An important aspect is that these are models for which trees and visualization methods have been used to gain insight into the machine learning process.In another position 3 , the next article deals with defects resulting from inadequate pressure in the casting mold.The article presents an interesting approach consisting in the use of a method of predicting the quality of die castings based on machine learning (XGBoost).Also, in position, 4 the use of a model based on XGBoost to map the complex relationship between the conditions of the die-casting process and the formation of defective rims was indicated.A slightly different approach is indicated in a subsequent publication, 5 where, machine learning methods and techniques (in this case again support vector machine as the classifier) allow to assess which microstructure images represent modified samples.This is an indication of another important activity in the process of casting production process with the possibility of using methods described in research works.Hazela et al. 6 presents a general approach how different AI algorithms can be applied to support production in foundries (not specified in which ones).Sun et al. 7 provides context for unbalanced, semi-supervised, heterogeneous, and limited in sample size for sand cast foundry data.Wilk-Kołodziejczyk et al. 8 is an extension of the topics presented in this article.(Co-authors of the current article describe the prediction methods used and interpret their results.)Park et al. 9 indicates the application of artificial intelligence methods also in relation to image data.Similarly, in positions [9][10][11][12][13][14][15] , the problem solved as part of the described works was a model enabling modification of casting production parameters, mainly in order to improve their quality, reduce costs and avoid defects.On the basis of the possessed set of experimental data and the possibility of verification of the results obtained as a result of the operation of the model, the method of building the model and the method of its verification were selected.Based on the review of the literature, it can be seen that various methods based on artificial intelligence can be used to build the model.The literature also indicates an exemplary method of dealing with data from the production process performed in the foundry.However, we still do not know which model will be appropriate for our data and how the changes may affect the cost of metal casting.These activities are the subject of the research described in this article.

Methodology
Obtaining the appropriate parameters of properties (physical and material properties) of castings is related to the determination and later maintenance of appropriate production parameters.In the case of castings, important parameters that can be changed and controlled may be, for example, the chemical composition of the molten metal, melting and pouring temperature, time (in this process, for example, the aspheritization time can be measured), method of melting and pouring, the type of mold into which the liquid metal is poured, and in some cases its processing parameters.The manufacturing and resulting casting cost are greatly influenced by such changes.Reducing the cost of making a casting requires taking into account the mutual influence of various factors important in the production process.It may be helpful to try to define this problem using a cost function presented in Figure 1.
An attempt of this type was undertaken as part of the research presented in this paper.The first step leading to the development of the cost function was to draw up a diagram illustrating (Figure 1) the dependence of casting parameters and its heat treatment on the price.The model was presented as a function f (X 0 , X 1 , X 2 , X 3 , X 4 , X 5 ).The result of this function is the prediction of the mechanical properties of the casting.Based on the information prepared by experts, 16 as well as tables describing the impact of individual melting parameters on the price of the finished part (assuming a part weight of 1 kg), the cost function was developed: Eqn: 1 where: • CC (chemical composition)-a set of parameters of the chemical composition of the melt • HTP (heat treatment parameters)-a set of heat treatment parameters, which includes the following elements: • Austenitizing temperature, • Austenitizing time, • Ausferritization temperature, • Ausferritization time, • cost_inc_cc (cost increase)-a function that returns the percentage of the cost increase depending on the chemical composition (precisely on the content of nickel, copper and molybdenum), • cost_inc_htp (cost increase)-a function that returns the percentage of the cost increase depending on the value of the heat treatment parameter, • avg_iron_cost (average iron cost)-average price of ductile iron, • htp-parameter from the set of heat treatment parameters, e.g., austenitization temperature, 880 °C,

Cost Function
A review of various casting properties tests shows that these tests are often carried out in the form of experiments in which sets of parameters that are not used in mass production are explored.Such parameter sets may be considered unreliable by the system user.For this purpose, a function was proposed to determine the quality of parameters for user-defined nominal ranges of parameters and weights of these parameters.The value of such a function will determine how much the parameters returned by the system are in line with the user's expectations.The function has following form: where: International Journal of Metalcasting/Volume 17, Issue 4, 2023 • P-set of production parameters (chemical composition, heat treatment) • p-parameter from the set P • in_range-a function that determines whether the value of a given parameter is within a user-defined range • wp-weight of the p parameter, defined by the user

Heuristic Optimization
The work assumes the use of various heuristic algorithms in the field of single-criteria optimization.There is also a need to define a set of parameters that will be explored by algorithms.

A Set of Parameters
The construction of a set of production parameters will be based on: • Possible changes in heat treatment parameters adopted by cast iron manufacturers, i.e., temperature changes by ± 5 degrees Celsius, time changes by ± 15 min.This is a numerical range indicating what changes are possible for the time and temperature of heat treatment of castings (i.e., for auspheritization temperature), • Assumption that the set of chemical compositions is finite and limited to compositions that occurred during training and testing of the predictive model and compositions entered by the user, • Minimum and maximum values of production parameters that occurred during training and testing of the predictive model.
In the case of using single-criteria optimization algorithms, there is a need to bring the previously defined criteria, i.e., cost and quality, to one criterion.One way to do this is to use weighted scalarization, which consists in normalizing the criteria values to the same range of values, e.g., [0,1], and then summing these values multiplied by the weights of these criteria.In this approach, it will be assumed that the user enters the weights of the optimization criteria.The weighted scalarization problem for normalized price and quality criteria looks like this:: where: • CC-a set of parameters of the chemical composition of the melt, • HTP-set of heat treatment parameters • X-set of all possible parameters, • C_norm-normalized value of the cost function, • Q_ norm-normalized value of the quality function, • qH a set of cost and quality criteria weights, • QC function of the following form: QC X 1 ; X the problem presented above consists in minimizing the QC function for production parameters.In order for the solutions found by the algorithm to be correct, restrictions resulting from the parameter values applicable to the species ordered by the customer must be introduced.As can be seen from the above, one of the elements of cost reduction is the control of the chemical composition of the cast detail.Selected methods of creating predictive models used in the process were described in the work 8 by the coauthors of this article.In this work, work was also undertaken to better develop the predictive model.The cost function is one of the elements supporting the casting production process and is very important in the context of the prediction models described in previously publication.
Research was described, the purpose of which was to check which of the algorithms will allow the optimization of cost and quality criteria presented in the form of weighted scalarization (QC function).The research involved the preparation of the following elements: initial solutions that will allow to show how algorithms will cope with cases very distant from optimal solutions-for this purpose, 2 initial solutions were selected in 300 random steps, one of which was selected with the largest value of the cost function and the other with the smallest value of the quality function, • Weights of criteria which, due to the greater complexity of the cost function, were selected with greater consideration of this criterionweights: Configurations have been selected: • {'num_replicas':5, 'minTemperature':1, 'maxTemperature':200}, • {'num_replicas':10, 'minTemperature':10, 'maxTemperature':100} Taking into account two initial solutions, 3 different sets of criteria weights and 9 algorithms (including different configurations for Tabu Search, Metropolis Search and Parallel Tempering), the optimization process was run a total of 54 times.
Running the algorithms resulted in saving the results together for runs with the same initial solution and the same criteria weights.
The results of all launches in such a group are presented in tabular form, with the following columns: • 'algo' -the name of the algorithm along with the configuration of parameters, for example, 'METRO_50' means the Metropolis Search algorithm with the initial temperature parameter of 50, International Journal of Metalcasting/Volume 17, Issue 4, 2023 • 'step' -step of the algorithm in which the best solution was found, • 'millis' -the number of milliseconds after which the best solution was found, • 'qce' -the number of QC function evaluations until the best solution is found, • 'me' -the number of evaluations of mechanical properties until the best solution is found, • 'qc' -the value of the QC function for the best solution.
Then, the best 5 algorithms were selected from each group and their course was presented together on graphs.The xaxis in the graphs is the number of milliseconds since the start, and the y-axis shows the values of the QC function.
Results for the first solution with weights [cost -1.0, quality 0.0].
In Table 1 showing the results of running the algorithms for the configuration contained in the title of this subsection, we can see that the last two algorithms did not cope very well with the optimization task in this case.The first two places were taken by the Tabu Search algorithm with a tabu table of size 10 and 50 minimizing the QC function to the same value.The difference here was the time, which was longer for the second configuration, probably due to more operations performed on the larger tabu table.In addition, the configuration from the first position needed the least time to find the optimal solution.The waveforms of the five best configurations are shown in Figure 2.

Analysis of the results
The analysis of the conducted research brings the following conclusions: Random Descent and Steepest Descent algorithms ended up in local minima in each case and were always outside the top five, • the Parallel Tempering algorithm achieved the best results in the configuration with 5 replicas and temperatures from 1 to 200.It was in the top five 4 times, but compared to competitors it was characterized by a longer time needed for finding the optimal solution, • the Tabu Search algorithm was in the top five 11  times, and the best solutions were found in the configuration with a tabu table of size 50, • Metropolis Search turned out to be the best algorithm, appearing with all its configurations in every top five.The best configuration turned out to be the one with a temperature of 50, which always found an optimal or very close to optimal solution.
The analysis shows that the best algorithms turned out to be: • Tabu Search with tabu table size 50, • Metropolis Search with a starting temperature of 50.
For these two configurations, the search times for nearoptimal solutions, the number of calls to the QC function, and the number of calls to evaluate the mechanical properties model were averaged.The results are presented in Table 2.They show that the Tabu Search algorithm needed on average almost 29 less time to find optimal solutions.When comparing the average number of QC function calls, here the difference is almost 20 times in favor of the Tabu Search algorithm.Similarly for the average number of model evaluations, where the difference here is about 2 times.The values in the table in parentheses were calculated without taking into account the results for TABU_50 from Table 2, because in this case the algorithm did not approach the optimal solution and its results distort the collected statistics to some extent.Taking into account all the results and comparisons, it can be concluded that the Metropolis Search algorithm will be the right choice for the environment in which the evaluation of the mechanical properties model and the evaluation of the QC function will not be a bottleneck because it will be affected by the amount of time needed to find optimal solutions.The Tabu Search algorithm, requiring less time and remembering what solutions are suboptimal, will work when the evaluation of QC models and functions will be more time-consuming.
Predictive algorithms indicated exemplary casting parameters.These data were verified by performing a computer simulation using the MAGMASOFT software and by performing a physical experiment to confirm the validity of the obtained results.

Computer Simulation
Based on the conducted research, certain chemical compositions of cast iron were simulated to obtain prediction of mechanical properties and microstructure.Simulation was conducted in MAGMASoft with the MAGMAIron module which allows for prediction of microstructure and mechanical properties based on chemical composition.For the virtual casting trials, the Y-sample model was used.The geometry of CAD model is presented in Figure 3 and the area of samples analysis.
The iteration setup was prepared based on planned laboratory experiment.The alloy of GJS 500-7 with chemical composition presented in Table 3 was simulated along with filling and solidification.In simultaion pouring temperature was similar to the experimental.Tpour = 1400 °C, as molding material, the green sand was used.For the spheroidization process simulation software allows to set the influence of the modification and inoculation based on 3 possible scenarios which is based on the foundry practice.
Based on the three scenarios of melt treatment, the prediction of mechanical properties was conducted.Use of FeSiMg9 allows to obtain optimal process parameters and final material properties.Visualization of filling process is presented in Figure 4.
Filling time was set to 11s.The temperature drop during filling is approximately 50 °C.Next, the solidification simulation was analyzed.In Figure 5, the solidification path is presented.
The simulation run includes the solidification and cooling to temperature 600 °C, since the phase transformation for cast iron occurs below 720 °C.Time of the solidification and cooling process is approximately 43 min.The solidification occurs from the mold wall toward hot spot, which is located in the center of the feeder part of the casting.The Y-shape sample forces the porosity to occur in the feeder area, which allows to obtain the sample without any defects.Predicted porosity is located in the feeding area (Figure 6).Based on the chosen area of the sample (Figure 3) in Table 3, predicted mechanical properties for different melt treatment scenarios are gathered.
Possibility of using numerical analysis allows to check different boundary and melt treatment conditions and its possible influence on the mechanical properties of the casting (Figure 7).

Experiment
The experimental melt was prepared in a 50-kg-capacity crucible with neutral lining using an electrical induction furnace of an intermediate frequency Radyne AMF 45/100.The furnace charge consisted of pig iron: 4.04 wt% C, 0.77 wt% Si, 0.03 wt% Mn, 0.005 wt% S, 0.043 wt% P), Fe-Si75, Fe-Mn80, carburizer, technically pure Cu and Ni, ductile iron scrap returns.After being melted, the liquid metal was held for about 2 minutes at 1450 °C, than tapped into slim ladle where spheroidization and inoculation processes were performed.As spheroidizing agent a FeSiMg9 master alloy while as inoculant FeSi75 were used.The cast iron was poured at about 1400 °C into 25-mm-thick YII keel-blocks (according to EN 1563 standard) in a green sand mold.The chemical composition tests of the experimental ductile iron were carried out using a GNR S3 MiniLab 300 emission spectrometer with spark excitation.The obtained chemical composition is presented in Tables 4 and 5.

Conclusions and Discussion
Models that use combined methods of classification and prediction allow for obtaining new production parameters without performing high-volume experiments.Additional introduction of the cost function to the built model results in the possibility of reducing the production costs of the cast element.The first important element of model development is the preparation of output data that take into account the parameters of phenomena and mechanisms occurring in the material during casting solidification and are controlled during the production process.It has been proven that a set of parameters normally measured during the production process, even with a small number of test results, can be modeled (reproduced) using machine learning methods and computer simulation.The adaptation of the classification algorithms and their combination with

Figure 1 .
Figure 1.Diagram of the dependence between the parameters of the casting and heat treatment on the physical properties of the casting and the impact on the price of the detail.

Figure 2 .
Figure 2. Graph showing the history of the 5 best algorithms for the first solution with weights [cost -1.0, quality 0.0].

Figure 3 .
Figure 3. Dimensions of Y-sample geometry and cutting area of visualization of simulation results.

Figure 5 .
Figure 5. Solidification path of the Y-shape casting.

Figure 6 .
Figure 6.Prediction of porosity in the casting.

Figure 7 .
Figure 7. Depicts the microstructure of experimental cast iron which consists of graphite nodules embedded in pearlitic matrix consisting of up to 2% of ferrite.Samples for tensile testing where taken from the bottom part of the YII ingots.All the mechanical properties were determined on 5 samples.

Table 1 .
Results Achieved by the Examined Search Algorithms for the First Solution with Weights [Cost -1.0, Quality 0.0]

Table 2 .
Comparison of Tabu Search and Metropolis Search Algorithms in Terms of Average Time, Number of QC Function Calls and Number of Mechanical Properties Model Evaluation Calls

Table 3 .
Predicted Mechanical Properties for Different Melt Treatment Scenarios

Table 4 .
The Chemical Composition of Ductile Iron

Table 5 .
Mechanical PropertiesInternational Journal of Metalcasting/Volume 17, Issue 4, 2023 machine learning algorithms have been verified using a computer simulation, which gives the opportunity to obtain a very precise set of data close to the real ones.The results obtained in the classification process were verified by simulation and a physical experiment was carried out.The algorithm has been enhanced to train the model based on user responses if the microstructure is misclassified.Such an action may lead to a reduction in the number of real tests and thus is associated with a reduction in costs and greater protection of the environment.This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made.The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material.If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.To view a copy of this licence, visit http://creativecommons.org/ licenses/by/4.0/.