A PSO supervision-based LSTM-PID gain scheduling method and system
Patent Information
- Application Number
- CN202611196272.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-07
- Publication Date
- 2026-10-30
AI Technical Summary
但现有学习类方法大多聚焦参数预测,常仅以预测误差作为训练目标,缺少闭环控制效果验证;单纯缩小预测参数与PSO标签的误差,并不能保证控制器具备优良的频率调节能力
1.本发明提出一种基于PSO监督的LSTM-PID增益调度方法,将离线优化与在线快速推理相结合。利用PSO作为离线“教师”模型生成高质量PID参数标签,利用LSTM作为快速在线增益调度器,实现了含可再生能源微电网的自适应频率调节。该方法在保持PID控制器作为最终执行层的同时,使控制增益能够随运行场景动态变化。
Smart Images

Figure CN123018899A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of microgrid frequency control technology, specifically relating to a Long Short-Term Memory (LSTM)-PID gain scheduling method and system based on Particle Swarm Optimization (PSO) supervision, which is suitable for efficient frequency regulation in microgrids containing renewable energy. Background Technology
[0002] However, the high proportion of renewable energy has changed the architecture and operation mode of microgrids. The local power supply architecture of microgrids, which includes photovoltaic, wind power, energy storage and adjustable units, improves system flexibility, but random fluctuations in renewable energy output and load can easily cause power imbalance. In islanded mode, the difficulty of frequency stability control increases significantly. Maintaining frequency stability under disturbances is the core challenge of microgrid control.
[0003] The proportional-integral-derivative (PID) controller has a simple control structure and is easy to implement in engineering, making it widely used in microgrid frequency regulation. However, fixed-parameter PID controllers are difficult to adapt to varying operating conditions, and their control performance is limited when the source load and energy storage state change dynamically. Existing research often uses particle swarm optimization (PSO) to tune PID parameters, which can achieve better dynamic performance than manual tuning. However, PSO requires repeated closed-loop simulations to evaluate parameters, and its computational efficiency is low when operating conditions change frequently.
[0004] Meanwhile, LSTM, with its ability to extract time-series features, is suitable for modeling time-series operation data of microgrids and is gradually gaining attention in the field of power frequency regulation. However, most existing learning methods focus on parameter prediction, often using only the prediction error as the training objective, and lack verification of closed-loop control performance; simply reducing the error between the predicted parameters and the PSO label cannot guarantee that the controller has excellent frequency regulation capabilities.
[0005] In summary, there is currently a lack of a solution that can combine the advantages of PSO offline optimization with the fast inference characteristics of LSTM, and construct a gain scheduling strategy with closed-loop control performance as the core evaluation criterion. Summary of the Invention
[0006] (a) Purpose of the invention: The purpose of this invention is to overcome the shortcomings of the prior art and provide an LSTM-PID gain scheduling method and system based on PSO supervision. This method combines offline optimization with online fast inference, and while maintaining frequency control performance close to that of PSO optimization, it achieves fast PID parameter generation through LSTM learning. This allows for a balance between frequency control performance and computational efficiency in microgrids containing renewable energy.
[0007] (II) Technical Solution: A PSO-supervised LSTM-PID gain scheduling method for frequency regulation in microgrids containing renewable energy includes the following steps: S1. Construct multiple microgrid operation scenarios containing renewable energy sources. Each operation scenario includes a photovoltaic power sequence, a wind power sequence, a load demand sequence, and the initial state of charge of the battery. S2. Using the particle swarm optimization algorithm as the offline teacher model, for each operating scenario, with the goal of minimizing the normalized closed-loop objective function, the optimal PID control gain is searched within the preset parameter search range, and PID parameter labels corresponding to each operating scenario are generated. S3. Perform quality review on the generated PID parameter labels. After the review is passed, construct a supervised learning dataset using the running scenario sequence and the corresponding PID parameter labels. S4. Construct a long short-term memory network gain scheduler, taking the running scenario sequence as input and the PID control gain as output. Train the LSTM network using a supervised learning dataset to learn the mapping relationship between the running condition sequence and the PID parameters. S5. Train multiple LSTM candidate models, and substitute the PID parameters output by the multiple LSTM candidate models into the microgrid closed-loop model for verification. Select the final LSTM gain scheduler based on the closed-loop control performance on the verification set. The evaluation indicators of the closed-loop control performance include normalized comprehensive cost, maximum frequency deviation, root mean square error of frequency, time-weighted absolute error integral, and constraint violation. S6: Freeze the selected LSTM gain scheduler. For a new operating scenario, input the operating scenario sequence into the frozen LSTM gain scheduler for a single forward inference to generate the corresponding PID control gain, which is then directly applied to the microgrid frequency control.
[0008] Preferably, the normalized closed-loop objective function in S2 is expressed as: ; in, To normalize the overall cost, For the first A normalized target term, For the corresponding weighting coefficients, To constrain violation penalty items; constraint violation penalty items are used to handle one or more of the following constraint exceedance situations: frequency exceeding limit, control input saturation, battery power constraint violation, diesel generator power constraint violation, and battery state of charge constraint violation.
[0009] Preferably, the quality review in S3 includes: Whether the PSO optimization process successfully converges and generates complete labels; Are the optimized PID parameters within the preset search range? Can the closed-loop simulation be completed normally? Are there any violations of physical constraints? Compared to a fixed-parameter PID reference controller, can the PSO parameter improve the system's frequency response performance? Only after all five review criteria are met will the PSO label be included in the supervised learning dataset.
[0010] Preferably, the input features of the LSTM network include: photovoltaic power sequence. Wind power series Load demand sequence and the initial state of charge of the battery The output consists of three PID control parameters: proportional gain. .
[0011] Preferably, in S5, the final LSTM gain scheduler is selected based on the closed-loop control performance on the validation set, specifically as follows: The validation set scenario is input into each LSTM candidate model to obtain the predicted PID parameters. The PID parameters are then applied to the same microgrid closed-loop model for simulation and compared with the fixed PID benchmark controller and the PSO teacher controller. A candidate model is considered a qualified model only if it meets all of the following conditions: No constraint violation occurs; Compared to a fixed PID reference, it can reliably improve closed-loop performance; Among all qualified models, the model with the lowest average normalized synthesis cost on the validation set is selected as the final LSTM gain scheduler.
[0012] Preferably, in S6, after freezing the selected LSTM gain scheduler, the generalization performance of the frozen LSTM scheduler is evaluated on an independent test set. The independent test set does not participate in the model training and model selection process, and the evaluation results on the independent test set are used to finally verify the frequency regulation effect of the LSTM scheduler in unseen operating scenarios.
[0013] Preferred options also include post-event methods. Ablation analysis steps: Without retraining the LSTM scheduler, extract the differential gain of the frozen LSTM gain scheduler output. The differential gain was forced to zero and retested in the closed-loop model to analyze its contribution to frequency regulation performance.
[0014] A PSO-supervised LSTM-PID gain scheduling system, which runs a PSO-supervised LSTM-PID gain scheduling method, includes: The operation scenario generation module is used to construct multiple operation scenarios of microgrids containing renewable energy, including photovoltaic power sequence, wind power sequence, load demand sequence and battery initial state of charge. The offline PSO teacher module is used as an offline teacher model. For each operating scenario, the offline PSO teacher module aims to minimize the normalized closed-loop objective function, searches for the optimal PID control gain within a preset parameter search range, and generates PID parameter labels corresponding to each operating scenario. The dataset construction module is used to perform quality review on the generated PID parameter labels. After the dataset construction module passes the review, it uses the running scenario sequence and the corresponding PID parameter labels to construct a supervised learning dataset. The LSTM gain scheduler training module is used to construct a long short-term memory network gain scheduler. The LSTM gain scheduler training module takes the running scenario sequence as input and PID control gain as output, and uses the supervised learning dataset to train the LSTM network. The closed-loop performance verification and model selection module is used to train multiple LSTM candidate models. The closed-loop performance verification and model selection module substitutes the PID parameters output by multiple LSTM candidate models into the microgrid closed-loop model for verification, and selects the final LSTM gain scheduler based on the closed-loop control performance on the verification set. The online inference and parameter generation module is used to freeze the selected LSTM gain scheduler. For a new running scenario, the online inference and parameter generation module inputs the running scenario sequence into the frozen LSTM gain scheduler to perform a single forward inference and generate the corresponding PID control gain. The PID control execution module is used to apply the generated PID control gain to the microgrid frequency control.
[0015] Preferably, in the LSTM gain scheduler training module, the training loss function is defined as the mean square error between the predicted PID parameters and the PSO labels: ; in, This represents the total number of samples in the supervised learning dataset used for LSTM training and validation. For the index number of the running scenario, In order to target the PID parameters predicted by LSTM for each running scenario In order to target the The PID parameter labels generated by PSO for each running scenario.
[0016] Preferably, the operating scenario is divided into three parts: a training set, a validation set, and an independent test set, and this division remains unchanged in all experiments. The training set is used to train the LSTM gain scheduler, the validation set is used for model selection based on closed-loop performance, and the independent test set is used only to evaluate generalization performance after the final scheduler is determined.
[0017] (III) Beneficial Effects: Compared with the prior art, the present invention has the following advantages: 1. This invention proposes an LSTM-PID gain scheduling method based on PSO supervision, combining offline optimization with online fast inference. PSO is used as an offline "teacher" model to generate high-quality PID parameter labels, and LSTM is used as a fast online gain scheduler to achieve adaptive frequency regulation in microgrids containing renewable energy. This method maintains the PID controller as the final execution layer while enabling the control gain to dynamically change according to the operating scenario.
[0018] 2. In the model selection process, this invention not only considers parameter prediction error but also evaluates the scheduler through closed-loop simulation performance, thereby ensuring control effectiveness. The model evaluation criterion has been changed from "whether the parameters are close to the PSO label" to "whether the control performance is close to the PSO teacher," avoiding the problem of poor control performance caused by relying solely on parameter prediction error to select a model.
[0019] 3. This invention significantly reduces parameter generation time while ensuring frequency adjustment performance is close to that of PSO optimization. PSO requires an average of about 102 seconds to generate a single-scene gain, while LSTM only needs about 9.856 milliseconds to complete one forward inference, with an average speedup of over 10,000 times. It achieves an effective balance between control performance and computational efficiency and has high engineering application value.
[0020] 4. The final execution layer of this invention is still a PID controller. The LSTM does not directly output battery power or diesel generator power, nor does it replace the microgrid controller itself. It is only responsible for generating PID parameters, thus retaining the advantages of the PID control structure, such as its simplicity, ease of implementation, and strong interpretability.
[0021] 5. The monitoring information in this invention originates from closed-loop optimization. The PSO label is not an empirical parameter, but is obtained through microgrid closed-loop simulation and objective function optimization. It naturally includes information such as frequency regulation performance, control cost, and constraint satisfaction, ensuring the quality and effectiveness of the monitoring signal.
[0022] 6. Simulation results show that, in 40 independent test scenarios, the selected LSTM-PID controller reduces the average overall cost from 1.000000 to 0.897420. Compared with the fixed-parameter PID, the average peak frequency deviation, root mean square error of frequency (RMSE), and time-weighted integral of absolute error (ITAE) are reduced by 27.187%, 28.200%, and 29.261%, respectively. In all test scenarios, the LSTM scheduler outperforms the fixed-parameter PID, recovering 92.683% of the performance advantage of the PSO teacher controller, without any constraint violations. Attached Figure Description
[0023] Figure 1 This is a schematic diagram of the structural principle of an LSTM-PID gain scheduling system based on PSO supervision according to the present invention. Figure 2 This is a general framework diagram of an LSTM-PID gain scheduling method based on PSO supervision according to the present invention. Figure 3 Figure (a) shows the verification diagram of PSO teacher label quality and frequency constraints of the LSTM-PID gain scheduling method and system based on PSO supervision of the present invention. The count distribution diagram, Figure (b) is The count distribution diagram, Figure (c) is The count distribution chart, Figure (d) is the PSO teacher improvement chart, Figure (e) is... Distribution map, Figure (f) is Distribution map; Figure 4 Figure 1 shows a comparison of the closed-loop performance of an independent test set of the LSTM-PID gain scheduling method and system based on PSO supervision of the present invention. Figure 2 shows the average cost of the composite target, Figure 3 shows the peak frequency deviation, Figure 4 shows the root mean square error of the frequency, and Figure 5 shows the time-weighted frequency error. Figure 5 Figure (a) shows the closed-loop cost and performance improvement of the LSTM-PID gain scheduling method and system based on PSO supervision in various scenarios according to the present invention. Figure (b) shows the closed-loop cost diagram divided by scenario and the performance improvement diagram compared with fixed PID. Figure 6 Figure 1 shows the PID gain generation and calculation efficiency diagram of the LSTM-PID gain scheduling method and system based on PSO supervision of the present invention. Figure 2 shows the time cost diagram for each scenario, Figure 3 shows the acceleration distribution diagram, Figure 4 shows the speedup ratio diagram divided by case, and Figure 5 shows the average time comparison diagram. Figure 7The following are representative operating condition test_307 data graphs of the LSTM-PID gain scheduling method and system based on PSO supervision of the present invention, wherein Figure (a) is the frequency deviation graph, Figure (b) is the battery output power graph, Figure (c) is the diesel generator output power graph, and Figure (d) is the battery charging state graph. Figure 8 The following are the optimal improvement conditions test_306 data graphs for the LSTM-PID gain scheduling method and system based on PSO supervision of the present invention, wherein Figure (a) is the frequency deviation graph, Figure (b) is the battery output power graph, Figure (c) is the diesel generator output power graph, and Figure (d) is the battery charging state graph. Figure 9 The following are challenging test_288 data graphs for the LSTM-PID gain scheduling method and system based on PSO supervision of the present invention, wherein Figure (a) is the frequency deviation graph, Figure (b) is the battery output power graph, Figure (c) is the diesel generator output power graph, and Figure (d) is the battery charging state graph. Figure 10 This invention provides an LSTM-PID gain scheduling method and system based on PSO supervision, and its LSTM-PID... A case-by-case comparison of ablation in various scenarios, where Figure (a) shows LSTM-PID and The comparison images have been removed; Figure (b) shows the images that have been retained. The benefits are illustrated in the diagram. Figure 11 This invention relates to a PSO-supervised LSTM-PID gain scheduling method and system with fixed PID, LSTM-PID, and... The average performance comparison charts of ablation are shown, where (a) is the average cost chart of the composite target, (b) is the peak frequency deviation chart, (c) is the root mean square error of frequency chart, and (d) is the time-weighted frequency error chart. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be described in detail below with reference to the accompanying drawings and embodiments.
[0025] The following is in conjunction with the appendix Figures 1-11 The embodiments of the present invention will be described in detail below.
[0026] Example 1, theoretical derivation, such as Figure 1 , Figure 2 As shown: S1: Construct multiple microgrid operation scenarios containing renewable energy sources. Each operation scenario includes a photovoltaic power sequence, a wind power sequence, a load demand sequence, and an initial state of charge of the batteries. The operation scenario is represented as follows: in, For the first Complete working condition sequence samples in each scenario For the first Photovoltaic power sequences in various scenarios For the first Wind power sequence in a specific scenario For the first Load demand sequence in each scenario For the first The initial state of charge of the battery in each scenario.
[0027] Operating conditions are not described by a single scalar value at a certain moment, but rather retain complete time-series information because the system frequency response depends not only on the magnitude of the disturbance, but also on the process by which the disturbance changes over time.
[0028] S2: Using particle swarm optimization as the offline teacher model, for each operating scenario, the optimal PID control gain is searched within a preset parameter search range with the goal of minimizing the normalized closed-loop objective function. This generates PID parameter labels corresponding to each operating scenario. For the first... In a given operational scenario, the PSO optimization problem can be represented as: ; in, This represents the feasible search space for PID parameters.
[0029] The PSO search process is based on closed-loop simulation. Each particle corresponds to a set of candidate PID parameters. When a set of parameters is applied to the microgrid model, the frequency deviation, control cost, and constraint penalty are calculated through closed-loop simulation to obtain the objective function value. The particle is updated based on its individual historical optimal information and global optimal information until the maximum number of iterations is reached or the convergence condition is met.
[0030] S3: Perform quality review on the generated PID parameter labels. After passing the review, construct a supervised learning dataset using the running scenario sequences and the corresponding PID parameter labels. The quality review includes the following: (1) Whether the PSO optimization process successfully converged and generated complete labels; (2) Whether the optimized PID parameters are within the preset search range; (3) Whether the closed-loop simulation can be completed normally; (4) Are there any violations of physical constraints? (5) Whether the PSO parameter can improve the system frequency response performance compared with the fixed parameter PID reference controller.
[0031] Only after all five review criteria are met will the PSO label be included in the supervised learning dataset. The supervised learning dataset is represented as follows: .
[0032] S4: Construct a Long Short-Term Memory (LSTM) network gain scheduler, using the operating scenario sequence as input and the PID control gain as output. Train the LSTM network using the supervised learning dataset to learn the mapping relationship between the operating condition sequence and the PID parameters. The input features of the LSTM network include photovoltaic power sequences. Wind power series Load demand sequence and the initial state of charge of the battery The output consists of three PID control parameters. The mapping relationship of the LSTM gain scheduler is expressed as follows: ; in, This represents the learned gain scheduling function.
[0033] The training loss function is defined as the mean squared error between the predicted PID parameters and the PSO labels: ; This loss function makes the LSTM output approximate the PSO label as closely as possible.
[0034] S5: Train multiple LSTM candidate models (using different random seeds), substitute the PID parameters output by each candidate model into the microgrid closed-loop model for verification, and select the final LSTM gain scheduler based on the closed-loop control performance on the verification set.
[0035] Evaluation metrics for closed-loop control performance include: (1) Normalized total cost ; (2) Maximum frequency deviation ; (3) Root mean square error of frequency ; The total time for integrating the frequency deviation; for System frequency deviation at any given time; (4) Time-weighted absolute error integral ; (5) Constraint violations (including frequency exceeding limits, control input saturation, battery power constraint violations, diesel generator power constraint violations, and battery state of charge constraint violations).
[0036] The specific model selection strategy based on closed-loop performance is as follows: The validation set scenario is input into each LSTM candidate model to obtain the predicted PID parameters. These PID parameters are then applied to the same microgrid closed-loop model for simulation, and compared with a fixed PID benchmark controller and a PSO teacher controller. A candidate model is considered a qualified model only if it meets all of the following conditions: (1) it does not generate any constraint violations; (2) it can stably improve the closed-loop performance compared to the fixed PID benchmark. Among all qualified models, the model with the lowest average normalized synthesis cost in the validation set is selected as the final LSTM gain scheduler.
[0037] S6: Freeze the selected LSTM gain scheduler. For a new running scenario, input the running scenario sequence into the frozen LSTM gain scheduler for a single forward inference to generate the corresponding PID control gain. It is directly applied to microgrid frequency control, among which, The proportional gain value predicted by LSTM. The integral gain value predicted by LSTM. This represents the differential gain value predicted by the LSTM.
[0038] After training is complete, the LSTM scheduler only needs to perform one forward inference to generate PID parameters, thus avoiding repeated execution of the PSO optimization process.
[0039] All operating scenarios were divided into three parts: a training set, a validation set, and an independent test set. The training set was used to learn the mapping relationship between operating conditions and controller parameters; the validation set was used to select the final LSTM gain scheduler; and the independent test set was used only after the model parameters were fully determined to more objectively evaluate the generalization performance of the proposed method. Once the dataset partitioning was determined, it remained unchanged in all subsequent experiments.
[0040] Afterwards Ablation analysis steps: Without retraining the LSTM scheduler, extract the differential gain of the frozen LSTM gain scheduler output. The differential gain was forced to zero and retested in the closed-loop model to analyze its contribution to frequency regulation performance.
[0041] Example 2: Simulation Platform and Experiment Setup This embodiment completes all simulation experiments on MATLAB and Simulink platforms. The established microgrid frequency control model includes photovoltaic power generation units, wind power generation units, battery energy storage systems, diesel generators, load disturbances, and PID controllers; among them, the photovoltaic branch, wind power branch, and load branch all adopt a dual-input structure of base power superimposed with corresponding disturbance power, and output the actual operating power through their respective dynamic models; the power of each branch is according to... The net power imbalance is obtained by summarizing the relationships. Then, the power system frequency dynamic model is input, and the transfer function of this model is... , The Laplace transform operator outputs the system frequency deviation. After the frequency deviation signal is input to the PID controller to generate the control quantity, it is split into battery power command and diesel generator power command by the control distribution / execution module, and sent to the battery energy storage branch and the diesel generator branch respectively. The battery energy storage branch is equipped with a state of charge (SOC) constraint power limiter. The real-time SOC value is obtained by calculating the rate of change of state of charge dSOC / dt and integrating it to form an SOC feedback constraint to limit the range of battery output power and ensure that the battery operates within a reasonable state of charge range. The fixed PID scheme, PSO teacher model and LSTM-PID scheme share the same microgrid simulation platform as described above. The only difference is the source of PID gain generation.
[0042] 1. Scene generation and dataset partitioning 320 microgrid operation scenarios with renewable energy were constructed. Each scenario consists of a photovoltaic power sequence, a wind power sequence, a load demand sequence, and the initial state of charge of the batteries. Different intensity levels of disturbance signals were designed, including normal fluctuations and strong disturbances.
[0043] The scenes are divided as follows: Training set: 240 scenarios, used for training the LSTM gain scheduler; Validation set: 40 scenarios for model selection based on closed-loop performance; Independent test set: 40 scenarios, used only to evaluate generalization performance after the final scheduler is determined.
[0044] Once the dataset partitioning is determined, it remains unchanged in all subsequent experiments to prevent test set information from being leaked into the training or model selection process.
[0045] 2. PSO Teacher Model Parameter Settings The particle swarm size is set to 12, the maximum number of iterations is set to 10, the maximum number of stalled iterations is set to 4, and the function tolerance is set to... .
[0046] The PID gain search range is set as follows: By using the parameters of a fixed-parameter PID controller as part of the initial particle swarm, a reliable benchmark solution is always ensured during the optimization process.
[0047] 3. LSTM Scheduler Training Setup The LSTM scheduler takes into account photovoltaic power sequence, wind power sequence, load demand sequence, and initial state of charge (SOC) of batteries, and outputs three PID control parameters. =0.
[0048] Before training, both input features and output labels are normalized using statistical information from the training set to reduce the impact of differences in the scale of different variables on neural network training. The validation and test sets are processed using the same normalization parameters obtained from the training set to avoid data leakage.
[0049] Multiple LSTM candidate models were trained using different random seeds. After training, the parameter prediction metrics were used to initially evaluate each candidate model. Then, closed-loop simulation tests were performed on the validation set, and the final model was determined based on the closed-loop control performance.
[0050] Example 3: PSO Teacher Tag Quality Verification: Before training the LSTM gain scheduler, the quality of the tags generated by PSO is verified by checking three aspects: tag integrity, constraint satisfaction, and frequency control performance improvement relative to a fixed PID benchmark.
[0051] like Figure 3 The inspection results showed that: PSO instructors successfully generated PID parameter labels for training and validation scenarios; The optimized parameters are all within the preset search range; The corresponding closed-loop simulations were all successfully completed; No violations of constraints such as frequency exceeding limits, power exceeding limits, or SOC exceeding limits were observed. PSO teachers showed significant improvements over the fixed PID baseline in terms of overall cost, maximum frequency deviation, frequency RMSE, and ITAE.
[0052] PSO does not simply converge all scenarios to the same set of fixed parameters, but generates different combinations of PID parameters for different operating scenarios, indicating that gain scheduling for different scenarios has practical significance.
[0053] Example 4: Verification of the closed-loop model selection results: On the validation set, the average synthesis cost of the selected LSTM-PID scheduler was 0.899033, with a fixed PID baseline of 1.000000. The maximum frequency deviation decreased from 0.038248 to 0.027687, the frequency RMSE decreased from 0.017057 to 0.012361, and the time-weighted absolute error (ITAE) decreased from 72.980 to 52.182.
[0054] In 40 validation scenarios, LSTM-PID outperformed the fixed PID benchmark in 39 of them, representing 97.50%. Simultaneously, the method recovered approximately 94.43% of the PSO teacher closed-loop performance gain without any constraint violations. This indicates that LSTM learned effective gain scheduling patterns from the scenario sequence.
[0055] Example 5: Independent test set closed-loop performance: like Figure 4 , Figure 5 On the independent test set, the normalized average cost of the fixed PID controller is 1.000000; the PSO teacher reduces this value to 0.889320; the selected LSTM-PID scheduler reaches 0.897420, close to the PSO teacher, and significantly better than the fixed PID benchmark.
[0056] The specific frequency control parameters are as follows:
[0057] Compared to a fixed PID benchmark, the selected LSTM-PID scheduler enables: The average overall cost decreased by 10.258%; The average maximum frequency deviation decreased by 27.187%; The average frequency RMSE decreased by 28.200%; The average ITAE decreased by 29.261%; It outperformed the fixed PID benchmark in all 40 independent test scenarios; Approximately 92.683% of the PSO teacher closed-loop performance gain was restored; No violations of the constraints were found.
[0058] Example 6: Comparison of computational efficiency: like Figure 6 The average parameter generation time for PSO teachers was 102.045 seconds, and the median time was 95.408 seconds. The average inference time of the selected LSTM-PID scheduler was only 9.856 milliseconds, and the median inference time was 9.583 milliseconds.
[0059] Based on the comparison of PSO optimization time, the LSTM scheduler has an average speedup of 10371.79 times and a median speedup of 9908.41 times. Taking the total teacher time including the baseline calculation as a reference, the average speedup is approximately 10470.14 times.
[0060] On average, PSO requires approximately 102 objective function evaluations per test scenario, corresponding to an average of 7.50 iterations. The LSTM scheduler, on the other hand, requires only one forward inference to generate the PID gain vector.
[0061] Example 7, Typical Dynamic Response Analysis: Three representative operational scenarios were selected from the independent test set for dynamic response analysis: (1) such as Figure 7 Representative operating condition (test_307, normal disturbance) ) The cost of fixed PID is 1.000000, PSO cost is 0.915150, and LSTM-PID cost is 0.897968. LSTM-PID reduces the overall cost by 10.203% compared to fixed PID, which is very close to the average improvement level of the entire test set.
[0062] (2) such as Figure 8 The optimal improved operating condition (test_306, strong disturbance) ) LSTM-PID reduces the maximum frequency deviation from 0.055834 for fixed PID to 0.035042; RMSE from 0.027462 to 0.017234; and ITAE from 116.010 to 70.778. The overall cost is reduced by 20.446% compared to fixed PID.
[0063] (3) such as Figure 9 Challenging operating conditions (test_288, strong disturbances) ) The teacher cost for PSO is 0.835423, and for LSTM-PID it is 0.889446. Compared to fixed PID, LSTM-PID still shows significant improvement: the maximum frequency deviation decreased from 0.045732 to 0.035247, RMSE decreased from 0.021821 to 0.017136, and ITAE decreased from 94.199 to 70.962.
[0064] The dynamic response curves show that LSTM-PID suppresses frequency oscillations more effectively than fixed PID in most cases, and its power compensation trend is quite similar to that of PSO. Battery power response demonstrates rapid compensation, while diesel engine response provides slower support. The SOC trajectories of all controllers remain within a narrow range, indicating that frequency improvement does not come at the cost of excessive battery energy consumption.
[0065] Example 8, Post-event Ablation experiment: To verify whether the differential channel is a necessary structure, the output of the frozen LSTM-PID scheduler was tested without retraining the LSTM scheduler. Force the values to zero and retest in the closed-loop microgrid model.
[0066] like Figure 10 , Figure 11 The ablation results showed: The original LSTM-PID scheduler had an average comprehensive cost of 0.897420; The average cost of the ablation controller is 0.896220; The maximum frequency deviation is 0.027585 in LSTM-PID. The ablation value was 0.027590. The frequency RMSEs were 0.012146 and 0.012147, respectively. The ITAE values are 51.020 and 51.025, respectively. The complete LSTM-PID achieved lower costs in 9 out of 40 test cases. The ablation model achieved lower costs in 31 scenarios; No constraint violations were observed in either controller.
[0067] The results indicate that, under the current microgrid model, disturbance distribution, and objective function settings, the differential channel is not the key source of performance improvement. The main performance gain of the selected scheduler comes from adaptive proportional and integral actions, exhibiting a clear proportional-integral (PI) dominant characteristic.
[0068] Example 9: Online Deployment Process: This embodiment describes the online deployment process of the method of the present invention in a practical microgrid frequency control system: Step 1: Offline phase. Based on historical or simulation data, a set of typical operating scenarios is constructed, covering different combinations of photovoltaic fluctuations, wind power changes, load disturbances, and initial state of charge of batteries.
[0069] Step 2: Use the PSO teacher model to perform offline optimization for each scenario, generate high-quality PID parameter labels, and construct a supervised learning dataset after quality review.
[0070] Step 3: Train the LSTM gain scheduler, select the optimal model by validating the closed-loop performance of the validation set, and freeze the selected model.
[0071] Step 4: During the online operation phase, real-time information on the current operating scenario is collected, including photovoltaic power sequence, wind power sequence, load demand sequence, and initial battery SOC, which is then input into the frozen LSTM gain scheduler.
[0072] Step 5: The LSTM scheduler generates PID control parameters through a single forward inference (approximately 9.856 milliseconds). .
[0073] Step 6: Apply the generated PID parameters to the microgrid frequency controller and output adjustment commands to the battery energy storage system and diesel generator to achieve frequency regulation.
[0074] Step 7: When the operating scenario changes significantly, repeat steps 4 to 6 to achieve adaptive updates of the control gain.
[0075] In summary, this invention discloses an LSTM-PID gain scheduling method and system based on PSO supervision for frequency regulation in microgrids containing renewable energy. This method utilizes Particle Swarm Optimization (PSO) as an offline teacher model to generate high-quality PID gain labels for different operating scenarios, and constructs a supervised dataset after quality review. It employs a Long Short-Term Memory (LSTM) network to learn the mapping relationship between operating condition sequences and PID parameters, and selects the optimal model through the closed-loop performance of the validation set. The model is frozen in the online stage, requiring only a single forward inference to quickly generate PID gains. This invention prioritizes closed-loop control performance over parameter prediction error in its evaluation, balancing adaptive control effectiveness with computational efficiency. Experiments show that this scheduler outperforms fixed-parameter PID in all test scenarios, recovering approximately 92.683% of the performance advantage of the PSO teacher, reducing frequency deviation, RMSE, and ITAE by 27.187%, 28.200%, and 29.261%, respectively. Simultaneously, it reduces gain generation time from hundreds of seconds to milliseconds, while maintaining the interpretability and ease of deployment of the PID structure.
[0076] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Those skilled in the art can make modifications or equivalent substitutions to the technical solutions of the present invention, and such modifications or equivalent substitutions do not depart from the spirit and protection scope of the technical solutions of the present invention.
Claims
1. A PSO-supervised LSTM-PID gain scheduling method, characterized in that, Frequency regulation for microgrids containing renewable energy includes the following steps: S1. Construct multiple microgrid operation scenarios containing renewable energy sources. Each operation scenario includes a photovoltaic power sequence, a wind power sequence, a load demand sequence, and the initial state of charge of the battery. S2. Using the particle swarm optimization algorithm as the offline teacher model, for each operating scenario, with the goal of minimizing the normalized closed-loop objective function, the optimal PID control gain is searched within the preset parameter search range, and PID parameter labels corresponding to each operating scenario are generated. S3. Perform quality review on the generated PID parameter labels. After the review is passed, construct a supervised learning dataset using the running scenario sequence and the corresponding PID parameter labels. S4. Construct a long short-term memory network gain scheduler, taking the running scenario sequence as input and the PID control gain as output. Train the LSTM network using a supervised learning dataset to learn the mapping relationship between the running condition sequence and the PID parameters. S5. Train multiple LSTM candidate models, and substitute the PID parameters output by the multiple LSTM candidate models into the microgrid closed-loop model for verification. Select the final LSTM gain scheduler based on the closed-loop control performance on the verification set. The evaluation indicators of the closed-loop control performance include normalized comprehensive cost, maximum frequency deviation, root mean square error of frequency, time-weighted absolute error integral, and constraint violation. S6: Freeze the selected LSTM gain scheduler. For a new operating scenario, input the operating scenario sequence into the frozen LSTM gain scheduler for a single forward inference to generate the corresponding PID control gain, which is then directly applied to the microgrid frequency control.
2. The LSTM-PID gain scheduling method based on PSO supervision according to claim 1, characterized in that, The normalized closed-loop objective function in S2 is expressed as: ; in, To normalize the overall cost, For the first A normalized target term, For the corresponding weighting coefficients, To constrain violation penalty items; constraint violation penalty items are used to handle one or more of the following constraint exceedance situations: frequency exceeding limit, control input saturation, battery power constraint violation, diesel generator power constraint violation, and battery state of charge constraint violation.
3. The LSTM-PID gain scheduling method based on PSO supervision according to claim 1, characterized in that, Quality review in S3 includes: Whether the PSO optimization process successfully converges and generates complete labels; Are the optimized PID parameters within the preset search range? Can the closed-loop simulation be completed normally? Are there any violations of physical constraints? Compared to a fixed-parameter PID reference controller, can the PSO parameter improve the system's frequency response performance? Only after all five review criteria are met will the PSO label be included in the supervised learning dataset.
4. The LSTM-PID gain scheduling method based on PSO supervision according to claim 1, characterized in that, The input features of the LSTM network include: photovoltaic power sequence Wind power series Load demand sequence and the initial state of charge of the battery The output consists of three PID control parameters: proportional gain. .
5. The LSTM-PID gain scheduling method based on PSO supervision according to claim 1, characterized in that, In S5, the final LSTM gain scheduler is selected based on the closed-loop control performance on the validation set. Specifically: The validation set scenario is input into each LSTM candidate model to obtain the predicted PID parameters. The PID parameters are then applied to the same microgrid closed-loop model for simulation and compared with the fixed PID benchmark controller and the PSO teacher controller. A candidate model is considered a qualified model only if it meets all of the following conditions: No constraint violation occurs; Compared to a fixed PID reference, it can reliably improve closed-loop performance; Among all qualified models, the model with the lowest average normalized synthesis cost on the validation set is selected as the final LSTM gain scheduler.
6. The LSTM-PID gain scheduling method based on PSO supervision according to claim 1, characterized in that, In S6, after freezing the selected LSTM gain scheduler, the generalization performance of the frozen LSTM scheduler is evaluated on an independent test set. The independent test set does not participate in the model training and model selection process. The evaluation results on the independent test set are used to finally verify the frequency regulation effect of the LSTM scheduler in unseen operating scenarios.
7. The LSTM-PID gain scheduling method based on PSO supervision according to claim 1, characterized in that, Includes aftermath Ablation analysis steps: Without retraining the LSTM scheduler, extract the differential gain of the frozen LSTM gain scheduler output. The differential gain was forced to zero and retested in the closed-loop model to analyze its contribution to frequency regulation performance.
8. A PSO-supervised LSTM-PID gain scheduling system, characterized in that, Running the LSTM-PID gain scheduling method based on PSO supervision as described in any one of claims 1-7 includes: The operation scenario generation module is used to construct multiple operation scenarios of microgrids containing renewable energy, including photovoltaic power sequence, wind power sequence, load demand sequence and battery initial state of charge. The offline PSO teacher module is used as an offline teacher model. For each operating scenario, the offline PSO teacher module aims to minimize the normalized closed-loop objective function, searches for the optimal PID control gain within a preset parameter search range, and generates PID parameter labels corresponding to each operating scenario. The dataset construction module is used to perform quality review on the generated PID parameter labels. After the dataset construction module passes the review, it uses the running scenario sequence and the corresponding PID parameter labels to construct a supervised learning dataset. The LSTM gain scheduler training module is used to construct a long short-term memory network gain scheduler. The LSTM gain scheduler training module takes the running scenario sequence as input and PID control gain as output, and uses the supervised learning dataset to train the LSTM network. The closed-loop performance verification and model selection module is used to train multiple LSTM candidate models. The closed-loop performance verification and model selection module substitutes the PID parameters output by multiple LSTM candidate models into the microgrid closed-loop model for verification, and selects the final LSTM gain scheduler based on the closed-loop control performance on the verification set. The online inference and parameter generation module is used to freeze the selected LSTM gain scheduler. For a new running scenario, the online inference and parameter generation module inputs the running scenario sequence into the frozen LSTM gain scheduler to perform a single forward inference and generate the corresponding PID control gain. The PID control execution module is used to apply the generated PID control gain to the microgrid frequency control.
9. The LSTM-PID gain scheduling system based on PSO supervision according to claim 8, characterized in that, In the LSTM gain scheduler training module, the training loss function is defined as the mean square error between the predicted PID parameters and the PSO labels: ; in, This represents the total number of samples in the supervised learning dataset used for LSTM training and validation. For the index number of the running scenario, In order to target the PID parameters predicted by LSTM for each running scenario In order to target the The PID parameter labels generated by PSO for each running scenario.
10. The LSTM-PID gain scheduling system based on PSO supervision according to claim 8, characterized in that, The operating scenario is divided into three parts: training set, validation set, and independent test set, which remain unchanged in all experiments. The training set is used to train the LSTM gain scheduler, the validation set is used for model selection based on closed-loop performance, and the independent test set is used only after the final scheduler is determined to evaluate generalization performance.
