1. Introduction and Background
Sand casting remains the most widely used casting process, accounting for over 80% of total casting production in China. The production route is long and complex, involving multiple process steps such as core making, molding, melting, pouring, heat treatment, and finishing. Quality problems related to sand casting defects, such as sand holes, shrinkage, and gas porosity, together with insufficient mechanical properties, often lead to direct scrapping of castings. Traditional process parameter settings rely heavily on empirical knowledge and trial-and-error experiments, making it difficult to accurately adjust parameters when failures occur.
With the rapid development of informatization in foundries, enterprise resource planning (ERP) and manufacturing execution system (MES) have recorded massive first-line production data. These data contain valuable information about the relationship between process parameters and final casting quality. The objective of this research is to mine these production data, build data-driven prediction models for mechanical properties and sand casting defects, and then optimize casting process parameters using hybrid algorithms.

2. Data Mining and Analysis of Multi-Process Casting Data
2.1 Production and Inspection Workflow
The sand casting process in this study involves the following key steps: core making, core assembly, sand mixing, molding, closing, melting, pouring, shakeout, fettling, heat treatment, and finishing. Inspection activities are interleaved between processes, including sand strength testing, spectrochemical analysis of alloy composition, X-ray inspection, and tensile testing of attached test bars. These inspections generate quantitative data points that are stored in the ERP system.
2.2 Key Factors Influencing Mechanical Properties and Sand Casting Defects
Through fishbone analysis, the main factors affecting mechanical properties and sand casting defects were identified as:
- Molding sand properties (tensile strength, compressive strength, moisture, compactability)
- Pouring temperature
- Chemical composition (C, Si, Mn, P, S, Cr, Ni, Mo, Cu, V)
- Heat treatment parameters (maximum temperature, holding time, type)
- Environmental conditions (ambient temperature, weather conditions)
2.3 Data Association Using Casting Single-Piece Number
The ERP system tracks each casting with a unique single-piece number. By using this identifier as the primary key, all multi-process parameters were linked to the corresponding quality outputs. The typical casting selected for this study is the 304 stainless steel gland (SCP300/400HA-GR.03). After data cleaning, 696 complete records were obtained. Table 1 summarizes the statistical characteristics of these records.
Table 1: Statistical analysis of process parameters for the 304 steel gland casting
| Parameter | Unit | Max | Min | Mean | Variance |
|—|—|—|—|—|—|
| Sand tensile strength | MPa | 0.863 | 0.189 | 0.387 | 0.168 |
| Sand compressive strength | MPa | 3.183 | 0.491 | 1.916 | 0.480 |
| Ambient temperature | °C | 32.5 | 1 | 13.711 | 7.987 |
| C content | % | 0.071 | 0.050 | 0.057 | 0.007 |
| Si content | % | 0.885 | 0.370 | 0.545 | 0.155 |
| Mn content | % | 1.444 | 0.920 | 1.143 | 0.162 |
| P content | % | 0.040 | 0.025 | 0.033 | 0.005 |
| S content | % | 0.015 | 0.001 | 0.006 | 0.005 |
| Cr content | % | 18.486 | 17.572 | 18.203 | 0.133 |
| Ni content | % | 9.474 | 8.010 | 8.151 | 0.220 |
| Mo content | % | 0.365 | 0 | 0.032 | 0.076 |
| Cu content | % | 0.345 | 0 | 0.011 | 0.057 |
| V content | % | 0.094 | 0 | 0.003 | 0.016 |
| Pouring temperature | °C | 1650 | 1564 | 1610.260 | 14.861 |
| Heat treatment max temperature | °C | 1150 | 630 | 1092.651 | 60.338 |
| Holding time | h | 1 | 0.5 | 0.803 | 0.244 |
| Yield strength | MPa | 315 | 215 | 262.865 | 27.240 |
| Tensile strength | MPa | 595 | 510 | 538.115 | 21.647 |
| Elongation | % | 75 | 52 | 61.374 | 5.612 |
2.4 Linear Regression Baseline
Before applying nonlinear models, multiple linear regression was established for the three mechanical properties using stepwise regression. The adjusted coefficient of determination $R_a^2$ was 0.939 for yield strength, 0.889 for tensile strength, and 0.787 for elongation, as shown in Table 2. The poor performance for elongation suggests a nonlinear relationship between process parameters and mechanical properties, motivating the use of neural networks.
Table 2: Performance of linear regression models for mechanical properties
| Model | S | $R^2$ | $R_a^2$ | $R_a^2$ (pred) |
|—|—|—|—|—|
| Yield strength | 6.82345 | 0.943 | 0.942 | 0.939 |
| Tensile strength | 6.94769 | 0.900 | 0.897 | 0.889 |
| Elongation | 2.52120 | 0.804 | 0.799 | 0.787 |
3. BP Neural Network Prediction Models
3.1 Model Design and Data Preprocessing
The back-propagation (BP) neural network was selected for its strong nonlinear mapping capability. Each record after preprocessing contained 23 input variables: molding sand properties, 10 alloy element contents, pouring temperature, heat treatment parameters, and one-hot encoded categorical variables (heat treatment type and weather condition). The output layer contained one node for each mechanical property or sand hole defect probability. Continuous variables were normalized to [-1, 1] using the formula:
$$x_N = \frac{2x – x_{\max} – x_{\min}}{x_{\max} – x_{\min}}$$
where $x_N$ is the normalized value, $x$ is the original value, and $x_{\min}$, $x_{\max}$ are the minimum and maximum values in the dataset.
Categorical variables (weather condition, heat treatment type) were encoded using one-hot encoding. The dataset was randomly divided into 60% training, 20% validation, and 20% testing sets.
3.2 Determination of Network Structure
The optimal network structure was determined through systematic testing. For tensile strength prediction, single hidden layer structures with 6 to 50 hidden nodes were evaluated using mean squared error (MSE), coefficient of determination ($R^2$), and average error rate (AER). The best single hidden layer configuration was 23-37-1 with MSE = 0.960, $R^2$ = 0.998, and AER = 0.0003. A double hidden layer structure (23-8-4-1) gave MSE = 2.757, which was worse. The comparison is given in Table 3.
Table 3: Comparison of best single and double hidden layer structures
| Hidden layers | Structure | MSE | $R^2$ | AER |
|—|—|—|—|—|
| Single | 23-37-1 | 0.960 | 0.998 | 0.0003 |
| Double | 23-8-4-1 | 2.757 | 0.995 | 0.0005 |
Five learning algorithms were compared: trainlm (Levenberg-Marquardt), trainoss (one-step secant), trainrp (resilient backpropagation), trainscg (scaled conjugate gradient), and traingdx (variable learning rate). The LM algorithm (trainlm) consistently outperformed others in terms of MSE, $R^2$, and AER across different hidden node counts.
3.3 Final Prediction Performance
Table 4 summarizes the final network structures and prediction results for all models.
Table 4: Final network structures and performance metrics
| Model | Structure | Activation | MSE | $R^2$ | AER |
|—|—|—|—|—|—|
| Yield strength | 23-37-1 | tansig-purelin | 2.313 | 0.997 | 0.0005 |
| Tensile strength | 23-37-1 | tansig-purelin | 0.960 | 0.998 | 0.0003 |
| Elongation | 23-45-1 | tansig-purelin | 0.197 | 0.994 | 0.0007 |
| Sand hole defect | 23-35-1 | Relu-Sigmoid | – | accuracy = 93.68% | – |
For the sand hole defect classification problem, the confusion matrix in Table 5 shows that the overall accuracy was 93.68% (652/696). For defect-free samples, the accuracy was 94.44% (594/629); for defective samples with sand casting defects, the accuracy was 86.57% (58/67).
Table 5: Confusion matrix for sand hole defect prediction
| Actual | Predicted: No defect | Predicted: Defect |
|—|—|—|
| No defect | 594 | 35 |
| Defect | 9 | 58 |
3.4 Influence of Each Factor on Mechanical Properties
Using the trained BP model, single-factor influence analyses were performed by varying one factor while keeping others at their mean values. The results for selected elements are shown in Table 6. For example, increasing Ni content from 8.01% to 9.474% increased yield strength from 220.7 to 265.7 MPa (amplitude 45.0 MPa), while tensile strength increased by 25.0 MPa. Ambient temperature also had a significant effect on tensile strength, with an amplitude of 49.7 MPa.
Table 6: Single-factor influence on mechanical properties (ranges and amplitudes)
| Factor | Range | Yield strength (MPa) | Tensile strength (MPa) | Elongation (%) |
|—|—|—|—|—|
| C (%) | 0.05–0.071 | 217.8–238.6 (20.8) | 527.4–530.8 (3.5) | 51.1–72.2 (21.1) |
| Si (%) | 0.37–0.885 | 217.0–239.0 (22.0) | 515.6–542.6 (26.9) | 64.3–66.2 (1.9) |
| Mn (%) | 0.92–1.444 | 221.2–223.3 (2.1) | 511.6–549.9 (38.4) | 56.6–78.8 (22.2) |
| P (%) | 0.025–0.040 | 194.9–255.5 (60.6) | 517.5–538.2 (20.7) | 54.6–71.8 (17.1) |
| Cr (%) | 17.572–18.486 | 219.8–230.7 (10.9) | 517.8–536.0 (18.2) | 58.1–68.1 (10.0) |
| Ni (%) | 8.01–9.474 | 220.7–265.7 (45.0) | 526.5–551.5 (25.0) | 62.6–66.1 (3.5) |
| Pouring temp (°C) | 1564–1650 | 219.8–239.6 (19.8) | 521.9–531.9 (10.0) | 63.6–68.4 (4.7) |
| Ambient temp (°C) | 1–32.5 | 216.8–245.7 (28.9) | 499.2–548.8 (49.7) | 58.9–72.6 (13.7) |
Dual-factor analyses were also conducted, e.g., C-Si, C-Cr, Cr-Ni, and Mn-Ni pairs. The results confirmed that increasing Mn and Ni contents leads to a significant increase in tensile strength, consistent with single-factor trends.
3.5 Sensitivity Analysis Using Garson’s Algorithm
Garson’s algorithm was used to quantify the relative importance of each input variable to the tensile strength output. The improved formula for the sensitivity coefficient $R_k(i)^*$ is:
$$R_k(i)^* = \frac{\sum_{j=1}^{n} \left( |W_{ij} V_{jk}| / \sum_{i=1}^{n} |W_{ij}| \right)}{\sum_{i=1}^{n} \sum_{j=1}^{n} \left( |W_{ij} V_{jk}| / \sum_{i=1}^{n} |W_{ij}| \right)}$$
The analysis showed that Cu content, holding time, sand tensile strength, and P content were the most influential factors for tensile strength. The relative contributions were relatively evenly distributed, confirming the production experience that every process step affects final quality.
4. Process Parameter Optimization under Different Data Volume Scenarios
4.1 Data Volume and Neural Network Prediction Performance
Experiments were conducted using a ZG270-500 carbon steel flange casting with 1126 records. Figure-like analysis showed that when the training set size was below 300, the test $R^2$ was very low (< 0.2). As training data increased to 700 records, $R^2$ reached above 0.9. Table 7 shows the relationship between training set size and test $R^2$.
Table 7: Effect of training data volume on tensile strength prediction
| Training size | Test $R^2$ | Optimal hidden nodes |
|—|—|—|
| 90 | 0.0995 | 5 |
| 180 | 0.17 | 7 |
| 270 | 0.233 | 10 |
| 360 | 0.524 | 15 |
| 450 | 0.659 | 20 |
| 540 | 0.619 | 23 |
| 630 | 0.835 | 28 |
| 720 | 0.876 | 30 |
| 810 | 0.927 | 32 |
| 900 | 0.955 | 34 |
Simulation of a real production scenario, where data accumulate over time, showed that the test $R^2$ improved from 0.784 at 300 training records to 0.964 at 900 training records.
4.2 Hybrid BP Neural Network and Genetic Algorithm
For the scenario with sufficient data, a genetic algorithm (GA) was combined with the BP neural network to solve for optimal process parameters. The fitness function was designed as:
$$gap = \begin{cases}
w_1 |T_{\sigma_s} – \sigma_s| + w_2 |T_{R_m} – R_m| + w_3 |T_A – A| & \text{①} \\
C_{1\max} & \text{②}
\end{cases}$$
$$fitness = C_{2\max} – gap$$
where $T_{\sigma_s}$, $T_{R_m}$, $T_A$ are the user-specified target values for yield strength, tensile strength, and elongation, respectively; $\sigma_s$, $R_m$, $A$ are the predicted values from the BP neural network. Branch ① is executed when the prediction indicates no sand hole defect; branch ② is executed when a defect is predicted, setting the gap to a large constant. The weights $w_1, w_2, w_3$ are user-defined.
The GA parameters were set as: population size 100, crossover probability 0.8, mutation probability 0.001, and maximum generations 500.
4.3 Simulation Test Results
Two simulation experiments were performed.
Table 8: Simulation experiment 1 – target values and predicted results
| Item | Target | Predicted | Difference |
|—|—|—|—|
| Yield strength (MPa) | 315 | 314.80 | 0.20 |
| Tensile strength (MPa) | 530 | 530.22 | 0.22 |
| Elongation (%) | 52 | 52.09 | 0.09 |
| Sand hole defect | No defect | No defect | Consistent |
Table 9: Optimized process parameters for simulation experiment 1
| Category | Parameter | Value |
|—|—|—|
| Molding | Sand tensile strength (MPa) | 0.675 |
| | Sand compressive strength (MPa) | 2.059 |
| | Ambient temperature (°C) | 1.7 |
| | Weather | Sunny |
| Composition | C (%) | 0.059 |
| | Si (%) | 0.841 |
| | Mn (%) | 1.213 |
| | P (%) | 0.028 |
| | S (%) | 0.011 |
| | Cr (%) | 17.999 |
| | Ni (%) | 8.077 |
| | Mo (%) | 0.281 |
| | Cu (%) | 0.073 |
| | V (%) | 0.065 |
| Pouring | Pouring temperature (°C) | 1645 |
| Heat treatment | Max temperature (°C) | 1144 |
| | Holding time (h) | 0.5 |
| | Type | Solution |
In the second experiment, the goal was to reduce Ni content while maintaining similar mechanical properties. By adding the Ni content into the fitness function, the optimization reduced Ni usage from 9.232% to 8.055%, a reduction of 12.7%, while the predicted mechanical properties remained nearly identical (Table 10).
Table 10: Comparison of historical and optimized Ni content
| Parameter | Historical | Optimized |
|—|—|—|
| Ni (%) | 9.232 | 8.055 |
| Predicted yield strength (MPa) | 255 | 255.18 |
| Predicted tensile strength (MPa) | 550 | 549.86 |
| Predicted elongation (%) | 71 | 71.08 |
| Sand hole defect | No | No |
4.4 Nelder-Mead Simplex Method for Scarce Data
When data are insufficient for training neural networks, particularly during the trial production of new products or materials, the Nelder-Mead simplex method (NMSM) provides an efficient direct search alternative. The algorithm iterates through reflection, expansion, contraction, and shrinkage operations. The reflected point is calculated as:
$$x^{(r)} = \bar{x} + \alpha(\bar{x} – x^{(h)})$$
The expansion point is:
$$x^{(e)} = \bar{x} + \gamma(x^{(r)} – \bar{x})$$
The single contraction point is:
$$x^{(c)} = \bar{x} + \beta(x^{(h)} – \bar{x})$$
where $\alpha$, $\gamma$, $\beta$, $\delta$ are coefficients set to 1, 2, 0.5, and 0.5, respectively.
The algorithm was first validated on a numerical function:
$$f(x_1, x_2) = (x_1 – 3)^2 + 2(x_2 + 2)^2, \quad -6 \le x_i \le 6$$
After 16 user interactions, the function values of three random simplexes decreased to 0.125, 0.044, and 0.067, demonstrating fast convergence.
4.5 Optimization of New Inorganic Sand Proportion
The optimization case involved four parameters of a new silicate inorganic binder system: binder addition (%), hardener addition (%), heating temperature (°C), and heating time (s). The objective was to maximize the 24-hour tensile strength of sand specimens, which is critical for preventing sand casting defects such as erosion and sand holes. Table 11 shows the sequential simplex search process.
Table 11: Simplex search process for inorganic sand parameters
| Exp. | Binder (%) | Hardener (%) | Temp (°C) | Time (s) | Strength (MPa) | Simplex vertices | Next action |
|—|—|—|—|—|—|—|—|
| 1 | 1.5 | 30 | 140 | 120 | 0.741 | 1 | Init |
| 2 | 1.5 | 40 | 160 | 140 | 1.409 | 1,2 | Init |
| 3 | 1.5 | 50 | 180 | 160 | 2.292 | 1,2,3 | Init |
| 4 | 2.0 | 30 | 160 | 160 | 1.207 | 1,2,3,4 | Init |
| 5 | 2.5 | 40 | 140 | 160 | 1.005 | 1,2,3,4,5 | Reflect |
| 6 | 2.25 | 50 | 180 | 190 | 3.009 | 2,3,4,5,6 | Expand |
| 7 | 2.625 | 60 | 200 | 225 | 3.005 | 2,3,4,5,6 | Reflect |
| 8 | 1.125 | 45 | 200 | 165 | 1.648 | 2,3,4,6,8 | Reflect |
| 9 | 1.188 | 62.5 | 200 | 167.5 | 2.490 | 2,3,6,8,9 | Reflect |
| 10 | 1.531 | 63.75 | 220 | 201.25 | 3.255 | 3,6,8,9,10 | End |
After only 10 experiments, the 24-hour tensile strength reached 3.255 MPa, much higher than the initial best of 2.292 MPa and worst of 0.741 MPa. This demonstrates that the simplex method can find satisfactory results with very few experiments, making it ideal for scarce-data scenarios.
4.6 Interactive Simplex Search System
To facilitate the practical use of NMSM, an interactive system was proposed and implemented. The system recommends the next experimental point to the user, accepts the user’s experimental result, determines the type of point (reflection, expansion, contraction, or shrinkage), and updates the simplex automatically. This shields the user from complex algorithm details and enables efficient human-in-the-loop optimization. The system creates a new experiment, initializes the simplex, and then iteratively recommends parameter combinations. Users perform physical experiments and enter results, repeating until satisfactory performance is achieved.
5. Development and Application of the Casting Process Parameter Optimization System
5.1 System Architecture
The developed system follows a three-tier architecture: database layer, business logic layer, and presentation layer. MySQL was used for data persistence. The business logic layer handles user management, experiment management, prediction, and optimization logic. The main software framework is JavaEE SSM (Spring + MyBatis + Spring MVC). The system supports three types of experiments: casting quality prediction experiments, process parameter optimization experiments, and simplex search optimization experiments.
5.2 Application Testing
The system was tested using actual production data. The quality prediction module was applied to 18 new production records. The prediction errors are summarized in Table 12.
Table 12: Prediction error on 18 new production records
| Output | Maximum error | Average error (AER) |
|—|—|—|
| Yield strength | 2.09% | 0.75% |
| Tensile strength | 1.94% | 0.89% |
| Elongation | 5.14% | 1.76% |
These small errors confirm the high prediction accuracy of the trained models for new data. The parameter optimization module allows users to enter target mechanical properties and weights, and then solves for the recommended process parameters. The interface also allows locking specific parameters, which are then treated as fixed constraints in the optimization. The interactive simplex module was tested in the inorganic sand optimization experiment described in Section 4.5, successfully guiding the user through ten experiments to reach a high-strength formulation.
6. Conclusion and Outlook
This research demonstrated a complete methodology for using production data to predict and optimize sand casting quality. The key conclusions are:
1. Multi-process production data from an ERP system can be effectively associated using the casting single-piece number, enabling the construction of a high-quality dataset for modeling.
2. BP neural networks significantly outperform linear regression in predicting mechanical properties, with $R^2$ values of 0.997, 0.998, and 0.994 for yield strength, tensile strength, and elongation, respectively. The sand hole defect prediction model achieved an overall accuracy of 93.68%, confirming its ability to foresee sand casting defects.
3. For scenarios with sufficient data, the hybrid BP-GA optimization method can solve for process parameters that meet user-specified mechanical property targets while avoiding sand casting defects. The method successfully reduced Ni usage by 12.7% without compromising performance.
4. For scarce-data scenarios, the interactive Nelder-Mead simplex system provides a simple and fast optimization approach. The new inorganic sand proportion was optimized in only 10 experiments, showing its practical value in reducing experimental costs.
5. The developed sand casting process parameter optimization system integrates prediction, optimization, and interactive simplex functions. Application tests on new production records confirmed high prediction accuracy and useful decision support for process control.
Future work will extend the models to casting families with similar structures and integrate automatic model training when new data are imported. Furthermore, using genetic algorithms to optimize neural network structures could reduce the manual tuning effort and improve training stability.
