Method for predicting optimal rotating speed of motor by optimizing neural network based on whale optimization algorithm
By combining the improved whale optimization algorithm and BP neural network, the local optima and stability problems of BP neural network in predicting the optimal speed of pump-machine integrated permanent magnet synchronous motor system are solved, and more efficient prediction results are achieved.
Patent Information
- Application Number
- CN202511687025.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-02-27
AI Technical Summary
Existing BP neural network algorithms are prone to getting stuck in local optima when predicting the optimal speed of a pump-machine integrated permanent magnet synchronous motor system. They are highly sensitive to initial weights and lack theoretical guidance in network structure design, resulting in poor prediction accuracy and stability. Furthermore, the whale optimization algorithm has slow convergence speed and insufficient search diversity in high-dimensional complex problems, which affects the optimization effect.
An adaptive weighting strategy and a nonlinear convergence factor are introduced to improve the whale optimization algorithm. The weights and thresholds of the BP neural network are optimized. The global search capability and convergence performance of the algorithm are improved through prey encirclement, spiral bubble net predation and random search mechanisms. The mean squared error (MSE) is combined as the fitness function to optimize the model performance.
It significantly improves the accuracy and stability of predicting the optimal speed of the motor, reduces error fluctuations, and enhances the accuracy and speed of optimization, thus achieving accurate prediction of the optimal speed of the pump-motor integrated permanent magnet synchronous motor system.
Smart Images

Figure CN121581099A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of whale optimization algorithm technology, and in particular to a method for predicting the optimal speed of a motor using a neural network based on the whale optimization algorithm. Background Technology
[0002] Compared to traditional asynchronous motors, permanent magnet synchronous motors (PMSMs) have higher efficiency, often exceeding 90%. However, their efficiency is also affected by factors such as speed and load, and their transmission structure also influences the overall system efficiency. This is especially true for integrated pump-machine PSM oil production systems (hereinafter referred to as "the system"), where the transmission structure is more complex. The efficiency of the screw pump is typically around 50% to 70%, influenced by factors such as crude oil viscosity, sand content, and gas-liquid ratio. High-viscosity or high-sand-content crude oil increases the load on the screw pump, reducing efficiency. High wellbore temperatures and insufficient cooling also lead to increased motor heat generation, affecting the overall system efficiency. Therefore, the optimal speed for an integrated pump-machine PSM oil production system to achieve an overall efficiency of over 50% can be considered the system's optimal speed.
[0003] Currently, machine learning techniques are commonly used to predict the optimal rotational speed of a system. A commonly used prediction algorithm in machine learning is the backpropagation (BP) neural network (BPNN) algorithm. However, in practice, the BPNN prediction model has the following problems: First, the model is prone to getting trapped in local optima. Its gradient descent algorithm may converge to a suboptimal solution on complex error surfaces, leading to a significant decrease in prediction accuracy. Second, the training process is highly sensitive to initial weights; different initial parameters may cause the model to converge to completely different results, increasing the difficulty of parameter tuning. Finally, the network structure design lacks theoretical guidance; the number of hidden layer nodes needs to be determined through repeated trials using empirical formulas, and there is a risk of overfitting. When training data is insufficient, the model's generalization ability drops sharply.
[0004] The Whale Optimization Algorithm (WOA) can, to some extent, address the problems encountered by the aforementioned BP neural network algorithm in prediction. Whale Optimization (WOA) is a metaheuristic algorithm simulating the hunting behavior of humpback whales. It features a simple mechanism, few parameters, and strong optimization capabilities. Its core framework consists of three main parts: prey encirclement, spiral bubble net predation, and random search. In prey encirclement, since the coordinates of the global optimum are uncertain, the algorithm uses the optimal solution in the current iteration as the target prey. By defining an optimal search agent, other search agents gradually move closer to this optimal solution to update their own positions. In spiral bubble net predation, there are two predation methods: encirclement and bubble net predation. Since there are two predation behaviors, the choice of which predation method to use is determined by random probability. In random search, to ensure a comprehensive search of the solution space, Whale Optimization (WOA) dynamically adjusts the positions of search agents by calculating the relative distances between individual whales, thereby achieving the purpose of random search.
[0005] However, the Whale Optimization Algorithm (WOA) suffers from several problems in practical applications: First, its convergence factor is linear, which has several drawbacks. The linear convergence factor makes the algorithm conservative during optimization, easily leading to local optima; the convergence speed is slow, especially when dealing with high-dimensional and complex problems; and the linear convergence factor may result in insufficient diversity among individuals in the population, preventing the algorithm from fully exploring the search space and thus affecting optimization performance. Second, insufficient search diversity during the search process leads to repeated search paths and a high probability of getting trapped in local optima. Finally, its global search capability and convergence performance are poor, and it has poor adaptability to handling high-dimensional problems. Summary of the Invention
[0006] To address the issues of poor prediction stability and low prediction accuracy when using the whale optimization algorithm and BP neural network to predict the optimal speed of a pump-machine integrated permanent magnet synchronous motor system, this invention provides a method for predicting the optimal speed of the motor based on a whale optimization algorithm and optimized neural network.
[0007] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: The method for predicting the optimal motor speed using a neural network based on the whale optimization algorithm includes the following steps: S1, inputting sensor detection data and the optimal speed, and normalizing the data; S2, designing the topology of the BP neural network and initializing its parameters; S3, initializing the parameters of the whale optimization algorithm, improving the whale optimization algorithm by introducing a weight strategy and a nonlinear convergence factor, and optimizing the weights and thresholds of the BP neural network by improving the whale optimization algorithm; S4, outputting the optimal weights and thresholds of the BP neural network, and performing training and testing; S5, constructing a model for predicting the optimal speed using the optimized BP neural network.
[0008] Furthermore, in S2, the prediction process of the BP neural network is as follows: S21, input data preprocessing to ensure standardization and normalization of the input data, and inputting the processed data into the input layer of the BP neural network; S22, designing the topology of the BP neural network, and determining the number of neurons in the input layer, hidden layer, and output layer; S23, initializing the BP neural network parameters, including weights and thresholds; S24, calculating the predicted value through forward propagation and quantifying the prediction bias using a loss function; S25, calculating gradient information using the backpropagation algorithm and optimizing the BP neural network parameters using gradient descent; S26, iteratively training the prediction model to achieve the predetermined performance index.
[0009] Furthermore, in S3, the whale optimization algorithm consists of three parts: prey encirclement, spiral bubble net predation, and random search; Prey Encirclement: The optimal rotation speed in the current iteration is taken as the target prey. By defining the optimal rotation speed as the optimal search agent, other search agents will gradually move closer to this optimal search agent to update their own positions. Its expression is: ; ; In the formula, Indicates the current iteration number; Indicates the current rotational speed; Indicates iteration to Rotational speed at +1 time; This indicates the optimal rotational speed in the current iteration; , Both are coefficient vectors; This indicates the distance between the current position and the prey's position, where the current position represents the current rotation speed and the prey's position represents the optimal rotation speed. in, , The expressions are as follows: ; ; In the formula, , It is a random vector in the interval [0,1]. The convergence factor; The spiral bubble net predation mechanism includes bubble net predation and encirclement predation; The expression for bubble web predation is: ; ; In the formula, This represents the spiral shape parameter, set to 1; A random number within the interval [-1, 1]; This represents the distance between the current search agent and the optimal search agent, where the current search agent represents the current rotation speed and the optimal search agent represents the optimal rotation speed. Encirclement predation has two methods: contraction encirclement and spiral encirclement. These two predatory behaviors are carried out through... To determine, when Less than When, the position is updated, and a shrinking wrapper is used. Greater than or equal to At this time, a spiral approach is made to the target, employing a spiral encirclement; the expression for encirclement and predation is: ; In the formula, This represents the predation method determinant, and is a random number within the interval [0,1]. Take 0.5; As the iteration proceeds, the convergence factor... It shows a decreasing trend, at the same time Continuously decreasing, when At this time, the current search agent, i.e. the current rotation speed, will gradually move closer to the current optimal agent, i.e. the optimal rotation speed, thus entering the local optimization stage; Random search mechanism: To ensure a comprehensive search in the solution space, the whale optimization algorithm dynamically adjusts the position of the search agent by calculating the relative distance between individual whales, thereby achieving the purpose of random search; During the exploration phase, the whale optimization algorithm enhances its global exploration capability by using a randomly selected search agent, i.e., a random rotation. The expression for the random search is: ; ; In the formula, Indicates random rotational speed; This represents the distance between the current search agent and the random agent, where the search agent represents the current rotation speed and the random agent represents the random rotation speed.
[0010] Furthermore, an adaptive weight strategy is introduced into the whale optimization algorithm. This approach aims to improve the algorithm's global search capability and convergence performance, enhance its adaptability in handling high-dimensional problems, and achieve a dynamic balance between exploration and development through an adaptive weighting strategy. The expression is: ; In the formula, Indicates the maximum number of iterations; Introducing a weighting strategy The position update expression for the subsequent whale optimization algorithm is: .
[0011] Furthermore, the convergence factor As a nonlinear convergence factor, a weighting strategy is introduced. Then a nonlinear convergence factor is introduced. The whale optimization algorithm is improved by generating adaptive weights and nonlinear convergence curves, through a nonlinear convergence factor. This enables the whale optimization algorithm to converge non-linearly in the number of iterations, thereby increasing the diversity of the search process and its ability to escape local optima. (Non-linear convergence factor) The expression is: .
[0012] Furthermore, in S3, the weights and thresholds of the BP neural network model affect the accuracy and stability of the prediction. The mean squared error (MSE) is set as the fitness function, and the improved whale optimization algorithm is used to optimize the weights and thresholds of the BP neural network. The expression for mean squared error (MSE) is: ; In the formula, This indicates the predicted optimal rotational speed; This represents the optimal rotational speed obtained from the experiment; This indicates the lower bound of the summation formula; This indicates the upper bound of the summation formula.
[0013] Furthermore, in S4, the population size and number of iterations for the improved whale optimization algorithm are set, and training is performed to compare the coefficient of determination R before and after optimization. 2 The performance of the prediction model is evaluated by comparing the root mean square error (RMSE). Coefficient of determination R 2 The expression is: ; In the formula, This represents the average value of the optimal rotational speed obtained from the experiment; The expression for the root mean square error (RMSE) is: .
[0014] The beneficial effects of this invention are as follows: By introducing an improved whale optimization algorithm based on adaptive weights and nonlinear convergence, this invention not only improves the optimization accuracy and speed but also reduces errors. Furthermore, by using the improved whale optimization algorithm to optimize the BP neural network, the stability of the predicted optimal motor speed is significantly improved, the fluctuation of the prediction performance is reduced, the error curve is made more regular, and the accuracy of the predicted optimal motor speed is significantly improved. Attached Figure Description
[0015] Figure 1 The diagram shows the prediction flowchart of the improved whale optimization algorithm for optimizing neural networks.
[0016] Figure 2 The diagram shown is a schematic of the BP neural network.
[0017] Figure 3 The diagram shows the flowchart of a BP neural network.
[0018] Figure 4 The diagram shows the structure of a random forest decision tree.
[0019] Figure 5 The diagram shows the flowchart of a random forest.
[0020] Figure 6 The image shows a comparison of the mean squared error (MSE) of random forests.
[0021] Figure 7 The image shown is a prediction graph of the training set of a BP neural network.
[0022] Figure 8 The image shown is a prediction graph for the test set of the BP neural network.
[0023] Figure 9 The image shows the percentage error of the training set for the BP neural network.
[0024] Figure 10 The image shows the percentage error of the BP neural network on the test set.
[0025] Figure 11 The image shown is a prediction graph for the training set of a random forest.
[0026] Figure 12 The image shown is a prediction graph for the test set of a random forest.
[0027] Figure 13 The image shows the percentage error of the training set in a random forest.
[0028] Figure 14 The image shows the percentage error of the random forest on the test set.
[0029] Figure 15 The flowchart shown is for the whale optimization algorithm.
[0030] Figure 16 The image shown is a training set prediction graph for the improved whale optimization algorithm.
[0031] Figure 17 The image shown is a test set prediction graph for the improved whale optimization algorithm.
[0032] Figure 18 The image shows the percentage error of the training set for the improved whale optimization algorithm.
[0033] Figure 19 The figure shows the percentage error on the test set for the improved whale optimization algorithm.
[0034] Figure 20 The image shows the training set predictions for random forest, BP neural network, and improved whale optimization algorithm optimized neural network models.
[0035] Figure 21 The image shows the test set predictions for random forest, BP neural network, and improved whale optimization algorithm optimized neural network models.
[0036] Figure 22 The image shows the percentage error of the training set for Random Forest, BP Neural Network, and Improved Whale Optimization Algorithm optimized neural network models.
[0037] Figure 23 The figure shows the percentage error on the test set for Random Forest, BP Neural Network, and Improved Whale Optimization Algorithm optimized neural network models. Detailed Implementation
[0038] The method for predicting the optimal motor speed using a neural network based on the whale optimization algorithm includes the following steps: S1, inputting sensor detection data and the optimal speed, and normalizing the data; S2, designing the topology of the BP neural network and initializing its parameters; S3, initializing the parameters of the whale optimization algorithm, improving the whale optimization algorithm by introducing a weight strategy and a nonlinear convergence factor, and optimizing the weights and thresholds of the BP neural network by improving the whale optimization algorithm; S4, outputting the optimal weights and thresholds of the BP neural network, and performing training and testing; S5, constructing a model for predicting the optimal speed using the optimized BP neural network.
[0039] Furthermore, in S2, the prediction process of the BP neural network is as follows: S21, input data preprocessing to ensure standardization and normalization of the input data, and inputting the processed data into the input layer of the BP neural network; S22, designing the topology of the BP neural network, and determining the number of neurons in the input layer, hidden layer, and output layer; S23, initializing the BP neural network parameters, including weights and thresholds; S24, calculating the predicted value through forward propagation and quantifying the prediction bias using a loss function; S25, calculating gradient information using the backpropagation algorithm and optimizing the BP neural network parameters using gradient descent; S26, iteratively training the prediction model to achieve the predetermined performance index.
[0040] Furthermore, in S3, the whale optimization algorithm consists of three parts: prey encirclement, spiral bubble net predation, and random search; Prey Encirclement: The optimal rotation speed in the current iteration is taken as the target prey. By defining the optimal rotation speed as the optimal search agent, other search agents will gradually move closer to this optimal search agent to update their own positions. Its expression is: ; ; In the formula, Indicates the current iteration number; Indicates the current rotational speed; Indicates iteration to Rotational speed at +1 time; This indicates the optimal rotational speed in the current iteration; , Both are coefficient vectors; This indicates the distance between the current position and the prey's position, where the current position represents the current rotation speed and the prey's position represents the optimal rotation speed. in, , The expressions are as follows: ; ; In the formula, , It is a random vector in the interval [0,1]. The convergence factor; The spiral bubble net predation mechanism includes bubble net predation and encirclement predation; The expression for bubble web predation is: ; ; In the formula, This represents the spiral shape parameter, set to 1; A random number within the interval [-1, 1]; This represents the distance between the current search agent and the optimal search agent, where the current search agent represents the current rotation speed and the optimal search agent represents the optimal rotation speed. Encirclement predation has two methods: contraction encirclement and spiral encirclement. These two predatory behaviors are carried out through... To determine, when Less than When, the position is updated, and a shrinking wrapper is used. Greater than or equal to At this time, a spiral approach is made to the target, employing a spiral encirclement; the expression for encirclement and predation is: ; In the formula, This represents the predation method determinant, and is a random number within the interval [0,1]. Take 0.5; As the iteration proceeds, the convergence factor... It shows a decreasing trend, at the same time Continuously decreasing, when At this time, the current search agent, i.e. the current rotation speed, will gradually move closer to the current optimal agent, i.e. the optimal rotation speed, thus entering the local optimization stage; Random search mechanism: To ensure a comprehensive search in the solution space, the whale optimization algorithm dynamically adjusts the position of the search agent by calculating the relative distance between individual whales, thereby achieving the purpose of random search; During the exploration phase, the whale optimization algorithm enhances its global exploration capability by using a randomly selected search agent, i.e., a random rotation. The expression for the random search is: ; ; In the formula, Indicates random rotational speed; This represents the distance between the current search agent and the random agent, where the search agent represents the current rotation speed and the random agent represents the random rotation speed.
[0041] Furthermore, an adaptive weight strategy is introduced into the whale optimization algorithm. This approach aims to improve the algorithm's global search capability and convergence performance, enhance its adaptability in handling high-dimensional problems, and achieve a dynamic balance between exploration and development through an adaptive weighting strategy. The expression is: ; In the formula, Indicates the maximum number of iterations; Introducing a weighting strategy The position update expression for the subsequent whale optimization algorithm is: .
[0042] Furthermore, the convergence factor As a nonlinear convergence factor, a weighting strategy is introduced. Then a nonlinear convergence factor is introduced. The whale optimization algorithm is improved by generating adaptive weights and nonlinear convergence curves, through a nonlinear convergence factor. This enables the whale optimization algorithm to converge non-linearly in the number of iterations, thereby increasing the diversity of the search process and its ability to escape local optima. (Non-linear convergence factor) The expression is: .
[0043] Furthermore, in S3, the weights and thresholds of the BP neural network model affect the accuracy and stability of the prediction. The mean squared error (MSE) is set as the fitness function, and the improved whale optimization algorithm is used to optimize the weights and thresholds of the BP neural network. The expression for mean squared error (MSE) is: ; In the formula, This indicates the predicted optimal rotational speed; This represents the optimal rotational speed obtained from the experiment; This indicates the lower bound of the summation formula; This indicates the upper bound of the summation formula.
[0044] Furthermore, in S4, the population size and number of iterations for the improved whale optimization algorithm are set, and training is performed to compare the coefficient of determination R before and after optimization. 2 The performance of the prediction model is evaluated by comparing the root mean square error (RMSE). Coefficient of determination R 2 The expression is: ; In the formula, This represents the average value of the optimal rotational speed obtained from the experiment; The expression for the root mean square error (RMSE) is: .
[0045] This invention discloses a method for predicting the optimal speed of a motor based on a whale optimization algorithm and a neural network. Taking a pump-machine integrated permanent magnet synchronous motor system as an example, the optimal speed of the pump-machine integrated permanent magnet synchronous motor system is predicted. An embodiment of this invention is described in detail below with reference to the accompanying drawings.
[0046] The method for predicting the optimal motor speed based on the whale optimization algorithm and neural network includes the following steps: First, input the data detected by the sensor and the optimal speed. The data detected by the sensor includes unit status data, crude oil temperature, screw pump differential pressure and winding temperature. Then, the above data is normalized.
[0047] The second step involves neural network prediction algorithms, including BP neural networks and random forests.
[0048] Backpropagation (BP) neural networks are multi-layer feedforward architectures optimized by gradient descent, widely used in pattern recognition, dynamic prediction, and other fields. Their core structure consists of a fully connected input layer, nonlinear hidden layers, and an output layer. Through their hierarchical structure, BP neural networks exhibit significant advantages in handling complex nonlinear relationships. The structure of a BP neural network is as follows: Figure 2 As shown.
[0049] The BP neural network prediction process is as follows: data preprocessing to ensure the standardization and normalization of input data; designing the neural network topology, determining the number of neurons in the input layer, hidden layer, and output layer; initializing the neural network parameters, including weights and thresholds; calculating the predicted value through forward propagation and quantifying the prediction bias using a loss function; calculating gradient information using the backpropagation algorithm and optimizing the neural network parameters using gradient descent; and iterative training to bring the prediction model to the predetermined performance index. The flowchart of the BP neural network is as follows: Figure 3 As shown.
[0050] The neural network was set to have 1 hidden layer, 1000 iterations, a learning rate of 0.01, and an expected error of [missing value]. Furthermore, since the prediction of the optimal speed of the pump-machine integrated permanent magnet synchronous motor system is a regression task with continuous output, the tansig function is selected as the activation function for the hidden layer and the purelin function is selected as the activation function for the output layer.
[0051] The expression for the tansig function is: ; The tansig function is the hyperbolic tangent function, which can provide a smooth nonlinear transformation and is suitable for small-scale prediction training. It produces a normalized centered output, making it suitable for regression tasks, especially for data with both positive and negative values. However, it may also experience gradient vanishing.
[0052] Used to calculate the number of neurons in the hidden layer. The expression is: ; In the formula, This indicates the number of neurons in the input layer, which is set to 3. This indicates the number of neurons in the output layer, set to 1. Usually, the value is between 1 and 10.
[0053] The number of neurons in the hidden layer can be determined from the above formula. Further, the hidden layer neuron array is configured, and a recurrent function is constructed. The mean squared error (MSE) of the training set is used as the evaluation criterion. The expression for the mean squared error (MSE) is: ; In the formula, This indicates the predicted optimal rotational speed; This represents the optimal rotational speed obtained from the experiment; By comparing the mean squared error (MSE) of different numbers of hidden layer neurons, the number of hidden layer neurons corresponding to the smallest MSE is selected as the optimal hidden layer structure to improve the prediction accuracy and generalization ability of the network.
[0054] Random forest is a machine learning method based on the ensemble learning paradigm, suitable for classification and regression tasks. This algorithm first constructs multiple decision trees and then integrates the multivariate prediction results based on majority voting or averaging mechanisms, thereby effectively improving the model's generalization ability and prediction accuracy. As a tree-structured model, decision trees achieve prediction functionality by recursively performing feature selection and segmentation operations on the data. The decision tree structure of random forest is as follows: Figure 4 As shown.
[0055] In the data preprocessing stage, Random Forest uses sampling with replacement to generate multiple distinct training subsets from the original training set. Subsequently, during the training of the decision trees, the algorithm randomly selects only a subset of features to search for the optimal split point at each node, rather than considering all features, thus introducing additional randomness to increase the diversity among the decision trees. Finally, the regression task output is the average of the predictions from all decision trees; while for the classification task, a majority voting method is used to determine the class label. The flowchart of Random Forest is as follows... Figure 5 As shown.
[0056] During the prediction process, the prediction accuracy of a random forest model is related to the number of decision trees and the size of the leaves. The size of the leaves directly affects the prediction complexity. Leaves that are too small can lead to overfitting, especially when there is little data. This results in high prediction accuracy on the training set but poor performance on the test set, indicating low generalizability. Conversely, larger leaves may lead to underfitting, affecting prediction accuracy. Increasing the number of decision trees can improve the stability and accuracy of the prediction model, but it also increases computation time. The common number of decision trees is between 100 and 1000.
[0057] To determine the parameter settings for random forests and compare the performance of different leaf sizes and numbers of decision trees, the mean squared error (MSE) was used as the evaluation metric. The results are as follows: Figure 6As shown. By Figure 6 It is known that the mean square error curve tends to stabilize when the number of trees is greater than 150, with different leaf sizes. Therefore, the number of trees is taken as 200, and the leaf size of 5 is taken as the smallest error.
[0058] Comparison of prediction results between BP neural network and random forest: To ensure sufficient training of the prediction model, the optimal rotation speed experimental data were shuffled, with 80% as the training set and 20% as the test set. Five prediction calculations were performed, as follows: Figure 7 , Figure 8 , Figure 9 , Figure 10 , Figure 11 , Figure 12 , Figure 13 as well as Figure 14 As shown in the figure, the percentage error range of the BP neural network is better than that of the random forest, but the percentage error curve is messy and irregular, indicating that its prediction performance is not stable enough. The percentage error curve of the random forest shows strong regular fluctuations and exhibits relatively stable performance, but its frequent high errors greatly affect the prediction accuracy.
[0059] Using the coefficient of determination R 2 To further compare the prediction performance of BP neural networks and random forests with the root mean square error (RMSE): Coefficient of determination R 2 The expression is: ; In the formula, This indicates the predicted optimal rotational speed; This represents the optimal rotational speed obtained from the experiment; This represents the average value of the optimal rotational speed obtained from the experiment; The expression for the root mean square error (RMSE) is: .
[0060] Obtain the test set R for both BP neural network and random forest models. 2 The RMSE is shown in the table below: Table 1 Predictive performance of the two models .
[0061] In the coefficient of determination R 2 Regarding the performance of the root mean square error (RMSE), Table 1 shows that the BP neural network has poor stability and fluctuates greatly in multiple predictions, while the random forest has more stable performance. However, the mean performance of the BP neural network is better than that of the random forest. Therefore, this invention uses the BP neural network for prediction.
[0062] The third step is to initialize the parameters of the whale optimization algorithm and optimize the weights and thresholds of the BP neural network by improving the whale optimization algorithm.
[0063] The whale optimization algorithm consists of three parts: prey encirclement, spiral bubble net predation, and random search. The flowchart of the whale optimization algorithm is shown below. Figure 15 As shown; Prey Encirclement: The optimal rotation speed in the current iteration is taken as the target prey. By defining the optimal rotation speed as the optimal search agent, other search agents will gradually move closer to this optimal search agent to update their own positions. Its expression is: ; ; In the formula, Indicates the current iteration number; Indicates the current rotational speed; Indicates iteration to Rotational speed at +1 time; This indicates the optimal rotational speed in the current iteration; , Both are coefficient vectors; This indicates the distance between the current position and the prey's position, where the current position represents the current rotation speed and the prey's position represents the optimal rotation speed. in, , The expressions are as follows: ; ; In the formula, , It is a random vector in the interval [0,1]. The convergence factor; The spiral bubble net predation mechanism includes bubble net predation and encirclement predation; The expression for bubble web predation is: ; ; In the formula, This represents the spiral shape parameter, set to 1; A random number within the interval [-1, 1]; This represents the distance between the current search agent and the optimal search agent, where the current search agent represents the current rotation speed and the optimal search agent represents the optimal rotation speed. Encirclement predation has two methods: contraction encirclement and spiral encirclement. These two predatory behaviors are carried out through... To determine, when Less than When, the position is updated, and a shrinking wrapper is used. Greater than or equal to At this time, a spiral approach is made to the target, employing a spiral encirclement; the expression for encirclement and predation is: ; In the formula, This represents the predation method determinant, and is a random number within the interval [0,1]. Take 0.5; As the iteration proceeds, the convergence factor... It shows a decreasing trend, at the same time Continuously decreasing, when At this time, the current search agent, i.e. the current rotation speed, will gradually move closer to the current optimal agent, i.e. the optimal rotation speed, thus entering the local optimization stage; Random search mechanism: To ensure a comprehensive search in the solution space, the whale optimization algorithm dynamically adjusts the position of the search agent by calculating the relative distance between individual whales, thereby achieving the purpose of random search; During the exploration phase, the whale optimization algorithm enhances its global exploration capability by using a randomly selected search agent, i.e., a random rotation. The expression for the random search is: ; ; In the formula, Indicates random rotational speed; This represents the distance between the current search agent and the random agent, where the search agent represents the current rotation speed and the random agent represents the random rotation speed.
[0064] This invention introduces an adaptive weighting strategy. With nonlinear convergence factor The whale optimization algorithm is improved by generating adaptive weights and nonlinear convergence curves. In particular, an adaptive weight strategy is introduced into the whale optimization algorithm. This approach aims to improve the algorithm's global search capability and convergence performance, enhance its adaptability in handling high-dimensional problems, and achieve a dynamic balance between exploration and development through an adaptive weighting strategy. The expression is: ; In the formula, Indicates the current iteration number; Indicates the maximum number of iterations; Introducing a weighting strategy The position update expression for the subsequent whale optimization algorithm is: .
[0065] Introducing a weighting strategy Then a nonlinear convergence factor is introduced. Through nonlinear convergence factor This enables the whale optimization algorithm to converge non-linearly in the number of iterations, thereby increasing the diversity of the search process and its ability to escape local optima. (Non-linear convergence factor) The expression is: ; The weights and thresholds of a BP neural network model affect the accuracy and stability of predictions. The mean squared error (MSE) is set as the fitness function, and an improved whale optimization algorithm is used to optimize the weights and thresholds of the BP neural network.
[0066] The fourth step is to output the optimal weights and thresholds of the BP neural network and perform training and testing.
[0067] The improved whale optimization algorithm was used to optimize a BP neural network model with a population size of 50 and an iteration count of 500. The model was trained five times, and the distribution of predictions and percentage errors on the training and test sets is shown in the figure below. Figure 16 , Figure 17 , Figure 18 as well as Figure 19 As shown.
[0068] Backpropagation Neural Network and Improved Whale Algorithm: Optimization of Backpropagation Neural Network, Test Set R before and after. 2 The RMSE is shown in the table below: Table 2 Prediction performance before and after the improved model .
[0069] As shown in the above figure and Table 2, the improved whale optimization algorithm significantly enhances the prediction performance of the BP neural network model compared to the traditional BP neural network. It exhibits better fitting performance on the test set, a smaller percentage error fluctuation range compared to before optimization (controlling the percentage error within ±1%), and higher stability, with improved error curve overlap. R0 2 The accuracy reached 0.9926, and the RMSE was 1.8554, a reduction of 46.14%. The improved whale optimization algorithm improved the prediction accuracy and stability of the BP neural network model.
[0070] To more intuitively compare the prediction performance of random forest, backpropagation neural network, and improved whale optimization algorithm optimized neural network models, the fitting training prediction and error of the three models are compared as follows: Figure 20 , Figure 21 , Figure 22 as well as Figure 23As shown in the figure above, the improved whale optimization algorithm for optimizing the BP neural network exhibits superior performance compared to the BP neural network and random forest algorithms. It provides more accurate fitting, and the percentage error distribution is more stable, remaining within ±1%. This enables accurate prediction of the optimal speed of the pump-machine integrated permanent magnet synchronous motor system.
[0071] The fifth step is to construct an optimized BP neural network model to predict the optimal rotational speed.
[0072] Of course, the above description is not intended to limit the present invention, and the present invention is not limited to the examples given above. Any changes, modifications, additions or substitutions made by those skilled in the art within the scope of the present invention should also fall within the protection scope of the present invention.
Claims
1. A method for predicting the optimal motor speed using a neural network based on the whale optimization algorithm, characterized in that, Includes the following steps: S1. Input sensor detection data and optimal rotation speed, and normalize the data; S2. Design the topology of the BP neural network and initialize its parameters. S3. Initialize the parameters of the whale optimization algorithm, improve the whale optimization algorithm by introducing a weight strategy and a nonlinear convergence factor, and optimize the weights and thresholds of the BP neural network by improving the whale optimization algorithm. S4. Output the optimal weights and thresholds of the BP neural network, and perform training and testing; S5. Construct a model to predict the optimal rotational speed by optimizing a BP neural network.
2. The method for predicting the optimal motor speed based on the whale optimization algorithm and neural network according to claim 1, characterized in that, In S2, the prediction process of the BP neural network is as follows: S21. Input data preprocessing: Ensure the standardization and normalization of input data, and input the processed data into the input layer of the BP neural network; S22. Design the topology of the BP neural network and determine the number of neurons in the input layer, hidden layer, and output layer. S23. Initialize the BP neural network parameters, which include weights and thresholds; S24. Calculate the predicted value through forward propagation and quantify the prediction bias using a loss function; S25. Calculate gradient information using the backpropagation algorithm and optimize the parameters of the BP neural network by combining gradient descent. S26. Through iterative training, the prediction model reaches the predetermined performance index.
3. The method for predicting the optimal motor speed based on the whale optimization algorithm and neural network according to claim 2, characterized in that, In S3, the whale optimization algorithm consists of three parts: prey encirclement, spiral bubble net predation, and random search; Prey Encirclement: The optimal rotation speed in the current iteration is taken as the target prey. By defining the optimal rotation speed as the optimal search agent, other search agents will gradually move closer to this optimal search agent to update their own positions. Its expression is: ; ; In the formula, Indicates the current iteration number; Indicates the current rotational speed; Indicates iteration to Rotational speed at +1 time; This indicates the optimal rotational speed in the current iteration; , Both are coefficient vectors; This indicates the distance between the current position and the prey's position, where the current position represents the current rotation speed and the prey's position represents the optimal rotation speed. in, , The expressions are as follows: ; ; In the formula, , It is a random vector in the interval [0,1]. The convergence factor; The spiral bubble net predation mechanism includes bubble net predation and encirclement predation; The expression for bubble web predation is: ; ; In the formula, This represents the spiral shape parameter, set to 1; A random number within the interval [-1, 1]; This represents the distance between the current search agent and the optimal search agent, where the current search agent represents the current rotation speed and the optimal search agent represents the optimal rotation speed. Encirclement predation has two methods: contraction encirclement and spiral encirclement. These two predatory behaviors are achieved through... To determine, when Less than When, the position is updated, and a shrinking wrapper is used. Greater than or equal to At this time, a spiral approach is made to the target, employing a spiral encirclement; the expression for encirclement and predation is: ; In the formula, This represents the predation method determinant, and is a random number within the interval [0,1]. Take 0.5; As the iteration proceeds, the convergence factor... It shows a decreasing trend, at the same time Continuously decreasing, when At this time, the current search agent, i.e. the current rotation speed, will gradually move closer to the current optimal agent, i.e. the optimal rotation speed, thus entering the local optimization stage; Random search mechanism: The whale optimization algorithm dynamically adjusts the position of the search agent by calculating the relative distance between individual whales, thereby achieving the purpose of random search; During the exploration phase, the whale optimization algorithm enhances its global exploration capability by using a randomly selected search agent, i.e., a random rotation. The expression for the random search is: ; ; In the formula, Indicates random rotational speed; This represents the distance between the current search agent and the random agent, where the search agent represents the current rotation speed and the random agent represents the random rotation speed.
4. The method for predicting the optimal motor speed based on the whale optimization algorithm and neural network according to claim 3, characterized in that, Introducing an adaptive weight strategy into the whale optimization algorithm This approach aims to improve the algorithm's global search capability and convergence performance, enhance its adaptability in handling high-dimensional problems, and achieve a dynamic balance between exploration and development through an adaptive weighting strategy. The expression is: ; In the formula, Indicates the maximum number of iterations; Introducing a weighting strategy The position update expression for the subsequent whale optimization algorithm is: 。 5. The method for predicting the optimal motor speed based on the whale optimization algorithm and neural network according to claim 4, characterized in that, Convergence factor As a nonlinear convergence factor, a weighting strategy is introduced. Then a nonlinear convergence factor is introduced. The whale optimization algorithm is improved by generating adaptive weights and nonlinear convergence curves, through a nonlinear convergence factor. This enables the whale optimization algorithm to converge non-linearly in the number of iterations, thereby increasing the diversity of the search process and its ability to escape local optima. (Non-linear convergence factor) The expression is: 。 6. The method for predicting the optimal motor speed based on the whale optimization algorithm using a neural network according to claim 5, characterized in that, In S3, the weights and thresholds of the BP neural network model affect the accuracy and stability of the prediction. The mean squared error (MSE) is set as the fitness function, and the improved whale optimization algorithm is used to optimize the weights and thresholds of the BP neural network. The expression for mean squared error (MSE) is: ; In the formula, This indicates the predicted optimal rotational speed; This represents the optimal rotational speed obtained from the experiment; This indicates the lower bound of the summation formula; This indicates the upper bound of the summation formula.
7. The method for predicting the optimal motor speed based on the whale optimization algorithm using a neural network according to claim 6, characterized in that, In S4, the population size and number of iterations for the improved whale optimization algorithm are set, and the training is performed. The coefficient of determination R before and after optimization is compared. 2 The performance of the prediction model is evaluated by comparing the root mean square error (RMSE). Coefficient of determination R 2 The expression is: ; In the formula, This represents the average value of the optimal rotational speed obtained from the experiment; The expression for the root mean square error (RMSE) is: 。