Photovoltaic ultra-short-term power prediction method based on PSO scene-based optimization of comprehensive similarity weight
Patent Information
- Application Number
- CN202610867959.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-16
- Publication Date
- 2026-09-22
AI Technical Summary
但不同季节、不同天气类型下,光伏功率波动特性存在本质差异,固定权重无法自适应适配场景变化,导致相似时段筛选精度不足,最终造成预测模型输入质量差、预测误差大,尤其在功率剧烈波动的复杂天气下,误差会显著放大
[0014]本发明与现有技术相比,具有以下显著有益效果:(1)构建了互补的综合相似度计算模型,同时覆盖功率数值匹配与变化趋势一致性两个核心维度,全面刻画序列间的相似特性,解决了单一相似度指标表征能力不足的问题;(2)建立分场景的相似度权重自适应优化框架,将季节-天气场景划分与 PSO 智能寻优算法深度结合,为每一类功率波动场景独立求解最优融合权重,可精准匹配不同场景的功率波动特性,有效提升了历史相似时段的筛选质量;(3)全流程仅依托光伏功率历史数据即可完成计算,无需任何气象监测设备与数据输入,彻底解决了偏远地区及分布式光伏电站因气象数据缺失导致的预测精度骤降问题,大幅降低了设备采购及运维成本,工程适配性极强;(4)显著提升了无气象数据场景下的光伏预测精度,大幅提高了预测模型的精度和泛化能力,可充分满足电力行业超短期预测技术规范要求,为电网调度与新能源消纳提供了可靠的技术支撑。
Smart Images

Figure CN122801211A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of photovoltaic power generation prediction technology, and specifically relates to a photovoltaic ultra-short-term power prediction method based on PSO scenario-based optimization of comprehensive similarity weight. Background Technology
[0002] Photovoltaic power generation has become a core component of my country's new power system. High-precision ultra-short-term photovoltaic power forecasting (0-4 hours into the future) is a core technological support for ensuring real-time grid dispatch, automatic power generation control, and efficient consumption of new energy. Existing mainstream high-precision photovoltaic forecasting methods heavily rely on numerical weather prediction or on-site meteorological data. However, over 30% of distributed photovoltaic power stations and some remote ground-mounted power stations in my country have long been without effective meteorological data input, leading to a dilemma of input loss for traditional forecasting models and a precipitous drop in forecast accuracy.
[0003] For scenarios lacking meteorological data, prediction methods based on historical similarity time periods have become the mainstream approach, with existing methods often employing fixed weights to fuse comprehensive similarity scores. However, the characteristics of photovoltaic power fluctuations differ fundamentally across seasons and weather types, making fixed weights unable to adapt to changing scenarios. This results in insufficient accuracy in similarity time period selection, ultimately leading to poor input quality and large prediction errors in the prediction model. The errors are significantly amplified, especially under complex weather conditions with drastic power fluctuations. Particle Swarm Optimization (PSO) is a classic heuristic optimization algorithm that can be used for adaptive solution of weight parameters. However, current techniques have not integrated it with the power fluctuation characteristics of different scenarios, failing to achieve scenario-based adaptive optimization of similarity weights and thus hindering the fundamental improvement of photovoltaic prediction accuracy in scenarios without meteorological data. Summary of the Invention
[0004] The purpose of this invention is to provide a photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights.
[0005] The technical solution to achieve the purpose of this invention is: a photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights, comprising the following steps:
[0006] Step 1: Preprocess the historical photovoltaic power data and obtain a standardized effective sample set by using the sliding window method;
[0007] Step 2: Construct power fluctuation features based on valid samples, complete weather type identification through K-Means++ clustering, and obtain independent sample subsets by season and weather type by combining seasonal grouping;
[0008] Step 3: Define power similarity and trend similarity respectively, and fuse the two types of similarity through dynamic weighting to obtain the comprehensive similarity calculation formula;
[0009] Step 4: Use the weighted relative average absolute error of the historical similar time period selection as the objective function of the PSO algorithm, and use the power similarity weight in the comprehensive similarity as the population feature of the PSO algorithm.
[0010] Step 5: Adaptive optimization of scene-specific weights based on PSO algorithm. For each scene sample subset, iterative optimization is performed with the objective function minimization as the criterion to obtain the optimal dynamic weights for each scene based on similarity.
[0011] Step 6: Filter historical similar time periods based on the optimal weight, match the optimal weight of the scene corresponding to the current time period, calculate the comprehensive similarity and filter the TOP-10 historical similar time periods;
[0012] Step 7: Photovoltaic ultra-short-term power prediction based on the Transformer model. Using historical power sequences and selected similar time period sequences as input, complete the model training and output the photovoltaic ultra-short-term power prediction results for the next 0-2 hours.
[0013] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method described above.
[0014] Compared with the prior art, the present invention has the following significant advantages: (1) It constructs a complementary comprehensive similarity calculation model, which covers two core dimensions: power value matching and consistency of change trend, and comprehensively depicts the similarity characteristics between sequences, solving the problem of insufficient characterization ability of a single similarity index; (2) It establishes a scenario-based adaptive optimization framework for similarity weights, deeply combining seasonal-weather scenario division with PSO intelligent optimization algorithm, and independently solves the optimal fusion weight for each type of power fluctuation scenario, which can accurately match the power fluctuation characteristics of different scenarios and effectively improve the screening quality of historical similar periods; (3) The entire process can be completed by relying solely on historical photovoltaic power data, without any meteorological monitoring equipment or data input, which completely solves the problem of sharp drop in prediction accuracy caused by the lack of meteorological data in remote areas and distributed photovoltaic power stations, greatly reducing equipment procurement and operation and maintenance costs, and has strong engineering adaptability; (4) It significantly improves the photovoltaic prediction accuracy in scenarios without meteorological data, greatly improves the accuracy and generalization ability of the prediction model, and can fully meet the requirements of the ultra-short-term prediction technical specifications of the power industry, providing reliable technical support for grid dispatch and new energy consumption. Attached Figure Description
[0015] Figure 1 This is a flowchart of the overall process of photovoltaic ultra-short-term prediction based on PSO scenario-specific optimization of comprehensive similarity weight.
[0016] Figure 2 This is a flowchart of the PSO algorithm for scene-specific weight optimization in this invention.
[0017] Figure 3 These are comparison curves of photovoltaic power prediction under different cloud-dense scenarios. Detailed Implementation
[0018] To overcome the shortcomings of existing technologies, this invention provides a photovoltaic ultra-short-term forecasting method based on PSO scenario-specific optimization of comprehensive similarity weights. It constructs a comprehensive similarity model integrating Euclidean distance and Pearson correlation coefficient, and uses the PSO algorithm to adaptively optimize similarity weights by season and weather type. Based on the optimal weights, it accurately selects historical similar time periods and combines this with a Transformer model to achieve photovoltaic ultra-short-term power forecasting without meteorological data. The method includes the following steps:
[0019] Step 1: Preprocessing and constructing effective samples of historical photovoltaic power data. After cleaning the original data, a standardized set of effective samples is obtained by partitioning the data using the sliding window method.
[0020] Step 2: Divide the sample subsets by scenario, construct power fluctuation features based on valid samples, complete weather type identification through K-Means++ clustering, and obtain independent sample subsets by season and weather type by combining seasonal grouping;
[0021] Step 3: Construct a comprehensive similarity calculation model, define power similarity and trend similarity respectively, and fuse the two types of similarity through dynamic weights to obtain the comprehensive similarity calculation formula;
[0022] Step 4: Determine the optimization objective and population characteristics. Use the weighted relative average absolute error of the historical similar time period as the objective function of the PSO algorithm, and use the dynamic weight of the comprehensive similarity as the population characteristics of the PSO algorithm.
[0023] Step 5: Adaptive optimization of scene-specific weights based on PSO algorithm. For each scene sample subset, iterative optimization is performed with the objective function minimization as the criterion to obtain the dynamic weights with the best similarity for each scene.
[0024] Step 6: Filter historical similar time periods based on the optimal weight, match the optimal weight of the scene corresponding to the current time period, calculate the comprehensive similarity and filter the TOP-10 historical similar time periods;
[0025] Step 7: Photovoltaic ultra-short-term power prediction based on the Transformer model. Using historical power sequences and selected similar time period sequences as input, complete the model training and output the photovoltaic ultra-short-term power prediction results for the next 0-2 hours.
[0026] Furthermore, the core innovation of this invention lies in the construction of a comprehensive similarity calculation model and the adaptive optimization of scene-specific weights based on the PSO algorithm. The remaining aspects provide basic support and implementation for the core innovation.
[0027] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of application of the present invention.
[0028] Combination Figure 1 A photovoltaic ultra-short-term forecasting method based on PSO scenario-specific optimization and comprehensive similarity weighting is proposed. The specific implementation steps are as follows:
[0029] Step 1: Preprocessing of historical photovoltaic power data and construction of effective samples
[0030] The original photovoltaic power data was split into units based on natural days, retaining data from the effective power generation period of 6:00-18:00 each day and removing invalid data with zero power at night. Outliers were detected using the 3σ criterion and corrected using quadratic interpolation. For missing values, forward filling was used to complete the data when there were ≤2 consecutive missing values, and forward filling combined with backward trend correction was used to complete the data when there were 3 consecutive missing values. The sliding window length was set to 8 data points and the sliding step size was set to 1 data point, corresponding to a 15-minute sampling interval and a 2-hour duration. The preprocessed sequence was segmented to obtain the effective sample set.
[0031] Step 2: Divide the sample subsets by scenario
[0032] For each valid sample window, a four-dimensional feature vector of power fluctuation is constructed, including the average slope, slope standard deviation, coefficient of variation, and range ratio. Max-min normalization is used to map the features to the [0,1] interval. The optimal number of clusters K=3 is determined by the elbow rule and the silhouette coefficient. The K-Means++ algorithm is used to complete unsupervised clustering, dividing the samples into three weather types: sunny, cloudy, and overcast. According to the natural months, December-February is divided into spring, March-May into summer, June-August into autumn, and September-November into winter. Combined with the weather type labels, 12 independent sample subsets of seasonal-weather types are formed, providing an independent sample space for scene-specific weight optimization.
[0033] Step 3: Construct a comprehensive similarity calculation model
[0034] This step is the core of the present invention, and its specific implementation is as follows:
[0035] 1) Sequence normalization processing: For the power sequence P of the current time period... c Power series P over historical periods hMax-min normalization is performed separately to eliminate the interference of power amplitude differences on similarity calculation, resulting in normalized sequences. , The values are mapped to the interval [0,1].
[0036] 2) Calculate power similarity based on Euclidean distance: The Euclidean distance measures the numerical similarity between two sequences, which is then mapped to the [0,1] interval using an exponential decay transformation. The formula is as follows:
[0037] (1)
[0038] (2)
[0039] The sequence length M is fixed at 8, corresponding to a duration of 2 hours. , λ represents the normalized power value of the current time period and the ith power value of the historical time period, respectively; λ is the scale parameter, set to 0.1; D euclid S is the Euclidean distance between the two sequences; euclid This represents power similarity; a larger value indicates that the two sequences are more similar in value.
[0040] 3) Calculate the trend similarity based on the Pearson correlation coefficient to measure the consistency of the changing trends of the two sequences. After linear mapping to the [0,1] interval, the formula is as follows:
[0041] (3)
[0042] (4)
[0043] In the formula: , These are the normalized power series mean values for the current time period and the historical time period, respectively; r pearson S is the Pearson correlation coefficient, with a value range of [-1, 1]; pearson This represents trend similarity; a higher value indicates a greater consistency in the trends of the two sequences.
[0044] 4) Dynamic weight fusion to obtain comprehensive similarity: The two types of similarity are fused using the dynamic weight α to be optimized, as shown in the formula:
[0045] (5)
[0046] In the formula: α is the dynamic weight of power similarity, with a value range of [0,1], and is the core optimization variable of the PSO algorithm; The dynamic weights for trend similarity; S combine To assess overall similarity, a higher value indicates a higher overall similarity between the two sequences.
[0047] Step 4: Determine the optimization objective and population characteristics
[0048] This step is the core of the present invention, and its specific implementation is as follows:
[0049] The weighted relative average absolute error of historical similar time periods is used as the objective function of the PSO algorithm, and the dynamic weight α of power similarity in the comprehensive similarity is used as the population feature of the PSO algorithm. The range of the optimization variable is constrained to α∈[0,1].
[0050] Constructing the fitness function: For a single sample, the optimization objective is to minimize the weighted relative average absolute error of the top-10 similar time periods. The fitness function formula is as follows:
[0051] (6)
[0052] In the formula: Fit(α) is the fitness function value, the smaller the value, the better the weight optimization effect; k is the index of the TOP-10 similar time period; ω k RMAE represents the similarity percentage of the k-th similar time period. k This represents the relative average absolute error between the k-th similar time period and the current time period.
[0053] The formulas for calculating the similarity ratio and the relative average absolute error are as follows:
[0054] (7)
[0055] (8)
[0056] In the formula, S combine,k Let M = 8 be the overall similarity for the k-th time period, and y be the sequence length. j Let y be the actual power value at time j in the current time period. k,j This represents the power value at time j in the k-th similar time period;
[0057] Step 5: Adaptive Optimization of Scene-Specific Weights Based on PSO Algorithm
[0058] 1) PSO algorithm parameter configuration: set the number of particles to 50, the maximum number of iterations to 100, the search space to α∈[0,1], the inertia weight ω to decrease linearly from 0.9 to 0.4, the acceleration coefficients c1=c2=2.0, and the maximum velocity v. max =0.5, the boundary processing adopts the Clip pruning strategy, and the convergence threshold is set to 0.5. .
[0059] 2) Particle iterative optimization, such as Figure 2 As shown:
[0060] ① Initialization: Randomly generate the initial positions (uniformly randomized within the interval [0,1]) and initial velocities (uniformly randomized within the interval [-0.5,0.5]) of 50 particles, and initialize the individual optimal positions and the global optimal positions;
[0061] ② Fitness calculation: For the current position of each particle (i.e., the candidate value of weight α), calculate the comprehensive similarity and filter the TOP-10 similar time periods, and substitute them into the fitness function to calculate the function value;
[0062] ③ Optimal position update: Compare the current fitness of each particle with its historical best fitness to update the individual's optimal position; compare the fitness of all particles to update the global optimal position of the population.
[0063] ④ Velocity and Position Update: Update the particle's velocity and position according to the following formula, and handle boundary overflow issues through the Clip strategy to limit the maximum velocity:
[0064] (9)
[0065] (10)
[0066] In the formula: t is the current iteration number, Let be the velocity of particle i in the t-th iteration. Let be the position of particle i in the t-th iteration, and the candidate value of the weight α. Let be the optimal position of particle i. The global optimal position for the group is r1 and r2, which are random numbers in the interval [0,1].
[0067] ⑤ Convergence criterion: If the maximum number of iterations (100) is reached, or the change in the global optimal fitness over three consecutive iterations is less than the convergence threshold. The iteration terminates, and the optimal candidate weight value for the sample is output.
[0068] Determining the optimal weights for each scenario: For each of the 12 seasonal-weather type sample subsets, 1000 samples from each subset were randomly selected and PSO optimization was performed independently to obtain 1000 candidate weights. After removing the top 5% and bottom 5% outliers, the average of the remaining 900 effective weights was taken as the final optimal weights for that scenario. .
[0069] Step 6: Filter historical similar time periods based on optimal weights
[0070] For the current forecast period, the historical candidate database is limited to power sequences at the same time within the previous 90 days, and the weather type labels of the samples are retained; the season and weather type of the current period are identified, and the optimal weights for the corresponding scenarios are matched. Based on the optimal weight, the comprehensive similarity between the current time period and all samples in the candidate database is calculated, and the TOP-10 samples are selected as historical similar time periods after being sorted in descending order.
[0071] Step 7: Photovoltaic ultra-short-term power prediction based on the Transformer model
[0072] The Transformer model employs an encoder-decoder architecture, with both the encoder and decoder using a 3-layer stacked structure. It has 8 multi-head attention heads and a feature dimension of 128. The dataset is partitioned sequentially using time series data: the training set consists of data from January to October of the current year, and the test set consists of data from November to December of the current year, to prevent future data leakage. The model training hyperparameters are configured as follows: batch size 64, training epochs 100, AdamW optimizer, and initial learning rate 1e. -4 Weight decay coefficient 1e -5 The dropout probability is 0.1. The current power sequence and the selected TOP-10 historical similar time periods are input into the trained model to output the photovoltaic ultra-short-term power prediction results for the next 0-2 hours.
[0073] This embodiment is based on the measured power data of a 50MW photovoltaic power station in Northwest my country without meteorological monitoring equipment throughout 2024. The data sampling interval is 15 minutes, and a total of 17,568 raw data points are collected throughout the year, which is perfectly in line with the application scenario without meteorological data, and verifies the technical effect of the present invention.
[0074] In this embodiment, the PSO algorithm population size is 50, the maximum number of iterations is 100, and the optimization variable is the power similarity weight α. Different methods are used to determine the similarity weight and predict photovoltaic power, and four sets of control experiments are set up:
[0075] Case 1: Single Pearson correlation coefficient similarity method (α=1)
[0076] Case 2: Single Euclidean distance similarity method (α=1);
[0077] Case 3: Traditional fixed-weight method (α=0.5);
[0078] Case 4: The PSO scenario-based weight optimization method proposed in this invention.
[0079] The optimal weight results for 12 scenarios obtained by the method of this invention are shown in Table 1:
[0080] Table 1 Optimal Weight Results by Scenario
[0081]
[0082] The prediction performance results of the three control experiments are shown in Table 2, and the prediction errors in the dense cloud scenario are shown in Table 3. Figure 3 As shown:
[0083] Table 2 Comparison of prediction performance of different methods
[0084] Case 1 17.901 4.231 3.272 8.25 0.903 Case 2 16.582 4.072 3.105 8.17 0.905 Case 3 13.294 3.646 2.763 7.24 0.914 Case 4 10.857 3.295 2.345 6.29 0.930
[0085] Table 3 Comparison of prediction performance in cloud-dense scenarios
[0086] Case 1 5.634 4.752 0.861 Case 2 5.539 4.635 0.864 Case 3 4.843 3.963 0.883 Case 4 3.987 3.345 0.901
[0087] According to Table 2, Table 3 and Figure 3 The analysis of the results leads to the following conclusions:
[0088] The PSO scene-specific weight optimization method proposed in this invention reduces RMSE by 9.63%, MAE by 15.10%, and R² by 1.75% compared to the traditional fixed weight method, resulting in a significant improvement in prediction accuracy. Compared to the single Euclidean distance method, the accuracy improvement is even greater, fully demonstrating the effectiveness of the integrated similarity model and scene-specific weight optimization.
[0089] The verification results by weather type show that the method of the present invention reduces RMSE by 17.67% and MAE by 15.59% in the cloud-dense scenario. In the complex scenario with power fluctuations, the optimization and improvement of RMSE and MAE are higher than the 9.63% and 15.10% of the overall scenario, which significantly improves the problem of large prediction error of the fixed weight method in complex scenarios.
[0090] The method of this invention requires no meteorological data input throughout the entire process and can complete high-precision prediction solely based on historical photovoltaic power data. It fully meets the error requirements of the "Technical Specification for Ultra-Short-Term Power Prediction of Power Systems" and has extremely high engineering application and promotion value.
[0091] The above discussion is merely one embodiment of the present invention. Any equivalent modifications made based on the present invention are included within the scope of patent protection of the present invention.
Claims
1. A photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights, characterized in that, Includes the following steps: Step 1: Preprocess the historical photovoltaic power data and obtain a standardized effective sample set by using the sliding window method; Step 2: Construct power fluctuation features based on valid samples, complete weather type identification through K-Means++ clustering, and obtain independent sample subsets by season and weather type by combining seasonal grouping; Step 3: Define power similarity and trend similarity respectively, and fuse the two types of similarity through dynamic weighting to obtain the comprehensive similarity calculation formula; Step 4: Use the weighted relative average absolute error of the historical similar time period selection as the objective function of the PSO algorithm, and use the power similarity weight in the comprehensive similarity as the population feature of the PSO algorithm. Step 5: Adaptive optimization of scene-specific weights based on PSO algorithm. For each scene sample subset, iterative optimization is performed with the objective function minimization as the criterion to obtain the optimal dynamic weights for each scene based on similarity. Step 6: Filter historical similar time periods based on the optimal weight, match the optimal weight of the scene corresponding to the current time period, calculate the comprehensive similarity and filter the TOP-10 historical similar time periods; Step 7: Photovoltaic ultra-short-term power prediction based on the Transformer model. Using historical power sequences and selected similar time period sequences as input, complete the model training and output the photovoltaic ultra-short-term power prediction results for the next 0-2 hours.
2. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 1, characterized in that, Step 1 specifically involves: retaining valid power generation data from 6:00 to 18:00 daily, using the 3σ criterion to detect and correct outliers, and filling in missing values using the corresponding method according to the length of the missing data; setting the sliding window length to 8 data points and the sliding step size to 1 data point, corresponding to a 15-minute sampling interval and a 2-hour duration, to obtain the valid sample set.
3. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 1, characterized in that, Step 2 involves dividing the sample subsets by scenario. Specifically, a four-dimensional feature vector of power fluctuation is constructed, which includes the average slope, standard deviation of the slope, coefficient of variation, and range ratio. After normalization, the vector is clustered into three weather types: sunny, cloudy, and overcast using the K-Means++ algorithm. The data is then divided into four seasons: spring, summer, autumn, and winter, based on the natural months. Finally, 12 independent sample subsets of seasonal-weather types are formed.
4. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 1, characterized in that, Step 3 involves constructing a comprehensive similarity calculation model, specifically as follows: 1) Sequence normalization processing: For the power sequence P of the current time period... c Power series P over historical periods h Max-min normalization is performed separately to eliminate the interference of power amplitude differences on similarity calculation, resulting in normalized sequences. , ; 2) Calculate the power similarity based on Euclidean distance to measure the numerical closeness of the two sequences. Map the result to the [0,1] interval using an exponential decay transformation. The formula is: ; ; Where M is the sequence length, , These represent the normalized power values for the current time period and the i-th power value for a historical time period, respectively; λ is the scale parameter; D euclid S is the Euclidean distance between the two sequences; euclid This represents power similarity; a larger value indicates that the two sequences are more similar in value. 3) Calculate the trend similarity based on the Pearson correlation coefficient to measure the consistency of the changing trends of the two sequences. After linear mapping to the [0,1] interval, the formula is as follows: ; ; In the formula: , These are the normalized power series mean values for the current time period and the historical time period, respectively; r pearson S is the Pearson correlation coefficient, with a value range of [-1, 1]; pearson This represents trend similarity; a higher value indicates a greater consistency in the trends of the two sequences. 4) The overall similarity is obtained by dynamic weight fusion, and the formula is: ; In the formula: α is the dynamic weight of power similarity, with a value range of [0,1]; The dynamic weights for trend similarity; S combine To assess overall similarity, a higher value indicates a higher overall similarity between the two sequences.
5. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 4, characterized in that, Step 4 is as follows: The objective function is defined as follows: for a single sample, the optimization objective is to minimize the weighted relative average absolute error of the top-10 similar time periods. The fitness function is then constructed as follows: ; In the formula: Fit(α) is the fitness function value, the smaller the value, the better the weight optimization effect; k is the index of the TOP-10 similar time period; ω k RMAE represents the similarity percentage of the k-th similar time period. k The relative average absolute error between the k-th similar time period and the current time period; The formulas for calculating the similarity ratio and the relative average absolute error are as follows: ; ; In the formula, S combine,k Let M = 8 be the overall similarity for the k-th time period, and y be the sequence length. j Let y be the actual power value at time j in the current time period. k,j This represents the power value at time j in the k-th similar time period.
6. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 5, characterized in that, Step 5, the scene-specific weight adaptive optimization based on the PSO algorithm, specifically involves: 1) PSO algorithm parameter configuration: set the number of particles to 50, the maximum number of iterations to 100, the search space to α∈[0,1], the inertia weight ω to decrease linearly from 0.9 to 0.4, the acceleration coefficients c1=c2=2.0, and the maximum velocity v. max =0.5, and the boundary processing adopts the Clip clipping strategy; 2) Particle iterative optimization, the velocity and position update formulas are: ; ; In the formula: t is the current iteration number, Let be the velocity of particle i in the t-th iteration. Let be the position of particle i in the t-th iteration, and the candidate value of the weight α. Let be the optimal position of particle i. The global optimal position for the group is r1 and r2, which are random numbers in the interval [0,1].
7. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 1, characterized in that, Step 6 involves filtering historically similar time periods, specifically: limiting the historical candidate library to power sequences at the same time within the previous 90 days, and matching the optimal weights for the corresponding scenario in the current time period. The overall similarity is calculated and sorted in descending order. The top 10 samples are selected as historical similar time periods.
8. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 1, characterized in that, In step 7, the Transformer model prediction is specifically as follows: an encoder-decoder architecture is adopted, with both the encoder and decoder having a 3-layer stacked structure, 8 multi-head attention heads, and 128 feature dimensions; the current power sequence and the selected TOP-10 similar time periods are used as inputs to output the photovoltaic power prediction value for the next 2 hours.
9. The photovoltaic ultra-short-term power prediction method based on PSO scenario-specific optimization of comprehensive similarity weights as described in claim 1, characterized in that, The convergence threshold of the PSO algorithm is set to If the change in the global optimal fitness over three consecutive iterations is less than this threshold, the iteration is terminated early.
10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method described in any one of claims 1-9.