Optimal model predictive control method and system for optical storage system
By adaptively decomposing the query vector and key vector of the optical storage system, calculating the weighted similarity score, and adjusting the core key and context extraction range, the problem of the impact of historical data fluctuations in the optical storage system is solved, and more accurate prediction and control are achieved.
Patent Information
- Application Number
- CN202611368114.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-04
- Publication Date
- 2026-11-24
AI Technical Summary
Existing model predictive control methods for photovoltaic-storage systems struggle to accurately identify the operational trends of state variables, and historical data contains abnormal fluctuations that affect the accuracy of prediction results.
By decomposing the query vector and key vector into state amplitude sub-vectors and first-order difference sub-vectors of change trends, calculating weighted similarity scores, adaptively adjusting the number of core keys and the scope of context extraction, and performing consistency screening on the context data, a more reliable prediction sequence for external disturbances and energy storage battery state of charge is generated.
It improves the control stability and operational constraint satisfaction of the photovoltaic-storage system under fluctuating conditions, reduces the interference of abnormal data on prediction results, and enhances the accuracy of model predictive control.
Smart Images

Figure CN123162980A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of photovoltaic energy storage systems, and in particular relates to an adaptive model predictive control method and system for photovoltaic energy storage systems. Background Technology
[0002] With the continuous development of renewable energy, photovoltaic (PV) and energy storage (ESS) systems are widely used in microgrids and smart grids. Model predictive control (MMCC) can handle multivariable and multi-constraint operation control problems and is often used for energy management and online optimization of PV systems. In the rolling optimization process of MMCC, the accuracy of future prediction information directly affects the solution of the optimal control sequence. Currently, data-driven methods based on attention mechanisms have been used in the prediction stage of PV systems. However, the operation of PV systems is affected by factors such as illumination, temperature, and load fluctuations, and historical operating data exhibits significant time-varying and nonlinear characteristics. Conventional attention calculations often fail to fully identify the changing trends of state variables over time, resulting in similarity scores that cannot accurately reflect the correlation between current and historical operating conditions in terms of evolutionary patterns.
[0003] When extracting contextual information from historical data based on similarity scores, existing methods often employ a fixed number of core key matches or a static context extraction window. This makes it difficult to adapt to changes in local features, easily introducing redundant data with low relevance, or missing crucial historical evolution information. Furthermore, the extracted historical data set may contain anomalous fluctuation values inconsistent with the current evolutionary trend. Directly participating in weighted aggregation can interfere with prediction results, thus affecting the accuracy of the model predictive control optimizer in solving for the optimal control sequence. Therefore, in the field of photovoltaic-storage system operation control, there is an urgent need for a historical feature matching method that can simultaneously evaluate state amplitude characteristics and trend characteristics, adaptively adjust the context extraction range based on similarity score distribution and local fluctuation characteristics, and perform consistency screening on the extracted context data. This would generate more reliable external disturbance prediction sequences and energy storage battery state-of-charge prediction sequences, providing more accurate prediction information for online rolling optimization of model predictive control. Summary of the Invention
[0004] To address the problems in existing technologies where attention matching relies excessively on state amplitudes, struggles to identify operational trends, and suffers from fixed core key numbers and context windows, and where abnormal historical data easily interferes with predictions, resulting in insufficient accuracy in model predictive control solutions, this invention proposes an adaptive model predictive control method and system for photovoltaic storage systems.
[0005] In a first aspect, the present invention proposes an adaptive model predictive control method for a photovoltaic-storage system, comprising the following steps: Historical operation data and real-time status data of the photovoltaic storage system are acquired. The real-time status data is used as the prediction initial point. Based on the prediction initial point, the control prior sequence, and the long-range dependency features generated from the historical operation data, a prediction query matrix is constructed. The historical operation data is then feature-encoded to obtain a key matrix and a value matrix. Both the query vector and the key vector are decomposed into sub-vectors representing state amplitudes and first-order difference numerator vectors representing change trends. The dot product scores are calculated for each sub-vector. The two scores are weighted and summed to obtain the final similarity score, which is then normalized to the initial attention weight. The number of core keys is determined based on the flatness of the distribution of the final similarity scores. The corresponding number of core keys is determined from the final similarity scores. The core keys and core values are located in the key matrix and value matrix. The context extraction range is determined based on local features. Context keys and context values are extracted from the range to form a context aggregation set. Consistency screening is performed on the value vectors within the context aggregation set. Based on the screening results, the target attention weight is obtained. The value vectors within the context aggregation set are weighted, summed, and decoded according to the target attention weight to generate an external disturbance prediction sequence. The energy storage battery state of charge prediction sequence is then recursively obtained based on the real-time energy storage battery state of charge and candidate control sequences. The candidate control sequence is used as the variable to be optimized. The optimal control sequence is solved online by a model predictive control optimizer and then sent to the photovoltaic-storage system for execution.
[0006] Optionally, constructing the prediction query matrix based on the prediction initial point, the control prior sequence, and the long-range dependency features generated from the historical running data includes: The historical operating data is downsampled according to a set fixed time step to obtain the state data of sampling points at equal time intervals, and then concatenated in chronological order to form the long-range dependency feature. The prediction initial point and the long-range dependency feature are concatenated by dimension to form a joint state vector; The control prior sequence is input into a multilayer perceptron network for feature transformation, and the output is the control feature vector sequence for each prediction time step. The joint state vector is concatenated and mapped with the feature vectors of each time step in the control feature vector sequence to generate the query vectors corresponding to each time step in the prediction time domain, and the prediction query matrix is output by combining them in chronological order.
[0007] Optionally, the step of decomposing both the query vector and the key vector into sub-vectors representing state amplitudes and first-order difference numerator vectors representing changing trends, calculating the dot product score for each, and then weighted summing the two types of scores to obtain the final similarity score includes: Calculate the average of the absolute values of all elements in the first-order difference numerator vector representing the trend of change in the query vector, and use the average as the change evaluation coefficient; The difference between the change evaluation coefficient and the preset center threshold is then input into the Sigmoid function to calculate the feature index, which is between 0 and 1. The feature index is used as the first weight of the dot product score corresponding to the first difference numerator vector, and the difference between the value 1 and the feature index is used as the second weight of the dot product score corresponding to the subvector representing the state amplitude. The first weight is multiplied by the dot product score corresponding to the first difference numerator vector to obtain the first product, the second weight is multiplied by the dot product score corresponding to the subvector representing the state amplitude to obtain the second product, and the first product and the second product are added to obtain the final similarity score.
[0008] Optionally, determining the number of core keys based on the flatness of the distribution of the final similarity scores includes: Calculate the statistical variance of the final similarity scores of all historical keys corresponding to the current query time step, and use the reciprocal of the statistical variance as a measure of the flatness of the distribution. The target value is obtained by adding the pre-calibrated proportional gain constant and the distribution flatness metric index to the set base number constant value. The target value is rounded down to obtain the number of core bonds.
[0009] Optionally, determining the context extraction range based on local features includes: Extract the historical key sequence within three fixed time steps before and after the time point corresponding to each core key; The sum of squares of the differences between each adjacent key vector in the extracted historical key sequence is calculated as the local volatility parameter of the core key. Divide the local volatility parameter by a preset reference constant to obtain a dimensionless volatility value; take the negative of the dimensionless volatility value as the exponent of the natural constant e to calculate the characteristic scaling factor; multiply the set maximum time offset constant by the characteristic scaling factor to obtain the scaling radius, and round the scaling radius to an integer time step. The original time step index of the core key in the key matrix is extended by the integer time step distance to the past time period and to the future time period, and the entire extended time interval is determined as the context extraction range.
[0010] Optionally, the step of performing consistency filtering on the value vectors within the context aggregation set and obtaining the target attention weights based on the filtering results includes: Calculate the arithmetic mean of all value vectors within the context aggregation set in each corresponding dimension, and construct a baseline average vector accordingly. Calculate the Euclidean distance between each value vector and the benchmark average vector; Remove the value vectors whose Euclidean distance exceeds a given discrete boundary constant, and form a subset of all the remaining value vectors that have not been removed that is consistent with the mainstream trend. The target attention weights corresponding to the removed value vectors are assigned zero values. The final similarity scores of each value vector retained within the subset consistent with the mainstream trend are uniformly recalculated using the Softmax normalization function to obtain the numerical update results. The results are then used as the target attention weights to complete the distribution adjustment operation.
[0011] Optionally, the step of using candidate control sequences as variables to be optimized and solving for the optimal control sequence online using a model predictive control optimizer includes: A constrained model predictive control optimization model is established. The objective function of the optimization model includes a battery state-of-charge tracking error term and a control input smoothness term. The constraints are the battery state-of-charge evolution, power limit, photovoltaic active power reduction range, and power balance relationship. The power balance relationship includes obtaining the net photovoltaic output power by subtracting the photovoltaic active power reduction from the available photovoltaic output power, and ensuring that the net photovoltaic output power, energy storage charging and discharging power, and load demand power satisfy energy balance. A gradient-free heuristic algorithm is used to perform optimization iterations within a set constraint space to obtain a time-dimensional control variable sequence solution that minimizes the objective function value. The optimal control sequence is generated by combining the solutions of the control variable sequence in chronological order.
[0012] On the other hand, the present invention also proposes an adaptive model predictive control system for a photovoltaic-storage system, comprising the following modules: The calculation module is used to acquire historical operation data and real-time status data of the photovoltaic storage system. The real-time status data is used as the prediction initial point. Based on the prediction initial point, the control prior sequence, and the long-range dependency features generated from the historical operation data, a prediction query matrix is constructed. The historical operation data is then feature-encoded to obtain a key matrix and a value matrix. Both the query vector and the key vector are decomposed into sub-vectors representing state amplitude and first-order difference numerator vectors representing change trends. The dot product scores are calculated for each sub-vector. The two scores are weighted and summed to obtain the final similarity score, which is then normalized to the initial attention weight. The determination module is used to determine the number of core keys based on the distribution flatness of the final similarity score, determine the corresponding number of core keys from the final similarity score, locate the core keys and core values in the key matrix and value matrix, determine the context extraction range based on local features, and extract context keys and context values from the range to form a context aggregation set. The filtering module is used to perform consistency filtering on the value vectors within the context aggregation set, obtain the target attention weight based on the filtering results, perform weighted summation and decoding on the value vectors within the context aggregation set according to the target attention weight, generate an external disturbance prediction sequence, and recursively obtain the energy storage battery state of charge prediction sequence based on the real-time energy storage battery state of charge and candidate control sequences; using the candidate control sequence as the variable to be optimized, the optimal control sequence is solved online in a rolling manner through the model predictive control optimizer and sent to the photovoltaic-storage system for execution.
[0013] Preferably, constructing the prediction query matrix based on the prediction initial point, the control prior sequence, and the long-range dependency features generated from the historical operating data includes: The historical operating data is downsampled according to a set fixed time step to obtain the state data of sampling points at equal time intervals, and then concatenated in chronological order to form the long-range dependency feature. The prediction initial point and the long-range dependency feature are concatenated by dimension to form a joint state vector; The control prior sequence is input into a multilayer perceptron network for feature transformation, and the output is the control feature vector sequence for each prediction time step. The joint state vector is concatenated and mapped with the feature vectors of each time step in the control feature vector sequence to generate the query vectors corresponding to each time step in the prediction time domain, and the prediction query matrix is output by combining them in chronological order.
[0014] Preferably, the step of decomposing both the query vector and the key vector into sub-vectors representing state amplitudes and first-order difference numerator vectors representing changing trends, calculating the dot product score for each, and then weighted summing the two types of scores to obtain the final similarity score includes: Calculate the average of the absolute values of all elements in the first-order difference numerator vector representing the trend of change in the query vector, and use the average as the change evaluation coefficient; The difference between the change evaluation coefficient and the preset center threshold is then input into the Sigmoid function to calculate the feature index, which is between 0 and 1. The feature index is used as the first weight of the dot product score corresponding to the first difference numerator vector, and the difference between the value 1 and the feature index is used as the second weight of the dot product score corresponding to the subvector representing the state amplitude. The first weight is multiplied by the dot product score corresponding to the first difference numerator vector to obtain the first product, the second weight is multiplied by the dot product score corresponding to the subvector representing the state amplitude to obtain the second product, and the first product and the second product are added to obtain the final similarity score.
[0015] Preferably, determining the number of core keys based on the flatness of the distribution of the final similarity score includes: Calculate the statistical variance of the final similarity scores of all historical keys corresponding to the current query time step, and use the reciprocal of the statistical variance as a measure of the flatness of the distribution. The target value is obtained by adding the pre-calibrated proportional gain constant and the distribution flatness metric index to the set base number constant value. The target value is rounded down to obtain the number of core bonds.
[0016] Preferably, determining the context extraction range based on local features includes: Extract the historical key sequence within three fixed time steps before and after the time point corresponding to each core key; The sum of squares of the differences between each adjacent key vector in the extracted historical key sequence is calculated as the local volatility parameter of the core key. Divide the local volatility parameter by a preset reference constant to obtain a dimensionless volatility value; take the negative of the dimensionless volatility value as the exponent of the natural constant e to calculate the characteristic scaling factor; multiply the set maximum time offset constant by the characteristic scaling factor to obtain the scaling radius, and round the scaling radius to an integer time step. The original time step index of the core key in the key matrix is extended by the integer time step distance to the past time period and to the future time period, and the entire extended time interval is determined as the context extraction range.
[0017] Preferably, the step of performing consistency filtering on the value vectors within the context aggregation set and obtaining the target attention weight based on the filtering results includes: Calculate the arithmetic mean of all value vectors within the context aggregation set in each corresponding dimension, and construct a baseline average vector accordingly. Calculate the Euclidean distance between each value vector and the benchmark average vector; Remove the value vectors whose Euclidean distance exceeds a given discrete boundary constant, and form a subset of all the remaining value vectors that have not been removed that is consistent with the mainstream trend. The target attention weights corresponding to the removed value vectors are assigned zero values. The final similarity scores of each value vector retained within the subset consistent with the mainstream trend are uniformly recalculated using the Softmax normalization function to obtain the numerical update results. The results are then used as the target attention weights to complete the distribution adjustment operation.
[0018] Preferably, the step of using candidate control sequences as variables to be optimized and solving for the optimal control sequence online using a model predictive control optimizer includes: A constrained model predictive control optimization model is established. The objective function of the optimization model includes a battery state-of-charge tracking error term and a control input smoothness term. The constraints are the battery state-of-charge evolution, power limit, photovoltaic active power reduction range, and power balance relationship. The power balance relationship includes obtaining the net photovoltaic output power by subtracting the photovoltaic active power reduction from the available photovoltaic output power, and ensuring that the net photovoltaic output power, energy storage charging and discharging power, and load demand power satisfy energy balance. A gradient-free heuristic algorithm is used to perform optimization iterations within a set constraint space to obtain a time-dimensional control variable sequence solution that minimizes the objective function value. The optimal control sequence is generated by combining the solutions of the control variable sequence in chronological order.
[0019] This invention decomposes the query vector and key vector into state amplitude sub-vectors and first-order difference numerator vectors, and adaptively weights the amplitude scores and trend scores. This allows for the simultaneous characterization of the absolute state and changing trends of the photovoltaic-storage system's operating data, improving the accuracy of matching historical similar operating conditions. By determining the number of core keys based on the score distribution flatness and defining the context extraction range in conjunction with local fluctuation characteristics, redundant historical data is reduced in the calculation, while key local context information is preserved. By performing consistency screening on the value vectors within the context aggregation set and reallocating attention weights, the interference of abnormal or conflicting data on the prediction results can be reduced. Therefore, more reliable external disturbance prediction sequences and energy storage battery state-of-charge prediction sequences can be provided for the online rolling solution of model predictive control, improving the control stability and operational constraint satisfaction capability of the photovoltaic-storage system under fluctuating operating conditions. Attached Figure Description
[0020] Figure 1 A flowchart of the first embodiment; Figure 2 This is a schematic diagram illustrating the scope of context extraction. Detailed Implementation
[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] In the first embodiment, the present invention proposes an adaptive model predictive control method for a photovoltaic-storage system, such as... Figure 1 As shown, it includes the following steps: S1. Obtain historical operating data and real-time status data of the photovoltaic storage system. Use the real-time status data as the prediction initial point. Construct a prediction query matrix based on the prediction initial point, the control prior sequence, and the long-range dependency features generated from the historical operating data. Encode the historical operating data to obtain a key matrix and a value matrix. Decompose both the query vector and the key vector into sub-vectors representing state amplitude and first-order difference numerator vectors representing change trends, and calculate the dot product score for each. Sum the two scores with weights to obtain the final similarity score, which is then normalized to the initial attention weight.
[0023] Through voltage sensors, current sensors, temperature sensors, and a data acquisition and monitoring control system deployed in the photovoltaic-storage system, the actual output power of the photovoltaic array, the state of charge of the energy storage battery, the load demand power, ambient irradiance, and temperature are collected in real time. Based on the ambient irradiance, temperature, and the rated parameters of the photovoltaic array, the available output power of the photovoltaic array is estimated in real time. The actual output power of the photovoltaic array, the available output power of the photovoltaic array, the state of charge of the energy storage battery, the load demand power, the ambient irradiance, and temperature are associated and stored according to the same timestamp, forming the status data in the historical operating data. Simultaneously, the energy storage charging and discharging power is recorded, forming the control execution record in the historical operating data. The latest frame of status data generated at the current moment is read as the real-time status data. The historical operating data includes historical status data and historical control execution records.
[0024] Before feature encoding, the actual output power of the photovoltaic array, the available output power of the photovoltaic array, the state of charge of the energy storage battery, the load power demand, the ambient irradiance, the temperature, and the energy storage charging and discharging power are normalized. This real-time state data is used as the initial prediction point with a time step of 0.
[0025] Historical operating data is downsampled and concatenated according to a set fixed time step to form the long-range dependency feature. Based on the control time domain of model predictive control, a set of control prior sequences is generated within the constraints of energy storage charging and discharging power and photovoltaic active power reduction. The control prior sequences include the energy storage charging and discharging power and photovoltaic active power reduction at each prediction time step.
[0026] The prediction initial point, control prior sequence, and long-range dependency features are fused to generate joint state control features corresponding to each time step in the prediction time domain, and a prediction query matrix is constructed based on the joint state control features. Historical running data is feature-encoded to obtain a key matrix and a value matrix. The query vector in the prediction query matrix and the key vector in the key matrix are both constructed as the same even-dimensional hidden feature vector, with a feature dimension of 2^m, where m is a positive integer.
[0027] The query vector and key vector are formed by concatenating an m-dimensional amplitude sub-vector and an m-dimensional first-order difference numerator vector, respectively. The amplitude sub-vector is obtained by mapping the encoded features of the corresponding time step, and the first-order difference numerator vector is obtained by mapping the difference in encoded features between adjacent time steps. For the first prediction time step, the difference between the joint state control features of the first prediction time step and the baseline joint features obtained by mapping the prediction initial point and long-range dependency features is used as the basis for constructing the first-order difference numerator vector.
[0028] For each query vector in the prediction query matrix and each key vector in the key matrix, an amplitude sub-vector and a first-order difference numerator vector are extracted. The dot product of the query amplitude sub-vector and the key amplitude sub-vector is calculated as the amplitude score, and the dot product of the query first-order difference numerator vector and the key first-order difference numerator vector is calculated as the trend score. The average absolute value of all elements of the query first-order difference numerator vector is calculated as the change evaluation coefficient. The difference between this change evaluation coefficient and a preset center threshold is input into the Sigmoid function to obtain the feature index. The feature index is used as the weight of the trend score, and the difference between 1 and the feature index is used as the weight of the amplitude score. The amplitude score and the trend score are weighted and summed to obtain the final similarity score.
[0029] The final similarity scores corresponding to each historical key at the same query time step are normalized using Softmax to obtain the initial attention weights.
[0030] In an optional embodiment, constructing the prediction query matrix based on the prediction initial point, the control prior sequence, and the long-range dependency features generated from the historical running data includes: The historical operating data is downsampled according to a set fixed time step to obtain the state data of sampling points at equal time intervals, and then concatenated in chronological order to form the long-range dependency feature. The prediction initial point and the long-range dependency feature are concatenated by dimension to form a joint state vector; The control prior sequence is input into a multilayer perceptron network for feature transformation, and the output is the control feature vector sequence for each prediction time step. The joint state vector is concatenated and mapped with the feature vectors of each time step in the control feature vector sequence to generate the query vectors corresponding to each time step in the prediction time domain, and the prediction query matrix is output by combining them in chronological order.
[0031] For example, historical operational data is collected once per second for a total duration of 600 seconds. This includes data sequences across six state dimensions: actual photovoltaic array output power, available photovoltaic output power, energy storage battery state of charge, load power demand, ambient irradiance, and temperature; and one control dimension: energy storage charging and discharging power. The available photovoltaic output power is estimated from the ambient irradiance, temperature, and rated parameters of the photovoltaic array. Specifically, let the ambient irradiance at the current time step be G(k), and the rated power of the photovoltaic array be... The standard test irradiance is The photovoltaic module temperature is T(K), and the standard test temperature is... If the temperature power correction factor is β, then the usable output power of the photovoltaic system can be estimated using the following formula: .in, Take 1000W / m 2 , Take 25℃, and β is determined based on the rated parameters of the photovoltaic module. The calculated... Limited to 0 to Between these points, the available output power of the photovoltaic system at the current time step is considered.
[0032] A fixed time step of 60 seconds was set, and historical data was downsampled to extract state data from 10 sampling points at seconds 60, 120, 180 to 600. These 10 6-dimensional state vectors were concatenated in chronological order to obtain a 1-dimensional vector containing 60 elements, which served as the long-range dependency feature.
[0033] The 6-dimensional state data obtained from the current moment, after collection and estimation, is used as the initial point for prediction. This initial point is then concatenated with the aforementioned 60-dimensional long-range dependent feature vector along its feature dimensions to construct a 66-dimensional joint state vector. For example, when the prediction time domain length is 5 future time steps, two control variables are set for each prediction time step: energy storage charging and discharging power and photovoltaic active power reduction. The range of energy storage charging and discharging power is determined based on the rated power of the energy storage converter, the upper and lower limits of the energy storage battery's state of charge, and the maximum charge and discharge rate. The range of photovoltaic active power reduction is determined based on the available photovoltaic output power of the corresponding prediction time step, and satisfies the constraint that it is not less than zero and not greater than the available photovoltaic output power of that prediction time step.
[0034] When generating the control prior sequence, sampling is performed within the range of energy storage charging and discharging power and the range of photovoltaic active power reduction, respectively, to obtain the candidate values of energy storage charging and discharging power and photovoltaic active power reduction corresponding to each prediction time step. The two candidate values under the same prediction time step are combined into a two-dimensional control action vector, and the five two-dimensional control action vectors are stacked in chronological order to form a control prior sequence matrix with a dimension of 5×2.
[0035] The 5×2 control prior sequence is flattened into a 10-dimensional control input vector in chronological order and input into a multilayer perceptron network for nonlinear feature extraction. The multilayer perceptron network includes an input layer, two hidden layers, and an output layer. The two hidden layers have 16 and 8 neurons respectively, and the activation function is ReLU. Adjacent network layers are connected using a fully connected approach. After mapping by the output layer, the network outputs a 5×8 control feature vector sequence, i.e., five 8-dimensional feature vectors corresponding to the five future prediction time steps.
[0036] The 66-dimensional joint state vector is copied 5 times, and each copy is concatenated with 5 8-dimensional control feature vectors to obtain 5 74-dimensional transition concatenation vectors. Each transition concatenation vector is used as the joint state control feature for the corresponding prediction time step.
[0037] For each prediction time step, the first fully connected mapping layer is used to perform feature mapping on the joint state control features of the prediction time step, and outputs a 32-dimensional amplitude sub-vector. The amplitude sub-vector is used to represent the overall feature amplitude of the state and control combination at the prediction time step.
[0038] Starting from the second prediction time step, the difference between the joint state control features of the current prediction time step and the joint state control features of the previous prediction time step is first calculated. This difference is then input into the second fully connected mapping layer, outputting a 32-dimensional first-order difference numerator vector. This first-order difference numerator vector represents the trend of change between adjacent prediction time steps. For the first prediction time step, the prediction initial point and long-range dependency features are mapped and concatenated with an 8-dimensional zero control feature vector to obtain a 74-dimensional baseline joint feature with the same dimension as the joint state control features. The difference between the joint state control features of the first prediction time step and the baseline joint feature is calculated, and this difference is input into the second fully connected mapping layer, outputting a 32-dimensional first-order difference numerator vector corresponding to the first prediction time step.
[0039] The 32-dimensional amplitude sub-vector and the 32-dimensional first-order difference numerator vector corresponding to each prediction time step are concatenated to obtain a 64-dimensional query vector. These are then stacked row-wise according to the order from the 1st to the 5th prediction time step to generate a 5×64 prediction query matrix. Here, 64 is the even-numbered dimension of the hidden features, with the first 32 dimensions serving as the state amplitude sub-vector and the last 32 dimensions serving as the first-order difference numerator vector of the changing trend.
[0040] Historical key vectors are generated by using the same feature mapping method for the status data and control execution records of each historical time step in the historical operation data. The available output power of photovoltaics and the load demand power after the corresponding historical time step are encoded into value vectors and arranged into key matrix and value matrix in chronological order.
[0041] In an optional embodiment, the step of decomposing both the query vector and the key vector into sub-vectors representing state amplitudes and first-order difference numerator vectors representing changing trends, calculating the dot product score for each, and then weighted summing the two types of scores to obtain the final similarity score includes: Calculate the average of the absolute values of all elements in the first-order difference numerator vector representing the trend of change in the query vector, and use the average as the change evaluation coefficient; The difference between the change evaluation coefficient and the preset center threshold is then input into the Sigmoid function to calculate the feature index, which is between 0 and 1. The feature index is used as the first weight of the dot product score corresponding to the first difference numerator vector, and the difference between the value 1 and the feature index is used as the second weight of the dot product score corresponding to the subvector representing the state amplitude. The first weight is multiplied by the dot product score corresponding to the first difference numerator vector to obtain the first product, the second weight is multiplied by the dot product score corresponding to the subvector representing the state amplitude to obtain the second product, and the first product and the second product are added to obtain the final similarity score.
[0042] For example, in the query vector obtained from the decomposition, the first-order difference numerator vector representing the trend of change contains four elements with values of 0.5, -1.2, 0.8, and -0.3. The absolute values of all elements are extracted and their arithmetic mean is calculated, resulting in a value of 0.7, which is used as the change evaluation coefficient.
[0043] A preset center threshold of 0.5 is set. The difference between the change evaluation coefficient of 0.7 and the preset center threshold of 0.5 is calculated to obtain 0.2. This 0.2 is then input into the Sigmoid activation function to calculate the feature exponent, which is approximately 0.5498. This 0.5498 is designated as the first weight of the dot product score corresponding to the first difference numerator vector. By subtracting this exponent from 1, the second weight of the score corresponding to the subvector representing the state amplitude is calculated to be 0.4502.
[0044] For example, in this cross-attention operation, the dot product score calculated by performing an inner product operation between the current query vector's state amplitude subvector and the corresponding subvector of a specific historical key vector is 4.5, while the dot product score calculated between the first difference numerator vector and the corresponding subvector of that historical key vector is 6.2. Multiplying the first weight 0.5498 by the first difference numerator dot product score of 6.2 yields a first product of approximately 3.4088; multiplying the second weight 0.4502 by the state amplitude subvector score of 4.5 yields a second product of approximately 2.0259. Adding the two products together gives a value of 5.4347. This value is used as the final similarity score output.
[0045] S2, determine the number of core keys based on the flatness of the distribution of the final similarity scores, determine the corresponding number of core keys from the final similarity scores, locate the core keys and core values in the key matrix and value matrix, determine the context extraction range based on local features, and extract context keys and context values from the range to form a context aggregation set.
[0046] The prediction query matrix contains query vectors corresponding to multiple prediction time steps. Therefore, the final similarity score forms a two-dimensional score matrix based on the prediction time step and the historical key index. For each query time step within the prediction time domain, the number of corresponding core keys is determined based on the final similarity scores of all historical keys corresponding to that query time step.
[0047] Specifically, the flatness of the distribution of the final similarity scores of each historical key at the current query time step is calculated, and the number of core keys is determined based on the flatness of the distribution. A flatter score distribution indicates higher uncertainty in historical matching, thus increasing the number of core keys; a more concentrated score distribution indicates the existence of more prominent historical matching objects, thus decreasing the number of core keys. Subsequently, all final similarity scores corresponding to the current query time step are sorted in descending order of numerical value, and the historical keys that rank highest and have a number equal to the stated number of core keys are selected as the core keys for that query time step.
[0048] Based on the time step index of the core key in the original historical time series, the key vector and value vector at the corresponding index positions are extracted from the key matrix and value matrix as the core key and core value.
[0049] For each located core key, extract the historical key sequence within three fixed time steps before and after the corresponding time point of the core key, calculate the sum of squares of the differences between each adjacent key vector in the extracted historical key sequence, and use it as the local volatility parameter of the core key; divide the local volatility parameter by a preset reference constant to obtain the dimensionless volatility value; take the negative of the dimensionless volatility value as the exponent of the natural constant e, and calculate the feature scaling ratio; multiply the set maximum time offset constant by the feature scaling ratio to obtain the scaling radius, and round the scaling radius to an integer time step.
[0050] Centered on the time step index of each core key, the integer time steps mentioned above are extended in the past and future directions. All key and value vectors within this extended time period are extracted. After removing duplicate vectors by time step index, the remaining vector set constitutes the context aggregation set corresponding to the current query time step. The context extraction range is illustrated below. Figure 2 As shown above, when local fluctuations are large, the scope of context extraction is correspondingly narrowed, which helps to reduce the mixing of data from different operating conditions; when local fluctuations are small, the scope of context extraction is correspondingly expanded, which helps to retain more continuous historical evolution information.
[0051] In an optional embodiment, determining the number of core keys based on the flatness of the distribution of the final similarity scores includes: Calculate the statistical variance of the final similarity scores of all historical keys corresponding to the current query time step, and use the reciprocal of the statistical variance as a measure of the flatness of the distribution. The target value is obtained by adding the pre-calibrated proportional gain constant and the distribution flatness metric index to the set base number constant value. The target value is rounded down to obtain the number of core bonds.
[0052] In the prediction step, by matching the query vector with the historical key matrix, a one-dimensional dataset containing the final similarity scores of 100 historical time steps is generated for a given prediction time step. The arithmetic mean of these 100 similarity scores is calculated, for example, the result is 3.2. The statistical variance of this dataset is calculated using the sum of squared deviations formula, for example, the statistical variance result is 4.8. Taking the reciprocal of this statistical variance, we get 1 / 4.8 ≈ 0.2083, and this value is used as a measure of the flatness of the distribution.
[0053] A base key quantity constant is preset, for example, to be 5, and a proportional gain constant is preset, for example, to be 24. This proportional gain constant of 24 is multiplied by the previously calculated distribution flatness metric of 0.2083, yielding approximately 5.0. The preset base constant of 5 is added to the calculated increment of 5.0 to obtain the target value used as the basis for allocation, which is 10.0. A round-down operation is then performed to obtain the exact integer result of 10.
[0054] The top 10 keys from all historical keys, sorted by score, are selected as the core keys for this attention process. Therefore, when the statistical variance is small, the distribution flatness index increases, and the number of core keys increases accordingly; conversely, when the statistical variance is large, the distribution flatness index decreases, and the number of core keys decreases accordingly.
[0055] In an optional embodiment, determining the context extraction range based on local features includes: Extract the historical key sequence within three fixed time steps before and after the time point corresponding to each core key; The sum of squares of the differences between each adjacent key vector in the extracted historical key sequence is calculated as the local volatility parameter of the core key. Divide the local volatility parameter by a preset reference constant to obtain a dimensionless volatility value; take the negative of the dimensionless volatility value as the exponent of the natural constant e to calculate the characteristic scaling factor; multiply the set maximum time offset constant by the characteristic scaling factor to obtain the scaling radius, and round the scaling radius to an integer time step. The original time step index of the core key in the key matrix is extended by the integer time step distance to the past time period and to the future time period, and the entire extended time interval is determined as the context extraction range.
[0056] For example, if a core key is located, the original historical time step index of which the core key corresponds to the timestamp t=100. On the time series axis, extract t=97, 98, 99 from the past and t=101, 102, 103 from the future, and construct a historical key vector sequence containing 7 time steps together with the original point.
[0057] The differences between six adjacent key vectors within the sequence are calculated sequentially and then squared. For example, if the squared differences between adjacent vectors are 0.2, 0.5, 0.3, 0.8, 0.4, and 0.2, respectively, these six numbers are added together to obtain a total of 2.4. This result of 2.4 is used as the local volatility parameter.
[0058] Set the preset baseline constant to 2.0. Divide the calculated volatility parameter 2.4 by the baseline constant 2.0 to obtain the dimensionless value 1.2. Extract the negative of this value, -1.2, and use this negative as the exponent of the natural constant e to perform exponential operations to calculate the characteristic scaling factor. ≈0.301.
[0059] The maximum time offset constant is set to, for example, 15 time steps. Multiplying 15 by the scaling factor 0.301 yields a scaling radius of 4.515. Rounding is then applied to determine the integer time step size as 5. Using the core key index t=100 as the center, the time is extended 5 time steps forward to t=95 and 5 time steps forward to t=105. The entire time interval consisting of 11 consecutive time steps from t=95 to t=105 is defined as the context extraction range.
[0060] S3, perform consistency screening on the value vectors in the context aggregation set, obtain the target attention weight based on the screening result, perform weighted summation and decoding on the value vectors in the context aggregation set according to the target attention weight, generate an external disturbance prediction sequence, and recursively obtain the energy storage battery state of charge prediction sequence based on the real-time energy storage battery state of charge and candidate control sequences; use the candidate control sequence as the variable to be optimized, solve the optimal control sequence online through the model predictive control optimizer, and send it to the photovoltaic-storage system for execution.
[0061] For each prediction time step, the context aggregation set is used to calculate the arithmetic mean of all value vectors in the context aggregation set in each corresponding dimension, thereby constructing a benchmark average vector. The Euclidean distance between each value vector and the benchmark average vector is calculated. A given discrete boundary constant is set. If the Euclidean distance exceeds the given discrete boundary constant, the corresponding value vector is determined to be inconsistent with the mainstream trend, and the value vector is removed from the context aggregation set. Value vectors that do not exceed the given discrete boundary constant are retained to complete the consistency screening.
[0062] The given discrete boundary constant is pre-set based on the distance distribution in historical training samples, ensuring that the context aggregation set under normal operating data retains at least one value vector. For removed context value vectors, they are set as mask terms that do not participate in normalization during weight calculation, and their target attention weights are assigned zero values. For value vectors retained in the context aggregation set, the corresponding final similarity scores are uniformly normalized using the Softmax normalization function to recalculate the weights, and the target attention weights are output.
[0063] The weighted summation operation described above is performed on each query vector within the prediction time domain to obtain the fused feature vector corresponding to each prediction time step. This fused feature vector is then input into the state decoding layer to map and obtain an external disturbance prediction vector containing the available photovoltaic output power and load demand power. These are then combined in chronological order to form an external disturbance prediction sequence for the future prediction time domain. The available photovoltaic output power and load demand power are external disturbance quantities, used as fixed prediction inputs within the same rolling optimization cycle, and are not directly changed by variations in candidate energy storage charging / discharging power or photovoltaic active power reduction.
[0064] The state of charge (SOC) of the energy storage battery, as a controlled state, is recursively derived during the model predictive control (MDC) solution process based on the real-time SOC, candidate energy storage charge / discharge power, and the battery SOC evolution equation, forming a predicted SOC trajectory for the energy storage battery. Thus, the external disturbance prediction sequence provides future available photovoltaic output power and load demand power, while the predicted SOC trajectory characterizes the state changes of the energy storage system under candidate control actions; both together serve as the predictive information required for the MDC solution.
[0065] In the model predictive control (MMC) solution process, a cost objective function is constructed using candidate control sequences as the variables to be optimized. This cost objective function includes a weighted squared penalty term for the control error between the predicted trajectory of the energy storage battery's state of charge (SOC) and the preset SOC reference trajectory, as well as a second-order difference smoothness penalty term for the control input variables. Simultaneously, equality constraints and inequality constraints are constructed. The equality constraints employ an energy balance equation between the net photovoltaic (PV) output power, the energy storage charging / discharging power, and the load demand power. The net PV output power equals the available PV output power in the external disturbance prediction sequence minus the PV active power reduction at the corresponding prediction time step. The inequality constraints include upper and lower limits for the SOC of the energy storage battery, the maximum charging / discharging power constraint of the bidirectional converter, and the range of values for the PV active power reduction. For the same prediction time step, the PV active power reduction and the energy storage charging / discharging power are correlated through energy balance constraints. When updating the candidate control sequences, candidate solutions that do not satisfy the power balance relationship are constrained, corrected, or eliminated to ensure that the candidate control sequences participating in the objective function evaluation satisfy the equality constraints.
[0066] A gradient-free heuristic algorithm, such as particle swarm optimization, is used to solve the cost objective function iteratively online. In each iteration, each individual in the population corresponds to a candidate control sequence. The external disturbance prediction sequence remains unchanged within the same rolling optimization cycle. When the candidate control sequence is updated, the predicted trajectory of the energy storage battery's state of charge is recalculated based on the updated energy storage charging and discharging power, and the energy balance constraints and objective function value are recalculated in conjunction with the external disturbance prediction sequence. Therefore, the predicted external disturbance does not change with the control action, while the controlled state trajectory and objective function evaluation results are updated synchronously with the candidate control sequence, thus forming a closed-loop computational process between the prediction and online optimization stages.
[0067] The candidate control sequence that satisfies the constraints and minimizes the cost objective function is selected as the optimal control sequence, and the first control action corresponding to the current time step is extracted. This control action is converted into a pulse width modulation signal with a corresponding duty cycle by a digital signal processor and sent to the underlying drive circuits of the photovoltaic DC-DC converter and the energy storage bidirectional inverter to control the on / off state of the power devices and execute control commands. At the arrival of the next control sampling cycle, new real-time state data is collected as a new prediction initial point, the prediction time domain is advanced by one step into the future, and the above query aggregation prediction and optimization solution process is repeated to achieve closed-loop online rolling control. Through this rolling control process, the updated real-time state can be used to continuously correct the prediction initial conditions, which helps to improve the control stability and constraint satisfaction capability of the photovoltaic-energy storage system under fluctuating operating conditions.
[0068] In an optional embodiment, the step of performing consistency filtering on the value vectors within the context aggregation set and obtaining the target attention weight based on the filtering results includes: Calculate the arithmetic mean of all value vectors within the context aggregation set in each corresponding dimension, and construct a baseline average vector accordingly. Calculate the Euclidean distance between each value vector and the benchmark average vector; Remove the value vectors whose Euclidean distance exceeds a given discrete boundary constant, and form a subset of all the remaining value vectors that have not been removed that is consistent with the mainstream trend. The target attention weights corresponding to the removed value vectors are assigned zero values. The final similarity scores of each value vector retained within the subset consistent with the mainstream trend are uniformly recalculated using the Softmax normalization function to obtain the numerical update results. The results are then used as the target attention weights to complete the distribution adjustment operation.
[0069] For example, the context aggregation set contains 5 two-dimensional value vectors, which correspond to the following: =[2.0,3.0]、 =[2.2,3.1]、 =[8.0,9.0]、 =[1.9,2.8] and =[2.1,3.2]. Calculate the arithmetic mean on each feature dimension of the vector: 3.24 is calculated for the first dimension and 4.22 is calculated for the second dimension, constructing a baseline mean vector of [3.24,4.22].
[0070] Calculate the Euclidean distance between each value vector and the reference vector. For The square root is calculated to be 1.74. Similarly, the result is... to The corresponding Euclidean distance values are approximately 1.52, 6.72, 1.95, and 1.53, respectively.
[0071] The given discrete boundary constant is, for example, 3.0. Compare the five distance values with the boundary constant to determine... The corresponding distance value of 6.72 exceeds the constant, so this value is removed from the aggregation set. Four vectors do not exceed the 3.0 boundary limit. , , , The retained vectors are concatenated to form a subset. The removed vectors... The corresponding target attention weights are assigned zero values. For example, the final similarity scores for the four vectors in the retained subset are 2.5, 2.8, 2.0, and 2.9, respectively. These four scores are remapped using the Softmax formula, resulting in a new set of output values of approximately 0.225, 0.303, 0.136, and 0.335. This set of weight values serves as the target attention weights. This consistency screening process reduces the impact of historical value vectors that significantly deviate from the mainstream trend on the weighted prediction results.
[0072] In an optional embodiment, the step of using candidate control sequences as variables to be optimized and solving for the optimal control sequence online using a model predictive control optimizer includes: A constrained model predictive control optimization model is established. The objective function of the optimization model includes a battery state-of-charge tracking error term and a control input smoothness term. The constraints are the battery state-of-charge evolution, power limit, photovoltaic active power reduction range, and power balance relationship. The power balance relationship includes obtaining the net photovoltaic output power by subtracting the photovoltaic active power reduction from the available photovoltaic output power, and ensuring that the net photovoltaic output power, energy storage charging and discharging power, and load demand power satisfy energy balance. A gradient-free heuristic algorithm is used to perform optimization iterations within a set constraint space to obtain a time-dimensional control variable sequence solution that minimizes the objective function value. The optimal control sequence is generated by combining the solutions of the control variable sequence in chronological order.
[0073] For example, a nonlinear programming solution model is constructed, with the rolling view set to 5 prediction time steps. In the objective function, the predicted battery state-of-charge vector for the next 5 steps is subtracted from the reference SOC trajectory. A diagonal weight matrix with all diagonal elements equal to 10 is used to weight the deviations, resulting in the sum of the squared control error terms. Control input variables, such as charging and discharging active power, undergo continuous second-order difference operations, with a smoothness penalty term having a multiplier of 2.0. Where N is the prediction time domain length, and P(k) represents the energy storage charging and discharging power at the k-th prediction time step; the sum of the two constitutes the objective function.
[0074] The constraints consist of the state equations governing the battery's state of charge evolution, such as the discretized expression of the ampere-hour integral differential equation, the constraint of SOC in the range of [0.1, 0.9], and the constraint of the inverter's charging and discharging power in the range of [-50kW, 50kW].
[0075] Let the available photovoltaic output power at the k-th prediction time step be... The reduction in active power from photovoltaic power is The energy storage charging and discharging power is The load power requirement is Then the net output power of photovoltaic is - And adopt in energy balance constraints Describe, in which A positive value indicates discharging, and a negative value indicates charging. The reduction in active power output from photovoltaic power satisfies 0 ≤ ≤ .
[0076] Online solutions are obtained using gradient-free heuristic algorithms such as particle swarm optimization. For example, the population size is set to 50, and the maximum number of iterations is set to 100. Each individual in the population corresponds to a candidate control sequence, which covers the next 5 prediction time steps.
[0077] The position vector of an individual in the population is encoded as a continuous control vector for the energy storage charging and discharging power for the next 5 predicted time steps. The range of the energy storage charging and discharging power is set to [-50kW, 50kW]. For each predicted time step, based on the photovoltaic available output power, load demand power and the currently encoded energy storage charging and discharging power in the external disturbance prediction sequence, the corresponding photovoltaic active power reduction is determined through energy balance constraints, and the photovoltaic active power reduction satisfies the constraint that it is not less than zero and not greater than the corresponding photovoltaic available output power.
[0078] After each generation or update of the candidate control sequence, the external disturbance prediction sequence remains a fixed prediction input within the current rolling optimization cycle. The energy storage battery state-of-charge prediction trajectory is recalculated based on the energy storage charging and discharging power in the current candidate control sequence, and the energy balance constraints are re-verified and the objective function value is calculated in conjunction with the photovoltaic active power reduction, available photovoltaic output power, and load demand power. The particle swarm optimization algorithm updates the population individual positions based on the objective function value corresponding to each candidate control sequence until the difference between the optimal objective function values of adjacent generations is less than the preset residual, or the number of iterations reaches 100.
[0079] After the iteration stops, the candidate control sequence with the smallest objective function value is selected as the optimal control sequence for the current rolling optimization cycle. For example, the energy storage charging and discharging powers corresponding to the next five predicted time steps in the optimal control sequence are 12kW, 15kW, 10kW, 8kW, and 2kW, respectively. The corresponding photovoltaic active power reduction is determined based on the available photovoltaic output power, load demand power, and energy balance constraints for each predicted time step. Finally, the energy storage charging and discharging power and photovoltaic active power reduction corresponding to the first predicted time step in the optimal control sequence are extracted and used as the control action sent to the hardware for execution in the current control sampling cycle, and a new rolling optimization process is initiated in the next control sampling cycle.
[0080] In this embodiment, the network parameters of the aforementioned multilayer perceptron network, the first fully connected mapping layer, the second fully connected mapping layer, and the state decoding layer are pre-trained using historical operating data. During training, the historical operating data is divided into training samples according to a sliding time window. The historical state data, historical control execution records, and corresponding control prior sequences within the window are used as inputs. The available photovoltaic output power and load demand power at subsequent prediction time steps are used as supervision labels. A loss function is constructed using the error between the prediction result and the supervision label, and the network parameters are updated through backpropagation.
[0081] In the second embodiment, the present invention also proposes an adaptive model predictive control system for a photovoltaic-storage system, comprising the following modules: The calculation module is used to acquire historical operation data and real-time status data of the photovoltaic storage system. The real-time status data is used as the prediction initial point. Based on the prediction initial point, the control prior sequence, and the long-range dependency features generated from the historical operation data, a prediction query matrix is constructed. The historical operation data is then feature-encoded to obtain a key matrix and a value matrix. Both the query vector and the key vector are decomposed into sub-vectors representing state amplitude and first-order difference numerator vectors representing change trends. The dot product scores are calculated for each sub-vector. The two scores are weighted and summed to obtain the final similarity score, which is then normalized to the initial attention weight. The determination module is used to determine the number of core keys based on the distribution flatness of the final similarity score, determine the corresponding number of core keys from the final similarity score, locate the core keys and core values in the key matrix and value matrix, determine the context extraction range based on local features, and extract context keys and context values from the range to form a context aggregation set. The filtering module is used to perform consistency filtering on the value vectors within the context aggregation set, obtain the target attention weight based on the filtering results, perform weighted summation and decoding on the value vectors within the context aggregation set according to the target attention weight, generate an external disturbance prediction sequence, and recursively obtain the energy storage battery state of charge prediction sequence based on the real-time energy storage battery state of charge and candidate control sequences; using the candidate control sequence as the variable to be optimized, the optimal control sequence is solved online in a rolling manner through the model predictive control optimizer and sent to the photovoltaic-storage system for execution.
[0082] The above description represents the preferred embodiments of the present invention. It should be noted that, for those skilled in the art, various improvements and modifications can be made without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method of adaptive model predictive control for optical storage systems, characterized in that, The method comprises the following steps: obtaining historical operation data and real-time state data of the optical storage system, taking the real-time state data as a prediction initial point, constructing a prediction query matrix based on the prediction initial point, a control prior sequence and long-range dependence features generated from the historical operation data, and performing feature coding on the historical operation data to obtain a key matrix and a value matrix; decomposing the query vector and the key vector into a sub-vector representing a state amplitude and a first-order difference sub-vector representing a change trend, respectively calculating dot product scores, and obtaining a final similarity score by weighted sum of the two types of scores and normalization into an initial attention weight; determining the number of core keys according to the flatness of the distribution of the final similarity score, determining a corresponding number of core keys from the final similarity score, locating the core keys and core values in the key matrix and the value matrix, determining a context extraction range according to local features, extracting context keys and context values from the range to form a context aggregation set; performing consistency screening on the value vectors in the context aggregation set, obtaining a target attention weight based on the screening result, performing weighted sum and decoding on the value vectors in the context aggregation set according to the target attention weight, generating an external disturbance prediction sequence, and recursively obtaining a storage battery state of charge prediction sequence based on a real-time storage battery state of charge and a candidate control sequence; taking the candidate control sequence as a to-be-optimized variable, solving an optimal control sequence by a model predictive control optimizer online rolling, and issuing the optimal control sequence to the optical storage system for execution.
2. The method of claim 1, wherein, The prediction query matrix is constructed based on the prediction initial point, the control prior sequence and the long-range dependence features generated from the historical operation data, comprising: down-sampling the historical operation data according to a set fixed time step to obtain state data of sampling points at equal time intervals, and concatenating the state data in time sequence to form the long-range dependence features; splicing the prediction initial point and the long-range dependence features into a joint state vector according to dimensions; inputting the control prior sequence into a multi-layer perception network for feature transformation, and outputting a control feature vector sequence at each prediction time step; splicing and mapping the joint state vector and the feature vector at each time step in the control feature vector sequence to generate a query vector corresponding to each time step in the prediction time domain, and combining and outputting the prediction query matrix in time sequence.
3. The method of claim 1, wherein, The query vector and the key vector are decomposed into a sub-vector representing a state amplitude and a first-order difference sub-vector representing a change trend, respectively calculating dot product scores, and obtaining a final similarity score by weighted sum of the two types of scores, comprising: calculating the absolute value average of all elements of the first-order difference sub-vector representing the change trend in the query vector, and taking the average as a change evaluation coefficient; inputting the difference between the change evaluation coefficient and a preset center threshold into a Sigmoid function to obtain a feature index between 0 and 1; taking the feature index as a first weight of the dot product score corresponding to the first-order difference sub-vector, and taking the difference between the value 1 and the feature index as a second weight of the dot product score corresponding to the sub-vector representing the state amplitude; The first weight is multiplied by a dot product score corresponding to a first-order difference sub-vector to obtain a first product, the second weight is multiplied by a dot product score corresponding to a state amplitude sub-vector to obtain a second product, and the first product and the second product are added to obtain a final similarity score.
4. The method of claim 3, wherein, The number of core keys is determined according to flatness of a distribution of the final similarity scores, including: A statistical variance of the final similarity scores of all historical keys corresponding to a current query time step is calculated, and an inverse of the statistical variance is taken as a metric numerical indicator of the distribution flatness; A target value is obtained by adding a preset basic key number constant value to a product of a preset proportional gain constant and the metric numerical indicator of the distribution flatness; The number of core keys is obtained by performing a floor operation on the target value.
5. The method of claim 1, wherein, The context extraction range is determined according to local features, including: A historical key sequence within each three fixed time steps before and after a time point corresponding to each core key is extracted; A sum of squares of difference values of adjacent key vectors in the extracted historical key sequence is calculated as a local fluctuation degree parameter of the core key; The local fluctuation degree parameter is divided by a preset reference constant to obtain a dimensionless fluctuation value, and an exponential of an inverse of the dimensionless fluctuation value is calculated as a feature scaling rate; a scaling radius is obtained by multiplying a preset maximum time offset constant and the feature scaling rate, and the scaling radius is rounded to an integer time step length; An original time step index of the core key in the key matrix is extended by the integer time step length to a past time period and to a future time period, respectively, and a time interval extended by the extension is determined as the context extraction range.
6. The method of claim 1, wherein, The value vectors in the context aggregation set are filtered for consistency, and target attention weights are obtained based on a filtering result, including: An arithmetic mean value of all value vectors in the context aggregation set in each dimension is calculated to construct a reference average vector; Euclidean distance values of each value vector and the reference average vector are calculated, respectively; Value vectors with Euclidean distance values exceeding a given discrete boundary constant are removed, and all unremoved value vectors remaining in the removal are grouped into a subset consistent with a mainstream trend; A target attention weight corresponding to a removed value vector is assigned a value of zero, and a final similarity score of each value vector in the subset consistent with the mainstream trend is uniformly applied to a Softmax normalization function to recalculate a numerical update result, and the result is taken as the target attention weight to complete a distribution adjustment operation.
7. The method of claim 1, wherein, The candidate control sequence is taken as a to-be-optimized variable, and an optimal control sequence is solved by an online rolling of a model predictive control optimizer, including: An optimization model of model predictive control with constraints is established, a target function of the optimization model includes a storage battery state of charge tracking error term and a control input smoothness term, and a storage battery state of charge evolution, a power limit, a photovoltaic active reduction range and a power balance relationship are taken as constraint conditions; the power balance relationship includes a photovoltaic net output power obtained by deducting the photovoltaic active reduction from the photovoltaic available output power, and the photovoltaic net output power, the storage battery charging and discharging power and the load demand power satisfy the energy balance; A gradient-free heuristic algorithm is used to expand optimization iteration in the set constraint condition space to obtain a time dimension control variable sequence solution which makes the target function value meet the minimization requirement; The control variable sequence solution is combined in time sequence to generate an optimal control sequence under the current rolling prediction field of view.
8. An adaptive model predictive control system for a light storage system, characterized by, The method comprises the following modules: A calculation module is configured to obtain historical operation data and real-time state data of the energy storage system, take the real-time state data as a prediction initial point, construct a prediction query matrix based on the prediction initial point, a control prior sequence and long-range dependence features generated from the historical operation data, and perform feature coding on the historical operation data to obtain a key matrix and a value matrix; the query vector and the key vector are both decomposed into a sub-vector representing a state amplitude and a first-order difference sub-vector representing a change trend, and dot products are calculated respectively to obtain two types of scores, and a final similarity score is obtained by weighted sum of the two types of scores and normalized as an initial attention weight; A determination module is configured to determine the number of core keys according to the flatness of the distribution of the final similarity score, determine a corresponding number of core keys from the final similarity score, locate the core keys and core values in the key matrix and the value matrix, determine a context extraction range according to local features, extract context keys and context values from the range to form a context aggregation set; A screening module is configured to perform consistency screening on the value vectors in the context aggregation set, obtain a target attention weight based on the screening result, perform weighted sum and decoding on the value vectors in the context aggregation set according to the target attention weight, generate an external disturbance prediction sequence, and recursively obtain a storage battery state of charge prediction sequence based on the real-time storage battery state of charge and the candidate control sequence; the candidate control sequence is taken as a to-be-optimized variable, an optimal control sequence is solved online by a model predictive control optimizer, and the optimal control sequence is delivered to the energy storage system for execution.
9. The system of claim 8, wherein, The prediction query matrix is constructed based on the prediction initial point, the control prior sequence and the long-range dependence features generated from the historical operation data, which comprises: The historical operation data is down-sampled according to a set fixed time step to obtain state data of sampling points at equal time intervals, which are concatenated in time sequence to form the long-range dependence features; The prediction initial point and the long-range dependence features are spliced into a joint state vector according to dimensions; The control prior sequence is input into a multi-layer perception network for feature transformation, and a control feature vector sequence at each prediction time step is output; The joint state vector is spliced with the feature vector of each time step in the control feature vector sequence respectively and mapped, to generate a query vector corresponding to each time step in a prediction time domain, and the query vectors are combined in time sequence to output a prediction query matrix.
10. The system of claim 8, wherein, The query vector and the key vector are decomposed into a sub-vector representing a state amplitude and a first-order difference sub-vector representing a change trend, and dot product scores are calculated respectively, and the final similarity score is obtained by weighted sum of the two types of scores, comprising: An absolute value average of all elements of the first-order difference sub-vector representing the change trend in the query vector is calculated, and the average is taken as a change evaluation coefficient; The change evaluation coefficient is input into a Sigmoid function after being subtracted from a preset central threshold to obtain a feature index between 0 and 1; The feature index is taken as a first weight of the dot product score corresponding to the first-order difference sub-vector, and a difference between the value 1 and the feature index is taken as a second weight of the dot product score corresponding to the sub-vector representing the state amplitude; The first weight is multiplied by the dot product score corresponding to the first-order difference sub-vector to obtain a first product, the second weight is multiplied by the dot product score corresponding to the sub-vector representing the state amplitude to obtain a second product, and the final similarity score is obtained by adding the first product and the second product.
