Active power control method based on transformer for power spot market clearing results

CN123019112APending Publication Date: 2026-10-30TECH & ECONOMIC CONSULTING CENT FOR ELECTRIC POWER CONSTR OF CHINA ELECTRICITY COUNCIL +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611215838.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-12
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0005]为了克服现有技术的上述缺陷,本发明的实施例提供基于Transformer的电力现货市场出清结果有功控制方法,通过将电网拓扑谱特征投影至统一参考空间,并将节点发电成本偏差转化为经济代价掩码融入Transformer交叉注意力计算,以解决拓扑变化下运行状态特征表达一致性不足以及控制策略对市场经济信息感知能力不足的问题

Benefits of technology

1.本发明通过将当前电网拓扑谱特征投影至预设参考拓扑特征空间,并基于投影后的谱特征将电网运行数据转化为拓扑状态表征,使不同拓扑下的电网状态在统一参考空间中表达,降低了运行状态特征对拓扑变化的敏感度,提高了控制模型对电网拓扑动态变化的适应能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123019112A_ABST
    Figure CN123019112A_ABST
Patent Text Reader

Abstract

The application discloses a power spot market clearing result active control method based on a transformer, relates to the technical field of power system operation control, and comprises the following steps: acquiring power grid topology spectrum features and projecting them to a reference feature space, and converting power grid operation data into topology state representation; calculating node power generation cost deviation according to a clearing result, constructing an initial weight matrix, and normalizing the initial weight matrix to obtain an economic cost mask; inputting the power grid operation data and the topology state representation into a transformer network, and combining the mask to perform cross attention calculation to generate an initial active control instruction; extracting the hidden state of the transformer network when the initial active control instruction is generated, and decoding the hidden state into a steady-state operation equilibrium point; and combining a real-time active power deviation to adjust the initial active control instruction to obtain a real-time active control instruction. The application is used to solve the problems of insufficient consistency of operation state feature expression and insufficient market economic information perception ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power system operation control technology, and more specifically, to a method for active power control based on the clearing results of the electricity spot market using Transformer. Background Technology

[0002] Existing active power control schemes in the electricity spot market mostly adopt optimal power flow calculation based on physical modeling or deep learning-based methods to cope with the real-time power balance requirements under high-proportion renewable energy access and random load fluctuations.

[0003] Among them, the active power control method based on deep learning usually establishes a mapping relationship between the operating status and active power control commands based on a preset power grid topology to ensure online inference efficiency; while the economic information such as unit bids and nodal marginal electricity prices in the spot market clearing results are mostly used as targets and constraints for model training or offline optimization. In the real-time inference stage, the control model mainly generates control commands based on the power grid operating status.

[0004] However, existing technologies still face several technical challenges in practical applications: First, when power grids undergo topology reconfiguration due to line maintenance, fault tripping, or other reasons, deep learning models based on fixed topologies struggle to maintain consistency in the representation of operational state characteristics under different topologies, resulting in insufficient adaptability to topology change scenarios. Second, during real-time control, the economic information from market clearing is typically used as an external optimization basis for the control model, independent of the model's online inference process, making it difficult for control commands to synchronously respond to the economic requirements formed by market clearing. Finally, existing data-driven control methods typically output control commands directly in an end-to-end manner, with opaque internal decision-making processes, making it difficult to effectively coordinate with physical model-based feedback control, thus limiting the online dynamic adjustment capability of the control strategy. Summary of the Invention

[0005] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention provide an active power control method based on the clearing results of the electricity spot market using Transformer. This method projects the grid topology spectrum features onto a unified reference space and incorporates the node generation cost deviation into an economic cost mask into the Transformer cross-attention calculation. This addresses the problems of insufficient consistency in the expression of operating state features under topology changes and insufficient perception of market economic information by the control strategy.

[0006] To achieve the above objectives, the present invention provides the following technical solution: A Transformer-based method for active power control based on the clearing results of the electricity spot market includes the following steps: The spectral features of the current power grid topology are obtained and projected onto a preset reference topology feature space. Based on the projected spectral features, the power grid operation data are transformed into a topology state representation. Based on the spot market clearing results, the power generation cost deviation at each node is calculated, an initial weight matrix is ​​constructed and alternating normalization is performed to obtain the economic cost mask. The power grid operation data and topology state representation are input into a pre-built Transformer network, and cross-attention calculation is performed in conjunction with the economic cost mask to generate initial active power control commands. The hidden state of the Transformer network when the initial active power control command is generated is extracted and decoded to obtain the steady-state operating equilibrium point. The initial active power control command is then adjusted in conjunction with the real-time active power deviation to obtain the real-time active power control command.

[0007] In a preferred embodiment, generating the initial active power control command includes: using the economic cost mask as a bias term and incorporating it into the cross-attention calculation of the topology state representation and the power grid operation data to obtain a cross-attention weight; and performing a weighted summation of the value features of the power grid operation data based on the cross-attention weight to obtain the initial active power control command.

[0008] In a preferred embodiment, obtaining the spectral features of the current power grid topology and projecting them onto a preset reference topology feature space includes: performing eigenvalue decomposition on the admittance parameters of the current power grid topology, extracting the feature vectors corresponding to the non-zero feature values ​​as the spectral features; calculating the orthogonal alignment matrix between the spectral features and the reference topology spectral features, and performing a rotation transformation on the spectral features corresponding to the current power grid topology to obtain the projected spectral features.

[0009] In a preferred embodiment, the step of converting power grid operation data into a topology state representation includes: constructing an operation data matrix including node injected power and unit output parameters based on the power grid operation data; and multiplying the projected spectral features with the operation data matrix to obtain the topology state representation.

[0010] In a preferred embodiment, generating real-time active power control commands includes: modifying the initial active power control command by combining it with a preset steady-state operating boundary to obtain a reference power command; using the steady-state operating equilibrium point as a reference, locally linearizing the nonlinear motion equation of the generator rotor, constructing a state matrix and a control matrix, and solving the state feedback gain matrix, then adjusting the reference power command by combining it with the real-time active power deviation to obtain a real-time adjustment command; and performing quadratic programming to solve the real-time adjustment command under preset transient safety constraints to generate the real-time active power control command.

[0011] In a preferred embodiment, the decoding to obtain the steady-state operating equilibrium point includes: performing feature mapping on the hidden state input, which is composed of a fully connected network, to output the corresponding generator steady-state power angle and steady-state electromagnetic power; and using the generator steady-state power angle and steady-state electromagnetic power as the steady-state operating equilibrium point.

[0012] In a preferred embodiment, obtaining the economic cost mask includes: calculating the difference between the unit price and the corresponding node marginal electricity price in the spot market clearing result, as the generation cost deviation of each node; constructing an economic cost matrix based on the relative distance between the generation cost deviations of each node; performing exponential mapping on the economic cost matrix to obtain the initial weight matrix; and performing alternating normalization on the initial weight matrix to obtain a double random matrix that satisfies a preset convergence condition, as the economic cost mask.

[0013] In a preferred embodiment, obtaining the reference power command includes: performing sensitivity analysis based on branch power flow balance constraints, transforming the preset steady-state operating boundary, which is composed of the power transmission limit of the power grid branch and the node voltage limit, into linearized constraint conditions; and, under the premise of satisfying the linearized constraint conditions, performing a quadratic programming solution with the objective of minimizing the correction between the reference power command and the initial active power control command to obtain the reference power command.

[0014] In a preferred embodiment, the step of performing a quadratic programming solution on the real-time adjustment command to generate the real-time active power control command includes: establishing a frequency safety barrier function based on the nonlinear motion equation of the generator rotor and a preset frequency offset extreme value; obtaining the transient safety constraint by differentiating the barrier function; and generating the real-time active power control command by performing a quadratic programming solution under the transient safety constraint with the objective of minimizing the correction amount between the real-time active power control command and the real-time adjustment command.

[0015] An active power control system based on the clearing results of the electricity spot market, comprising the following modules: a spectral feature projection module, used to acquire the spectral features of the current power grid topology and project them onto a preset reference topology feature space, and convert the power grid operation data into a topology state representation based on the projected spectral features; an economic mask module, used to calculate the generation cost deviation of each node according to the clearing results of the spot market, construct an initial weight matrix and perform alternating normalization processing to obtain an economic cost mask; an initial command module, used to generate an initial active power control command by inputting the power grid operation data and the topology state representation into a pre-constructed Transformer network, and performing cross-attention calculation in combination with the economic cost mask; and a feedback adjustment module, used to extract the hidden state of the Transformer network when generating the initial active power control command, decode it to obtain the steady-state operating equilibrium point, and adjust the initial active power control command in combination with the real-time active power deviation to obtain a real-time active power control command.

[0016] The technical effects and advantages of the active power control method based on the clearing results of the electricity spot market in this invention are as follows: 1. This invention projects the current power grid topology spectral features onto a preset reference topology feature space, and transforms the power grid operation data into a topology state representation based on the projected spectral features. This allows the power grid state under different topologies to be expressed in a unified reference space, reducing the sensitivity of the operation state features to topology changes and improving the adaptability of the control model to dynamic changes in the power grid topology.

[0017] 2. This invention constructs an economic cost mask based on the clearing results of the spot market and integrates it into the Transformer cross-attention calculation, enabling market economic information to directly participate in the control decision-making during the online inference stage of the model. By integrating the grid operating status and economic information during the generation of active power control commands, this invention improves the coordination ability between physical operating objectives and market economic objectives in real-time control, and provides a way to achieve active power control in the electricity spot market that takes into account both operational constraints and economic efficiency.

[0018] 3. This invention extracts the hidden state of the Transformer network when generating the initial active power control command and decodes it to obtain the corresponding steady-state operating equilibrium point, providing a physical state reference corresponding to the current operating state for real-time active power control. Without having to re-solve the power flow, it provides a reference benchmark for state feedback adjustment based on real-time active power deviation, improving the synergy between data-driven control and physical feedback control. Attached Figure Description

[0019] Figure 1 This is a schematic flowchart of an active power control method for the clearing results of the electricity spot market based on Transformer, provided in an embodiment of the present invention.

[0020] Figure 2 This is a schematic diagram of the distribution of the economic cost mask matrix provided in an embodiment of the present invention.

[0021] Figure 3 This is a schematic diagram showing the comparison of the dynamic response curves of real-time frequency deviation before and after the introduction of transient safety constraints, provided in an embodiment of the present invention.

[0022] Figure 4 This is a schematic diagram of an active power control system module for the clearing result of the electricity spot market based on Transformer, provided in an embodiment of the present invention. Detailed Implementation

[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0024] Example 1, Figure 1 This invention presents an active power control method based on the clearing results of the electricity spot market using Transformer, comprising the following steps: Step 1: Obtain the spectral features of the current power grid topology and project them onto a preset reference topology feature space. Based on the projected spectral features, transform the power grid operation data into a topology state representation.

[0025] 1.1 Obtain the spectral characteristics of the current power grid topology and project them onto a preset reference topology feature space, including: 1.1.1 Eigenvalue decomposition is performed on the admittance parameters of the current power grid topology, and the eigenvectors corresponding to the non-zero eigenvalues ​​are extracted as spectral features, as follows: Within a preset scheduling cycle (e.g., a 15-minute or 1-hour scheduling cycle), the global circuit breaker switching status is acquired through the Supervisory Control and Data Acquisition (SCADA) system and the Energy Management System (EMS) to construct the topology for the current cycle. Simultaneously, the line impedance and ground admittance parameters for the current cycle are read to generate a node admittance matrix; the dimension of the node admittance matrix is ​​always [0, 1]. , The total number of physical nodes in the power grid is given. For isolated nodes that are taken out of service due to maintenance or faults, their dimension position is preserved in the node admittance matrix, and the off-diagonal elements of the corresponding rows and columns are set to zero. The absolute values ​​of the imaginary parts (i.e., susceptance parameters) of the off-diagonal elements in the node admittance matrix are extracted as edge weights and arranged in rows and columns to construct an adjacency matrix representing the topological connectivity of the power grid. The sum of the elements in each row of this adjacency matrix is ​​calculated to form the degree matrix, and the adjacency matrix is ​​subtracted to obtain the Laplace matrix of the current power grid topology.

[0026] The eigenvalue decomposition of the Laplacian matrix is ​​performed using the Lanzos algorithm and the QR algorithm. The specific steps are as follows: First, the Laplace matrix is ​​used as the input to the Lanzos algorithm. Starting with a random initial non-zero vector, an orthogonal Krylov subspace is constructed through repeated multiplication of the original Laplace matrix and the vector. The orthogonal basis vectors generated in each iteration are then combined column-wise to form the basis vector matrix of this subspace, thus projecting the original high-dimensional Laplace matrix into a dimension-reduced real symmetric tridiagonal matrix. During the iteration process, to eliminate the loss of basis vector orthogonality caused by the accumulation of computer floating-point operation errors and to prevent the algorithm from converging to spurious eigenvalues, this embodiment configures a complete reorthogonalization strategy. That is, after each generation of a new basis vector, it is forcibly orthogonalized with all previously generated historical basis vectors. The convergence condition of this dimension reduction iteration is: the norm of the current eigenvalue residual is less than a preset tolerance (e.g., 10). -6 ), or the dimension of the generated Krylov subspace reaches a preset upper limit (e.g., 10% of the dimension of the original Laplace matrix).

[0027] Secondly, the real symmetric tridiagonal matrix obtained after dimensionality reduction convergence is used as the input to the QR algorithm. Through successive iterations of orthogonal similarity transformation, the off-diagonal elements of the tridiagonal matrix gradually converge to zero. The convergence condition for this iteration is that the absolute value of the off-diagonal elements is less than a minimum tolerance threshold (e.g., 10). -16 The main diagonal elements of the diagonal matrix that finally converges are the eigenvalues ​​of the tridiagonal matrix, and the cumulative product of the orthogonal matrices during the iteration process constitutes its corresponding eigenvector.

[0028] Finally, the generated Krylov subspace basis vector matrix is ​​multiplied by the eigenvectors of the tridiagonal matrix to reverse-map the eigenvectors of the tridiagonal matrix back to the original high-dimensional space, thus obtaining the eigenvectors of the original Laplacian matrix. At the same time, according to the principle of eigenvalue invariance of orthogonal projection, the main diagonal elements (i.e., eigenvalues) of the tridiagonal matrix are used as the eigenvalues ​​of the original Laplacian matrix.

[0029] The eigenvalues ​​of the Laplace matrix are arranged in ascending order, and a predetermined number of non-zero eigenvalues ​​and their corresponding eigenvectors are extracted to form the spectral feature matrix of the current power grid topology. The predetermined number is determined by the following rules: the first-order difference between two adjacent eigenvalues ​​after sorting is calculated first, and the smaller of the pair of adjacent eigenvalues ​​corresponding to the maximum difference is taken as the cutoff point, retaining the cutoff point and all non-zero eigenvalues ​​before it; if the number of eigenvalues ​​corresponding to the cutoff point determined in this way exceeds the range of 20 to 50, or the ratio of the maximum difference to its previous difference is less than a predetermined threshold (e.g., 2.0 to 3.0), then a fixed value between 20 and 50 is directly taken as the predetermined number to retain the main low-frequency components reflecting the macroscopic connection structure of the power grid and filter out high-frequency topology noise corresponding to local minor changes.

[0030] 1.1.2 Calculate the orthogonal alignment matrix between the spectral features and the reference topology spectral features, and perform a rotation transformation on the spectral features corresponding to the current power grid topology to obtain the projected spectral features, as follows: Using the same Laplace matrix construction method and eigenvalue decomposition method as in step 1.1.1, based on the standard admittance matrix of the power grid under fault-free, fully connected standard operation mode, the same number of eigenvectors corresponding to non-zero eigenvalues ​​are extracted as the reference topology spectrum feature matrix. The orthogonal basis space spanned by the column vectors of the reference topology spectrum feature matrix is ​​the reference topology feature space.

[0031] The orthogonal alignment matrix between the spectral feature and the reference topological spectral feature is calculated by solving the orthogonal Procrustes problem to find an optimal orthogonal rotation transformation matrix that minimizes the square of the Frobenius norm between the current spectral feature after rotation and the reference topological spectral feature. The formula for calculating the orthogonal alignment matrix is ​​as follows: (1) in, To obtain the optimal orthogonal alignment matrix, Let be the rotation transformation matrix to be optimized; for Group of orthogonal matrices of order 1 This is the preset number of non-zero feature values ​​to be extracted as mentioned above; The reference topological spectral feature matrix has the following dimensions: ; This is the spectral feature matrix of the current power grid topology, with the same dimension. .

[0032] The specific steps for solving the optimal orthogonal alignment matrix are as follows: multiply the transpose of the spectral feature matrix of the current power grid topology with the spectral feature matrix of the reference topology to obtain a cross-covariance matrix reflecting the geometric correlation between the two; perform standard singular value decomposition on the cross-covariance matrix to obtain a left singular vector matrix and a right singular vector matrix; multiply the transpose of the left singular vector matrix and the right singular vector matrix to obtain the product matrix, which is the optimal orthogonal alignment matrix.

[0033] Multiply the spectral feature matrix of the current power grid topology on the right by the optimal orthogonal alignment matrix to complete the rotation transformation of the spectral features of the current power grid topology, and obtain the projected spectral feature matrix.

[0034] 1.2 Based on the projected spectral features, the power grid operation data is transformed into a topological state representation, including: 1.2.1 Based on power grid operation data, an operation data matrix including node injected power and unit output parameters is constructed, as follows: Within the current scheduling cycle, grid operation data for the current section is acquired through a phasor measurement unit (PMU) or energy management system (EMS). This grid operation data includes node active power injection, reactive power injection, node voltage amplitude, and generator active power output. The total number of physical nodes N in the grid is used as the row number, and the total number of dimensions of all grid operation characteristic parameters contained in a single node is used as the column. To determine the number of columns, the nodes are concatenated row by row according to the inherent topological order of the power grid node numbers, resulting in a structure with dimension [value missing]. The running data matrix.

[0035] 1.2.2 Multiplying the projected spectral features with the running data matrix yields the topological state representation, as follows: Multiplying the transpose of the projected spectral features by the operational data matrix is ​​essentially performing a graph Fourier transform on the operational data along an orthogonal basis in the graph frequency domain. This operation maps the operational data defined in the physical node space to the global graph spectral space, thereby eliminating coordinate system dimensional interference caused by changes in relative node positions and local branch tripping. This ensures that, under different power grid topology reconfiguration scenarios, the operational state features can be projected into an orthogonal basis space with the same physical meaning and unified dimensions. The calculation formula for the topology state representation is as follows: (2) in, It is a topological state representation, with dimensions of ; To run the data matrix, the dimension is ; This is the transpose of the projected spectral feature matrix.

[0036] This step effectively alleviates the feature representation drift problem caused by topology changes such as line fault tripping by orthogonally rotating the current power grid spectrum features to the reference feature space and processing the power grid operation data with graph Fourier transform. This enables the active power control model to obtain input features with consistent physical dimensions and spatial alignment under different topology structures, thereby improving the robustness of feature representation.

[0037] Step 2: Calculate the generation cost deviation at each node based on the spot market clearing results, construct an initial weight matrix, and perform alternating normalization to obtain the economic cost mask, including: 2.1 Calculate the difference between the unit price quoted in the spot market clearing results and the corresponding marginal electricity price at each node, as the deviation of generation cost at each node, as follows: During the current dispatch cycle, clearing data of the day-ahead or intraday spot market is obtained through the data interface with the power trading center. The clearing data includes the unit price of each generating unit and the clearing results of the nodal marginal electricity price of each node in the power grid.

[0038] To establish the correspondence between generator unit prices and node marginal electricity prices, the generator unit prices of each physical grid-connected node are equivalently converted: if a node is connected to only a single generator unit, the generator unit price is directly used as the equivalent generator unit price of the node; if the same node is connected to multiple generator units, the weighted average price is calculated using the rated active capacity of each generator unit as the weight, and this is used as the equivalent generator unit price of the node; for pure load nodes or interconnected substation nodes without generator unit connections, since there is no actual market bidding behavior, the equivalent generator unit price of such nodes is directly assigned to be equal to the marginal electricity price of the node.

[0039] The difference between the equivalent unit price and the marginal electricity price of each node is calculated to obtain the generation cost deviation of that node. This generation cost deviation is used to reflect the relative economic cost of adjusting the active power output of the node, and serves as the basis for constructing the economic cost mask and adjusting the information interaction weights between nodes in the Transformer cross-attention calculation process.

[0040] 2.2 An economic cost matrix is ​​constructed based on the relative distance between the deviations in power generation costs at each node. An initial weight matrix is ​​obtained by performing an exponential mapping on the economic cost matrix, as follows: All adjustable generator nodes in the current power grid are selected, and the absolute difference in generation cost deviation between each pair of adjustable generator nodes is calculated as the relative distance. This relative distance is then used as the corresponding row and column element values ​​to construct a matrix with dimension . The economic cost matrix, in which This represents the total number of adjustable generating units within the power grid. A negative exponential mapping is applied to each element of the economic cost matrix to convert the relative distance into a similarity weight within the [0,1] interval, resulting in an initial weight matrix. This mapping operation ensures that the smaller the difference in generation cost deviation between node pairs, the closer their mapping weights are to 1. The formula for the negative exponential mapping is as follows: (3) in, The first in the economic cost matrix Line number The element of the column, i.e., the first Taiwan and the The absolute difference in the power generation cost of the two generating units, expressed in yuan per megawatt-hour; The first weight in the initial weight matrix Line number The elements of the column are dimensionless parameters; This is a preset temperature adjustment coefficient used to control the smoothness of the exponential mapping. Its value is usually between 10 and 50, and can be determined based on the distribution range of the price difference between conventional nodes in the electricity spot market. Its dimension is yuan / megawatt-hour.

[0041] 2.3 The initial weight matrix is ​​subjected to alternating normalization to obtain a double random matrix that satisfies the preset convergence condition, which is used as the economic cost mask, as follows: The Sinkhorn algorithm is used to alternately normalize the initial weight matrix. Specifically, the initial weight matrix is ​​used as the algorithm input. In each iteration, the current matrix is ​​sequentially normalized by row (i.e., each element of the matrix is ​​divided by the sum of the elements in its row) and column (i.e., each element of the matrix is ​​divided by the sum of the elements in its column). By repeatedly performing row and column normalization operations alternately, the sum of the elements in each row and the sum of the elements in each column of the current matrix gradually approach 1. The convergence condition of the Sinkhorn algorithm iteration process is set as follows: after two consecutive iterations, the norm of the relative change of the matrix elements is less than a preset norm threshold (e.g., 10). -5 The convergence condition is met, or the maximum number of iterations is reached (e.g., 100 iterations). When the convergence condition is met, the iterative calculation is stopped, and the approximately double random matrix output at this time is used as the economic cost mask.

[0042] To visually represent the characteristic distribution of the economic cost mask, Figure 2 A schematic diagram of the matrix distribution of the economic cost mask between local generator nodes under a certain cross section is given; by Figure 2It can be seen that after processing by the Sinkhorn alternating normalization algorithm, the economic cost mask matrix possesses the mathematical characteristics of a double random matrix. This allows the economic cost mask to effectively prevent certain nodes from being systematically over-focused on in global attention allocation due to their low absolute power generation costs when subsequently injected as bias terms into network operators. This ensures the balance of the network's extraction of collaborative features from each adjustable generator node. Furthermore, combined with... Figure 2 The numerical gradient distribution characteristics show that node pairs with similar power generation costs (such as elements corresponding to the main diagonal and specific sub-diagonal blocks) obtained higher bias gains, indicating that the mask matrix can effectively guide the network attention weights to shift towards the cluster of generating units with similar economic attributes, thereby achieving economical and coordinated allocation of control commands while ensuring numerical stability.

[0043] This step calculates the power generation cost deviation at each node and constructs an economic cost matrix. After alternating normalization, it generates an economic cost mask in the form of a double random matrix, transforming spot market clearing information into bias features that can directly participate in the model's attention calculation. This approach establishes a direct mathematical link between market economic indicators and online inference calculations, improving the control response lag caused by economic information being treated as an external constraint in traditional methods, and enhancing the coordinated control capability of the control model to synchronously respond to market economic requirements.

[0044] Step 3: Input the power grid operation data and topology state representation into the pre-built Transformer network, perform cross-attention calculation using the economic cost mask, and generate the initial active power control command.

[0045] 3.1 Construct and train a Transformer network that includes a multi-task learning branch, including: 3.1.1 Construct the Transformer network model and multi-task branch architecture, as detailed below: The Transformer network architecture consists of cascaded multi-layer encoders and decoders, for example, each encoder and decoder has 6 layers. At the network input, the power grid operation data matrix is ​​input to the encoder to extract the operation physical features, and the topology state representation is input to the decoder as a structural prior query. The input feature data flows through each network layer in sequence, and each layer sequentially performs multi-head attention calculation, layer normalization processing and feedforward neural network transformation to gradually extract high-dimensional deep feature representations.

[0046] Specifically, a multi-task learning branch architecture is employed at the end of the Transformer network: the output of the feedforward neural network of the last decoder is... The sequence features are input into a global average pooling layer for pooling compression. The final output after pooling is used as a shared hidden state feature variable, which has a feature dimension of 512. This hidden state feature variable is input in parallel into two independent branch networks. The first branch is a command generation layer, composed of a single-layer linear mapping network, used to output the initial active power control commands for each generator unit. The second branch is a state decoding layer, composed of a multi-layer fully connected network, used for feature mapping from the hidden state to the steady-state physical quantities of the generator unit. The state decoding layer contains three hidden layers with 256, 128, and 64 neurons respectively. Each hidden layer uses ReLU as a non-linear activation function, and its output layer has a dimension of 512. This is used to output the corresponding generator steady-state power angle and steady-state electromagnetic power vector in parallel.

[0047] 3.1.2 Based on the historical best current data set, the Transformer network is trained offline under supervision, as follows: Using typical operating sections of the actual power grid as a benchmark, and the benchmark active and reactive loads of each node as expected averages, it is assumed that the random fluctuations of the load at each node follow an independent normal distribution. The standard deviation is set to 5% to 10% of the benchmark value, and the absolute fluctuation range of a single sampling is limited to ±20% of the benchmark value through a truncation operation. Under this statistical distribution constraint, basic operating scenarios covering multiple load levels are generated through Monte Carlo sampling. In each basic operating scenario, N-1 or N-2 branch disconnection faults are randomly superimposed to simulate changes in the power grid topology. Based on historical spot market declaration records, each generator node is assigned the real historical bid parameters for the corresponding time period, thereby simulating diverse market clearing boundary conditions. For the panoramic operating scenario set generated above, the objective function is to minimize the power generation cost of the entire network, and the generator node with the largest installed capacity is taken as the balancing node (its voltage phase angle is calibrated to zero). The original dual interior point method is used to solve the optimal power flow of each section one by one. During the solution process, sections with divergent power flow caused by the non-convergence of numerical algorithm iteration and abnormal sections with no feasible solution due to physical constraint conflicts are eliminated. The scenario inputs and solution results of all effective sections are summarized to form the optimal power flow (OPF) historical dataset containing massive (e.g., 100,000 section samples) section data.

[0048] The power grid operation data and topology representation of each effective section in the Optimal Power Flow (OPF) historical dataset are extracted as input features for the samples. Simultaneously, the optimal active power output of the generator, the voltage phase angle of the node where the generator is located, and the active power output of the generator are extracted from the OPF solution results corresponding to that effective section. The optimal active power output, voltage phase angle, and active power of the generator are Z-score standardized to remove dimensions and uniformly map them to a standard distribution interval with a mean of 0 and a variance of 1. The standardized optimal active power output, voltage phase angle, and active power are used as active power control command labels, steady-state power angle vector labels, and steady-state electromagnetic power vector labels, respectively, and combined with the sample input features under the corresponding section to form <input feature, output label> data pairs, constituting the training sample set of the Transformer network.

[0049] To simultaneously constrain the accuracy of control commands and the safety of physical states, a joint loss function is constructed that includes active power command errors and steady-state physical quantity errors. The formula for the joint loss function is as follows: (4) (5) (6) in, For the joint loss function, This is the active power control command error term. This is the state decoding error term; The preset joint loss weight coefficient, for example, 0.5, is used to balance the gradient magnitudes of the two types of tasks; This represents the total number of samples in each training batch, for example, 64. , , Based on the first The input features of each sample, including the active power control command vector, generator steady-state power angle vector, and generator steady-state electromagnetic power vector predicted by the Transformer network, are all dimensionless parameters after standardization. , , The first The active power control command label, steady-state power angle vector label, and steady-state electromagnetic power vector label in each sample are all dimensionless parameters after standardization. The L2 norm of a vector.

[0050] In each training epoch, training samples are input into the network in batches to calculate the joint loss function, and the Adam optimization algorithm is used (with an initial learning rate set to 10). -4Backpropagation is performed to update network weights, and a cosine annealing learning rate decay strategy is configured to smoothly decrease the learning rate with each training epoch, thus avoiding getting stuck in local optima in the later stages of training. The convergence condition for the training is that the value of the joint loss function tends to stabilize (i.e., in 10 consecutive training epochs, the magnitude of the change in the value of the loss function is less than a preset relative tolerance, for example, 10). -5 The offline training will end when the convergence condition is met, or when the preset maximum number of training epochs (e.g., 500 epochs) is reached. All weight parameters within the Transformer network will then be stored and ready for direct loading and invocation during the online inference phase.

[0051] 3.2 Input the power grid operation data and topology state representation into the Transformer network to generate initial active power control commands, including: During the online inference phase, the projected spectral feature matrix from step 1.1.2 above is invoked to perform an inverse graphical Fourier transform on the topological state representation, projecting it back from the spectral space. The physical node space is used to obtain the physical node topology features. The purpose of this inverse graph Fourier transform is to restore the topology features, which have undergone spectral space alignment and decoupling, to a physical coordinate system that corresponds one-to-one with the actual power grid nodes, so that subsequent attention calculations and active power command outputs can be located at each adjustable generator unit; at the same time, the physical node topology features filter out local high-frequency disturbances and retain the low-frequency smooth components that characterize the global topology of the power grid.

[0052] The physical node topology features are input into the decoder of the Transformer network as query features for cross-attention; the power grid operation data described in step 1.2.1 is input into the encoder of the Transformer network, and after encoding by each layer, the hidden state output of the last layer of the encoder is linearly projected to generate key features and value features; wherein, the weight matrix used for the linear projection is fixed in the Transformer network after being optimized and converged by backpropagation during the offline training stage.

[0053] 3.2.1 The economic cost mask is used as a bias term and incorporated into the cross-attention calculation of the topology state representation and power grid operation data to obtain the cross-attention weights, as follows: Since offline-trained Transformer networks solidify objective laws such as power grid physical topology constraints and power flow conservation, and considering price fluctuations in the spot market, an economic cost mask is injected into the cross-attention operator as a bias term, achieving an online fusion of physical laws and market characteristics. Specifically, in the economic cost mask generated in step 2, the larger the mask value for node pairs with similar generation costs, the more positive the bias is introduced before the Softmax operator, which mathematically increases the probability of cross-regional interaction between units with similar costs. This automatically weakens the collaborative weights between units with vastly different costs, prompting active power control commands to be more inclined to be allocated within clusters of units with similar economics. The formula for calculating the cross-attention weights using the economic cost mask as a bias term is as follows: (7) (8) (9) in, This is the query feature matrix mapped from the topological features of physical nodes. , These are the key feature matrix and value feature matrix mapped to the power grid operation data after deep feature extraction by the encoder, respectively. To obtain the cross-attention weight matrix; is the scaling factor for the hidden layer dimension of the key features, and is a fixed constant determined based on the network embedding dimension (e.g., when the network dimension is 512 and the number of attention heads is 8). The value is 64, used to prevent the gradient from vanishing due to an excessively large dot product result. As an economic cost mask, the dimension is ; The preset economic adjustment scaling factor has a value range of 0.1 to 1.0 to balance the order-of-magnitude difference between physical security characteristics and the economic adjustment range. For normalized exponential functions, For the first The output matrix of each attention head; This represents the total number of heads in the multi-head attention mechanism, and its value typically ranges from 4 to 16 (set to 8 in this embodiment). Characteristic matrix feature concatenation operation; It is the linear projection matrix of the output of the multi-head attention that has been trained and solidified.

[0054] 3.2.2 Based on cross-attention weights, the value characteristics of the power grid operation data are weighted and summed to obtain the initial active power control command, as follows: Based on the cross-attention weight matrix, matrix multiplication is performed on the value feature matrix of the power grid operation data. Mathematically, this matrix multiplication is equivalent to using the probability distribution elements in the cross-attention weight matrix to perform a weighted summation of each row vector in the value feature matrix. This outputs a deep context feature matrix that integrates topological constraints, operating status, and economic cost penalty features. This deep context feature matrix is ​​then further input into a subsequently offline-trained and solidified feedforward neural network (FFN) for nonlinear transformation, generating the final hidden state feature variables of the Transformer network.

[0055] Subsequently, the latent state feature variable is input in parallel into the multi-task learning branch architecture of the Transformer network: On one hand, the latent state feature variable is input to the instruction generation layer, where it is linearly mapped to generate dimensionless control instruction prediction values. The mean and standard deviation of the active power output of each generator set, calculated and saved during the offline training phase, are then called to perform an inverse Z-score restoration transformation (i.e., inverse normalization) on the prediction value to restore its actual physical dimensions, thereby generating the initial active power control instruction. The initial active power control instruction represents the absolute value of the target active power of each adjustable generator set in the current scheduling cycle (in MW), and its output dimension is a one-dimensional column vector. On the other hand, the latent state feature variable passes through the state decoding layer composed of a fully connected network for dimension transformation and physical decoding, and after inverse normalization, it outputs the generator steady-state power angle and steady-state electromagnetic power for subsequent safety verification.

[0056] This step integrates the underlying topological physical laws of the power grid with market economic fluctuations at the model operator level by injecting the online-generated economic cost mask as a bias term into the cross-attention mechanism of the pre-trained Transformer. This alleviates the computational bottleneck of traditional neural network physical-economic coupling retraining and improves the efficiency of online adaptive adjustment of the model to spot market clearing results while ensuring the physical safety characteristics of power grid operation.

[0057] Step 4: Extract the hidden state of the Transformer network when generating the initial active power control command, and map it to obtain the steady-state operating equilibrium point represented by the hidden state. Combine the real-time active power deviation to adjust the initial active power control command and obtain the real-time active power control command.

[0058] 4.1 By combining the preset steady-state operating boundary with the corrected initial active power control command, a reference power command is obtained, including: 4.1.1 Sensitivity analysis based on branch power flow balance constraints transforms the preset steady-state operating boundary, composed of the power transmission limit of the power grid branch and the node voltage limit, into linearized constraint conditions, as follows: Since the power flow equations of AC power grids have nonlinear characteristics, in order to reduce the computational complexity of online safety verification, at the current operating point, the Jacobian matrix after the convergence of the Newton-Raphson power flow calculation is extracted, and after inversion, the partial derivative sub-blocks of the node voltage phase angle and magnitude with respect to the node injected active power are extracted, thereby deriving the sensitivity matrix of branch active power with respect to node injected active power and the sensitivity matrix of node voltage with respect to node injected active power.

[0059] Introducing dimensions as The generator-node correlation matrix, wherein the matrix elements are uniquely determined by the grid connection relationship of the power grid physical topology, that is: if the first... The adjustable generator set was connected to the grid on the first Then the i-th power grid node, the i-th correlation matrix Line number The elements of the column are either 1 or 0. This correlation matrix maps the active power output vector of the generator set to the active power injection increment vector of all network nodes. The branch transmission power limit and node voltage amplitude limit issued by the Supervisory Control and Data Acquisition (SCADA) system are obtained to form the preset steady-state operating boundary. Using the two sensitivity matrices, the generator-node correlation matrix, and introducing relaxation variables, the preset steady-state operating boundary is transformed into linearized constraints. Simultaneously, combining the inherent physical output limit of the generator set and the non-negativity of the relaxation variables used to ensure the solvability of the optimization model, a set of linearized constraint inequalities is formed, as follows: (10) (11) (12) (13) in, The power limit of the branch is expressed in megawatts (MW). This is the active power flow vector of the branch at the current cross section, with the dimension of megawatts; The sensitivity matrix of active power injected into nodes by branch active power is dimensionless. The generator-node correlation matrix is ​​dimensionless. The reference power command is in megawatts. The active power injection vector for the nodes of the current section is expressed in megawatts. , These are the lower and upper limits of the node voltage amplitude, respectively, and are expressed in per-unit (pu). This represents the voltage magnitude vector of the current node, with units of per unit. This is the sensitivity matrix of node voltage to active power injection at the node, with the dimension being per unit value per megawatt (pu / MW). , These represent the lower and upper limits of the physical output of each generator unit, in megawatts. , These are relaxation variables introduced for branch power and node voltage, respectively, with corresponding dimensions of megawatts and per-unit values. They participate in the optimization along with the reference power command in the subsequent quadratic programming problem to ensure that the optimization space is constant and non-empty.

[0060] 4.1.2 Under the premise of satisfying the linearization constraint, a quadratic programming solution is performed with the objective of minimizing the correction between the reference power command and the initial active power control command to obtain the reference power command, as follows: An objective function is constructed with the goal of minimizing the Euclidean distance between the reference power command and the initial active power control command, as well as the sum of the penalty terms for the slack variables; the specific objective function is as follows: (14) in, This is the initial active power control command; , The maximum penalty weight is a preset constant, for example, all values ​​are 10. 4 This forces the solver to prioritize reducing slack variables to satisfy hard constraints under normal operating conditions, and only allows moderate overshooting when the solution is unsolvable.

[0061] Based on the linearized constraint inequalities, a convex quadratic programming problem is constructed. The primal-dual interior-point method is used to solve the convex quadratic programming problem. The linear inequality constraints are handled by introducing a logarithmic barrier function, and the Lagrange multipliers are iteratively updated using Newton's method. Within the feasible region that satisfies the linearized constraints, the baseline power command that satisfies the steady-state boundary of the physical network is obtained by optimization.

[0062] 4.2 Extract the hidden states of the Transformer network when generating the initial active power control command, and decode them to obtain the steady-state operating equilibrium point, including: The hidden state input is processed by a state decoding layer composed of a fully connected network. Feature mapping is performed using a pre-trained weight matrix and a nonlinear activation function to output the corresponding generator steady-state power angle and steady-state electromagnetic power. This state decoding layer has already completed the above feature mapping and result output during the generation of the initial active power control command in step 3.2.2, and is directly invoked here.

[0063] From the perspective of power system dynamics, the generator's steady-state power angle and steady-state electromagnetic power correspond to the equilibrium position where the rotor acceleration is zero. Using the decoded generator steady-state power angle and steady-state electromagnetic power as the steady-state operating equilibrium point provides a numerical reference origin for subsequent Taylor expansion and state feedback control of the generator's nonlinear motion equations within the equilibrium point's neighborhood.

[0064] 4.3 Using the steady-state operating equilibrium point as a reference, the nonlinear motion equations of the generator rotor are locally linearized. After constructing the state matrix and control matrix and solving the state feedback gain matrix, the reference power command is adjusted based on the real-time active power deviation to obtain the real-time adjustment command, including: The nonlinear motion equations of the generator rotor adopt the classical second-order rocking equations, and its first-order differential equations are as follows: (15) (16) in, This is the time derivative of the angle of attack deviation, with dimensions in radians per second (rad / s). The rated synchronous angular velocity is typically taken as . rad / s; This represents the rotor angular velocity deviation, measured in per-unit (pu). The generator's inertial time constant is retrieved from the generator set's nameplate parameters and offline parameter database, and its unit is seconds. This is the time derivative of the rotor angular velocity deviation, i.e., the rotor angular acceleration; This refers to the mechanical power deviation, i.e., the active control input, measured in per-unit values. The electromagnetic power deviation is expressed as a per-unit value at the corresponding power angle. The preset damping coefficient is determined based on the inherent mechanical friction and electrical damping characteristics of the generator set, for example, 2.0, with the dimension being per unit.

[0065] At the steady-state equilibrium point, a Taylor series expansion of the nonlinear motion equations is performed, and higher-order nonlinear terms are ignored, to derive the locally linearized state-space equations, whose general expression is as follows: (17) in, Let the first derivative vector of the state vector with respect to time be denoted as . A state vector that describes the dynamic characteristics of the system. The state matrix, To control the input vector, This is the control matrix.

[0066] Based on this, the state vector is defined as That is, it is composed of the power angle deviation and the rotor angular velocity deviation variables; the control input vector is defined as After Taylor expansion, the constructed state matrix The synchronization coefficient is included, which characterizes the local slope of the power angle characteristic. Further, based on the ratio of the change in active power to the change in the phase angle (power angle) of the terminal voltage within adjacent short time intervals measured by the PMU, the synchronization coefficient is approximately calculated using the following formula: (18) in, Synchronization coefficient; It represents the change in generator active power within adjacent short time intervals (such as two consecutive PMU sampling periods), with the dimension being per unit (pu). This represents the change in the generator terminal power angle within the same time sequence.

[0067] To prevent the risk of the synchronization coefficient being divided into zero and non-physical fluctuations caused by measurement noise when the change in power angle is small, an effective physical range is set for the synchronization coefficient identified online. (e.g., [0.5, 3.0]) and minimum value protection threshold (e.g., 10) -5 (rad); when the change in the power angle at the generator terminal is less than the minimum protection threshold, or when the calculated synchronization coefficient exceeds the above effective physical range, the static synchronization coefficient (e.g., the theoretical slope static value of 1.2 at the steady-state operating point) pre-calibrated in the offline parameter library for the current operating point is automatically called to replace the online identification value, so as to ensure the numerical stability of the state feedback matrix calculation.

[0068] After clarifying the specific physical representations of the aforementioned state vector and control input vector, substituting the aforementioned nonlinear motion equations of the generator rotor into the general expression and performing a local linearization expansion yields the state matrix and control matrix characterizing the system's dynamic properties. Furthermore, substituting the approximately obtained synchronization coefficients into these expressions, the specific mathematical expressions for the state matrix and control matrix are obtained, as follows: (19) The optimal control algorithm of a linear quadratic regulator (LQR) is adopted, taking the state matrix and control matrix as inputs, and solving the algebraic Riccati equation (ARE) is performed, i.e.: (20) Obtain the optimal state feedback gain matrix ;in, For example, the pre-defined positive semidefinite state weight matrix. , used to penalize state deviations; For example, a preset positive definite control weight matrix. Used to penalize cost control; Let be the positive definite symmetric solution matrix of the algebraic Riccati equation.

[0069] Using a synchronous phasor measurement unit (PMU) installed at the generator terminal, rotor angular velocity deviation and real-time active power are acquired in real time on a millisecond timescale. The difference between the real-time active power and the steady-state electromagnetic power at the steady-state equilibrium point is calculated to obtain the real-time active power deviation. Based on the local linearization relationship of the generator power angle characteristic curve in the neighborhood of the equilibrium point, the real-time active power deviation is divided by the synchronization coefficient to obtain the real-time power angle deviation. The real-time power angle deviation and rotor angular velocity deviation are combined into a real-time state vector, multiplied by the optimal state feedback gain matrix, and then inverted to serve as the state feedback compensation term. The compensation components of each unit in the state feedback compensation term are multiplied by the rated reference capacity of the corresponding generator unit, restored to a megawatt nominal value, and then added to the reference power command to generate a preliminary real-time adjustment command.

[0070] Furthermore, since the aforementioned optimal state feedback gain matrix is ​​solved independently based on a single-machine model, the sum of the initial real-time adjustment commands of each unit may deviate from the total active power compensation actually required by the system. Therefore, after obtaining the initial real-time adjustment commands of each unit: using the system's real-time frequency deviation and its time integral as input, the total active power compensation required by the entire network is calculated by a PI (proportional-integral) controller; the sum of the initial real-time adjustment commands of each unit is subtracted from the total active power compensation to obtain the unbalanced power margin of the entire network caused by the independent solution of each unit; the unbalanced power margin of the entire network is proportionally allocated to each unit as a correction compensation term using the rated capacity of each unit as a weight; the correction compensation term is added to the initial real-time adjustment command of the corresponding unit to obtain the final real-time adjustment command issued to each unit.

[0071] 4.4 Under preset transient safety constraints, a quadratic programming solution is performed on the real-time adjustment commands to generate real-time active power control commands, including: 4.4.1 Based on the nonlinear motion equation of the generator rotor and the preset frequency offset extreme value, a frequency safety barrier function is established. The transient safety constraint is obtained by differentiating the barrier function, as follows: The quadratic frequency security barrier function (CBF) is constructed as follows: (twenty one) in, For frequency security barrier functions; The real-time frequency deviation is obtained synchronously from the aforementioned PMU real-time measurement data; The preset frequency offset extreme value (e.g., 0.5Hz) is determined based on the system-level low-frequency load shedding protection threshold and after conservative conversion considering the maximum allowable deviation between the single unit frequency and the system inertial center frequency (COI). This ensures that when each unit meets the single-unit level constraint with its local frequency deviation, the overall system frequency will necessarily be within the safe boundary.

[0072] It should be noted that the constants in the barrier function are related to the subsequent mathematical derivation. With variables All values ​​have been converted to per-unit (pu) by dividing by the rated reference frequency (e.g., 50Hz); under this unified per-unit reference, frequency deviation and angular velocity deviation are equivalent in numerical and physical sense, that is... .

[0073] To ensure that the system's state trajectory does not exceed the safe frequency boundary after being disturbed, the instantaneous evolution rate of the barrier function must satisfy the following safety condition: (twenty two) in, The Lie derivative of the barrier function is the instantaneous evolution rate. For preset adjustment coefficient and For example, 10s -1 .

[0074] To obtain the specific form of the above safety conditions with respect to the active power control input, the Lie derivative is solved along the vector field of the generator rotor nonlinear motion equation (i.e., the swing equation), as follows: (twenty three) in, This represents the gradient of the barrier function with respect to the frequency deviation. This represents the rate of change of frequency.

[0075] Based on the aforementioned quadratic frequency security barrier function, the gradient term in the Lie derivative is calculated, i.e.: (twenty four) In the rocking equation, the rate of change of frequency (equivalent to rotor angular acceleration in per unit value) The control input is determined by the mechanical power deviation, electromagnetic power deviation, and system damping. To uniformly represent the control input as independent optimization variables in a quadratic programming problem, the difference between the mechanical power deviation and the electromagnetic power deviation is combined and defined as the equivalent control variable. ,Right now The equivalent control variable essentially characterizes the deviation of the acceleration power in the swing equation. In this embodiment, using it as an optimization variable essentially represents the total active power compensation required by the generator set and its supporting components (such as fast electrochemical energy storage devices, coaxial flywheels, or fast-opening valve control systems) during transient throughput in order to maintain transient safety. Substituting the above definition into the swing equation, the rate of change of frequency can be expressed as an algebraic expression of the equivalent control variable and the frequency deviation, i.e. Substituting the gradient term and the aforementioned rate of frequency change into the Lie derivative expression, we obtain the Lie derivative expression for the active control input variable and the real-time frequency deviation.

[0076] Furthermore, substituting the expression into the safety conditions yields an affine inequality concerning the active power control input variable, i.e., a transient safety constraint; the formula for the transient safety constraint is as follows: (25) 4.4.2 Under transient security constraints, a quadratic programming solution is performed with the objective of minimizing the correction amount between real-time active power control commands and real-time adjustment commands to generate real-time active power control commands, as follows: Expand the active power control input variables in the transient safety constraints into named value form, i.e. ,in For the final real-time active power control command decision variables, This represents the currently measured electromagnetic power. The rated baseline capacity of the unit is used. The expanded active power control input variables are substituted into the formula of the transient safety constraint to establish the mathematical mapping relationship between the transient frequency safety boundary conditions and the MW-level active power decision command to be solved.

[0077] The optimization objective is to minimize the Euclidean distance (i.e., the squared L2 norm) between the real-time active power control command and the real-time adjustment command. A convex quadratic programming problem is constructed by using the transient safety constraints, after substitution and expansion, as the constraint inequalities for this objective. The effective set method is employed to solve this problem. By taking the Hessian matrix of the objective function and the constraint Jacobian matrix as inputs, the effective constraint set and Lagrange multipliers are iteratively updated. Upon convergence, a numerical approximate solution is output, which is the real-time active power control command (in megawatts). The real-time active power control command represents the optimal active power target action that each adjustable generator unit and its configured fast compensation device should jointly execute under the premise of satisfying the current transient safety constraints.

[0078] To further verify the technical effectiveness of the transient safety constraint described in this invention, Figure 3A schematic diagram comparing the dynamic response curves of the system frequency deviation before and after the introduction of transient safety constraints is provided; the extreme safety red line marked in the figure corresponds to the lower safety limit (i.e., -0.5Hz) determined by the preset frequency offset extreme value in the aforementioned construction of the quadratic frequency safety barrier function (CBF); by Figure 3 It is known that when encountering a sudden load step disturbance without transient safety constraints (relying only on conventional LQR control), the drop in system frequency deviation exceeds the safety lower limit, posing a risk of triggering low-frequency load shedding. However, after adopting the CBF-based transient safety constraint filtering in this embodiment, the generated final active power control command can adaptively adjust the active power output before the frequency deviation approaches the safety lower limit, smoothly limiting the dynamic evolution trajectory of the system frequency deviation to within -0.5Hz. The above time-domain response results show that the method in this embodiment can effectively ensure that the issued control commands meet the transient physical safety constraints of the power grid system while achieving economic dispatch command following control.

[0079] This step extracts the steady-state operating equilibrium point by analyzing the latent features of the Transformer, establishing a numerical benchmark mapping between the data-driven network and the underlying generator dynamic equations. By combining local linearized state feedback and transient safety constraints based on barrier functions, the initial active power control command is dynamically corrected and over-limit intercepted, enhancing the physical security and adaptability of active power control under load or topology disturbances.

[0080] Example 2, Figure 4 A Transformer-based active power control system for the clearing results of the electricity spot market is presented, comprising the following modules: The spectral feature projection module is used to acquire the spectral features of the current power grid topology and project them onto a preset reference topology feature space. Based on the projected spectral features, the power grid operation data is transformed into a topology state representation. The economic mask module is used to calculate the generation cost deviation of each node based on the spot market clearing results, construct an initial weight matrix and perform alternating normalization to obtain the economic cost mask. The initial instruction module is used to generate an initial active power control instruction by inputting the power grid operation data and topology state representation into a pre-built Transformer network, and performing cross-attention calculation in conjunction with the economic cost mask. The feedback adjustment module is used to extract the hidden state of the Transformer network when the initial active power control command is generated, decode it to obtain the steady-state operating equilibrium point, and adjust the initial active power control command in combination with the real-time active power deviation to obtain the real-time active power control command.

[0081] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.

[0082] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, in the form of a computer program product.

[0083] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0084] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.

[0085] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0086] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for active power control based on the clearing result of the electricity spot market using Transformer, characterized in that, Includes the following steps: The spectral features of the current power grid topology are obtained and projected onto a preset reference topology feature space. Based on the projected spectral features, the power grid operation data are transformed into a topology state representation. Based on the spot market clearing results, the power generation cost deviation at each node is calculated, an initial weight matrix is ​​constructed and alternating normalization is performed to obtain the economic cost mask. The power grid operation data and topology state representation are input into a pre-built Transformer network, and cross-attention calculation is performed in conjunction with the economic cost mask to generate initial active power control commands. The hidden state of the Transformer network when the initial active power control command is generated is extracted and decoded to obtain the steady-state operating equilibrium point. The initial active power control command is then adjusted in conjunction with the real-time active power deviation to obtain the real-time active power control command.

2. The method according to claim 1, characterized in that, The generation of the initial active power control command includes: The economic cost mask is used as a bias term and incorporated into the cross-attention calculation of the topology state representation and power grid operation data to obtain the cross-attention weight. Based on the cross-attention weights, the value characteristics of the power grid operation data are weighted and summed to obtain the initial active power control command.

3. The method according to claim 1, characterized in that, The step of obtaining the spectral features of the current power grid topology and projecting them onto a preset reference topology feature space includes: The admittance parameters of the current power grid topology are decomposed into eigenvalues, and the eigenvectors corresponding to the non-zero eigenvalues ​​are extracted as the spectral features. Calculate the orthogonal alignment matrix between the spectral features and the reference topology spectral features, and perform a rotation transformation on the spectral features corresponding to the current power grid topology to obtain the projected spectral features.

4. The method according to claim 1, characterized in that, The process of converting power grid operation data into a topology state representation includes: Based on the power grid operation data, an operation data matrix including node injection power and unit output parameters is constructed; The projected spectral features are multiplied by the running data matrix to obtain the topological state representation.

5. The method according to claim 1, characterized in that, The generation of real-time active power control commands includes: The initial active power control command is corrected by combining the preset steady-state operating boundary to obtain the reference power command; Based on the steady-state operating equilibrium point, the nonlinear motion equation of the generator rotor is locally linearized, the state matrix and control matrix are constructed, and the state feedback gain matrix is ​​solved. Then, the reference power command is adjusted by combining the real-time active power deviation to obtain the real-time adjustment command. Under preset transient safety constraints, the real-time adjustment command is solved by a secondary programming approach to generate the real-time active power control command.

6. The method according to claim 1, characterized in that, The decoding process yields the steady-state operating equilibrium point, including: The hidden state input is feature-mapped by the state decoding layer composed of a fully connected network, and the corresponding generator steady-state power angle and steady-state electromagnetic power are output. The steady-state power angle and steady-state electromagnetic power of the generator are taken as the steady-state operating equilibrium point.

7. The method according to claim 1, characterized in that, The obtained economic cost mask includes: The difference between the unit price and the corresponding node marginal electricity price in the spot market clearing results is calculated as the generation cost deviation of each node; An economic cost matrix is ​​constructed based on the relative distance between the deviations in power generation costs at each node, and the initial weight matrix is ​​obtained by performing an exponential mapping on the economic cost matrix. The initial weight matrix is ​​subjected to alternating normalization to obtain a double random matrix that satisfies the preset convergence condition, which is used as the economic cost mask.

8. The method according to claim 5, characterized in that, The process of obtaining the reference power command includes: Sensitivity analysis based on branch power flow balance constraints transforms the preset steady-state operating boundary, which consists of the power transmission limit of the power grid branch and the node voltage limit, into linear constraint conditions. Under the premise of satisfying the linearization constraint, a quadratic programming solution is performed with the objective of minimizing the correction between the reference power command and the initial active power control command to obtain the reference power command.

9. The method according to claim 5, characterized in that, The step of performing a quadratic programming solution on the real-time adjustment command to generate the real-time active power control command includes: Based on the nonlinear motion equation of the generator rotor and the preset frequency offset extreme value, a frequency safety barrier function is established, and the transient safety constraint is obtained by differentiating the barrier function. Under the transient safety constraints, a quadratic programming solution is performed with the objective of minimizing the correction amount between the real-time active power control command and the real-time adjustment command to generate the real-time active power control command.

10. An active power control system based on the clearing result of the electricity spot market using Transformer, characterized in that, Includes the following modules: The spectral feature projection module is used to acquire the spectral features of the current power grid topology and project them onto a preset reference topology feature space. Based on the projected spectral features, the power grid operation data is transformed into a topology state representation. The economic mask module is used to calculate the generation cost deviation of each node based on the spot market clearing results, construct an initial weight matrix and perform alternating normalization to obtain the economic cost mask. The initial instruction module is used to generate an initial active power control instruction by inputting the power grid operation data and topology state representation into a pre-built Transformer network, and performing cross-attention calculation in conjunction with the economic cost mask. The feedback adjustment module is used to extract the hidden state of the Transformer network when the initial active power control command is generated, decode it to obtain the steady-state operating equilibrium point, and adjust the initial active power control command in combination with the real-time active power deviation to obtain the real-time active power control command.