Numerical control machine tool spindle thermal error modeling method based on MSSSA-LSTM
By using a multi-strategy fusion sparrow search algorithm to optimize the LSTM model in the spindle thermal error prediction of CNC machine tools, the problems of insufficient prediction accuracy and poor robustness in the prior art are solved, and higher prediction accuracy and stronger robustness are achieved.
Patent Information
- Application Number
- CN202411932910.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-26
AI Technical Summary
The existing CNC machine tool spindle thermal error prediction methods have problems of insufficient accuracy and poor robustness, making it difficult to effectively reduce spindle thermal errors and affect machining accuracy.
The spindle thermal error prediction model is constructed by using the Sparrow Search Algorithm (MSSSA) based on multi-strategy fusion to optimize the long and short-term memory neural network (LSTM). Through cube chaotic mapping initialization, Levy flight perturbation strategy and adaptive t-distribution mutation strategy, the hyperparameters of LSTM are optimized to improve prediction accuracy.
It improves the accuracy and robustness of the spindle thermal error prediction, achieves more reliable thermal error prediction and compensation, and improves processing accuracy.
Smart Images

Figure CN119884800A_ABST
Abstract
Description
Technical Field
[0001] The 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 achieve efficient and precise processing tasks in a highly automated manner, significantly improving production efficiency and processing accuracy. During the machining process, the geometric accuracy of the workpiece will be affected by many factors, including the geometric error of the machine tool, thermal error, error caused by cutting force and other possible errors, of which the first two are the main sources of error. In the field of high-precision machining, the proportion of spindle thermal error in the total error can be as high as 40%-70%. Therefore, reducing thermal error is of great significance to high-precision machine tools.
[0003] Due to the complex structure of the spindle and the existence of internal coupling, heat dissipation is difficult, resulting in uneven heating of each component, uneven temperature field, thermal deformation and error, and reduced processing accuracy. In order to reduce thermal errors, measures such as thermal symmetry design, heat source isolation, and spindle structure optimization can be taken, but these methods are limited by hardware and technical levels, and are costly and difficult to popularize in a wide range of applications. Compared with the above methods, establishing an accurate and reliable thermal error prediction model to accurately predict and compensate for the thermal error of the spindle is an economical and efficient method. Selecting appropriate temperature measurement points is the basis and prerequisite for establishing a high-precision and robust thermal error model. With the popularization of machine learning technology, it has been widely used in temperature measurement point optimization and spindle thermal error modeling. In terms of temperature measurement point optimization, machine learning can select the most representative temperature sensor position from multiple measurement points in a data-driven manner, reduce redundant data, improve measurement efficiency and model accuracy, reduce measurement costs, and ensure the accuracy of the model. In spindle thermal error modeling, machine learning captures complex nonlinear relationships by processing a large amount of temperature, spindle speed, and thermal displacement data, 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 networks (LSTM) can further improve the dynamic response capability to the time-varying spindle thermal errors. The sparrow algorithm with multi-strategy fusion is used to optimize the hyperparameters of the LSTM neural network to improve its prediction accuracy. Summary of the invention
[0004] In view of the shortcomings of the existing machine tool spindle thermal deformation prediction methods, the purpose of the present invention is to propose a CNC machine tool spindle thermal error modeling method based on MSSSA-LSTM. The method of the present invention is a spindle thermal error modeling method based on a multi-strategy fusion sparrow search algorithm (MSSSA) optimized long short-term memory neural network (LSTM) based on cube chaos map initialization, levy flight perturbation strategy, and adaptive t distribution mutation strategy. MSSSA can effectively balance global and local searches and optimize the hyperparameters of LSTM. LSTM performs well in processing complex time series data by selectively retaining key information and ignoring irrelevant information. The MSSSA-LSTM model combines the memory capacity of LSTM with the global optimization ability of MSSSA, and can effectively process complex data and provide more reliable prediction results. Experimental results show that compared with the SSA-LSTM model, the LSTM model and the traditional SVR model, the MSSSA-LSTM model has higher prediction accuracy and stronger robustness.
[0005] In order to achieve the above object, the technical solution adopted by the present invention to solve its 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 operation of the spindle system of a CNC machine tool, arrange multiple temperature sensors at the location of the spindle system of the machine tool, and use a displacement sensor to monitor the z-direction thermal deformation value data of the spindle of the machine tool;
[0008] Step 2: Conduct an experiment on the spindle system of a CNC machine tool under idling. Use a temperature sensor to measure the temperature of different temperature measurement points of the machine tool and the temperature data of the processing environment. Use a displacement sensor to obtain the z-direction thermal deformation value data of the machine tool spindle. Use fuzzy c-means clustering and grey correlation analysis to screen out key temperature measurement points. Test the temperature values and z-direction thermal deformation value data of the key temperature measurement points of the spindle at different 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 sparrow search algorithm with multi-strategy fusion to optimize a series of hyperparameters of LSTM, including the number of hidden layer nodes, learning rate, and number of training times. 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 MSSSA-LSTM;
[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 of the temperature measuring point and the thermal deformation value in the z direction obtained in the experiment, and divide the machine tool state into segments evenly according to uniform time intervals. The temperature information and thermal deformation value information in the z direction 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-direction thermal deformation value in each sample data;
[0015] 3) The fuzzy c-means clustering algorithm is used to perform cluster analysis on each temperature measurement point to obtain the classification results of temperature measurement points of different categories, and the temperature measurement points of the same category are placed in a temperature data group; then the correlation between the temperature sequence of each temperature measurement point and the z-direction thermal deformation sequence is calculated by grey correlation analysis to obtain the correlation result data of each temperature measurement point, and the temperature measurement point with the largest correlation is selected from each temperature data group as the key temperature measurement point;
[0016] 4) After the temperature values and z-axis 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 z-axis thermal deformation value feature matrix vector after data preprocessing is used as a label to form a data set corresponding to the temperature feature 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 definitions: 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 last moment, C t Indicates the cell state at the current moment, h t-1 represents 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] In the formula, 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 the input gate, respectively, and 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 represents 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 cubic chaos map to initialize the population, determine the number of sparrow 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 cubic chaos operator to initialize the population. The cubic mapping formula is as follows:
[0034] y(n+1)=4y(n) 3 -3y(n) #(7)
[0035] In the formula, n represents the number of iterations, and y(n) is the individual value after the nth iteration;
[0036] First, randomly generate a d-dimensional vector y 1 , the value range of each dimension is -1 to 1, and 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 through the following formula:
[0037] X i =X lb +(X lb -X ub )×(y i +1)×0.5 #(8)
[0038] In the formula, 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, corresponding 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 position of the discoverer. 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 threat from predators, the search range will be expanded; if there is a threat, it will migrate to a safer area. The calculation formula for updating the discoverer's position is as follows:
[0041]
[0042] In the formula, t and iter max Respectively represent 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. It is R 2 represents the warning value, and ST represents the safety value;
[0043] (4) Update follower position: Followers tend to approach the discoverer or look 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's position update calculation formula as follows:
[0044]
[0045] In the formula, 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] In the formula, r 1 , r 2are two random numbers that are uniformly distributed in the range [0,1], 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 calculation formula is as follows:
[0050]
[0051] In the formula, 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, the value 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 t-distribution, the solutions generated at different stages of the algorithm can both perform fine local search and explore the global scope, effectively balancing local search and local development. During the iteration process, the shape of t-distribution is dynamically adjusted through the degree of freedom parameter m, thereby changing the mutation mode of individual sparrows:
[0053]
[0054] In the formula, 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 mutation mode is similar to the Cauchy distribution mutation in the early stage, allowing individuals to have a larger search range; in the later stage, as the number of iterations increases, the t distribution is similar to the Gaussian distribution mutation, 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 the present invention has better prediction accuracy than the LSTM model before optimization.
[0059] 2) The MSSSA_LSTM proposed in this invention has better generalization performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is a schematic diagram of the LSTM neural unit structure of the present invention;
[0061] Figure 2 A 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 thermal error of the spindle under the working condition of 5000 r / min in Example 1 of the present invention and the prediction results of each model;
[0063] Figure 4 Based on Figure 3 The residual diagram of the spindle thermal error prediction result under the 5000r / min working condition calculated by the results;
[0064] Figure 5 This is a comparison chart of the actual value of the thermal error of the spindle under the working condition of 2000r / min in Example 1 of the present invention and the prediction results of each model;
[0065] Figure 6 Based on Figure 5 The residual diagram of the spindle thermal error prediction result under the 2000r / min working condition calculated by the results;
[0066] Figure 7 This is a comparison chart of the actual value of the thermal error of the spindle under the working condition of 8000r / min in Example 1 of the present invention and the prediction results of each model;
[0067] Figure 8 Based on Figure 7 Result calculation residual diagram of the spindle thermal error prediction results under 8000r / min conditions. DETAILED DESCRIPTION
[0068] Embodiment 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 thermal error experiments on the spindle under no-load conditions, and collect real-time temperature data and thermal displacement data at spindle speeds of 2000r / min, 5000r / min, and 8000r / min;
[0071] Step 2: Use fuzzy c-means clustering and grey relational analysis to screen out key temperature measurement points and divide them into training sets and test sets;
[0072] Step 3: Build an LSTM thermal error prediction model;
[0073] Step 4: Use the sparrow search algorithm with multi-strategy fusion to optimize a series of hyperparameters of LSTM, such as the number of hidden layer nodes, learning rate, and number of training times. 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 MSSSA-LSTM;
[0074] Step 5: Using the data of 5000r / min 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 fitting performance of the model;
[0075] Step 6: Select the first 70% of the data under 5000r / min and 8000r / min conditions as the training set for thermal error prediction and input it into the 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 location distribution of the temperature sensors is shown in Table 1, respectively collecting the temperature field information of the machine tool spindle system at 2000r / min, 5000 rpm, and 8000r / min under idling, and conducting a total of 4 hours of experiments. 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 data, temperature and z-axis thermal deformation value, obtained from the experiment 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) Using the average value filtering algorithm to clean the temperature and z-direction thermal deformation value in each sample data;
[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 series and the thermal error series 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 to form a data set corresponding to the temperature feature matrix vector, and the data is divided into a training set and a test set. In this way, the data sets under the spindle speed of 2000r / min, 5000r / min, and 8000r / min can be obtained respectively.
[0088] Furthermore, the step three is as follows: LSTM algorithm can retain important information and pass it to the next unit while discarding unimportant information when processing long sequence data through its unique gating mechanism, including forget gate, input gate and output gate. LSTM effectively captures and retains dependencies in long time series, and can maintain the stability of gradient, thus avoiding the problem of gradient disappearance or explosion. 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 last moment, C t Indicates the cell state at the current moment, h t-1 represents 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 data should be discarded at the current time step. Through the sigmoid function, a value between 0 and 1 is output. 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] In the formula, 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.
[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 the input gate, respectively, and 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-1represents 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 establishing the LSTM model is:
[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, and the sparrow algorithm with multi-strategy fusion has the advantages of strong adaptability and few adjustable parameters in the swarm intelligence optimization algorithm, and can well balance global and local searches, which is suitable for optimizing the parameters 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 cubic chaos map to initialize the population, determine the number of sparrow 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 cubic chaos operator to initialize the population. The cubic mapping 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, randomly generate a d-dimensional vector y 1 , the value range of each dimension is -1 to 1, and 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 through the following formula:
[0109] X i =X lb +(X lb -X ub )×(y i +1)×0.5 #(8)
[0110] In the formula, X lb , X ubRespectively 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, corresponding 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 It is the individual value generated according to the above cube mapping formula in the case of sparrow individual i.
[0111] (2) The fitness function of individual sparrows is calculated and sorted. 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 updating the discoverer's position is as follows:
[0113]
[0114] In the formula, t and iter max Respectively represent 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. It is R 2 It indicates the warning value, and ST indicates the safety value.
[0115] (4) Update the follower position: Followers tend to look for food close to the discoverer or 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 by incorporating the Levy flight strategy is as follows:
[0116]
[0117] In the formula, 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] In the formula, r 1 , r 2 are two random numbers that are uniformly distributed in the range [0,1] and 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] In the formula, 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 t-distribution, the solutions generated at different stages of the algorithm can both conduct fine local search and explore the global scope, effectively balancing local search and local development. During the iteration process, the shape of t-distribution is dynamically adjusted through the degree of freedom parameter m, thereby changing the mutation mode of individual sparrows:
[0125]
[0126] In the formula, 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 mutation method is similar to the Cauchy distribution mutation in the early stage, allowing individuals to have a larger search range; in the later stage, as the number of iterations increases, the t distribution is similar to the Gaussian distribution mutation, which is more inclined to local 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 as follows: To verify the effectiveness of the MSSSA-LSTM model, the data obtained under the spindle speed of 5000r / min are trained to build a spindle thermal error prediction model, and the SVR, LSTM and SSA-LSTM thermal error prediction models built based on the same experimental data are compared and analyzed. The optimized network model parameters are shown in Table 4, and the prediction results and residual diagrams 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 when the spindle speed is 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, denoted 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. The prediction accuracy comparison of different prediction models under two working conditions is shown in Table 6. It can be seen that the RMSE1 value and RMSE2 value predicted by the MSSSA-LSTM model are the smallest, which are 0.1675μm and 1.1849μm respectively. It can be seen that the prediction performance of the MSSSA-LSTM prediction model at different spindle speeds is better than that of the unoptimized LSTM model and the traditional support vector regression model, showing stronger generalization ability.
[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 in that The following steps are involved: Step 1: Build an experimental platform for the operation of the spindle system of a CNC machine tool, arrange multiple temperature sensors at the location of the spindle system of the machine tool, and use a displacement sensor to monitor the z-direction thermal deformation value data of the spindle of the machine tool; Step 2: Conduct an experiment on the spindle system of a CNC machine tool under idling. Use a temperature sensor to measure the temperature of different temperature measurement points of the machine tool and the temperature data of the processing environment. Use a displacement sensor to obtain the z-direction thermal deformation value data of the machine tool spindle. Use fuzzy c-means clustering and grey correlation analysis to screen out key temperature measurement points. Test the temperature values and z-direction thermal deformation value data of the key temperature measurement points of the spindle at different 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 sparrow search algorithm with multi-strategy fusion to optimize a series of hyperparameters of LSTM, including the number of hidden layer nodes, learning rate, and number of training times. 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 MSSSA-LSTM; 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 of the temperature measuring point and the thermal deformation value in the z direction obtained in the experiment, and divide the machine tool state into segments evenly according to uniform time intervals. The temperature information and thermal deformation value information in the z direction in each segment are the initial sample data of the model; 2) Use the average value filtering algorithm to clean the temperature and z-direction thermal deformation value in each sample data; 3) The fuzzy c-means clustering algorithm is used to perform cluster analysis on each temperature measurement point to obtain the classification results of temperature measurement points of different categories, and the temperature measurement points of the same category are placed in a temperature data group; then the correlation between the temperature sequence of each temperature measurement point and the z-direction thermal deformation sequence is calculated by grey correlation analysis to obtain the correlation result data of each temperature measurement point, and the temperature measurement point with the largest correlation is selected from each temperature data group as the key temperature measurement point; 4) After the temperature values and z-axis 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 z-axis thermal deformation value feature matrix vector after data preprocessing is used as a label to form a data set corresponding to the temperature feature 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 definitions: 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 last moment, C t Indicates the cell state at the current moment, h t-1 represents 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) In the formula, 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 the input gate, respectively, and 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 represents 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 spindle thermal error prediction model of MSSSA-LSTM includes the following steps: (1) Use the cubic chaos map to initialize the population, determine the number of sparrow 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 cubic chaos operator to initialize the population. The cubic mapping formula is as follows: y(n+1)=4y(n) 3 -3y(n)#(7) In the formula, 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, and the value range of each dimension is -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: 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, corresponding 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 position of the discoverer. 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 threat from predators, the search range will be expanded; if there is a threat, it will migrate to a safer area. The calculation formula for updating the discoverer's position is as follows: In the formula, t and iter max Respectively represent 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 being 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 discoverer or look 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's position update calculation formula as follows: In the formula, 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: In the formula, r1 and r2 are two random numbers that are 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 calculation formula is as follows: In the formula, 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) Adaptive t-distribution mutation strategy: By introducing the flexibility and adaptive adjustment mechanism of t-distribution, the solutions generated at different stages of the algorithm can both perform fine local search and explore the global scope, effectively balancing local search and local development. During the iteration process, the shape of t-distribution is dynamically adjusted through the degree of freedom parameter m, thereby changing the mutation mode of individual sparrows: In the formula, 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 mutation mode is similar to the Cauchy distribution mutation in the early stage, allowing individuals to have a larger search range; in the later stage, as the number of iterations increases, the t distribution is similar to the Gaussian distribution mutation, which is more inclined to local search; (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.
Citation Information
Patent Citations
Power transmission line icing thickness prediction method based on VMD-SSA-LSTM
CN117592592A
Winter wheat yield estimation method based on SSA-LSTM
CN117611989A
Short-term offshore wind power prediction method based on improved sparrow search algorithm
CN118199050A
Cited By
Bearing bush gap regulation and control method based on LSTM-XGB integrated prediction model
CN121743856A