A CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM

By optimizing the LSTM neural network with a multi-strategy fusion sparrow search algorithm and constructing the MSSSA-LSTM model, the accuracy and popularity issues of thermal error prediction for CNC machine tool spindles were solved, achieving high-precision and economical thermal error prediction results.

CN119884800BActive Publication Date: 2025-09-23ZHEJIANG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411932910.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-09-23
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

It is difficult to establish a high-precision, economical and widely popular CNC machine tool spindle thermal error prediction model with existing technology, which makes it difficult to effectively reduce the impact of thermal error on machining accuracy.

Method used

The long short-term memory neural network (MSSSA-LSTM) was optimized by the sparrow search algorithm based on multi-strategy fusion. The hyperparameters of LSTM were optimized through cube chaos mapping, levy flight perturbation and adaptive t-distribution mutation strategy. The MSSSA-LSTM model was constructed. The key temperature measurement points were screened and the spindle thermal error was predicted by combining fuzzy C-means clustering and grey relational analysis.

Benefits of technology

The accuracy and robustness of spindle thermal error prediction are improved, achieving higher prediction accuracy and stronger generalization performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119884800B_ABST
    Figure CN119884800B_ABST
Patent Text Reader

Abstract

The present invention discloses a CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM. When the spindle system is idling, the temperature of different temperature measurement points of the machine tool is measured by a temperature sensor, and the z-direction thermal deformation value data of the machine tool spindle is obtained by a displacement sensor. Fuzzy C-means clustering and grey correlation analysis are used to screen out key temperature measurement points, obtain the temperature values ​​and z-direction thermal deformation value data at the key temperature measurement points, and divide the training set and test set into a plurality of sets. An LSTM thermal error prediction model is constructed, and a multi-strategy fusion sparrow search algorithm is used to optimize a series of LSTM hyperparameters. Each sparrow represents a parameter combination of a long short-term memory neural network. The spindle thermal error prediction model of MSSSA-LSTM is constructed. The model is trained using the training set and verified using the test set. The trained model is used to predict the z-direction thermal deformation value of the machine tool spindle. The MSSSA_LSTM thermal error prediction model proposed in the present invention has better prediction accuracy than the unoptimized LSTM model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a CNC machine tool spindle thermal error modeling method based on a multi-strategy fusion sparrow search algorithm to optimize a long short-term memory neural network, and belongs to the field of spindle thermal error prediction. Background Art

[0002] CNC machine tools occupy a vital position in modern manufacturing. Relying on digital control technology, CNC machine tools can perform efficient and precise machining tasks in a highly automated manner, significantly improving production efficiency and machining accuracy. During the machining process, the geometric accuracy of the workpiece is affected by a variety of factors, including machine tool geometric errors, thermal errors, errors caused by cutting forces, and other possible errors. The first two are the main sources of error. In the field of high-precision machining, spindle thermal errors can account for as much as 40%-70% of the total error. Therefore, reducing thermal errors is of great significance to high-precision machine tools.

[0003] Due to the complex spindle structure and internal coupling, heat dissipation is difficult, resulting in uneven heating across various components and a nonuniform temperature field. This in turn causes thermal deformation and errors, reducing machining accuracy. To reduce thermal errors, measures such as thermally symmetrical design, heat source isolation, and spindle structure optimization can be adopted. However, these methods are limited by hardware and technical limitations, are costly, and are difficult to implement for widespread application. Compared to these methods, establishing an accurate and reliable thermal error prediction model to accurately predict and compensate for spindle thermal errors is a more economical and efficient approach. Selecting appropriate temperature measurement points is the foundation and prerequisite for establishing a highly accurate and robust thermal error model. With the increasing popularity of machine learning technology, it has been widely applied to temperature measurement point optimization and spindle thermal error modeling. In this regard, machine learning can use a data-driven approach to select the most representative temperature sensor locations from multiple measurement points, reducing redundant data while improving measurement efficiency and model accuracy, reducing measurement costs, and ensuring model accuracy. In spindle thermal error modeling, machine learning processes large amounts of temperature, spindle speed, and thermal displacement data to capture complex nonlinear relationships, thereby achieving accurate prediction of thermal errors. Regression models such as support vector machines (SVM) and random forests can handle complex feature-output relationships, while time series-based deep learning models such as long short-term memory (LSTM) networks can further enhance the dynamic response to time-varying spindle thermal errors. The multi-strategy fusion sparrow algorithm optimizes the hyperparameters of the LSTM neural network to improve its prediction accuracy. Summary of the Invention

[0004] To address the shortcomings of existing machine tool spindle thermal deformation prediction methods, this paper proposes a CNC machine tool spindle thermal error modeling method based on the MSSSA-LSTM. This method utilizes a multi-strategy fusion of cubic chaos map initialization, levy flight perturbation strategy, and adaptive t-distribution mutation strategy, using a sparrow search algorithm (MSSSA) to optimize a long short-term memory (LSTM) neural network. The MSSSA effectively balances global and local search and optimizes LSTM hyperparameters. By selectively retaining critical information and ignoring irrelevant information, the LSTM excels in processing complex time series data. The MSSSA-LSTM model combines the memory capacity of the LSTM with the global optimization capabilities of the MSSSA, effectively processing complex data and providing more reliable prediction results. Experimental results demonstrate that the MSSSA-LSTM model achieves higher prediction accuracy and greater robustness than the SSA-LSTM model, the LSTM model, and the traditional SVR model.

[0005] In order to achieve the above object, the technical solution adopted by the present invention to solve the technical problem is:

[0006] A CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM includes the following steps:

[0007] Step 1: Build an experimental platform for the spindle system of a CNC machine tool, arrange multiple temperature sensors at the location of the machine tool spindle system, and use a displacement sensor to monitor the z-axis thermal deformation value data of the machine tool spindle;

[0008] Step 2: Conduct an idling experiment on the spindle system of a CNC machine tool. Use a temperature sensor to measure the temperature of different temperature measurement points on the machine tool and the temperature data of the processing environment. Use a displacement sensor to obtain the z-axis thermal deformation value data of the machine tool spindle. Use fuzzy c-means clustering and grey relational analysis to screen out key temperature measurement points. Test the temperature values ​​and z-axis thermal deformation value data of key temperature measurement points at different spindle speeds to obtain a data set and divide it into a training set and a test set.

[0009] Step 3: Build an LSTM thermal error prediction model;

[0010] Step 4: Use the multi-strategy fusion sparrow search algorithm to optimize a series of LSTM hyperparameters including the number of hidden layer nodes, learning rate, and number of training times. Each sparrow represents a set of long short-term memory neural network parameter combinations, and further construct the MSSSA-LSTM spindle thermal error prediction model;

[0011] Step 5: Use the training set of step 2 to train the model described in step 4, and use the test set to verify it. The trained model is used to predict the z-direction thermal deformation value of the machine tool spindle.

[0012] Furthermore, the specific process of step 2 includes the following steps:

[0013] 1) Synchronize the time axis of the two different data sets of the temperature measurement point and the z-axis thermal deformation value obtained in the experiment, and divide the machine tool state into segments at even time intervals. The temperature information and z-axis thermal deformation value information in each segment are the initial sample data of the model;

[0014] 2) Use the average value filtering algorithm to clean the temperature and z-axis thermal deformation values ​​in each sample data;

[0015] 3) Cluster analysis was performed on each temperature measurement point using the fuzzy c-means clustering algorithm to obtain the classification results of temperature measurement points of different categories. Temperature measurement points of the same category were placed into a temperature data group. Then, the correlation between the temperature series of each temperature measurement point and the z-axis thermal deformation series was calculated using grey correlation analysis to obtain the correlation result data of each temperature measurement point. The temperature measurement point with the largest correlation was selected from each temperature data group as the key temperature measurement point.

[0016] 4) The temperature values ​​and z-direction thermal deformation value data of the key temperature measurement points of the spindle at different speeds are preprocessed using the average value filtering algorithm for data cleaning. The characteristic matrix vector of the z-direction thermal deformation value after data preprocessing is used as a label to form a data set corresponding to the temperature characteristic matrix vector, and the data is divided into a training set and a test set.

[0017] Furthermore, the construction process of the LSTM thermal error prediction model described in step 3 is as follows:

[0018] (1) Setting parameter definition: The LSTM algorithm includes a forget gate, an input gate, and an output gate. t is the data set input at the current moment, X t For all x t The collection of C t-1 Indicates the cell state at the previous moment, C t Indicates the cell state at the current moment, h t-1 Indicates the cell output at the previous moment, h t represents the cell output at the current moment, σ represents the sigmoid activation function, and tanh represents the hyperbolic tangent function;

[0019] (2) The specific process of the LSTM algorithm is as follows:

[0020] The forget gate determines which data should be retained and which data should be discarded at the current time step; the sigmoid function outputs a value between 0 and 1. An output value of 1 indicates that the information is fully retained, and an output value of 0 indicates that the information is completely discarded. The calculation formula is as follows:

[0021] f t =σ(W f ·[h t-1 ,x t ]+b f ) #(1)

[0022] Where, f t is the control signal of the forget gate, that is, the retention probability of each element; σ is the sigmoid activation function, W f is the weight matrix of the forget gate, x t is the input at the current moment, b f is the bias of the forget gate;

[0023] The input gate controls how new information is added to the memory cell state. It determines what information needs to be added to the memory cell at the current time step. The calculation formula is as follows:

[0024] i t =σ(W i ·[h t-1 ,x t ]+b i ) #(2)

[0025]

[0026] Where W i , W C are the weight matrices of the screening function and input gate, b i is the bias of the screening function, b C is the bias of the input gate, C t is the control signal of the input gate, C t-1 is the control signal of the input gate at the previous moment, f t is the control signal of the forget gate, i t represents the filtered signal, represents the bias of the input gate;

[0027] The output gate determines the output information of the LSTM unit. The calculation formula is as follows:

[0028] o t =σ(W o ·[h t-1 ,x t ]+b o ) #(5)

[0029] h t =o t tanh(C t ) #(6)

[0030] Where W ois the weight matrix of the output gate, b o is the bias of the output gate, h t-1 Indicates the cell output at the previous moment, h t is the cell output at the current moment, o t is the bias coefficient of the output gate;

[0031] The key temperature measurement point data is used as the input sample set, and the z-axis thermal deformation value feature matrix Z is used as the output sample set. Therefore, the number of LSTM input layer nodes is set to be the same as the number of key temperature measurement points, and the number of output layer nodes is 1.

[0032] Furthermore, the construction process of the spindle thermal error prediction model of step 4 MSSSA-LSTM specifically includes the following steps:

[0033] (1) Use the cube chaos map to initialize the population, determine the number of sparrows in the population N, the upper and lower bounds of the number of hidden layer neurons h, the upper and lower bounds of the learning rate η, the upper and lower bounds of the number of training epochs, determine the dimension d of the search space and the maximum number of iterations M, and use the cube chaos operator to initialize the population. The cube map formula is as follows:

[0034] y(n+1)=4y(n) 3 -3y(n) #(7)

[0035] Where n represents the number of iterations, and y(n) is the individual value after the nth iteration;

[0036] First, a d-dimensional vector y1 is randomly generated, where each dimension ranges from -1 to 1. Then, the cube mapping formula is used to iterate the dimensions of the initial individual to generate the remaining individuals. Finally, the variables generated by the cube mapping are mapped to the sparrow individuals using the following formula:

[0037] X i =X lb +(X lb -X ub )×(y i +1)×0.5 #(8)

[0038] Where, X lb , X ub Respectively represent the upper and lower boundaries of each individual in each dimension; X i is the individual variable value of the actual value, i represents the number of sparrow individuals, which corresponds to the number of iterations in the above cube mapping formula. The number of sparrow individuals is the same as the number of iterations, y i is the individual value generated according to the above cube mapping formula in the case of sparrow individual i;

[0039] (2) Calculate the fitness function of individual sparrows and sort them. The mean square error between the measured value and the predicted value of the LSTM thermal error model is used as the fitness function of the optimization algorithm. The fitness value of each individual sparrow is calculated and sorted according to the mean square error. The individuals are sorted from small to large according to the mean square error. That is, the individuals with smaller errors have higher fitness and are ranked higher.

[0040] (3) Update the discoverer's position. The discoverer is responsible for exploring and finding food in the population, leading the entire population to conduct a global search. If there is no predator threat, the search range will be expanded; if there is a threat, it will migrate to a safer area. The calculation formula for the discoverer's position update is as follows:

[0041]

[0042] Where t and iter max Represents the current number of iterations and the maximum number of iterations, X i,j represents the position information of the i-th sparrow in the j-th dimension, and represents the position information of the i-th sparrow in the j-th dimension at the current iteration and the next iteration respectively. The total number of all dimensions j is the dimension number d. Q is a constant. L is a 1×d matrix with all elements set to 1. α∈(0,1] is a random number. R2 represents the warning value and ST represents the safety value.

[0043] (4) Update follower position: Followers tend to approach the finder or search for food near it. At the same time, some individuals improve their foraging success rate through observation and competition. The Levy flight strategy is integrated into the follower position update calculation formula as follows:

[0044]

[0045] Where, represents the optimal position currently occupied by the discoverer after the discoverer position is updated in step (3), Indicates the current global worst position; when i>n / 2, this indicates that the i-th follower with a lower fitness value has not obtained food and is in a very hungry state. At this time, it needs to fly to other places to find food to obtain more energy; represents the Hadamard product symbol;

[0046] The Levy flight strategy formula is:

[0047]

[0048] Where r1 and r2 are two random numbers uniformly distributed in the range [0,1], which are used to introduce randomness, σ is the scale parameter, and β′ is the exponential parameter in the Levy distribution.

[0049] (5) Position adjustment when avoiding predators: When 10%-20% of the sparrows sense danger, the edge individuals quickly move to the safe area, while the inner individuals randomly adjust their positions to get closer to the group. The position update method is calculated as follows:

[0050]

[0051] Where, represents the current global optimal position, β is the step size control parameter, which obeys the normal distribution with mean 0 and variance 1; K∈[-1,1] is a random number that controls the direction and amplitude of the position update, f i represents the fitness value of the current sparrow individual; f g and f w are the current global best and worst fitness values ​​respectively; ε is a small constant, for example, it is 10 -6 , used to prevent the denominator from being zero;

[0052] (6) Adaptive t-distribution mutation strategy: By introducing the flexibility and adaptive adjustment mechanism of the t-distribution, the solutions generated at different stages of the algorithm can both conduct fine local searches and explore the global scope, effectively balancing local search and local development. During the iteration process, the shape of the t-distribution is dynamically adjusted through the degree of freedom parameter m, thereby changing the mutation mode of individual sparrows:

[0053]

[0054] Where, is the position of the sparrow after mutation, X i is the position of the i-th sparrow, t(M) is the t-distribution with the number of iterations as the degree of freedom, and M is the number of iterations. This variation is similar to the Cauchy distribution variation in the early stages, allowing individuals to have a larger search range. In the later stages, as the number of iterations increases, the t-distribution becomes similar to the Gaussian distribution variation, which is more inclined to local search.

[0055] (7) Repeat steps (2-6) until the maximum number of iterations is reached, terminate the loop, and output the optimal parameter combination;

[0056] (8) The optimal parameter combination is input into the LSTM neural network for training.

[0057] Compared with the prior art, the present invention has the following characteristics:

[0058] 1) The MSSSA_LSTM thermal error prediction model proposed in this invention has better prediction accuracy than the unoptimized LSTM model.

[0059] 2) The MSSSA_LSTM proposed in this invention has better generalization performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 Schematic diagram of the LSTM neural unit structure of the present invention;

[0061] Figure 2 Flowchart for establishing the MSSSA-LSTM model of the present invention;

[0062] Figure 3 This is a comparison chart of the actual value of the spindle thermal error under the 5000 r / min working condition in Example 1 of the present invention and the predicted results of each model;

[0063] Figure 4 Based on Figure 3 The residual diagram of the spindle thermal error prediction results under the 5000r / min working condition calculated by the results;

[0064] Figure 5 This is a comparison chart of the actual value of the spindle thermal error under the 2000 r / min working condition in Example 1 of the present invention and the predicted results of each model;

[0065] Figure 6 Based on Figure 5 The residual diagram of the spindle thermal error prediction results under the 2000r / min working condition calculated by the results;

[0066] Figure 7 This is a comparison chart of the actual value of the spindle thermal error under the 8000 r / min working condition in Example 1 of the present invention and the predicted results of each model;

[0067] Figure 8 Based on Figure 7 The residual diagram of the spindle thermal error prediction results under the 8000r / min working condition is calculated. DETAILED DESCRIPTION

[0068] Example 1:

[0069] A spindle thermal error modeling method based on multi-strategy fusion sparrow algorithm optimization long short-term memory neural network includes the following steps:

[0070] Step 1: Build an experimental platform, arrange appropriate temperature sensors and displacement sensors, conduct a thermal error experiment on the spindle under no-load conditions, and collect real-time temperature and thermal displacement data at spindle speeds of 2000 rpm, 5000 rpm, and 8000 rpm.

[0071] Step 2: Use fuzzy c-means clustering and grey relational analysis to screen out key temperature measurement points and divide them into training and test sets;

[0072] Step 3: Build an LSTM thermal error prediction model;

[0073] Step 4: Use the multi-strategy fusion sparrow search algorithm to optimize a series of hyperparameters such as the number of hidden layer nodes, learning rate, and number of training times of the LSTM. Each sparrow represents a set of parameter combinations of the long short-term memory neural network, and further construct the spindle thermal error prediction model of the MSSSA-LSTM.

[0074] Step 5: Using 5000 rpm data as input, the constructed MSSSA-LSTM spindle thermal error prediction model is compared with the SVR and LSTM thermal error prediction models constructed based on the same experimental data to verify the model's fitting performance.

[0075] Step 6: Select the first 70% of the data under the 5000 rpm and 8000 rpm conditions as the training set for the thermal error prediction input model to verify the prediction performance of the thermal error prediction model on unknown data.

[0076] Furthermore, the step one is specifically as follows: building a spindle thermal error data acquisition test bench, arranging multiple temperature sensors at locations where the temperature rise of the machine tool spindle system is obvious, and the temperature sensor position distribution is shown in Table 1. The temperature field information of the machine tool spindle system at 2000r / min, 5000 rpm, and 8000r / min under idling is collected respectively. The experiment is carried out for a total of 4 hours. At the same time, a displacement sensor is used to monitor the z-direction thermal deformation value data of the machine tool spindle, and the collected data is saved in a computer for subsequent processing and application.

[0077] Table 1 Temperature sensor location distribution

[0078]

[0079] Furthermore, the step 2 is specifically as follows:

[0080] (1) The two different sets of experimentally obtained temperature and z-axis thermal deformation data are synchronized on the time axis. The machine tool state is divided into 240 segments at 1-minute time intervals according to the total experimental duration. The temperature field information and z-axis thermal deformation value information in each segment are the initial sample data of the model.

[0081] (2) The temperature and z-direction thermal deformation values ​​in each sample data are cleaned using the average value filtering algorithm;

[0082] (3) The temperature measurement points are clustered using fuzzy C-means clustering. The clustering results are shown in Table 2. Then, the correlation between the temperature sequence and the thermal error sequence is calculated using grey correlation analysis. The correlation results of each temperature measurement point are shown in Table 3. The point with the largest correlation in each category is selected as the key temperature measurement. Therefore, the best thermal sensitive temperature measurement points are T2, T3, T7, and T10.

[0083] Table 2 FCM clustering results

[0084]

[0085] Table 3 Grey correlation degree of temperature measurement points

[0086]

[0087] (4) The z-axis thermal deformation value feature matrix vector after data preprocessing is used as a label and corresponds to the temperature feature matrix vector to form a data set, and the data is divided into a training set and a test set. In this way, data sets can be obtained under the spindle speed conditions of 2000r / min, 5000r / min, and 8000r / min respectively.

[0088] Furthermore, the specific step three is as follows: LSTM algorithm, through its unique gating mechanism including forget gate, input gate and output gate, can retain important information and pass it to the next unit when processing long sequence data, while discarding unimportant information. LSTM effectively captures and retains the dependencies in long time series, and can maintain the stability of gradient, thus avoiding the problem of gradient vanishing or exploding. The LSTM neural network structure is shown in the figure below. Figure 1 As shown, X t is the data set input at the current moment, X t For all x t The collection of C t-1 Indicates the cell state at the previous moment, C t Indicates the cell state at the current moment, h t-1 Indicates the cell output at the previous moment, h t represents the cell output at the current moment, σ represents the sigmoid activation function, and tanh represents the hyperbolic tangent function;

[0089] The specific process of the algorithm is as follows:

[0090] The forget gate determines which data should be retained and which should be discarded at the current time step. The sigmoid function outputs a value between 0 and 1. A value of 1 means that the information is fully retained, and a value of 0 means that the information is completely discarded. The calculation formula is as follows:

[0091] f t =σ(W f ·[h t-1 ,x t ]+b f )#(1)

[0092] Where, f tis the control signal of the forget gate, that is, the retention probability of each element. σ is the sigmoid activation function, W f is the weight matrix of the forget gate, x t is the input at the current moment, b f is the bias of the forget gate.

[0093] The input gate controls how new information is added to the memory cell state. It determines what information needs to be added to the memory cell at the current time step. The calculation formula is as follows:

[0094] i t =σ(W i ·[h t-1 ,x t ]+b i )#(2)

[0095]

[0096] Where W i , W C are the weight matrices of the screening function and input gate, b i is the bias of the screening function, b C is the bias of the input gate, C t is the control signal of the input gate, C t-1 is the control signal of the input gate at the previous moment, f t is the control signal of the forget gate, i t represents the filtered signal, Represents the bias of the input gate.

[0097] The output gate determines the output information of the LSTM unit. The calculation formula is as follows:

[0098] o t =σ(W o ·[h t-1 ,x t ]+b o )#(5)

[0099] h t =o t tanh(C t )#(6)

[0100] Where W o is the weight matrix of the output gate, b o is the bias of the output gate, h t-1 Indicates the cell output at the previous moment, h t is the cell output at the current moment, o t is the bias coefficient of the output gate.

[0101] Specifically, the process of building an LSTM model is as follows:

[0102] The key temperature point data is used as the input sample set, and the z-axis thermal deformation value feature matrix Z is used as the output sample set. Therefore, the number of LSTM input layer nodes is set to 4 and the number of output layer nodes is set to 1.

[0103] Furthermore, the step 4 is specifically as follows:

[0104] In the present invention, the number of neurons h in the two hidden layers, the learning rate η, and the number of training epochs are important parameters of the LSTM neural network. The multi-strategy fusion sparrow algorithm shows the advantages of strong adaptability and few adjustable parameters in the swarm intelligence optimization algorithm. It can well balance global and local searches and is suitable for parameter optimization of the LSTM neural network. The process of the MSSSA-LSTM thermal error model is as follows: Figure 2 As shown, specifically:

[0105] (1) Use the cube chaos map to initialize the population, determine the number of sparrows in the population N, the upper and lower bounds of the number of hidden layer neurons h, the upper and lower bounds of the learning rate η, the upper and lower bounds of the number of training epochs, determine the dimension d of the search space and the maximum number of iterations M, and use the cube chaos operator to initialize the population. The cube map formula is as follows:

[0106] y(n+1)=4y(n) 3 -3y(n) #(7)

[0107] Where n represents the number of iterations, and y(n) is the individual value after the nth iteration.

[0108] First, a d-dimensional vector y1 is randomly generated, where each dimension ranges from -1 to 1. Then, the cube mapping formula is used to iterate the dimensions of the initial individual to generate the remaining individuals. Finally, the variables generated by the cube mapping are mapped to the sparrow individuals using the following formula:

[0109] X i =X lb +(X lb -X ub )×(y i +1)×0.5 #(8)

[0110] Where, X lb , X ub Respectively represent the upper and lower boundaries of each individual in each dimension; X i is the individual variable value of the actual value, i represents the number of sparrow individuals, which corresponds to the number of iterations in the above cube mapping formula. The number of sparrow individuals is the same as the number of iterations, y iIt is the individual value generated according to the above cube mapping formula in the case of sparrow individual i.

[0111] (2) Calculate the fitness function of individual sparrows and sort them. The mean square error between the measured value and the predicted value of the LSTM thermal error model is used as the fitness function of the optimization algorithm. The fitness value of each individual sparrow is calculated and sorted according to the mean square error. The individual sparrows are sorted from small to large according to the mean square error. That is, the smaller the error, the higher the fitness of the individual and the higher the ranking.

[0112] (3) Update the discoverer's position. The discoverer is responsible for exploring and finding food in the population, leading the entire population to conduct a global search. If there is no predator threat, the search range will be expanded; if there is a threat, it will migrate to a safer area. The calculation formula for the discoverer's position update is as follows:

[0113]

[0114] Where t and iter max Represents the current number of iterations and the maximum number of iterations, X i,j represents the position information of the i-th sparrow in the j-th dimension, and represents the position information of the i-th sparrow in the j-th dimension at the current iteration and the next iteration, respectively. The total number of all dimensions j is the dimension number d. Q is a constant. L is a 1×d matrix with all elements set to 1. α∈(0,1] is a random number. R2 represents the warning value, and ST represents the safety value.

[0115] (4) Update follower position: Followers tend to approach the finder or search for food near it. At the same time, some individuals improve their foraging success rate through observation and competition. The calculation formula for the follower's position update is as follows:

[0116]

[0117] Where, represents the optimal position currently occupied by the discoverer after the discoverer position is updated in step (3), Indicates the current global worst position. When i>n / 2, this indicates that the i-th follower with a lower fitness value has not obtained food and is in a very hungry state. At this time, it needs to fly to other places to find food to obtain more energy; Represents the Hadamard product symbol.

[0118] The Levy flight strategy formula is:

[0119]

[0120] Where r1 and r2 are two random numbers uniformly distributed in the range [0,1], which are used to introduce randomness, σ is the scale parameter, and β′ is the exponential parameter in the Levy distribution.

[0121] (5) Position adjustment when avoiding predators: When 10%-20% of the sparrows sense danger, the edge individuals quickly move to the safe area, while the inner individuals randomly adjust their positions to get closer to the group. The position update calculation formula is as follows:

[0122]

[0123] Where, represents the current global optimal position, β is the step size control parameter, which obeys the normal distribution with mean 0 and variance 1; K∈[-1,1] is a random number that controls the direction and amplitude of the position update, f i represents the fitness value of the current sparrow individual; f g and f w are the current global best and worst fitness values ​​respectively; ε is a small constant used to prevent the denominator from being zero.

[0124] (6) Adaptive t-distribution mutation strategy: By introducing the flexibility and adaptive adjustment mechanism of the t-distribution, the solutions generated at different stages of the algorithm can both conduct fine local searches and explore the global scope, effectively balancing local searches and local development. During the iteration process, the shape of the t-distribution is dynamically adjusted through the degree of freedom parameter m, thereby changing the mutation mode of individual sparrows:

[0125]

[0126] Where, is the position of the sparrow after mutation, X i is the position of the i-th sparrow, t(M) is a t-distribution with the number of iterations as the degree of freedom, and M is the number of iterations. This variation is similar to the Cauchy distribution in the early stages, allowing individuals to search a wider range. Later, as the number of iterations increases, the t-distribution becomes more like the Gaussian distribution, favoring a more localized search.

[0127] (7) Repeat steps (2-6) until the maximum number of iterations is reached, terminate the loop, and output the optimal parameter combination.

[0128] (8) The optimal parameter combination is input into the LSTM neural network for training.

[0129] Furthermore, the step 5 is specifically as follows: To verify the effectiveness of the MSSSA-LSTM model, the data obtained under the spindle speed of 5000r / min is trained to build a spindle thermal error prediction model, and a comparative analysis is performed with the SVR, LSTM and SSA-LSTM thermal error prediction models built based on the same experimental data. The optimized network model parameters are shown in Table 4, and the prediction results and residual graphs of each model are shown in Table 4. Figure 3-4 As shown in Table 5, the root mean square error of the MSSAA-LSTM prediction model is 0.18123, the absolute mean error is 0.14403, and the determination coefficient R 2 is 0.9991, which is the best among the four models and has higher prediction accuracy.

[0130] Table 4 MSSSA-LSTM network model parameters

[0131]

[0132] Table 5 Comparison of evaluation parameters of each prediction model at spindle speed of 5000 rpm

[0133]

[0134] Furthermore, the step six is ​​specifically as follows: verifying the prediction accuracy of the thermal error prediction model on unknown data is an important criterion for evaluating the reliability of the model. In order to verify the generalization ability of the model, the first 70% of the data under the spindle speed conditions of S1=2000r / min and S2=8000r / min are selected as the training set for thermal error prediction, and the root mean square error under the two conditions is calculated respectively, which is recorded as RMSE1 and RMSE2. RMSE1 and RMSE2 represent the root mean square error results calculated under the spindle speed conditions of S1=2000r / min and S2=8000r / min respectively. The prediction results and residual results of SVR, LSTM, SSA-LSTM and MSSSA-LSTM are shown as follows: Figure 5-8 As shown in Table 6, the residual value = true value - model prediction value. Table 6 compares the prediction accuracy of different prediction models under two operating conditions. It can be seen that the MSSSA-LSTM model achieves the lowest RMSE1 and RMSE2 values, at 0.1675 μm and 1.1849 μm, respectively. This indicates that the MSSSA-LSTM prediction model outperforms the unoptimized LSTM model and the traditional support vector regression model in predicting performance at different spindle speeds, demonstrating stronger generalization capabilities.

[0135] Table 6 Comparison of prediction accuracy of different models

[0136]

Claims

1. A CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM, characterized by The following steps are involved: Step 1: Build an experimental platform for the spindle system of a CNC machine tool, arrange multiple temperature sensors at the location of the machine tool spindle system, and use a displacement sensor to monitor the z-axis thermal deformation value data of the machine tool spindle; Step 2: Conduct an idling experiment on the spindle system of a CNC machine tool. Use a temperature sensor to measure the temperature of different temperature measurement points on the machine tool and the temperature data of the processing environment. Use a displacement sensor to obtain the z-axis thermal deformation value data of the machine tool spindle. Use fuzzy c-means clustering and grey relational analysis to screen out key temperature measurement points. Test the temperature values ​​and z-axis thermal deformation value data of key temperature measurement points at different spindle speeds to obtain a data set and divide it into a training set and a test set. Step 3: Build an LSTM thermal error prediction model; Step 4: Use the multi-strategy fusion sparrow search algorithm to optimize a series of LSTM hyperparameters including the number of hidden layer nodes, learning rate, and number of training times. Each sparrow represents a set of long short-term memory neural network parameter combinations, and further construct the MSSSA-LSTM spindle thermal error prediction model; The spindle thermal error prediction model of the MSSSA-LSTM adopts an adaptive t-distribution mutation strategy. By introducing the flexibility and adaptive adjustment mechanism of the t-distribution, the solutions generated at different stages of the algorithm can both conduct refined local searches and explore the global scope, effectively balancing local search and local development. During the iteration process, the shape of the t-distribution is dynamically adjusted through the degree of freedom parameter m, thereby changing the mutation mode of individual sparrows: Where, is the position of the sparrow after mutation, X i is the position of the i-th sparrow, t(M) is the t-distribution with the number of iterations as the degree of freedom, and M is the number of iterations. This variation is similar to the Cauchy distribution variation in the early stages, allowing individuals to have a larger search range. In the later stages, as the number of iterations increases, the t-distribution becomes similar to the Gaussian distribution variation, which is more inclined to local search. Step 5: Use the training set of step 2 to train the model described in step 4, and use the test set to verify it. The trained model is used to predict the z-direction thermal deformation value of the machine tool spindle.

2. A CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM as claimed in claim 1, characterized in that The specific process of step 2 includes the following steps: 1) Synchronize the time axis of the two different data sets of the temperature measurement point and the z-axis thermal deformation value obtained in the experiment, and divide the machine tool state into segments at even time intervals. The temperature information and z-axis thermal deformation value information in each segment are the initial sample data of the model; 2) Use the average value filtering algorithm to clean the temperature and z-axis thermal deformation values ​​in each sample data; 3) Cluster analysis was performed on each temperature measurement point using the fuzzy c-means clustering algorithm to obtain the classification results of temperature measurement points of different categories. Temperature measurement points of the same category were placed into a temperature data group. Then, the correlation between the temperature series of each temperature measurement point and the z-axis thermal deformation series was calculated using grey correlation analysis to obtain the correlation result data of each temperature measurement point. The temperature measurement point with the largest correlation was selected from each temperature data group as the key temperature measurement point. 4) The temperature values ​​and z-direction thermal deformation value data of the key temperature measurement points of the spindle at different speeds are preprocessed using the average value filtering algorithm for data cleaning. The characteristic matrix vector of the z-direction thermal deformation value after data preprocessing is used as a label to form a data set corresponding to the temperature characteristic matrix vector, and the data is divided into a training set and a test set.

3. A CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM as claimed in claim 1, characterized in that The construction process of the LSTM thermal error prediction model described in step 3 is as follows: (1) Setting parameter definition: The LSTM algorithm includes a forget gate, an input gate, and an output gate. t is the data set input at the current moment, X t For all x t The collection of C t-1 Indicates the cell state at the previous moment, C t Indicates the cell state at the current moment, h t-1 Indicates the cell output at the previous moment, h t represents the cell output at the current moment, σ represents the sigmoid activation function, and tanh represents the hyperbolic tangent function; (2) The specific process of the LSTM algorithm is as follows: The forget gate determines which data should be retained and which data should be discarded at the current time step; the sigmoid function outputs a value between 0 and 1. An output value of 1 indicates that the information is fully retained, and an output value of 0 indicates that the information is completely discarded. The calculation formula is as follows: f t =σ(W f ·[h t-1 ,x t ]+b f ) (1) Where, f t is the control signal of the forget gate, that is, the retention probability of each element; σ is the sigmoid activation function, W f is the weight matrix of the forget gate, x t is the input at the current moment, b f is the bias of the forget gate; The input gate controls how new information is added to the memory cell state. It determines what information needs to be added to the memory cell at the current time step. The calculation formula is as follows: i t =σ(W i ·[h t-1 ,x t ]+b i ) (2) Where W i , W C are the weight matrices of the screening function and input gate, b i is the bias of the screening function, b C is the bias of the input gate, C t is the control signal of the input gate, C t-1 is the control signal of the input gate at the previous moment, f t is the control signal of the forget gate, i t represents the filtered signal, represents the bias of the input gate; The output gate determines the output information of the LSTM unit. The calculation formula is as follows: the t =σ(W o ·[h t-1 ,x t ]+b o ) (5) h t =o t ·tanh(C t ) (6) Where W o is the weight matrix of the output gate, b o is the bias of the output gate, h t-1 Indicates the cell output at the previous moment, h t is the cell output at the current moment, o t is the bias coefficient of the output gate; The key temperature measurement point data is used as the input sample set, and the z-axis thermal deformation value feature matrix Z is used as the output sample set. Therefore, the number of LSTM input layer nodes is set to be the same as the number of key temperature measurement points, and the number of output layer nodes is 1.

4. A CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM as claimed in claim 1, characterized in that Step 4: The construction process of the MSSSA-LSTM spindle thermal error prediction model includes the following steps: (1) Use the cube chaos map to initialize the population, determine the number of sparrows in the population N, the upper and lower bounds of the number of hidden layer neurons h, the upper and lower bounds of the learning rate η, the upper and lower bounds of the number of training epochs, determine the dimension d of the search space and the maximum number of iterations M, and use the cube chaos operator to initialize the population. The cube map formula is as follows: y(n+1)=4y(n) 3 -3y(n) (7) Where n represents the number of iterations, and y(n) is the individual value after the nth iteration; First, a d-dimensional vector y1 is randomly generated, where each dimension ranges from -1 to 1. Then, the cube mapping formula is used to iterate the dimensions of the initialized individual to generate the remaining individuals. Finally, the variables generated by the cube mapping are mapped to the sparrow individuals using the following formula: X i =X lb +(X lb -X ub )×(y i +1)×0.5 (8) Where, X lb , X ub Respectively represent the upper and lower boundaries of each individual in each dimension; X i is the individual variable value of the actual value, i represents the number of sparrow individuals, which corresponds to the number of iterations in the above cube mapping formula. The number of sparrow individuals is the same as the number of iterations, y i is the individual value generated according to the above cube mapping formula in the case of sparrow individual i; (2) Calculate the fitness function of individual sparrows and sort them. The mean square error between the measured value and the predicted value of the LSTM thermal error model is used as the fitness function of the optimization algorithm. The fitness value of each individual sparrow is calculated and sorted according to the mean square error. The individuals are sorted from small to large according to the mean square error. That is, the individuals with smaller errors have higher fitness and are ranked higher. (3) Update the discoverer's position. The discoverer is responsible for exploring and finding food in the population, leading the entire population to conduct a global search. If there is no predator threat, the search range will be expanded; if there is a threat, it will migrate to a safer area. The calculation formula for the discoverer's position update is as follows: Where t and iter max Represents the current number of iterations and the maximum number of iterations, X i,j represents the position information of the i-th sparrow in the j-th dimension, and represents the position information of the i-th sparrow in the j-th dimension at the current iteration and the next iteration respectively. The total number of all dimensions j is the dimension number d. Q is a constant. L is a 1×d matrix with all elements set to 1. α∈(0,1] is a random number. R2 represents the warning value and ST represents the safety value. (4) Update follower position: Followers tend to approach the finder or search for food near it. At the same time, some individuals improve their foraging success rate through observation and competition. The Levy flight strategy is integrated into the follower position update calculation formula as follows: Where, represents the optimal position currently occupied by the discoverer after the discoverer position is updated in step (3), Indicates the current global worst position; when i>n / 2, this indicates that the i-th follower with a lower fitness value has not obtained food and is in a very hungry state. At this time, it needs to fly to other places to find food to obtain more energy; represents the Hadamard product symbol; The Levy flight strategy formula is: Where r1 and r2 are two random numbers uniformly distributed in the range [0,1], which are used to introduce randomness, σ is the scale parameter, and β' is the exponential parameter in the Levy distribution. (5) Position adjustment when avoiding predators: When 10%-20% of the sparrows sense danger, the edge individuals quickly move to the safe area, while the inner individuals randomly adjust their positions to get closer to the group. The position update method is calculated as follows: Where, represents the current global optimal position, β is the step size control parameter, which obeys the normal distribution with mean 0 and variance 1; K∈[-1,1] is a random number that controls the direction and amplitude of the position update, f i represents the fitness value of the current sparrow individual; f g and f w are the current global best and worst fitness values ​​respectively; ε is a small constant used to prevent the denominator from being zero; (6) adopting the step of the adaptive t-distribution mutation strategy to adaptively change the position of individual sparrows; (7) Repeat steps (2-6) until the maximum number of iterations is reached, terminate the loop, and output the optimal parameter combination; (8) The optimal parameter combination is input into the LSTM neural network for training.