A method and system for checking a power distribution network topology model in a graph database
By using an embedded memory database and E-file snapshot recovery method, the distribution network topology model in the graph database is quickly verified, which solves the problem of the accuracy of topology analysis results in large-scale graph databases and realizes efficient topology model verification and analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NARI TECH CO LTD
- Filing Date
- 2023-04-12
- Publication Date
- 2026-05-15
AI Technical Summary
Existing technologies struggle to quickly and accurately verify distribution network topology models in graph databases. In particular, the correctness of topology analysis results in large-scale graph databases is difficult to verify, leading to large deviations in calculation results and low efficiency of manual verification.
An embedded in-memory database is used to cache the topology model. Through E-file snapshot and recovery methods, a microservice architecture is used to realize the rapid verification of the power distribution network topology model in the graph database. This includes topology model snapshot and recovery and verification units, parsing relational database and graph database models into graph models for comparison, and analyzing for missing or redundant data.
It enables rapid and accurate verification of distribution network topology models in graph databases, improves the reliability of topology analysis results, reduces access traffic to production-level databases, and enhances the speed and efficiency of topology model verification.
Smart Images

Figure CN116484059B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and system for verifying a distribution network topology model, and more particularly to a method and system for verifying a distribution network topology model in a graph database. Background Technology
[0002] With the continuous expansion of the power grid, the traditional relational database-based distribution network relationship model has greatly limited the performance of distribution network structure data retrieval, posing a severe challenge to the query of power grid equipment and its topology connections. Currently, the Neo4j graph database technology used by the distribution cloud master station for real-time topology analysis has further improved performance.
[0003] However, graph-based computation places high demands on model accuracy. Disordered topology relationships can lead to significant deviations in calculation results, especially since errors in the underlying topology analysis directly determine the complexity and accuracy of application-layer calculations. Furthermore, because the graphs in distribution cloud master stations are often very large, the accuracy of topology analysis results cannot be verified through effective technical means. Existing technologies can only verify the matching of feeder topology models with distribution network equipment using complex methods. For graph topology models, manual prediction followed by comparison with the graph is necessary for model analysis, which greatly complicates fault diagnosis and topology analysis testing. Summary of the Invention
[0004] Purpose of the invention: The purpose of this invention is to provide a method and system for quickly verifying distribution network topology models in a graph database.
[0005] Technical solution: The method for verifying the distribution network topology model in the graph database described in this invention includes the following steps:
[0006] (1) Topology model snapshot and recovery: The original power distribution network topology model data in the relational database and the graph database are stored as snapshots in the server E file respectively. The original power distribution network topology model data in the relational database and the graph database are recovered to the memory database through snapshot recovery to obtain the relational database topology model and the graph database topology model;
[0007] (2) Topology model verification: The relational database topology model is parsed into the original graph model, and the graph database topology model is parsed into the target graph model; the number of relational database topology models and the number of target graph models are compared, the number of original graph models and the number of target graph models are compared, the missing or redundant target graph models are verified, and the power distribution network topology model verification in the graph database is completed.
[0008] Further, step (1) of storing the original power distribution network topology model data in the relational database and graph database as snapshots in the server E file includes: taking the original power distribution network topology model data as snapshots and describing it as an E file in E language; generating version numbers of the original power distribution network topology model snapshots in the relational database and graph database respectively; saving the version numbers to the snapshot information table in the memory database; restoring the version numbers of the original power distribution network topology model snapshots in the relational database and graph database from the E file to obtain the relational database topology model and the graph database topology model; and storing the relational database topology model and the graph database topology model in the memory database.
[0009] Furthermore, the topology model verification described in step (2) is invoked by default or as a service during the startup phase;
[0010] When the topology model verification described in step (2) is called by default during the startup phase, the snapshot version number is empty, and the topology model verification in step (2) is executed.
[0011] When the topology model verification described in step (2) is called as a service, the user inputs a snapshot version number to verify a specific version of the distribution network topology model. If the snapshot version number input by the user exists in the memory database, the topology model verification in step (2) is executed. If the snapshot version number input by the user does not exist in the memory database, the relational database topology model and the graph database topology model in the memory database are cleared, the snapshot version number input by the user is imported, and the topology model verification in step (2) is executed.
[0012] Furthermore, the original distribution network topology model in the relational database is stored in the distribution network equipment table, which includes the main grid load table, distribution network switch table, distribution network disconnector table, distribution network feeder table, feeder segment table, distribution network load table, and distribution network transformer table. The original distribution network topology model in the graph database is stored based on equipment labels. According to the distribution network equipment table type in the relational database, the equipment labels established in the graph database include main grid load labels, distribution network switch labels, distribution network disconnector labels, distribution network feeder labels, feeder segment labels, distribution network load labels, and distribution network transformer labels.
[0013] Further, step (2) of parsing the relational database topology model into the original graph model includes querying the relational database topology model in the memory database, splitting the device ID and starting connection point number attributes of the two-node device into two edge structures of the graph, and splitting the device ID and connection point number attributes in the single-node device data into one edge structure of the graph; the graph edge data after parsing the relational database topology model is the original graph model.
[0014] Further, step (2) of parsing the graph topology model into a target graph model includes querying the graph topology model in the memory database. The graph topology model stores edge data of all device tags. The edge data consists of source vertex and target vertex attributes. The source vertex is the device ID and the target vertex is the node number. The graph edge data queried from the graph topology model is the target graph model.
[0015] Furthermore, the graph edge data parsed from the relational database topology model is stored in the corresponding Map collection. The key of the Map collection is the source vertex device ID, and the value of the Map collection is a List collection composed of target vertices.
[0016] Furthermore, the graph edge data retrieved from the graph library topology model is stored in a corresponding Map collection. The key of the Map collection is the source vertex device ID, and the value of the Map collection is a List collection composed of target vertices.
[0017] The verification system for the distribution network topology model in the graph database described in this invention includes:
[0018] The topology model snapshot and recovery unit is used to store the original distribution network topology model data in the relational database and the graph database as snapshots in the server E file, and restore the original distribution network topology model data in the relational database and the graph database to the memory database through snapshot recovery to obtain the relational database topology model and the graph database topology model.
[0019] The topology model verification unit is used to parse the relational database topology model into an original graph model and the graph database topology model into a target graph model; compare the number of the original graph models and the target graph models, verify the missing or redundant target graph models, and complete the verification of the distribution network topology model in the graph database.
[0020] Furthermore, the topology model snapshot and recovery unit is used to take the original distribution network topology model data as a snapshot and describe it as an E file in E language, generate the original distribution network topology model snapshot version number for relational database and graph database respectively, save the version number to the snapshot information table of memory database, recover the original distribution network topology model snapshot version number of relational database and graph database from E file to obtain relational database topology model and graph database topology model, and store relational database topology model and graph database topology model in memory database.
[0021] Beneficial effects: Compared with the prior art, the advantages of this invention are: (1) It fully considers that the accuracy of the distribution network topology model has a great impact on the calculation results when the topology calculation is based on graph database, and that with the increase of graph scale, the model faults and difficult troubleshooting problems arise. It proposes to use an embedded memory database to cache the topology model and realize the rapid verification of the distribution network topology relationship model and graph database model data; (2) Based on the microservice architecture, it adopts E-file snapshot and recovery method to support the analysis and inversion of topology model faults at different time periods, which greatly improves the speed of topology model verification, reduces the access traffic to the production-level database, and makes the distribution network topology analysis results more credible. Attached Figure Description
[0022] Figure 1 This is a flowchart of the verification method for the distribution network topology model in the graph database of the present invention.
[0023] Figure 2 This is a flowchart of the topology model verification process during the service startup phase in an embodiment of the present invention.
[0024] Figure 3 This is a flowchart of the topology model verification process during the service invocation phase in an embodiment of the present invention. Detailed Implementation
[0025] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0026] like Figure 1 As shown, the verification method for the distribution network topology model in the graph database includes two topology model data streams: topology model snapshot and recovery, and topology model verification. In the topology model snapshot and recovery data stream, the snapshot data is stored in the server's E file system, and the snapshot-recovered data is stored in a memory database. The topology model data cached in the memory database provides data support for the distribution network topology model verification. The verification method for the distribution network topology model in the graph database includes the following steps:
[0027] Step 1: Query the original distribution network topology equipment model data in the relational database and store the data as a snapshot in the server E file; query the original distribution network topology model data in the graph database (Neo4j) and store the data as a snapshot in the server E file.
[0028] In this embodiment, the relational database is DM and the graph database is Neo4j; the distribution network topology equipment model refers to the medium-voltage distribution network model, including but not limited to the main network load, distribution network switch, distribution network disconnector, distribution network feeder, feeder segment, distribution network load, and distribution network transformer equipment; the E file is a file generated based on E, a data model description language in the power system.
[0029] The original distribution network topology model data at the current point in time is retrieved from the relational database, including equipment tables such as the main network load table, distribution network switch table, distribution network disconnector table, distribution network feeder table, feeder segment table, distribution network load table, and distribution network transformer table. This data is stored as a snapshot in the server's snapshot directory, with the snapshot directory named in the format dmdb_${snapshot version number}. The snapshot contains E-files for distribution network disconnectors, distribution network feeders, feeder segments, distribution network loads, and distribution network transformers. The snapshot E-files are named in the format ${table number}_${table English name}_${table Chinese name}.
[0030] The original distribution network topology model data at the current point in time is retrieved from the graph database. This includes equipment label data such as main grid load labels, distribution network switch labels, distribution network disconnector labels, distribution network feeder labels, feeder segment labels, distribution network load labels, and distribution network transformer labels. This data is stored as a snapshot in the server snapshot directory. The snapshot directory is named in the format neo4j_${snapshot version number}. The snapshot contains E-files for distribution network disconnectors, distribution network feeders, feeder segments, distribution network loads, and distribution network transformers. The snapshot E-files are named in the format ${table number}_${table English name}_${table Chinese name}.
[0031] Step 2: Generate the snapshot version number of the relational database topology model, generate the snapshot version number of the graph database topology model, and save the version number to the snapshot information table in the in-memory database.
[0032] In this embodiment, the in-memory database is an embedded H2Database. The snapshot version number of the relational database topology model is in the format dmdb_yyyy-MM-dd_${current timestamp}; the snapshot version number of the graph library topology model is in the format neo4j_yyyy-MM-dd_${current timestamp}.
[0033] The snapshot information table contains attributes such as version number, data source type, snapshot time, and snapshot status. The data source type is a dictionary, with values of 0 (relational database type) or 1 (graph database type). The snapshot status indicates whether the current version number is a snapshot of the topology model restored from the in-memory database. For each data source type, at most one snapshot is active.
[0034] Step 3: Restore the snapshot data of the relational database topology model and the snapshot data of the graph library topology model generated in Step 1 from the E file, and store the data in the memory database device table.
[0035] The in-memory database device tables are established in the in-memory database and include the main network load table, distribution network switch table, distribution network disconnector table, distribution network feeder table, feeder segment table, distribution network load table, distribution network transformer table, Neo4j vertex information table, and Neo4j edge information table. The main network load table is a single-node device table, primarily containing node number and device ID attributes; the distribution network switches, distribution network disconnectors, distribution network feeder segments, and distribution network loads are also included. The distribution network transformer is a dual-node device table, primarily containing the first-end node number, device ID, and last-end node number attributes. The Neo4j vertex information table primarily contains vertex ID and its associated label attributes. The vertex ID can be device ID, node number, first-end node number, or last-end node number, and the associated label is the English name of the device table to which this vertex belongs. The Neo4j edge information table contains source vertex ID, target vertex ID, and its associated label attributes. The source vertex ID is the distribution network electrical equipment ID, the target vertex ID can be node number, first-end node number, or last-end node number, and the associated label is the English name of the table in the corresponding relational database.
[0036] The process of restoring the topology model snapshot in the relational database is as follows: Based on the snapshot version number, latest version number, and external input version number of the data source type relational database in the snapshot information table of the in-memory database, the topology model snapshot file under the current snapshot version number directory is retrieved from the snapshot directory, and the distribution network disconnect switch E file, distribution network feeder E file, feeder segment E file, distribution network load E file, and distribution network transformer E file are restored to the main network load table, distribution network switch table, distribution network disconnect switch table, distribution network feeder table, feeder segment table, distribution network load table, and distribution network transformer table in the in-memory database respectively.
[0037] Retrieving the snapshot version number, latest version number, and external input version number of the active state of data source type 0 (relational database type) in the in-memory database snapshot information table specifically includes: when the snapshot recovery service is called by a user, the external version number entered when calling the snapshot service is restored first; when no external version number is entered, the active state snapshot version number of data source type 0 (relational database type) is restored first; when the active snapshot version number does not exist, the latest time version number of data source type 0 (relational database type) is restored.
[0038] The process of restoring the topology model snapshot is as follows: Based on the snapshot version number, latest version number, and external input version number of the active snapshot files (data source type: graph database) in the snapshot information table of the in-memory database, the data in the topology model snapshot files starting with neo4j in the snapshot directory, including distribution network switch E-files, distribution network feeder E-files, feeder segment E-files, distribution network load E-files, and distribution network transformer E-files, are restored to the Neo4j edge information table in the in-memory database. Among them, the E-file data of the devices are saved in the Neo4j edge information table in the embedded memory library. The data in different E-files are stored in the Neo4j edge information table with different tag types. The tag type is taken from the English name of the table in the relational database to which the E-file belongs.
[0039] The process of retrieving the snapshot version number, latest version number, and external input version number of the active status of the data source type graph database in the in-memory database snapshot information table specifically includes: when the snapshot recovery service is called by a user, the external version number entered when calling the snapshot service is restored first; when no external version number is entered, the active status snapshot version number of data source type 1 (graph database type) is restored first; when the active snapshot version number does not exist, the latest time version number of data source type 1 (graph database type) is restored.
[0040] Step 4: Trigger the distribution network model verification service.
[0041] like Figure 2 and Figure 3 As shown, the triggering of distribution network model verification includes either a default call to distribution network model verification at startup or being called as a service. This invention provides a service interface for external calls, allowing users to initiate the verification of the graph database topology model by calling this interface service.
[0042] like Figure 2 The diagram shows the topology model verification process during the service startup phase. At startup, the distribution network model verification is called by default without carrying the snapshot version number parameter, and the subsequent topology model query and verification functions are performed directly.
[0043] like Figure 3 The diagram shows the topology model verification flowchart during the service call phase. When calling the model verification service, the user inputs the snapshot version number. The version of the distribution network topology model stored in the in-memory database needs to be verified. That is, the input snapshot version number is compared with the version number in the snapshot information table or the active status version number. If the version numbers are the same, the verification is successful, and the subsequent topology model query and verification functions can be performed. If the version numbers are different, the verification fails. The distribution network topology model stored in the current embedded memory library needs to be cleared first, and then the topology model data of the snapshot version carried when calling the service is restored to the in-memory database.
[0044] Step 5: Query the relational database topology model from the in-memory database and parse the relational database topology model into the original graph model.
[0045] Querying the relational database topology model includes querying the data in the main network load table, distribution network switch table, distribution network disconnecting switch table, distribution network feeder table, feeder segment table, distribution network load table, and distribution network transformer table in the in-memory database, and storing the queried data in different List collections respectively.
[0046] Parsing the relational database topology model into the original graph model includes splitting the device ID and the starting connection point number attribute of the two-node device in the queried relational database topology model into two edge structures of the graph, and splitting the device ID and the connection point number data in the single-node device data of the relational database topology model into one edge structure of the graph; for example, for the two-node device M, its device ID is 115967690572562457, the head node number is 17197782, and the tail node number is 17031504, which is split into edge A (source vertex is 115967690572562457 - target vertex is 17197782), edge B (source vertex is 115967690572562457 - target vertex is 17031504); for the single-node device N, its device ID is 3800475135564083681, and the node number is 17036312, which is split into edge C (source vertex is 3800475135564083681 - target vertex is 17036312).
[0047] The parsed graph edge structure data is stored in a Map collection, and the parsed graph edge data of different device tables is stored in different Map collections; the Key of the Map collection is the source vertex device ID, and the Value of the Map collection is a List collection composed of target vertices. For example, for edge A (source vertex is 115967690572562457 - target vertex is 17197782), edge B (source vertex is 115967690572562457 - target vertex is 17031504), the structure in the Map collection is <Key is the source vertex 115967690572562457, Value is the target vertex combination [17197782, 17031504]>. The edge set stored in the Map collection after parsing the relational database topology model is marked as the original graph model.
[0048] Step 6: Query the graph database model of the graph library topology model from the in-memory database as the target graph model.
[0049] Retrieving the graph database model from the in-memory database refers to querying data from the Neo4j edge information table in the in-memory database. This table stores edge data for all device labels, identifying the device type of each edge through its label attributes. The retrieved data structure consists of source and target vertex attributes; the source vertex is the device ID, and the target vertex is the node number. The graph database edge data is queried based on label type, which is the English name of the distribution network device table. Edges with different label types are stored in different Map collections. The key of each Map collection is the source vertex device ID, and the value is a List of target vertices. The set of edges retrieved from the graph database topology model and stored in the Map collection is identified as the target graph model.
[0050] Step 7: Compare the number of relational database topology models in Step 5 with the number of target graph models in Step 6.
[0051] Calculate the relational database topology model retrieved in step 5, such as the size of the distribution network switch table List set, which stores all the devices of the distribution network switch; calculate the number of target graph models in step 6, such as the number of distribution network switch tag Map set Keys, which stores all the device IDs of the distribution network switch; compare the size of the List set with the size of the Map set Key, and verify the number of main grid loads, distribution network switches, distribution network disconnectors, distribution network feeders, feeder segments, distribution network loads, and distribution network transformer devices in sequence.
[0052] Step 8: Compare the original graph model in Step 5 with the target graph model in Step 6 to analyze the missing models in the graph library.
[0053] The difference between the original graph model and the target graph model is calculated. Specifically, the difference between the Map set Key of the original graph model and the Map set Key of the target graph model is calculated, and the difference between the Value set of the same Key is calculated to analyze the missing models in the graph library.
[0054] Step 9: Compare the original graph model in Step 5 with the target graph model in Step 6 to analyze the redundant models in the graph library.
[0055] The difference between the target graph model and the original graph model is calculated. Specifically, the difference between the Map set Key of the target graph model and the Map set Key of the original graph model is calculated, and the difference between the Value sets of the same Key is calculated to identify redundant models in the graph library.
[0056] The verification system for the distribution network topology model in the graph database described in this invention includes:
[0057] The topology model snapshot and recovery unit is used to store the original distribution network topology model data in the relational database and the graph database as snapshots in the server E file, and restore the original distribution network topology model data in the relational database and the graph database to the memory database through snapshot recovery to obtain the relational database topology model and the graph database topology model.
[0058] The topology model verification unit is used to parse the relational database topology model into an original graph model and the graph database topology model into a target graph model; compare the number of the original graph models and the target graph models, verify the missing or redundant target graph models, and complete the verification of the distribution network topology model in the graph database.
[0059] The topology model snapshot and recovery unit is used to take the original distribution network topology model data as a snapshot and describe it as an E file in E language, generate the original distribution network topology model snapshot version number for relational database and graph database respectively, save the version number to the snapshot information table of memory database, recover the original distribution network topology model snapshot version number of relational database and graph database from E file to obtain relational database topology model and graph database topology model, and store relational database topology model and graph database topology model in memory database.
Claims
1. A method for verifying a distribution network topology model in a graph database, characterized in that, Includes the following steps: (1) Topology model snapshot and recovery: The original power distribution network topology model data in the relational database and the graph database are stored as snapshots in the server E file respectively. The original power distribution network topology model data in the relational database and the graph database are recovered to the memory database through snapshot recovery to obtain the relational database topology model and the graph database topology model; (2) Topology model verification: The relational database topology model is parsed into the original graph model, and the graph database topology model is parsed into the target graph model; the number of relational database topology models and the number of target graph models are compared, the number of original graph models and the number of target graph models are compared, the missing or redundant target graph models are verified, and the power distribution network topology model verification in the graph database is completed; Step (2) of parsing the relational database topology model into the original graph model includes querying the relational database topology model in the memory database, splitting the device ID and starting connection point number attributes of the two-node device into two edge structures of the graph, and splitting the device ID and connection point number attributes in the single-node device data into one edge structure of the graph; the graph edge data after parsing the relational database topology model is the original graph model; Step (2) of parsing the graph topology model into a target graph model includes querying the graph topology model in the memory database. The graph topology model stores edge data of all device tags. The edge data consists of source vertex and target vertex attributes. The source vertex is the device ID and the target vertex is the node number. The graph edge data retrieved from the graph library topology model is the target graph model.
2. The method for verifying the distribution network topology model in the graph database according to claim 1, characterized in that, Step (1) of storing the original power distribution network topology model data in the relational database and graph database as snapshots in the server E file includes: taking the original power distribution network topology model data as snapshots and describing it as an E file in E language; generating version numbers of the original power distribution network topology model snapshots in the relational database and graph database respectively; saving the version numbers to the snapshot information table in the memory database; restoring the version numbers of the original power distribution network topology model snapshots in the relational database and graph database from the E file to obtain the relational database topology model and the graph database topology model; and storing the relational database topology model and the graph database topology model in the memory database.
3. The method for verifying the distribution network topology model in the graph database according to claim 2, characterized in that, The topology model verification described in step (2) is invoked by default or as a service during the startup phase; When the topology model verification described in step (2) is called by default during the startup phase, the snapshot version number is empty, and the topology model verification in step (2) is executed. When the topology model verification described in step (2) is called as a service, the user inputs the snapshot version number to verify a specific version of the distribution network topology model. If the snapshot version number input by the user exists in the memory database, the topology model verification in step (2) is executed. If the snapshot version number entered by the user does not exist in the in-memory database, then clear the relational database topology model and the graph database topology model in the in-memory database, import the snapshot version number entered by the user, and perform the topology model verification in step (2).
4. The method for verifying the distribution network topology model in a graph database according to claim 1, characterized in that, The original distribution network topology model in the relational database is stored in the distribution network equipment table, which includes the main grid load table, distribution network switch table, distribution network disconnector table, distribution network feeder table, feeder segment table, distribution network load table, and distribution network transformer table. The original distribution network topology model in the graph database is stored based on equipment labels. According to the distribution network equipment table type in the relational database, the equipment labels established in the graph database include main grid load labels, distribution network switch labels, distribution network disconnector labels, distribution network feeder labels, feeder segment labels, distribution network load labels, and distribution network transformer labels.
5. The method for verifying the distribution network topology model in the graph database according to claim 1, characterized in that, The graph edge data parsed from the relational database topology model is stored in the corresponding Map collection. The key of the Map collection is the source vertex device ID, and the value of the Map collection is a List collection composed of target vertices.
6. The method for verifying the distribution network topology model in a graph database according to claim 1, characterized in that, The graph edge data retrieved from the graph library topology model is stored in the corresponding Map collection. The key of the Map collection is the source vertex device ID, and the value of the Map collection is a List collection composed of target vertices.
7. A verification system for a distribution network topology model in a graph database based on the method of claim 1, characterized in that it comprises: The topology model snapshot and recovery unit is used to store the original distribution network topology model data in the relational database and the graph database as snapshots in the server E file, and restore the original distribution network topology model data in the relational database and the graph database to the memory database through snapshot recovery to obtain the relational database topology model and the graph database topology model. The topology model verification unit is used to parse the relational database topology model into an original graph model and the graph database topology model into a target graph model; compare the number of the original graph models and the target graph models, verify the missing or redundant target graph models, and complete the verification of the distribution network topology model in the graph database.
8. The verification system for the distribution network topology model in the graph database according to claim 7, characterized in that the topology model snapshot and recovery unit is used to take the original distribution network topology model data as a snapshot and describe it as an E file in E language, generate the original distribution network topology model snapshot version number for the relational database and the graph database respectively, save the version number to the snapshot information table of the memory database, recover the original distribution network topology model snapshot version number of the relational database and the graph database from the E file to obtain the relational database topology model and the graph database topology model, and store the relational database topology model and the graph database topology model in the memory database.