A method for thermal error modeling of electric spindle based on Elman neural network optimized by elephant herding algorithm
Patent Information
- Application Number
- CN202210480474.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-05
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2042-05-05
AI Technical Summary
[0004]Elman神经网络同样不可避免的具有容易陷入局部极值,收敛速度慢,效率低等缺点
[0050] The beneficial effects of this invention are as follows: This invention is a method for modeling thermal errors of the electric principal axis of an Elman neural network based on the beetle whisker algorithm. It uses K-means algorithm analysis combined with grey relational analysis to decouple and reduce the dimensionality of the pre-input variables. Furthermore, by combining the beetle whisker algorithm and the Elman neural network, the resulting BAS-Elman thermal error prediction model has the advantages of simple structure and high prediction accuracy.
Smart Images

Figure CN114861879B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for modeling thermal errors of electric spindles based on the beetle whisker algorithm to optimize Elman neural networks, belonging to the field of thermal error analysis of high-speed electric spindles. Background Technology
[0002] As a key component of high-speed CNC machine tools, the electric spindle generates a large amount of heat during operation, leading to thermal expansion of spindle parts or deformation of the cutting tool. This affects the accuracy of the electric spindle and even the preload of the bearings, thus impacting the machining accuracy and service life of the machine tool. Therefore, reducing the thermal error of high-speed electric spindles is crucial for the development of high-speed precision machining technology. Thermal error compensation methods do not require altering the mechanical properties (structure, materials, etc.) of the electric spindle. Based on establishing a thermal error prediction model, the magnitude of thermal error can be predicted in advance, and errors can be avoided through compensation, making it the most economical and effective method.
[0003] Elman neural networks are dynamic recurrent neural networks that add local memory units to the structure of BP networks. By storing internal states, they enable the system to map dynamic features, thus giving the system the ability to adapt to time-varying characteristics and better learning capabilities. They can be used to solve problems such as rapid optimization, fitting, and regression prediction, and are suitable for modeling thermal errors of electric spindles.
[0004] Elman neural networks inevitably suffer from drawbacks such as susceptibility to local optima, slow convergence, and low efficiency. Existing techniques combine population evolution algorithms with neural networks to optimize the weights and thresholds of Elman neural networks, but these methods suffer from slow convergence and high computational cost. In contrast, the beetle whisker algorithm, a single-entity search algorithm, offers advantages such as simplicity, few parameters, and low computational cost. Therefore, this paper proposes using the beetle whisker algorithm to optimize the weights and thresholds of Elman neural networks and establishes an electric spindle thermal error model based on this algorithm. Summary of the Invention
[0005] To address the shortcomings of existing methods for predicting thermal errors in electric spindles, this invention proposes a method for modeling thermal errors in electric spindles based on the beetle whisker algorithm to optimize Elman neural networks. The key feature is the use of the beetle whisker algorithm to optimize the weights and thresholds of the Elman neural network. The beetle whisker algorithm offers advantages such as simple implementation, fast optimization speed, and strong global search capability, thus overcoming the randomness inherent in the selection of connection weights and thresholds within the Elman neural network itself. This results in stronger convergence of the Elman neural network, improving its learning and generalization abilities, and achieving higher prediction accuracy compared to a single neural network model.
[0006] The technical solution adopted by this invention to solve its technical problem is:
[0007] This invention provides a method for optimizing the thermal error modeling of the electric principal axis of an Elman neural network based on the beetle whisker algorithm, comprising the following steps:
[0008] Step 1: Collect temperature and thermal error data of the high-speed electric spindle at different speeds, and divide the collected data into training set and test set;
[0009] Step 2: Optimize the temperature measurement points using K-means clustering analysis and grey relational analysis to construct the model's input and output;
[0010] Step 3: Initialize the Elman neural network model parameters and the beetle whisker algorithm parameters;
[0011] Step 4: Using the beetle beard algorithm, the connection weights and thresholds of each network layer of the Elman neural network are iteratively updated and optimized to establish the BAS-Elman neural network electric spindle thermal error prediction model.
[0012] Further, step one specifically involves: collecting temperature and thermal error data from several temperature measurement points at different speeds of the high-speed electric spindle, and dividing the collected data into a training set and a test set according to the speed.
[0013] Furthermore, step two specifically involves:
[0014] (1) Use K-means clustering analysis to divide several temperature measurement points into the required number of classes;
[0015] (2) Using grey relational analysis, the temperature measuring points with the highest correlation with thermal error are selected from each group as temperature sensitive points;
[0016] (3) Use the selected temperature-sensitive points as the input of the model and the thermal error as the output.
[0017] Furthermore, step three specifically involves: determining the number of input layers, hidden layers, connecting layers, and output layers in the Elman neural network; and determining the positions X of the longhorn beetle's left and right antennae. l and X r The initial step size of the longhorn beetle is δ0, and the number of iterations is T.
[0018] Before determining the positions Xl and Xr of the longhorn beetle's left and right antennae, it is necessary to initialize the beetle's spatial position.
[0019] Furthermore, the number of input layers and output layers is determined based on the input and output parameters, and the number of hidden layers and inheriting layers is determined by the empirical formula h = (m + n). 1 / 2 +a, and determined by trial and error;
[0020] Where m is the number of input nodes, n is the number of output nodes, and a is a constant between 1 and 10.
[0021] Furthermore, step four specifically includes:
[0022] a. Create a k-dimensional random vector pointing towards the longhorn beetle and normalize it, using the following formula:
[0023]
[0024] In the formula: rands() is a random function, and k represents the spatial dimension;
[0025] b. Create the left and right spatial coordinates of the longhorn beetle, using the following formula:
[0026]
[0027] In the formula: x rt and x lt Let x represent the position coordinates of the right and left antennae of the longhorn beetle at the t-th iteration; t d represents the centroid coordinates of the longhorn beetle at the t-th iteration; d0 represents the distance between the two antennae.
[0028] c. Determine the fitness function, using the root mean square error of the training dataset as the fitness function, with the following formula:
[0029]
[0030] In the formula: N is the number of samples in the training set; This represents the predicted output value, y. i Indicates the actual value;
[0031] d. Determine the next moving position of the longhorn beetle based on the intensity of the left and right whisker odors according to the fitness function. The formula is:
[0032]
[0033] Where: δ t f(x) represents the step size factor at the t-th iteration, sign() is the sign function, and f(x) rt f(x) represents the fitness value of the right beetle's whiskers. lt Fitness value of the left beetle's whiskers;
[0034] The step size update formula for the longhorn beetle is:
[0035] δ t+1 =δ t* eta t=(0,1,2,…,n)
[0036] In the formula: eta takes the number closest to 1 between [0,1];
[0037] Calculate x at present t+1 If the applicability function value corresponding to the location is better than Y, then... best Update X best and Y best Soon x t+1 Replace x t Saved in X best In the middle, x t+1 The applicability function value corresponding to the position replaces x t The applicability function value corresponding to the position is stored in Y. best middle;
[0038] e. Determine if the termination condition is met: If the current iteration count reaches the maximum iteration count or the network training error reaches the accuracy requirement, stop the iteration and output the optimization result; otherwise, continue iterating to find the best solution.
[0039] f. Output the optimized connection weights and thresholds of the Elman network to establish a BAS-Elman neural network electric spindle thermal error prediction model.
[0040] Among them, Y best X represents the optimal fitness value. best This represents the optimal initial weights and thresholds for the neural network.
[0041] Furthermore, it also includes step five: using the BAS-Elman neural network electric spindle thermal error prediction model to predict and verify the thermal error of the high-speed electric spindle.
[0042] Further, step five specifically involves: inputting the training set and test set into the BAS-Elman neural network electric spindle thermal error prediction model to accurately predict the thermal error of the high-speed electric spindle; and using the coefficient of determination (R²)... 2 The evaluation is based on the root mean square error (RMSE) and the mean absolute error (MAE).
[0043] Specifically, verify the partial coefficient of determination (R²) 2 The calculation formula is:
[0044]
[0045] The formula for calculating the root mean square error (RMSE) is:
[0046]
[0047] The formula for calculating the mean absolute error (MAE) is:
[0048]
[0049] In the formula: N is the number of samples in the training set; This represents the predicted output value, y. i This represents the actual value.
[0050] The beneficial effects of this invention are as follows: This invention is a method for modeling thermal errors of the electric principal axis of an Elman neural network based on the beetle whisker algorithm. It uses K-means algorithm analysis combined with grey relational analysis to decouple and reduce the dimensionality of the pre-input variables. Furthermore, by combining the beetle whisker algorithm and the Elman neural network, the resulting BAS-Elman thermal error prediction model has the advantages of simple structure and high prediction accuracy.
[0051] Compared with current thermal error prediction methods, the advantages of this invention are as follows:
[0052] 1. Simple model structure. This invention reduces model input by combining the K-means algorithm with grey relational analysis, effectively solving the problems of excessively long training time and excessive network information redundancy caused by large training data in Elman neural networks;
[0053] 2. High prediction accuracy. This invention utilizes the beetle whisker algorithm (BAS) to optimize the connection weights and thresholds of the Elman neural network, improving the learning and generalization abilities of the Elman neural network, thus significantly improving the accuracy of the thermal error prediction model;
[0054] 3. Short running time. The longhorn beetle whisker algorithm, as a highly efficient intelligent optimization algorithm, requires only one search entity. Compared to other swarm intelligence algorithms, it has significant advantages such as simple parameter settings and low computational load. The BAS-Elman energy consumption prediction method proposed in this invention has the advantage of short running time while ensuring prediction accuracy. Attached Figure Description
[0055] Figure 1 This is a diagram of the Elman neural network structure.
[0056] Figure 2 The flowchart shows the training process for optimizing the Elman neural network based on the longhorn beetle whisker search algorithm.
[0057] Figure 3 The fitness change curve of the BAS-Elman neural network in this embodiment.
[0058] Figure 4 The BAS-Elman and Elman prediction curves at 4000 r / min;
[0059] Figure 5 The BAS-Elman and Elman prediction curves are shown at 8000 r / min. Detailed Implementation
[0060] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention and the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0061] This invention relates to a method for modeling the thermal error of the electric principal axis of an Elman neural network based on the beetle whisker algorithm, which specifically includes the following steps:
[0062] Step 1: Collect temperature and thermal error data of the high-speed electric spindle at different speeds, and divide the data into training set and test set;
[0063] Temperature and thermal error data were obtained from ten temperature measurement points at 4000 r / min, 6000 r / min, and 8000 r / min through experiments. First, the temperature measurement points were optimized, and suitable temperature-sensitive points were selected as the input vector of the model, with the axial thermal error as the output vector. The dataset at 6000 r / min was used as the training set, and the datasets at 4000 r / min and 8000 r / min were used as the test set.
[0064] Step 2: Optimize the temperature measurement points using K-means clustering analysis combined with grey relational analysis, and construct the model's input and output;
[0065] K-means clustering analysis was used to divide the ten temperature measurement points into the required number of classes. Grey relational analysis was used to select the temperature measurement points with the highest correlation with thermal error from each group as temperature sensitive points. The selected temperature sensitive points are the input of the model, and thermal error is the output.
[0066] Step 3: Initialize the Elman neural network model parameters and the beetle whisker algorithm parameters;
[0067] Figure 1 The diagram shows the structure of an Elman neural network. The Elman neural network is a typical recurrent neural network. Due to its internal feedforward and feedback structures, it has a stronger learning ability than ordinary neural networks and is very suitable for building hot error prediction models.
[0068] The model's input is temperature-sensitive points. Four temperature-sensitive points were selected through temperature measurement point optimization, meaning the input layer has 4 neurons. The output is thermal error, meaning the output layer has 1 neuron. The number of hidden layers was determined to be 9 through empirical formulas and trial and error, meaning each hidden layer and the connecting layer has 9 neurons. In this embodiment, the transfer function between the input layer and the hidden layer of the neural network is set to tansig, and the transfer function between the hidden layer and the output layer is set to purelin. In this embodiment, the initial step size of the beetle whisker algorithm is set to 50, the initial distance between the left and right whiskers is 5, and the number of iterations of the beetle whisker algorithm is 200.
[0069] The learning algorithm for Elman neural networks is as follows:
[0070] y(k)=g(ω3x(k))
[0071] x(k)=f(ω1x c (k)+ω2(u(k-1)))
[0072] x c (k)=x(k-1)
[0073] The learning metric function for Elman neural networks uses the sum of squared errors function, i.e.:
[0074]
[0075] Where: y is the m-dimensional output node vector; x is the n-dimensional intermediate layer node unit vector; u is the r-dimensional input vector; X c ω1 is the n-dimensional feedback state vector; ω2 is the weight of the connection from the input layer to the hidden layer; ω3 is the weight of the connection from the hidden layer to the output layer; g() is the transfer function of the output neuron; and f() is the transfer function of the intermediate layer neuron.
[0076] Step 4: The beetle beard algorithm iteratively updates and optimizes the connection weights and thresholds of each network layer of the Elman neural network to establish a BAS-Elman neural network thermal error prediction model. Figure 2 The flowchart shows the training process for optimizing an Elman neural network based on the beetle whisker search algorithm. The specific steps are as follows:
[0077] a. Create a k-dimensional random vector pointing towards the longhorn beetle and normalize it, using the following formula:
[0078]
[0079] In the formula: rands() is a random function, k represents the spatial dimension, which is also the number of parameters to be optimized. The search spatial dimension k = M*N + N + N*1 + 1 + N*N, where M is the number of neurons in the input layer, N is the number of neurons in the hidden layer, and the number of neurons in the output layer is 1.
[0080] b. Create the left and right spatial coordinates of the longhorn beetle, using the following formula:
[0081]
[0082] In the formula: x rt and x lt Let x represent the position coordinates of the right and left antennae of the longhorn beetle at the t-th iteration; t d represents the centroid coordinates of the longhorn beetle at the t-th iteration; d0 represents the distance between the two antennae.
[0083] c. Determine the fitness function, using the root mean square error of the training dataset as the fitness function, with the following formula:
[0084]
[0085] In the formula: N is the number of samples in the training set; This represents the predicted output value, y. i Indicates the actual value;
[0086] d. Determine the next moving position of the longhorn beetle based on the intensity of the left and right whisker odors according to the fitness function. The formula is:
[0087]
[0088] Where: δ t f(x) represents the step size factor at the t-th iteration, sign() is the sign function, and f(x) rt f(x) represents the fitness value of the right beetle's whiskers. lt Fitness value of the left beetle's whiskers;
[0089] The step size update formula for the longhorn beetle is:
[0090] δ t+1 =δ t* eta t=(0,1,2,…,n)
[0091] In the formula: eta is a number between [0,1] that is close to 1; in this embodiment, eta is set to 0.995.
[0092] Calculate x at present t+1 If the applicability function value corresponding to the location is better than Y, then... best Update X best and Y best Soon x t+1 Replace x t Saved in X best In the middle, x t+1 The applicability function value corresponding to the position replaces x t The applicability function value corresponding to the position is stored in Y. best middle;
[0093] e. Determine if the termination condition is met: If the current iteration count reaches the maximum iteration count or the network training error reaches the accuracy requirement, stop the iteration and output the optimization result; otherwise, continue iterating to find the best solution.
[0094] f. Output the optimization results, namely the connection weights and thresholds of the optimized Elman network.
[0095] Step 5: Predict and validate the thermal error of the high-speed electric spindle using the optimized BAS-Elman neural network prediction model. Using the optimized BAS-Elman neural network model, input the training and test sets into the BAS-Elman model to accurately predict the thermal error of the high-speed electric spindle; evaluate the results using the coefficient of determination (R²), root mean square error (RMSE), and mean absolute error (MAE).
[0096] R 2 R is an indicator of how well the model fits the sample. 2 The larger the value of R, the better the model fits the sample; 2 The calculation formula is as follows:
[0097]
[0098] RMSE represents the root mean square error of a regression model. The formula for calculating RMSE is as follows:
[0099]
[0100] MAE represents the mean absolute error of a regression model. The formula for calculating MAE is as follows:
[0101]
[0102] In the formula: N is the number of samples in the training set; This represents the predicted output value, y. i This represents the actual value.
[0103] Figure 3 This is the fitness change curve of the BAS-Elman neural network in this embodiment.
[0104] Depend on Figure 3 It can be seen that the BAS algorithm can find the optimal solution after 14 iterations, and the algorithm converges relatively quickly. The BAS algorithm can iterate 200 times to optimize the Elman neural network model and predict the thermal error in only about 39 seconds, which is a short running time. This is because the beetle whisker algorithm, as a highly efficient intelligent optimization algorithm, only requires one search entity, and compared with other swarm intelligence algorithms, it has significant advantages such as simple parameter settings and low computational load.
[0105] Figure 4 and Figure 5 The Elman and BAS-Elman prediction curves provided in this application are for speeds of 4000 r / min and 6000 r / min, respectively.
[0106] Table 1 shows the predicted performance parameters of Elman and BAS-Elman at different speeds provided in this application:
[0107]
[0108] By comparing the prediction curves of the BAS-Elman and Elman models at different rotational speeds, and analyzing Table 1, it can be seen that the BAS-Elman model has a higher degree of fit than the Elman model, with smaller root mean square error and mean absolute error. Therefore, the BAS-Elman model can improve the prediction accuracy of the Elman model, and the BAS-Elman model has a higher generalization ability.
[0109] In summary, this invention optimizes the initial connection weights and thresholds of the Elman neural network using the BAS algorithm, thus overcoming the shortcomings of the Elman neural network, such as slow convergence speed and susceptibility to local optima. This invention is highly practical, provides relatively accurate prediction results, and offers a simple method for predicting thermal errors.
[0110] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A method for modeling the thermal error of an electric spindle in an Elman neural network based on the beetle whisker algorithm, characterized in that, Includes the following steps: Step 1: Collect temperature and thermal error data of the high-speed electric spindle at different speeds, and divide the collected data into training set and test set; Step 2: Optimize the temperature measurement points using K-means clustering analysis and grey relational analysis to construct the model's input and output; Step 3: Initialize the Elman neural network model parameters and the beetle whisker algorithm parameters; Step 4: Using the beetle beard algorithm, the connection weights and thresholds of each network layer of the Elman neural network are iteratively updated and optimized to establish the BAS-Elman neural network electric spindle thermal error prediction model. Step three specifically involves: determining that the Elman neural network has 4 input layers, 9 hidden layers, 9 connecting layers, and 1 output layer; and determining the positions of the longhorn beetle's left and right antennae. and The distance between the left and right whiskers is 5, and the initial step length of the longhorn beetle is... The value is 50, and the number of iterations T is 200; Step one specifically involves: collecting temperature and thermal error data from several temperature measurement points at different speeds of the high-speed electric spindle, and dividing the collected data into a training set and a test set according to the speed. Step two specifically involves: (1) Use K-means clustering analysis to divide several temperature measurement points into the required number of classes; (2) Using grey relational analysis, the temperature measuring points with the highest correlation with thermal error are selected from each group as temperature sensitive points; (3) Use the selected temperature-sensitive points as the input of the model and the thermal error as the output; The high-speed electric spindle rotates at 8000 r / min; It also includes step five: using the BAS-Elman neural network electric spindle thermal error prediction model to predict and verify the thermal error of the high-speed electric spindle; Step five specifically involves: inputting the training and test sets into the BAS-Elman neural network electric spindle thermal error prediction model to accurately predict the thermal error of the high-speed electric spindle; and using the coefficient of determination. The root mean square error (RMSE) and mean absolute error (MAE) are used for evaluation. Verification of partial determination coefficients The calculation formula is: The formula for calculating the root mean square error (RMSE) is: The formula for calculating the Mean Absolute Error (MAE) is: In the formula: The number of samples in the training set; Indicates the predicted output value. This represents the actual value.
2. The method for modeling the thermal error of the electric spindle based on the beetle whisker algorithm for optimizing the Elman neural network according to claim 1, characterized in that, The number of input and output layers is determined based on the input and output parameters, while the number of hidden and inheriting layers is determined using empirical formulas. And determine it by trial and error; in, The number of input nodes, To output the number of nodes, It is a constant between 1 and 10.
3. The method for modeling the thermal error of the electric spindle based on the beetle whisker algorithm to optimize the Elman neural network according to claim 1, characterized in that, Step four specifically involves: a. Create a k-dimensional random vector pointing towards the longhorn beetle and normalize it, using the following formula: In the formula: It is a random function. Indicates spatial dimension; b. Create the left and right spatial coordinates of the longhorn beetle, using the following formula: In the formula: and These represent the position coordinates of the right and left antennae of the longhorn beetle at the t-th iteration; This represents the centroid coordinates of the longhorn beetle at the t-th iteration. Indicates the distance between the two whiskers; c. Determine the fitness function, using the root mean square error of the training dataset as the fitness function, with the following formula: In the formula: The number of samples in the training set; Indicates the predicted output value. Indicates the actual value; d. Determine the next moving position of the longhorn beetle based on the intensity of the left and right whisker odors according to the fitness function. The formula is: In the formula: This represents the step size factor at the t-th iteration. For symbolic functions, The fitness value of the right beetle. Fitness value of the left beard of the longhorn beetle; The step size update formula for the longhorn beetle is: In the formula: Take the number between [0, 1] that is closest to 1; Calculate the present If the applicability function value corresponding to the location is better than Y, then... best ,renew X best and Y best Soon Alternative Saved in X best middle, Replacement of the applicability function value corresponding to the position The applicability function value corresponding to the position is stored in Y. best middle; e. Determine if the termination condition is met: If the current iteration count reaches the maximum iteration count or the network training error reaches the accuracy requirement, stop the iteration and output the optimization result; otherwise, continue iterating to find the best solution. f. Output the optimized connection weights and thresholds of the Elman network to establish a BAS-Elman neural network electric spindle thermal error prediction model.
Citation Information
Patent Citations
Battery SOC dual-state switching estimation method based on BAS optimized ElmanNN-AH method
CN110579714A
Short-term traffic flow prediction system based on SARIMA-GA-Elman combined model
CN112767692A
Numerical control lathe spindle thermal error measuring device and modeling method
CN114296396A