A method for generating and querying power equipment topology graphs based on graph neural networks
The topology diagram of power equipment is generated through the graph neural network, and the graph convolutional neural network and coordinate optimization model are used to solve the problem of low efficiency in generating topology diagrams of traditional power equipment, achieving a more efficient and clearer topology diagram display.
Patent Information
- Application Number
- CN202510740617.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The generation efficiency of traditional power equipment is low, it is difficult to reflect the dynamic changes of the power grid in real time, and it is poor in interactivity.
The graph neural network is used to generate topology graphs, and the device features and topology relationships are learned through graph convolutional neural networks, and the topology graph is dynamically updated with the coordinate optimization model and multi-objective constraint loss function.
It improves the efficiency and real-timeness of topology map generation, reduces the crossover of connection lines between devices, and the generated topology map is more in line with the actual situation and has a clearer display.
Smart Images

Figure CN120256468B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method for generating and querying a topological map of power equipment based on a graph neural network. Background Art
[0002] A power equipment topology diagram is a graphical representation of the connections between various devices (such as generators and transformers) in a power grid. It plays a vital role in power system operation and management, helping to analyze the system's operating status, optimize energy distribution, and quickly locate faults.
[0003] As the scale and complexity of power grids increase, traditional power system topology diagrams are usually drawn manually. This method is not only time-consuming and labor-intensive, but also prone to omissions and makes it difficult to reflect the latest status of the power grid in a timely manner.
[0004] Although some dynamic topology maps can display the power grid status in real time, they are regenerated each time they are displayed, which is inefficient and has poor interactivity. Summary of the Invention
[0005] In view of the above analysis, an embodiment of the present invention aims to provide a method for generating and querying a topology map of power equipment based on a graph neural network, so as to solve the problems of low efficiency and long response time in the existing topology map generation of power equipment.
[0006] An embodiment of the present invention provides a method for generating and querying a topological map of power equipment based on a graph neural network, comprising the following steps:
[0007] Update the device's feature matrix and adjacency matrix based on the new ledger data received from the power equipment, and use a graph convolutional neural network to update the device topology relationship;
[0008] According to the received query conditions, the devices to be displayed and their topological relationships are obtained from the updated device topological relationships, and it is identified whether there is a topological record for the query conditions. If there is no topological record, or the difference between the devices to be displayed and their topological relationships and the topological records exceeds a threshold, the coordinate optimization model is used to generate the coordinates of the devices to be displayed, and then a topological map is rendered and generated, and the topological records corresponding to the query conditions are saved; otherwise, a topological map is rendered and generated according to the topological records; the coordinate optimization model is constructed based on the graph attention network and introduces a loss function with multi-objective constraints.
[0009] Based on a further improvement of the above method, the topology record includes: query conditions, generation time, version number, device list and edge list; the device list includes device identification and device coordinates; the edge list includes the device identification at both ends of each edge; when the device to be displayed corresponding to the query condition or the topological relationship of the device to be displayed changes, a new topology record is generated for the query condition according to the new version number.
[0010] Based on the further improvement of the above method, a topology map is generated according to the topology record rendering, including:
[0011] If the generation time of the topology record is later than the reception time of the ledger data, the topology graph is directly rendered based on the device list and edge list in the topology record;
[0012] Otherwise, when the device to be displayed and its topological relationship exist in the topological record, the coordinates of the device to be displayed are obtained from the topological record, and a topological map is generated based on the topological relationship of the device to be displayed; when there are new devices or topological relationships in the device to be displayed and its topological relationship, the device to be adjusted is obtained, the coordinates of other devices are solidified according to the topological record, the coordinates of the device to be adjusted are generated using the force-directed algorithm, and then a topological map is generated.
[0013] Based on the further improvement of the above method, the coordinates of the device to be displayed are generated using the coordinate optimization model, including:
[0014] Based on the geographical location of power equipment, the clustering method is used to divide the equipment to be displayed into multiple categories, and the coordinates of the equipment to be displayed in each category are initialized;
[0015] The initial coordinates of the device to be displayed are used as node features, and an adjacency matrix is constructed according to the topological relationship of the device to be displayed. The node features and the adjacency matrix are passed into the coordinate optimization model, the initial coordinates are optimized, and the optimized coordinates of the device to be displayed are output.
[0016] Based on the further improvement of the above method, the coordinates of various devices to be displayed are initialized including:
[0017] Obtain the angle of each area based on the number of devices, number of edges, and longest path length of each type;
[0018] According to the angle of each area, the area is divided clockwise or counterclockwise from the center point of the topological map display interface, and the vertices of each area boundary are calculated;
[0019] Initialize the coordinates of each candidate device based on the number of devices in each category and the vertices of each region boundary.
[0020] Based on the further improvement of the above method, the coordinate optimization model is constructed based on the graph attention network, which sequentially constructs the input encoding layer, multiple graph attention layers and coordinate decoding layer; the input encoding layer converts the initialized coordinates of the input node into a high-dimensional embedding vector, performs edge encoding according to the adjacency matrix of the input node, and passes it to multiple graph attention layers; multiple graph attention layers propagate topological information, and the output of each layer is used by the next layer to update the node hidden state; the coordinate decoding layer maps the node hidden state to the coordinate adjustment amount through the fully connected layer, and outputs the final optimized coordinates through a residual connection with the input initialized coordinates.
[0021] Based on the further improvement of the above method, the loss function of multi-objective constraints in the coordinate optimization model is obtained by calculating the node distance loss, node overlap loss, edge intersection loss and area constraint loss and performing weighted summation.
[0022] Based on the further improvement of the above method, the node distance loss and node overlap loss are calculated by the following formulas:
[0023] ,
[0024] ,
[0025] in, represents the node distance loss, represents the node overlap loss, E represents the node set, and Represents the coordinates of nodes i and j at both ends of the edge, Indicates the ideal distance between preset nodes, , r represents the radius of the node primitive; Represents the smoothing factor, which is a preset positive number; represents the Euclidean distance between node i and node j.
[0026] Based on the further improvement of the above method, the edge crossing loss is used to impose a penalty on any two crossing edges of the same type, which is calculated by the following formula:
[0027] ,
[0028] in, represents the edge crossing loss, represents the kth class generated by clustering, and express The two edges in , t and u represent edges and the edge The intersection parameters of the edge are solved by and the edge The parameterized equation is obtained when When the edge and the edge cross, represents the sigmoid function, represents the smoothing coefficient, .
[0029] Based on the further improvement of the above method, the regional constraint loss is used to impose a penalty on nodes that exceed the region of their class, which is calculated by the following formula:
[0030] ,
[0031] in, represents the regional constraint loss, represents the kth class generated by clustering, It represents the sum of the probabilities that the ray emitted horizontally to the right by node i intersects all boundaries of the region where the class to which it belongs is located.
[0032] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0033] 1. Use graph convolutional neural networks to learn the characteristics of power equipment and the topological relationships between devices, so as to more accurately predict the connection status between new or changed devices, generate more realistic topological maps, and better adapt to the dynamic changes of the power system.
[0034] 2. By first querying whether there are topology records with the same query conditions, repeated calculation of device coordinates in the topology map is avoided, saving computing resources and time, greatly shortening response time, and improving the real-time and interactivity of the query.
[0035] 3. By dynamically constraining the device layout area through clustering, different types of areas are relatively independent, while the same type of areas are denser, effectively reducing the problem of crossing connection lines between devices, reducing the overlap rate of network topology, and better displaying the device distribution and relative relationships; using the attention mechanism and multi-objective constraint loss function in the coordinate optimization model, the correlation between nodes is more accurately captured to automatically determine the position of the device in the topology map, effectively avoiding problems such as node overlap and edge crossing, making the topology map clearer and more intuitive.
[0036] In the present invention, the above-mentioned technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of the present invention will be described in the following description, and some advantages will become apparent from the description or be learned through practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. Throughout the drawings, the same reference symbols denote the same components.
[0038] Figure 1 This is a flow chart of a method for generating and querying a topology map of power equipment based on a graph neural network in an embodiment of the present invention;
[0039] Figure 2 This is a schematic diagram of dividing various regions according to clustering results in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, and are not used to limit the scope of the present invention.
[0041] A specific embodiment of the present invention discloses a method for generating and querying a topological map of power equipment based on a graph neural network, such as Figure 1 As shown, the following steps are included:
[0042] S1. Update the feature matrix and adjacency matrix of the equipment based on the new ledger data of the received power equipment, and use the graph convolutional neural network to update the equipment topology relationship.
[0043] It should be noted that the power system ledger data includes: device identification, device name, device type, voltage level, functional category, geographic location, operating status, change time, and the connection relationship between devices. The connection relationship between devices includes: upper-level device identification, lower-level device identification, and the connection method between devices. The ledger data is regularly received through the interface to obtain the latest device information.
[0044] Considering that the connection relationship between devices in the electric power survey system ledger may be wrong, missing or incomplete. For example, during the data entry process, due to human negligence, the connection description between the newly added equipment and some historical equipment may be omitted; or during the actual installation and debugging of the equipment, the connection is temporarily adjusted; or the new equipment changes the power transmission path, and these dynamically changing connection relationships are difficult to update in real time in the ledger. At this time, relying solely on the "connection relationship between devices" information in the ledger will result in deviations. Therefore, this embodiment trains the graph convolutional neural network by learning the topological relationship of devices in the historical ledger data, and uses the trained graph convolutional neural network to promptly derive the dynamically changing topological connection relationship between devices in the latest ledger, ensuring that the topology map can accurately reflect the real-time status of the power system.
[0045] It should be noted that the historical ledger data of the power system is first obtained and preprocessed, including: removing duplicate and empty data of equipment identification; standardizing the equipment name and equipment type; and converting the geographic location into plane position coordinates according to the radius of the earth.
[0046] Furthermore, based on the preprocessed historical ledger data, each device is treated as a node and the connections between devices as edges. A node feature matrix and a node adjacency matrix are constructed as input graph data. The node feature matrix is obtained by converting the features of each node into numerical form, where each row corresponds to a node's feature vector. The sample adjacency matrix represents the connection relationship between devices. If there is a connection between devices, the corresponding element in the matrix is 1, otherwise it is 0.
[0047] Specifically, the node feature vector is obtained by concatenating the device name embedding vector, the device's planar position coordinates, and the one-hot encoded device type. For example, the device name embedding vector is obtained using a Bert model or a Word2Vec model.
[0048] The constructed Graph Convolutional Networks (GCNs) consist of a graph embedding layer, a stack of multiple graph convolutional layers, a graph pooling layer, and an output layer. Graph data is fed into the GCN. The graph embedding layer directly maps the node feature vectors and encodes edges based on the node adjacency matrix, allowing subsequent graph convolution operations to leverage the graph's topological information. Within each convolutional layer, the feature vector of each node is continuously updated by aggregating information from neighboring nodes in the adjacency matrix, capturing a wider range of graph structural features and learning high-level topological semantics. The graph pooling layer reduces the dimensionality of the updated node feature vectors output by the convolutional layer through pooling, generating a hierarchical representation of the graph that facilitates a better understanding of the graph's overall structure. Finally, the output layer outputs the probability of a connection between nodes, resulting in the derived topological relationship.
[0049] Before training the graph convolutional neural network, binary labels (0 / 1) are used to mark whether a connection relationship exists between node pairs, which serves as the actual topological relationship. During training, the cross-entropy loss function is used to evaluate the difference between the derived topological relationship and the actual topological relationship. By continuously optimizing the parameters of the graph convolutional neural network to minimize the value of the loss function, the derived topological relationship becomes more accurate and stable. The Adam optimizer is used to optimize the network parameters and adjust the weights to minimize the value of the loss function.
[0050] After the graph convolutional neural network is trained, the new ledger data received is preprocessed and then compared with the historical ledger data to obtain the ledger information of the newly added devices. The corresponding feature vector is extracted, and its dimension is consistent with the dimension of the feature vector of the node during training. It is added to the node feature matrix; the newly added devices are added to the node adjacency matrix, and the initial connection is established based on the connection relationship between the newly added devices and other devices in their ledger information. If there is no connection, it is set to 0. It is understandable that if the ledger information of some historical devices is changed, such as modifying the device name or the device connection relationship, the node feature matrix and the node adjacency matrix are updated accordingly.
[0051] The updated node feature matrix and node adjacency matrix are passed into the trained graph convolutional neural network to obtain the latest topological relationship between devices.
[0052] S2. According to the received query conditions, the devices to be displayed and their topological relationships are obtained from the updated device topological relationships, and it is identified whether there is a topological record for the query conditions. If there is no topological record, or the difference between the devices to be displayed and their topological relationships and the topological records exceeds a threshold, the coordinates of the devices to be displayed are generated using the coordinate optimization model, and then a topological map is rendered and generated, and the topological record corresponding to the query conditions is saved; otherwise, a topological map is generated based on the topological record; the coordinate optimization model is constructed based on the graph attention network and introduces a loss function with multi-objective constraints.
[0053] It should be noted that since the power system contains a variety of power equipment, the user enters query conditions in the interface segment to obtain the equipment to be displayed and its topological relationship from the received new ledger data and the equipment topological relationship updated in step S1, and then displays the topological diagram.
[0054] In order to avoid repeated calculation of device coordinates in the topology map and save computing resources and time, this embodiment first queries the database according to the query conditions to see whether there are topology records corresponding to the same query conditions. If so, it further identifies whether the difference between the devices and their topological relationships in the topology records and the devices and their topological relationships in the new ledger data exceeds the threshold, thereby dynamically determining whether to use the stored topology records to shorten the response time and improve the real-time and interactivity of the query.
[0055] It should be noted that a topology record includes the query criteria, generation time, version number, device list, and edge list. The device list includes device identifiers and coordinates, and the edge list includes the device identifiers at each end of each edge. When a topology map is first generated and displayed for a device based on a query criteria, the topology record corresponding to that query criteria is saved in the database with the initial version number. If the device or topological relationship corresponding to the query criteria changes, a new topology record is generated for that query criteria with the new version number (incrementing the initial version number).
[0056] When displaying a topology map, (1) if there is no topology record, or the difference between the device to be displayed and its topological relationship and the topology record exceeds a threshold, the coordinates of the device to be displayed are generated using a coordinate optimization model, including:
[0057] Based on the geographical location of power equipment, the clustering method is used to divide the equipment to be displayed into multiple categories, and the coordinates of the equipment to be displayed in each category are initialized;
[0058] The initial coordinates of the device to be displayed are used as node features, and an adjacency matrix is constructed according to the topological relationship of the device to be displayed. The node features and the adjacency matrix are passed into the coordinate optimization model, the initial coordinates are optimized, and the optimized coordinates of the device to be displayed are output.
[0059] It should be noted that, given that geographically close proximity to power geostationary equipment increases the probability of physical connection, this embodiment uses a clustering algorithm to classify the devices to be displayed into multiple categories based on their planar location coordinates, identifying the devices within each category. Preferably, the HDBSCAN (Hierarchical DBSCAN) algorithm is used to automatically select the optimal neighborhood radius, suitable for scenarios with dynamically changing device location distributions.
[0060] Furthermore, the coordinates of each candidate device are initialized according to the clustering results, including:
[0061] ① Obtain the angle of each region based on the number of devices, number of edges, and longest path length of each category in the clustering results. The longest path length is the number of edges that the longest path passes through.
[0062] Specifically, we first normalize the number of devices, number of edges, and longest path length of each category, and then perform weighted summation using the following formula to obtain the spatial weight of each category:
[0063] ,
[0064] in, represents the spatial weight of the kth class, 、 and Represent the normalized data of the number of devices, number of edges and longest path length in the kth category, 、 and They represent the weight of the number of devices, the weight of the number of edges, and the weight of the longest path length, respectively. .
[0065] Then, according to the ratio of the spatial weight of each category to the total spatial weight, the angle of the area where each category is located is obtained through the following formula.
[0066] ,
[0067] in, Indicates the angle of the area where the kth class is located.
[0068] ② According to the angle of each area, the area is divided clockwise or counterclockwise using the center point of the topological map display interface, and the vertices of each area boundary are calculated.
[0069] It should be noted that this embodiment takes into account the existence of cross-class connections, and therefore divides the areas clockwise or counterclockwise based on the center point of the topology display interface.
[0070] For example, Figure 2 As shown, 3 categories are clustered and divided counterclockwise. The angle range of the area where the first category is located is , the angle range of the second category area is , the angle range of the third category is .
[0071] Furthermore, the length and width of the topology map display interface are obtained, and rays are emitted from the center point of the topology map display interface along the angular directions of each type of area to divide the display interface into multiple areas; the intersection points of each ray and the boundary of the topology map display interface are calculated; and the vertices of each area (irregular polygon) are obtained based on the center point, the intersection point and the vertices of the display interface.
[0072] For example, Figure 2 The vertices of the three regions are: OEDF, OFAG, and OGBCE.
[0073] Among them, when calculating the intersection of each ray and the boundary of the topology map display interface, first calculate the rays emitted from the center point through each vertex of the topology map display interface based on the length and width of the topology map display interface, and calculate the angular range corresponding to the four boundaries in a counterclockwise direction, and then obtain the boundary where the rays emitted along the angular direction of each type of area intersect, and calculate the intersection with the corresponding boundary.
[0074] ③ Initialize the coordinates of each candidate device based on the number of devices in each category and the vertices of each area boundary.
[0075] This embodiment uses a triangulation method to decompose each area into multiple triangles, randomly selects a triangle according to the area weight of each triangle, generates points inside the selected triangle, and obtains the coordinates of each candidate device.
[0076] Exemplarily, the polygon is triangulated using the functions of the Earcut library.
[0077] Furthermore, the coordinate optimization model is constructed based on the graph attention network, which sequentially constructs an input encoding layer, multiple graph attention layers, and a coordinate decoding layer; the input encoding layer converts the initialized coordinates of the input node into a high-dimensional embedding vector, performs edge encoding according to the adjacency matrix of the input node, and passes it to multiple graph attention layers; multiple graph attention layers propagate topological information, and the output of each layer is used by the next layer to update the node hidden state; the coordinate decoding layer maps the node hidden state to the coordinate adjustment amount through the fully connected layer, and outputs the final optimized coordinates through a residual connection with the input initialized coordinates.
[0078] In the topological diagram of this embodiment, nodes are represented by circles. To ensure that the optimized nodes maintain a reasonable distance, do not overlap, do not cross the lines between nodes, and do not exceed the area of the class to which they belong, the coordinate optimization model adopts an unsupervised training method. By adding corresponding penalty terms to the loss function, the optimized coordinates meet the layout quality and geometric constraints.
[0079] Specifically, the loss function L of the multi-objective constraint is calculated by calculating the node distance loss , node overlap loss , edge crossing loss and region constraint loss And perform weighted summation to obtain the formula as follows:
[0080] ,
[0081] in, 、 、 and Represent the weights of node distance loss, node overlap loss, edge intersection loss, and region constraint loss, respectively. Preferably, the weights of node distance loss and node overlap loss are larger at the beginning of training. As the number of training times increases, the weights of edge intersection loss and region constraint loss gradually increase.
[0082] It should be noted that the node distance loss It is used to encourage the nodes at both ends of the edge to maintain a reasonable distance to avoid the distance being too long or too short. The formula is as follows:
[0083] ,
[0084] Where E represents the node set, and Represents the coordinates of nodes i and j at both ends of the edge, Indicates the ideal distance between preset nodes, , r represents the radius of the node primitive; represents the Euclidean distance between node i and node j.
[0085] Node overlap loss It is used to apply repulsion to nodes to avoid node primitive overlap. The formula is as follows:
[0086] ,
[0087] in, Represents the smoothing factor, which is a preset positive number to avoid division by zero.
[0088] Edge Crossing Loss It is used to impose penalties on edges that cross. In order to improve computational efficiency, only edges between nodes belonging to the same class are judged. The sigmoid function is used for approximate calculations, and a smoothing coefficient is introduced. , , calculate the probability of edge crossing, the formula is as follows:
[0089] ,
[0090] in, represents the kth class generated by node clustering, and express The two edges in , t and u represent edges and the edge The intersection parameters of When the edge and the edge cross, Represents the sigmoid function, which is used to map values between 0 and 1.
[0091] and Used to verify whether the intersection point is inside the edge. The product term is larger when When it is not in the range [0,1], the product term approaches 0 and the penalty is reduced. and Used to avoid intersection points being too close to edge endpoints. Close to 0 or 1, the product term approaches 0 and reduces the penalty. Therefore, when the intersection of two edges is on the edge, , the product of these four items is large, and a larger penalty is imposed; when the intersection of two edges is near the endpoint, Close to 0 or 1, the product of these four items is small, reducing the penalty; when there is no intersection between the two edges, If the value is not in the range [0,1], the product of these four items is smaller, which reduces the penalty.
[0092] For example, the edge The two nodes are and ,but The parameterized equation is , , ; Composition edge The two nodes are and ,but The parameterized equation is , , .side and the edge The intersection point produced by the intersection satisfies the parameterized equations of both edges at the same time, so when When the edge and the edge cross.
[0093] Region Constraint Loss This constraint is used to constrain nodes to be within the region of their cluster. Clustering generates regions based on a rectangular display interface divided at different center angles. A region is at most 7-sided, and there is only one 7-sided region. Therefore, determining whether a node is within a region by comparing it to each boundary of the region is computationally inefficient.
[0094] It should be noted that the traditional ray method determines whether a point is inside a polygon by counting the number of intersections between the ray and the polygon edge. The output result is a binary result, not a continuous value. This discrete judgment cannot provide gradient information and cannot be directly used for optimization in the loss function. Therefore, this embodiment uses a differentiable Sigmoid function to approximate the traditional ray method judgment. By introducing the smoothing coefficient , controls the smoothness of the approximation so that the result retains the traditional ray method logic and is differentiable, so it can be used in the loss function.
[0095] Specifically, for a region boundary, ① calculate the node by the following formula The vertical coordinate At the regional boundary The probability within the range :
[0096] ,
[0097] in, and Indicates the minimum and maximum ordinate values of a vertex on the boundary of the region. If exist Within the range, Close to 1, otherwise close to 0.
[0098] ②Slave node The ray emitted horizontally to the right and the region boundary The intersection point of the ray and the boundary is calculated by the following formula :
[0099] ,
[0100] ,
[0101] in, and Indicates the region boundary of the k-th category The coordinates of the two vertices of Indicates the region boundary Parameters.
[0102] Further, when When the ray intersects the region boundary, the intersection is within the range of [0,1] and the abscissa of the intersection point is to the right of the node. The intersection of the ray and the region boundary is calculated using the following formula: Probability of intersection :
[0103] ,
[0104] Among them, if In the range [0,1] and the intersection point is on the right side of the ray, Close to 1, otherwise close to 0.
[0105] Therefore, the node The probability of intersecting a region boundary is obtained by adding the above and Multiply them together and get the node The probability that the emitted ray intersects all boundaries of the area and :
[0106] ,
[0107] in, Representation node The number of boundaries in the region.
[0108] It should be noted that based on the principle of the ray method, a ray is emitted horizontally to the right from the node. If the number of intersections between the ray and the polygon edge is odd, the node is inside the region; if the number of intersections is even, the node is outside the region. This embodiment uses the odd-even rule of the ray method to determine whether a node is inside the region using an approximate calculation method using the following formula:
[0109] ,
[0110] If the node is not within the region, Close to 0, a penalty is imposed to encourage the generation of internal coordinates.
[0111] The coordinate optimization model is trained through multiple iterations, and a trained coordinate optimization model is obtained at the end of the training.
[0112] During implementation, the initial coordinates of the devices to be displayed are used as corresponding node features, along with the adjacency matrix of the devices to be displayed. This is then fed into a trained coordinate optimization model, which outputs the optimized coordinates. On the topology display interface, a topology map is rendered based on the coordinates of the devices to be displayed and the connections between them. For example, the D3.js library is used to render and generate the topology map.
[0113] (2) If there is a topology record, and the difference between the device to be displayed and its topological relationship and the topology record is less than the threshold, a topology map is generated based on the topology record.
[0114] It should be noted that the topology map generated by rendering based on the topology records includes:
[0115] ① If the generation time of the topology record is later than the reception time of the ledger data, the topology graph is directly rendered based on the device list and edge list in the topology record; that is, after the topology record is generated, if the ledger data has not been updated, then the topology record can be used directly.
[0116] ② Otherwise, when the device to be displayed and its topological relationship exist in the topological record, the coordinates of the device to be displayed are obtained from the topological record, and a topological map is generated based on the topological relationship of the device to be displayed; when there are new devices or topological relationships among the device to be displayed and its topological relationship, the device to be adjusted is obtained, the coordinates of other devices are solidified according to the topological record, the coordinates of the device to be adjusted are generated using the force-directed algorithm, and then a topological map is generated.
[0117] Specifically, there are two situations in which the devices to be displayed and their topological relationships exist in the topology record: the devices to be displayed and their topological relationships are exactly the same as the device list and edge connections in the topology record, or the devices to be displayed or their topological relationships are part of the device list or edge connections in the topology record; in this case, the coordinates of the devices to be displayed are obtained from the topology record, and edges are established according to the latest topological relationships of the devices to be displayed, so as to render and generate a topological map.
[0118] When there are new devices in the list of devices to be displayed and their topological relationships, the coordinates of the new devices do not exist in the device list in the topological record. If there are new topological relationships, the new edges may intersect with existing edges. At this time, the devices to be adjusted obtained include the new devices and the devices corresponding to the new topological relationships. Since the new devices and their topological relationships do not exceed the threshold at this time, that is, the change is relatively small, the coordinates of the devices in the topological record other than the devices to be adjusted are solidified, and the coordinates of the devices to be adjusted are quickly generated using a force-directed algorithm. Then, combined with the solidified coordinates of the devices and the topological relationships of the devices to be displayed, a topological map is rendered in the topological display interface, improving the response speed of topological map queries.
[0119] Exemplarily, the force-directed algorithm in the D3.js library is used to fix the coordinates of the devices in the topology record except for the device to be adjusted by setting the fx and fy attributes of the nodes.
[0120] Compared with existing technologies, this embodiment provides a graph neural network-based power equipment topology map generation and query method. This method utilizes a graph convolutional neural network to learn the characteristics of power equipment and the topological relationships between devices, thereby more accurately predicting the connections between newly added or changed devices, generating a more realistic topology map, and better adapting to the dynamic changes of the power system. By first querying whether there are topological records with the same query conditions, repeated calculation of device coordinates in the topology map is avoided, saving computing resources and time, significantly shortening response time, and improving the real-time and interactive nature of the query. By dynamically constraining device layout areas through clustering, different types of areas are relatively independent, while similar areas are more densely populated. This effectively reduces the problem of intersecting connection lines between devices, reduces the overlap rate of network topology, and better displays the distribution and relative relationships of devices. By utilizing the attention mechanism and multi-objective constraint loss function in the coordinate optimization model, the correlation between nodes is more accurately captured to automatically determine the location of devices in the topology map, effectively avoiding problems such as node overlap and edge crossing, and making the topology map clearer and more intuitive.
[0121] Those skilled in the art will appreciate that all or part of the process steps of the above-described embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, such as a magnetic disk, an optical disk, a read-only memory, or a random access memory.
[0122] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.
Claims
1. A method for generating and querying a topological map of power equipment based on a graph neural network, characterized in that: The following steps are involved: Update the device's feature matrix and adjacency matrix based on the new ledger data received from the power equipment, and use a graph convolutional neural network to update the device topology relationship; According to the received query conditions, the devices to be displayed and their topological relationships are obtained from the updated device topological relationships, and it is identified whether there are topological records for the query conditions, that is, according to the query conditions, the database is first queried to see whether there are topological records corresponding to the same query conditions. The topological records include: query conditions, generation time, version number, device list and edge list; if there is no topological record, or the difference between the devices to be displayed and their topological relationships and the topological records exceeds a threshold, the coordinates of the devices to be displayed are generated using a coordinate optimization model, and then a topological map is rendered and generated, and the topological record corresponding to the query conditions is saved; otherwise, a topological map is generated by rendering according to the topological record; the coordinate optimization model is constructed based on a graph attention network and introduces a loss function with multi-objective constraints.
2. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 1, characterized in that: The device list includes device identifiers and device coordinates; the edge list includes device identifiers at both ends of each edge; when the device to be displayed corresponding to the query condition or the topological relationship of the device to be displayed changes, a new topology record is generated for the query condition according to the new version number.
3. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 2, characterized in that: The generating of a topology map according to the topology record rendering includes: If the generation time of the topology record is later than the reception time of the ledger data, the topology graph is directly rendered based on the device list and edge list in the topology record; Otherwise, when the device to be displayed and its topological relationship exist in the topological record, the coordinates of the device to be displayed are obtained from the topological record, and a topological map is generated based on the topological relationship of the device to be displayed; when there are new devices or topological relationships in the device to be displayed and its topological relationship, the device to be adjusted is obtained, the coordinates of other devices are solidified according to the topological record, the coordinates of the device to be adjusted are generated using the force-directed algorithm, and then a topological map is generated.
4. The method for generating and querying a topological map of power equipment based on a graph neural network according to any one of claims 1 to 3, characterized in that: The generating of the coordinates of the device to be displayed by using the coordinate optimization model includes: Based on the geographical location of power equipment, the clustering method is used to divide the equipment to be displayed into multiple categories, and the coordinates of the equipment to be displayed in each category are initialized; The initial coordinates of the device to be displayed are used as node features, and an adjacency matrix is constructed according to the topological relationship of the device to be displayed. The node features and the adjacency matrix are passed into the coordinate optimization model, the initial coordinates are optimized, and the optimized coordinates of the device to be displayed are output.
5. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 4, characterized in that: Initializing the coordinates of various devices to be displayed includes: Obtain the angle of each area based on the number of devices, number of edges, and longest path length of each type; According to the angle of each area, the area is divided clockwise or counterclockwise from the center point of the topological map display interface, and the vertices of each area boundary are calculated; Initialize the coordinates of each candidate device based on the number of devices in each category and the vertices of each region boundary.
6. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 1, characterized in that: The coordinate optimization model is built on a graph attention network, which sequentially constructs an input encoding layer, multiple graph attention layers, and a coordinate decoding layer. The input encoding layer converts the initial coordinates of the input node into a high-dimensional embedding vector, performs edge encoding based on the adjacency matrix of the input node, and passes it to the multiple graph attention layers. The multiple graph attention layers propagate topological information, and the output of each layer is used by the next layer to update the node hidden state. The coordinate decoding layer maps the node hidden state to the coordinate adjustment amount through the fully connected layer, and outputs the final optimized coordinates by performing a residual connection with the input initialization coordinates.
7. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 1 or 6, characterized in that: The loss function of the multi-objective constraints in the coordinate optimization model is obtained by calculating the node distance loss, node overlap loss, edge intersection loss and area constraint loss and performing weighted summation.
8. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 7, characterized in that: The node distance loss and node overlap loss are calculated by the following formulas: , , in, represents the node distance loss, represents the node overlap loss, E represents the node set, and Represents the coordinates of nodes i and j at both ends of the edge, Indicates the ideal distance between preset nodes, , r represents the radius of the node primitive; Represents the smoothing factor, which is a preset positive number; represents the Euclidean distance between node i and node j.
9. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 7, characterized in that: The edge crossing loss is used to impose a penalty on any two crossing edges of the same type and is calculated using the following formula: , in, represents the edge crossing loss, represents the kth class generated by clustering, and express The two edges in , t and u represent edges and the edge The intersection parameters of the edge are solved by and the edge The parameterized equation is obtained when When the edge and the edge cross, represents the sigmoid function, represents the smoothing coefficient, .
10. The method for generating and querying a topological map of power equipment based on a graph neural network according to claim 7, characterized in that: The area constraint loss is used to impose a penalty on nodes that exceed the area of their class and is calculated using the following formula: , in, represents the regional constraint loss, represents the kth class generated by clustering, It represents the sum of the probabilities that the ray emitted horizontally to the right by node i intersects all boundaries of the region where the class to which it belongs is located.
Citation Information
Patent Citations
Generation method and device for power system tidal current wiring diagram, and electronic equipment
CN107679276A
Network link attribute relation prediction method and device based on graph neural network
CN113988464A