# Optimization Design Method of Pipe-Insulating Joints Based on Surrogate Model and Genetic Algorithm
## 2 Methods
### Surrogate Model
#### 2.2.2 Surrogate Model Evaluation Methods  
The essential function of a surrogate model is to fit the relationship between independent and dependent variables with different algorithms adept at solving different types of problems. Therefore, the algorithm for establishing a surrogate model can be flexibly selected based on the target problem. Since current research on insulation joint optimization is relatively limited, the relationship between its dimensions and maximum stress was not well understood prior to this study. Therefore, it was necessary to select algorithms based on different principles and applicable types to maximize the potential for addressing the fitting problem of insulation joints. In this study, the algorithm that best predicts the maximum stress of the right flange among four commonly used fitting algorithms is chosen to build the surrogate model. The four algorithms are ridge regression, decision tree (DT), k-nearest neighbor (KNN), and gradient boosting decision tree (GBDT). Among them, \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**No.**} & \(\mathbf{b_{\text{B1}}}\) & \(\mathbf{b_{\text{B2}}}\) & \(\mathbf{t_{\text{B1}}}\) & \(\mathbf{t_{\text{B2}}}\) & \(\mathbf{\tau_{\text{B1}}}\) \\  & (mm) & (mm) & (mm) & (mm) & (mm) \\ \hline
1 & 76 & 66.4 & 28 & 28 & 5 \\ \hline
2 & 114 & 99.6 & 32 & 42 & 10 \\ \hline
3 & 152 & 132.8 & 36 & 56 & 15 \\ \hline
4 & 190 & 166 & 40 & 70 & 20 \\ \hline
5 & 228 & 199.2 & 44 & 84 & 25 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Range of values for each dimension of the right flange. Figure 8: Dimensions of the right flange. ridge regression is suitable for regression problems and performs better in handling linear relationships. Both GBDT and DT can be applied to regression and classification tasks, effectively addressing nonlinear problems. However, their final performance heavily depends on hyperparameter tuning. KNN is capable of handling both regression and classification tasks and is suitable for various data types, but it suffers from slow computational speed and generally poor performance in high-dimensional problems. Before inputting the algorithm for training, the dataset must be randomly shuffled and then divided, with 80% of the data reserved for the training set and the remaining data for the test set. An additional random test dataset was created in this study to investigate and validate the generalization capability of the fitting algorithms. For the random test dataset, the dimensions of the right flange, except for \(t_{\text{B1}}\), which is taken according to the upper and lower limits of Table 2, are varied by \(\pm 20\%\) from the upper and lower limits of Table 2. Random values within this range were then combined using a random function to generate the dataset, with the specific value ranges shown in Table 3. A random test dataset was established by correlating the size combinations with their corresponding maximum stress, comprising 100 sample points. Before utilizing the training dataset to train the algorithm, it is necessary to perform standard normalization on the data, which can accelerate the model's convergence and prevent gradient explosion. The method employed in this paper is the StandardScaler standard normalization algorithm, which aligns the input and output data with a standard normal distribution. Subsequently, a denormalization process is applied to the output data to revert it to the actual predicted values. The formula for standard normalization is shown in Equation (5):  
\[x^{*}=\frac{x-\mu}{\sigma} \tag{5}\]  
where \(x\) is the original data for a dimension, \(x^{*}\) is the normalized data, \(\mu\) is the mean of the data in the same dimension, and \(\sigma\) is the standard deviation of the data in the same dimension. To validate the performance of various algorithms, this study employs mean absolute error (MAE), root mean square error (RMSE), and the coefficient of determination (\(R^{2}\)) to assess the predictive outcomes of the algorithms.