Explainable analysis method of smart meter electricity consumption behavior based on causal graph
By constructing a multi-level causal map and real-time effective path index, the calculation complexity and resource overhead of the causal map in the analysis of the electricity consumption behavior of smart meters are solved, and efficient causal explanation and real-time electricity consumption behavior analysis are achieved.
Patent Information
- Application Number
- CN202510756548.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-06-09
AI Technical Summary
The existing smart meter electricity behavior analysis methods have problems of high computational complexity and high resource overhead in dynamic maintenance of causal maps and pre-computing path index maintenance, resulting in insufficient real-time and scalability, affecting the engineering application of causal maps in real-time electricity behavior analysis.
Through multi-source data fusion and multi-time-scale causal relationship discovery, a multi-level causal map is built, and a dynamic multi-level causal map and real-time effective path index are adopted, combined with counterfactual reasoning verification, a causal explanation report is generated, which reduces update complexity and index maintenance overhead, and improves query efficiency.
Real-time update and efficient query of the causal map are realized, the calculation efficiency is improved by 99.998%, and the index maintenance overhead is reduced to less than 10%, meeting the real-time and interpretability needs of smart meter electricity consumption behavior analysis.
Smart Images

Figure CN120278399B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to power electronics technology, and in particular to an interpretable analysis method for electricity consumption behavior of smart meters based on a causal graph. Background Art
[0002] With the rapid development of smart grid technology and the increasing sophistication of user electricity usage, smart meters have become a critical infrastructure for the digital transformation of power systems. The interpretable analysis method for smart meter electricity usage based on causal graphs not only accurately identifies anomalies in electricity usage but, more importantly, provides a transparent and understandable explanation mechanism for users and power companies. Interpretable analysis is crucial for improving user electricity management, optimizing grid operational efficiency, and supporting smart grid decision-making. In the context of carbon neutrality, accurately understanding the inherent causal mechanisms of user electricity usage behavior can help formulate more precise energy-saving and emission-reduction strategies and promote the formation of green electricity consumption patterns. Furthermore, interpretable electricity usage behavior analysis is a key technical support for building user trust and promoting the widespread application of smart grid technology.
[0003] Currently, there are two main approaches to analyzing smart meter electricity usage: statistical learning-based methods and deep learning-based methods. Statistical learning methods primarily employ traditional statistical techniques such as time series analysis and regression analysis, modeling and analyzing electricity usage data by constructing ARIMA models and support vector machines. Deep learning methods, on the other hand, primarily utilize neural network architectures such as LSTM and CNN, training on large amounts of historical electricity usage data to identify usage patterns and abnormal behavior. Regarding causal relationship identification, existing research primarily uses Granger causality testing as a single causal identification method, using lagged regression models to determine causal relationships between variables. Regarding graph construction, most methods employ static graph structures with predefined node and edge relationships, lacking dynamic adaptability. Regarding anomaly detection, existing methods primarily rely on threshold judgment or cluster analysis, identifying abnormal electricity usage behavior by setting fixed thresholds or distance metrics.
[0004] However, the existing technical solutions face two key technical bottlenecks in practical applications: one is the computational complexity of dynamic maintenance of the causal graph. When the electricity consumption behavior changes, the traditional method needs to recalculate the relationship between all nodes and edges in the entire causal graph, and the computational complexity is O(n 2) level, which leads to serious lack of real-time performance in large-scale electricity consumption data scenarios; secondly, the maintenance overhead of the pre-computed path index is too high. In order to improve the efficiency of causal path queries, existing methods usually adopt a full pre-computed index strategy. However, when the causal graph changes, all pre-computed paths need to be updated synchronously. The index maintenance overhead accounts for more than 30% of the total computing resources, which seriously affects the overall performance and scalability of the system. These two problems directly restrict the engineering application of the causal graph method in real-time electricity consumption behavior analysis. Summary of the Invention
[0005] The purpose of the invention is to provide an interpretable analysis method for the electricity consumption behavior of smart meters based on causal graphs, in order to solve at least one technical problem existing in the prior art.
[0006] The technical solution is a method for interpretable analysis of smart meter electricity consumption behavior based on causal graphs, which includes the following steps:
[0007] Read the raw electricity consumption data of smart meters, and construct a primary multi-level causal graph through multi-source data fusion and multi-time scale causal relationship discovery;
[0008] When abnormal power consumption is detected, the influence range of the abnormal node in the primary multi-level causal graph is identified, maintained and updated, and a dynamic multi-level causal graph and real-time effective path index are generated;
[0009] Receive user query requests and search the key and important path indexes in the real-time valid path index in sequence. If no results are found, perform real-time search to obtain the target causal path set.
[0010] Read the target causal path set, verify and explain the output through counterfactual reasoning, and generate a verified causal explanation report.
[0011] Furthermore, through multi-source data fusion and multi-timescale causal relationship discovery, a multi-level causal map is constructed, including:
[0012] Read the original electricity consumption data of smart meters, perform standardization and stratification processing, and generate a stratified time window data set;
[0013] Based on the hierarchical time window dataset, MI, GC and TC are calculated and fused to generate a multidimensional causal strength vector;
[0014] Read the multi-dimensional causal strength vector, calculate each causal relationship and verify the stability at different time scales to generate a multi-scale causal strength matrix;
[0015] Based on the multi-scale causal intensity matrix, the causal relationships of different time scales are constructed and stored in layers to generate a multi-level causal map and the corresponding causal relationship basic index.
[0016] Furthermore, a multi-dimensional causal strength vector is generated, including:
[0017] Based on the hierarchical time window data set, the mutual information entropy MI, Granger causality GC and temporal consistency coefficient TC are calculated and normalized respectively;
[0018] Calculate the dynamic weights α, β, and γ of MI, GC, and TC based on the window stability coefficient and the temporal correlation strength;
[0019] Read the normalized MI, GC, TC and dynamic weights α, β, γ, and calculate the fusion strength K = (α × MI 2 +β×GC 2 +γ×TC 2 ) 0.5 , generating a multi-dimensional causal strength vector.
[0020] Furthermore, a real-time valid path index is generated, including:
[0021] Combined with multi-level causal graphs, abnormal nodes are identified from the current real-time electricity consumption data stream, the local impact propagation range is calculated, and the affected area identification is generated;
[0022] Based on the identification of affected areas, distributed asynchronous update scheduling is performed on the real-time layer, quasi-real-time layer, and background layer through intelligent allocation of three-layer computing resources and time slice rotation scheduling strategy, generating an optimized layered update task queue;
[0023] For the hierarchical update task queue and real-time electricity consumption data stream, weight update and accuracy correction are performed to generate a dynamically maintained multi-level causal graph and a real-time effective path index.
[0024] Furthermore, a dynamically maintained multi-level causal graph and real-time effective path index are generated, including:
[0025] Based on the optimized hierarchical update task queue and real-time electricity consumption data stream, the new edge weight Q is calculated as old weight - (expired data contribution / window size) + (new data contribution / window size). Based on this incremental calculation, the incremental update weight table is obtained.
[0026] For the incremental update weight table, record the number of consecutive updates and error change trends of each edge. When it exceeds the preset value, mark it as an edge that needs correction;
[0027] For edges that need to be marked, the edge weights are recalculated and corrected based on complete historical data to generate a dynamically maintained multi-level causal graph and a real-time effective path index.
[0028] Furthermore, the local impact propagation range is calculated and the affected area identification is generated, including:
[0029] Read real-time power consumption data streams and multi-level causal graphs, identify nodes where power changes exceed thresholds, and obtain a list of abnormal nodes and abnormal intensity levels. Based on this, the impact propagation formula is used to calculate the impact area and generate an impact intensity distribution map.
[0030] The influence propagation formula is:
[0031] Impact range I = initial intensity I0 × e -λd × Edge weight accumulation norm × attenuation adjustment factor;
[0032] Where: Edge weight accumulation norm = Σ(edge weight i ) / sqrt(path length); d is the number of propagation hops, which is limited to 3 hops forward and 3 hops backward. The adaptive attenuation coefficient λ = 0.3 + 0.2 × (anomaly intensity level / 5).
[0033] Furthermore, the key and important path indexes in the real-time valid path index are searched sequentially. If not found, a real-time search is performed, including:
[0034] Respond to user query requests, identify the source node set and target node set through query type classification and key entity extraction, and output them;
[0035] Read the dynamic multi-level causal graph and divide the pre-calculated paths in the causal relationship basic index into key path index, important path index and background path index to generate a real-time effective path index;
[0036] For the source node set and the target node set, first search in the key and important path indexes. If not found, perform a real-time search in the background path index.
[0037] Furthermore, a real-time valid path index is generated, including:
[0038] Read the causal relationship basic index and dynamic multi-level causal graph, calculate the node importance and path importance, and store the pre-calculated paths into the key, important and background path indexes respectively to generate a hierarchical path index architecture;
[0039] Read the hierarchical path index architecture, add a timestamp and valid flag to each pre-calculated path, update the critical path immediately, delay the update of important paths, and verify the background path query to generate a real-time valid path index.
[0040] Furthermore, the search is first performed in the key and important path indexes. If not found, a real-time search is performed in the background path index, which also includes:
[0041] Based on the search results, a candidate path set and search time records are formed;
[0042] For the candidate path set, combined with the dynamic multi-level causal graph, the current causal strength and connectivity of each edge in multiple candidate paths are checked in parallel, and paths containing invalid edges are eliminated to form a valid path set;
[0043] For each valid path, score and sort the paths to obtain the target causal path set;
[0044] Where, path score = (causal strength weight × a + (path length weight × b) + (historical success rate × c); a + b + c = 1.
[0045] Furthermore, counterfactual reasoning is used to verify and explain the output, generating a verified causal explanation report including:
[0046] Based on the target causal path set and dynamic multi-level causal graph, the engine removes or modifies key causal edges, combines parameter perturbation simulation, and constructs a set of counterfactual scenarios and expected result ranges. Combined with the original electricity consumption data of smart meters, the engine calculates the changes in electricity consumption patterns under each scenario, compares them with historical actual data for consistency, and generates an explanation credibility score and verification result report.
[0047] For the verification result report, the logical organization of the causal chain and the quantification of technical indicators are used to generate a causal explanation report that includes the causal relationship strength, impact delay and confidence interval.
[0048] Furthermore, remove or modify key causal edges, including:
[0049] When an edge in a causal path fails, an alternative path is selected from the candidate paths, or a new valid path is recalculated.
[0050] The beneficial effect is to reduce the update complexity and index maintenance overhead, improve the query efficiency, and provide an efficient explainable technical solution for the analysis of smart meter electricity consumption behavior. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 It is a flow chart of the present invention.
[0052] Figure 2 It is a flow chart of the present invention for constructing a multi-level cause-effect graph.
[0053] Figure 3 It is a flow chart of the present invention for generating a multi-dimensional causal strength vector.
[0054] Figure 4 This is a flow chart of the present invention for generating a real-time valid path index. DETAILED DESCRIPTION
[0055] like Figures 1 to 4 As shown, a method for interpretable analysis of smart meter electricity consumption behavior based on a causal graph is provided, which includes the following steps:
[0056] S1. Read the original electricity consumption data, basic user information and external environment data of the smart meter, and construct a multi-level causal graph and a basic causal relationship index through data preprocessing and an improved multi-window causal strength calculation method.
[0057] S11. Read the raw electricity consumption data of smart meters (such as power time series at 1, 3, and 15 minute intervals, with different meters having different sampling periods), basic user information (equipment list, house characteristics), and external environmental data (temperature, humidity, weather). Through timestamp alignment and data type unification, a synchronized standardized data matrix is obtained.
[0058] S12. Parallel calculation of causal strength in multiple time windows
[0059] S121. Read the synchronized standardized data matrix and construct a triple-nested window mechanism to simultaneously construct an A-second high-frequency response window, a B-second medium-frequency stability window, and a C-second low-frequency trend window. Each window independently maintains a data buffer, resulting in a layered time window dataset and window synchronization markers. While traditional methods use a single fixed window, this method's three-layer nested mechanism can simultaneously capture causal characteristics at different time scales.
[0060] S122. Calculating Mutual Information Entropy-Granger Fusion Causal Strength, including: reading a hierarchical time window dataset and obtaining a multidimensional causal strength vector using the comprehensive causal strength = α·MI(X;Y|Z) + β·GC(X→Y) + γ·TC(X,Y,t); where MI is the mutual information entropy, GC is the Granger causality, TC is the temporal consistency coefficient, α+β+γ=1, and the weights are dynamically adjusted based on the window type. Existing methods use Granger causality or mutual information alone. This method fuses these three causal metrics to improve the robustness of causal identification.
[0061] This approach addresses the inaccurate identification capabilities of traditional single-causal metrics in the complex electricity usage environments of smart meters. Specifically, MI captures nonlinear causal relationships (such as the nonlinear response of temperature to air conditioning power consumption), GC identifies temporal causal relationships (such as the delayed effect of device startup), and TC verifies the temporal stability of causal relationships (such as the consistency of periodic electricity usage patterns). Using an adaptive weighting mechanism of α = 0.4 + 0.2 × the window stability coefficient, MI weight is automatically increased when electricity usage data fluctuates significantly to improve nonlinear identification capabilities, while GC weight is increased when temporal correlation is strong to highlight temporal causal characteristics. Euclidean norm fusion ensures the geometric significance of the combined strength, increasing causal identification accuracy from 65% to 82% for traditional single-method approaches.
[0062] S123. Calculating the causal relationship stability score, including: reading the multi-dimensional causal strength vector and the window synchronization mark, calculating the stability of each causal relationship at different time scales through a cross-window consistency verification algorithm, and obtaining a causal stability score and a multi-scale causal strength matrix.
[0063] S13. Generate hierarchical causal graph construction and index, including: reading multi-scale causal strength matrix and causal stability score, storing causal relationships of different time scales in layers through hierarchical graph construction algorithm, generating multi-level causal graph (including real-time layer, quasi-real-time layer, background layer) and causal relationship basic index (pre-calculating the top 3 optimal paths between key nodes).
[0064] S2: Read the real-time electricity consumption data stream and multi-level causal graph, and dynamically update the causal graph and identify the affected areas through a load-balanced distributed update mechanism.
[0065] S21: Intelligent identification mechanism of affected areas
[0066] S211: Abnormal node rapid location algorithm, including: reading real-time power consumption data stream and multi-level causal graph, through the threshold dynamic adjustment mechanism (based on the 3σ standard deviation calculation of the user's historical baseline), identifying nodes with power changes exceeding 200% of the baseline, and obtaining a list of abnormal nodes and the abnormal intensity level.
[0067] S212: Calculate the local impact propagation range, including: reading the abnormal node list, abnormal intensity level and multi-level causal map, and using the impact propagation attenuation formula: impact range I(d) = initial intensity I0 × e^(-λd) × edge weight accumulation; where: d is the propagation distance, λ is the attenuation coefficient, and the propagation depth is limited to 3 hops forward and 3 hops backward, to obtain the affected area identification and impact intensity distribution map. Traditional methods require full graph traversal calculation, with a complexity of O(n 2 This method reduces the complexity to O(k·logn) by limiting the spread of the affected nodes, where k is the number of affected nodes, significantly improving computational efficiency.
[0068] Limiting the update scope of the causal graph to the forward 3 hops and backward 3 hops of the abnormal node solves the problem of computational complexity explosion caused by traditional full-graph traversal update. In the application scenario of smart meters, when an abnormality occurs in an electrical device, its impact is usually localized. For example, an air conditioner failure mainly affects the temperature control circuit and power supply circuit directly related to it, and will not affect independent equipment circuits such as water heaters or washing machines. Through the adaptive attenuation coefficient λ=0.3+0.2×(abnormality intensity level / 5), the higher the abnormality, the wider the propagation range. The edge weight accumulation normalization process avoids the numerical instability problem of long-distance propagation. The attenuation adjustment factor min(1.0, 2.0 / d) ensures the reasonable attenuation of propagation intensity. This method reduces the update computational complexity from O(n 2 ) is reduced to O(k•logn). In a 1000-node smart meter network, the amount of calculation is reduced from 1,000,000 times to 24 times, and the computing efficiency is improved by 99.998%, achieving the millisecond-level real-time causal graph update capability.
[0069] S213: Dynamic impact weight allocation mechanism, including: reading the impact intensity distribution map and causal stability score, and assigning a higher update priority to unstable causal relationships through an inverse proportional adjustment algorithm between impact weight and stability, to obtain a weighted impact area map.
[0070] S22: Distributed asynchronous update scheduling mechanism
[0071] S221: A three-tiered intelligent computing resource allocation algorithm, which reads a weighted impact region map and anomaly severity levels. It uses a resource allocation strategy: 15% of the CPU is allocated to the real-time layer (for processing high-priority causal edges), 20% to the quasi-real-time layer (for processing medium-priority causal edges), and 10% to the background layer (for processing low-priority causal edges). The allocation ratios are dynamically adjusted based on anomaly severity, resulting in a hierarchical resource allocation table. Existing methods use synchronous batch updates, which can cause computing load spikes. This method's three-tiered asynchronous resource allocation avoids computing contention and ensures real-time response.
[0072] S222: Implementing a time-slice round-robin scheduling strategy, including reading the hierarchical resource allocation table and the affected area identifiers, and using a time-slice round-robin mechanism: the real-time layer executes continuously in 50ms time slices, the quasi-real-time layer executes every 30 seconds, and the background layer executes every 5 minutes. Preemptive scheduling is employed (exceptional events can interrupt low-priority tasks), resulting in a hierarchical update task queue and a scheduled execution schedule. This priority-based time-slice round-robin mechanism resolves the resource contention issue associated with traditional synchronous updates and achieves load balancing.
[0073] S223: Dynamic load monitoring and adaptive adjustment, including: reading the scheduling execution schedule and the system's real-time CPU usage, detecting the computing load of each layer in real time through the load monitoring algorithm, and automatically downgrading the execution strategy (pausing background layer updates, extending the quasi-real-time layer interval) when the total CPU usage exceeds 50%, to obtain an optimized layered update task queue.
[0074] This solves the computational load spikes and response delays caused by traditional synchronous batch updates. In real-time smart meter monitoring scenarios, different types of causal relationships have different timeliness requirements: critical equipment failures require real-time responses (such as abnormal meter tripping), general equipment status changes can be processed in near-real time (such as normal load switching), and historical trend analysis can be processed in the background (such as monthly power consumption pattern analysis). An intelligent resource allocation algorithm dynamically adjusts the CPU allocation ratio based on the severity level of the anomaly to ensure that critical tasks are prioritized. The dynamic load monitoring mechanism automatically triggers a downgrade strategy when total CPU utilization exceeds 50%, suspending background layer updates and extending the near-real-time layer interval to avoid system overload.
[0075] S23: Incremental Causal Edge Weight Correction Algorithm
[0076] S231: Sliding window incremental weight update, including: reading the optimized hierarchical update task queue and real-time electricity consumption data stream, using the incremental update formula: new edge weight = old weight - (expired data contribution / window size) + (new data contribution / window size); performing incremental calculations on each causal edge that needs to be updated to obtain an incremental update weight table.
[0077] S232: Real-time cumulative error detection mechanism, including: reading the incremental update weight table, recording the number of consecutive updates and error change trends of each edge through the error accumulation tracking algorithm, and marking the edge as requiring correction when the error rate exceeds the 5% threshold or the number of consecutive updates exceeds 100 times, obtaining an error monitoring report and a correction requirement mark.
[0078] S233: Execute adaptive precision correction, including reading the correction requirement marker and the multi-level causal graph, locally recalculating the marked edges (recalculating edge weights using the complete historical data), and resetting the error counter after correction is complete, resulting in a dynamically updated causal graph. Traditional incremental updates suffer from error accumulation, which cannot be solved. This method uses an adaptive correction mechanism to keep the error within 5% while maintaining update speed.
[0079] This solves the problem of error accumulation and non-convergence in traditional incremental update methods. In the long-term operation scenario of smart meters, causal relationships need to be continuously updated based on new electricity consumption data. Traditional methods either use full recalculation (which has huge computational overhead) or simple incremental updates (which continuously accumulate errors). This embodiment records the number of consecutive updates and error trends for each edge. When the number of consecutive updates exceeds 100 or the error rate exceeds 5%, it automatically triggers local recalibration, recalculates the edge weight using complete historical data, and resets the error counter. This avoids frequent full recalculations and prevents unlimited error accumulation, ensuring the long-term stability of causal relationship identification. In a 30-day continuous operation test, the edge weight update accuracy remained above 95%, and the update speed was 15 times faster than full recalculation, providing technical support for the reliability maintenance of the causal graph of smart meters.
[0080] S3: Reads user query requests, dynamically updated causal graphs, and causal relationship basic indexes, and generates a target causal path set through a fast path search algorithm maintained by hierarchical indexes.
[0081] S31: Query intent parsing and path requirement identification, including: reading user query requests, identifying source node sets, target node sets, and query priority labels through query type classifiers (real-time anomaly interpretation, historical pattern analysis, predictive analysis) and key entity extraction.
[0082] S32: Hierarchical index dynamic maintenance mechanism
[0083] S321: Construct a three-level path index architecture, including reading a basic causal relationship index and a dynamically updated causal graph. Using a path importance evaluation algorithm (based on node access frequency and causal strength), the precomputed paths are divided into a critical path index (paths involving core power devices), an important path index (paths involving secondary devices), and a background path index (other paths), resulting in a hierarchical path index architecture. Existing precomputed indexes use a flat structure, resulting in high maintenance overhead. This method's three-level hierarchical index reduces maintenance overhead from 30% to less than 10%.
[0084] S322: Implementing a lazy update strategy, including reading the hierarchical path index structure and the affected region identifiers, and using a lazy update mechanism: immediate updates for critical paths, delayed updates for important paths, validating background paths only when queried, and employing path timeliness marking (recording the last time a path was verified) to obtain a timeliness-marked path index. Traditional indexes require synchronous maintenance of all paths. This approach significantly reduces maintenance overhead through a lazy strategy while ensuring path availability during queries.
[0085] S323: Intelligent verification of index consistency, including: reading the time-sensitive path index and the dynamically updated causal graph, checking the current state of each edge in the path through the path validity verification algorithm, replacing or deleting invalid paths, and obtaining a real-time valid path index and index update log.
[0086] S33: Fast Path Reconstruction and Verification Algorithm
[0087] S331: A multi-level degraded path search strategy, specifically: reading the source node set, target node set, real-time valid path index, and query priority label, and using a three-level degraded search mechanism: the first level searches from the critical path index (target <50ms), the second level searches and verifies from the important path index (target <100ms), and the third level performs a real-time graph search (target <200ms), to obtain a set of candidate paths and a record of search time.
[0088] In the real-time anomaly analysis scenario for smart meters, users expect immediate explanations upon discovering anomalies in electricity usage. However, traditional path search methods suffer from uncontrollable response times, ranging from tens of milliseconds to several seconds, failing to meet real-time requirements. This method, through a multi-level degradation strategy, first attempts to quickly match the target path from a precomputed critical path index. If no path is found, it then searches the important path index for validity verification, ultimately performing a real-time graph search as a backup. A path quality score ((causal strength weight × 0.4) + (path length weight × 0.3) + (historical success rate × 0.3)) ensures the reliability of the returned path, avoiding the problem of sacrificing quality in favor of speed. Traditional path search uses a single strategy with uncontrollable response times. This method, through a multi-level degradation mechanism, ensures that 95% of queries are completed within 100ms while maintaining path quality.
[0089] S332: Parallel verification mechanism for path validity
[0090] The candidate path set and the dynamically updated causal graph are read, and the current causal strength and connectivity of each edge in multiple candidate paths are checked simultaneously through a parallel verification algorithm. Paths containing invalid edges are eliminated to obtain a valid path set.
[0091] S333: Calculation of comprehensive path quality score
[0092] The valid path set and search time records are read, and the comprehensive scoring formula is used: path score = (causal strength weight × 0.4) + (path length weight × 0.3) + (historical success rate × 0.3); each valid path is scored and sorted to obtain the target causal path set and path credibility distribution.
[0093] S4: Read the target causal path set, the dynamically updated causal graph, and the raw electricity consumption data of the smart meter, and generate a verified causal explanation report through counterfactual scenario simulation and credibility assessment.
[0094] S41: Generate counterfactual scenarios automatically, including: reading the target causal path set and the dynamically updated causal graph, generating the counterfactual scenario set and the expected result range through causal chain break simulation (removing or modifying key causal edges) and parameter perturbation simulation.
[0095] S42: Simulation verification and credibility quantitative assessment, including: reading the counterfactual scenario set, the expected result range and the original electricity consumption data of the smart meter, calculating the changes in electricity consumption patterns under each scenario through the counterfactual simulation engine, and comparing the consistency with the historical actual data to generate an explanation credibility score and a verification result report.
[0096] S43: Generate a comprehensive explanation report, including: reading the target causal path set, path credibility distribution, explanation credibility score and verification result report, and generating a verified causal explanation report including causal relationship strength, impact delay and confidence interval through the logical organization of the causal chain and the quantification of technical indicators.
[0097] According to one aspect of the present application, S321, constructing a three-level path index architecture, specifically:
[0098] S3211. Quantitative evaluation of node importance: Read the causal relationship basic index and the dynamically updated causal graph, and calculate the node importance using the formula: node importance = (degree centrality × 0.3) + (access frequency × 0.4) + (sum of causal strength × 0.3);
[0099] Among them: degree centrality is the number of edges connecting the node, access frequency is the number of times the node is involved in historical queries, and the sum of causal strength is the accumulation of weights of all connecting edges to obtain the node importance score table.
[0100] S3212, Comprehensive Path Importance Calculation: This method reads the node importance score table and the causal relationship basic index and uses the path importance evaluation algorithm to perform a weighted average of the importance scores of all nodes in the path (with a weight of 0.4 for the start and end points and a weight of 0.2 for intermediate nodes). This is then corrected based on the path's historical query frequency to produce a path importance ranking table. Traditional indexes do not distinguish between path importances. This method achieves intelligent path ranking through a comprehensive evaluation of node centrality and query frequency.
[0101] S3213, three-level index hierarchical storage: read the path importance ranking table and divide it according to the importance threshold: paths with importance scores > 0.8 are stored in the critical path index, those with importance scores between 0.5 and 0.8 are stored in the important path index, and those with importance scores < 0.5 are stored in the background path index. Each level of index uses different data structure optimizations (hash tables are used for critical paths, B+ trees are used for important paths, and compressed storage is used for background paths), resulting in a hierarchical path index architecture.
[0102] According to one aspect of the present application, S322 refines the lazy update strategy, specifically:
[0103] S3221. Path timeliness marking mechanism: Read the hierarchical path index architecture and affected area identifiers, and add a timeliness mark to each pre-computed path: including the last verification timestamp, the list of involved edge identifiers, and the validity status flag. When any edge involved in the path changes, the validity status is marked as "pending verification" to obtain the timeliness marked path index.
[0104] S3222. Execution of the hierarchical update strategy: Read the timeliness-tagged path index and, through the hierarchical update mechanism, immediately re-verify and update the "pending verification" paths in the critical path index; add the "pending verification" paths in the important path index to the delayed update queue and process them in batches every 60 seconds; and verify the "pending verification" paths in the background path index only when they are queried, thus obtaining a hierarchical update task allocation table.
[0105] Traditional index maintenance relies on full synchronous updates, which is very expensive. This method uses a lazy strategy to verify only the paths that are truly needed, significantly reducing maintenance costs.
[0106] S3223. Dynamic verification mechanism during query: Read the hierarchical update task allocation table and query request. When the query involves the "pending verification" path in the background path index, immediately trigger the validity check of the path: traverse the status of each edge in the path in the current causal graph. If the edge still exists and the weight change is <10%, it is marked as valid. Otherwise, the path is removed from the index and an attempt is made to recalculate an alternative path to obtain real-time verification results and an updated real-time valid path index.
[0107] According to one aspect of the present application, S121, triple nested time windows are constructed in parallel, may also be:
[0108] By reading a synchronized, standardized data matrix, a triple-nested window mechanism is used to simultaneously construct a 1-minute high-frequency response window, a 15-minute medium-frequency stability window, and a 1-hour low-frequency trend window. Each window maintains its own independent data buffer, resulting in a hierarchical time-windowed dataset and window synchronization markers. While traditional methods use a single fixed window, this method's three-layer nested mechanism can simultaneously capture causal characteristics at different time scales.
[0109] According to one aspect of the present application, S122, calculating the mutual information entropy-Granger fusion causal strength, may also be:
[0110] Read the layered time window dataset and use the fusion calculation formula:
[0111] Standardization processing: MI_norm=(MI(X;Y|Z)-MI_min) / (MI_max-MI_min); GC_norm=(GC(X→Y)-GC_min) / (GC_max-GC_min); TC_norm=(TC(X,Y,t)-TC_min) / (TC_max-TC_min);
[0112] Adaptive weight calculation: α = 0.4 + 0.2 × window stability coefficient; β = 0.3 + 0.2 × temporal correlation strength; γ = 1 - α – β;
[0113] Calculate the comprehensive causal strength = (α×MI_norm^2+β×GC_norm^2+γ×TC_norm^2)^0.5;
[0114] Where MI_norm is the normalized mutual information entropy, GC_norm is the normalized Granger causality, and TC_norm is the normalized temporal consistency coefficient. The weights are dynamically adjusted based on the window type and data characteristics, resulting in a multidimensional causal strength vector. Existing methods use Granger causality or mutual information alone. This method standardizes and fuses these three causal metrics and adopts the Euclidean norm to eliminate dimensionality effects and improve the robustness of causal identification.
[0115] According to one aspect of the present application, S212, calculating the local impact propagation range, may also be:
[0116] Read the abnormal node list, abnormal intensity level and multi-level causal map, and use the influence propagation attenuation formula:
[0117] Normalized edge weight accumulation: edge weight accumulation_norm = Σ(edge weight_i) / √(path length);
[0118] The revised impact propagation formula is as follows: impact range (d) = initial intensity × e^(-λd) × edge weight accumulation_norm × attenuation adjustment factor; where: λ is the adaptive attenuation coefficient = 0.3 + 0.2×(abnormal intensity level / 5); the attenuation adjustment factor = min(1.0, 2.0 / d) prevents excessive amplification of long-distance propagation; the propagation depth is limited to 3 hops forward and 3 hops backward; the affected area identification and normalized impact intensity distribution map are obtained.
[0119] The traditional method requires full graph traversal calculation, with a complexity of O(n 2 This method avoids the exponential explosion problem through normalization processing and adaptive attenuation mechanism, reducing the complexity to O(k·logn), where k is the number of affected nodes, significantly improving computational efficiency and numerical stability.
[0120] About the specific implementation process of path update.
[0121] Critical Path Index (Real-time Update): Critical paths carry the majority of query load and must be kept up to date. Therefore, when changes to the causal graph affect critical paths, these paths are immediately and completely updated, including recalculating path weights, verifying path validity, and updating index records.
[0122] Critical Path Index (Delayed Update): To ensure path availability while reducing maintenance frequency, affected critical paths are not updated immediately. Instead, they are marked as "pending" and added to a delayed update queue. Updates are processed in batches at a predetermined interval, such as every 60 seconds (or 15 minutes, etc., as configured internally).
[0123] Background Path Index (Query-Time Verification): Affected background paths are also marked as "pending verification" but are not actively updated. Verification is performed only when a user actually queries the path. The verification process involves checking the current state of each edge in the path. If the edge still exists and its weight has changed by less than 10%, it is marked as valid and continues to be used. If the edge is invalid, it is removed from the index and an alternative path is recalculated.
[0124] Specifically, the critical path is "push updates" (active system updates), the important path is "scheduled batch updates," and the background path is "pull verification" (passive verification during queries). By using differentiated strategies to precisely match the frequency and importance of different paths, we achieve optimal allocation of index maintenance overhead.
[0125] In another embodiment of the present application,
[0126] Generate a real-time valid path index, including:
[0127] Read the causal relationship basic index and dynamic multi-level causal graph, and calculate the importance score of each node through the node importance quantitative evaluation algorithm, where the node importance score = (degree centrality × 0.3) + (normalized access frequency value × 0.4) + (sum of causal strength × 0.3), where degree centrality is the number of nodes connected, the normalized access frequency value is the number of historical query statistics divided by the maximum number of queries, and the sum of causal strength is the cumulative value of the weights of all nodes connected to the node;
[0128] Based on the node importance score, the path importance of each pre-calculated path is calculated using the path importance evaluation formula: path importance = starting point importance × 0.4 + end point importance × 0.4 + average importance of intermediate nodes × 0.2. This is adjusted based on the historical query frequency correction coefficient to generate a path importance ranking table.
[0129] The pre-computed paths are divided into three levels according to the preset importance threshold: paths with an importance score greater than 0.8 are stored in the key path index, using a hash table structure to achieve O(1) query complexity; paths with an importance score between 0.5 and 0.8 are stored in the important path index, using a B+ tree structure to achieve O(logn) query complexity; paths with an importance score less than 0.5 are stored in the background path index, using a compressed storage structure;
[0130] Add a timeliness mark to each pre-computed path, including the last verification timestamp, the list of involved edge identifiers, and the validity status flag. When the weight of any edge involved in the path changes, the validity status is marked as "pending verification";
[0131] Differentiated lazy update strategies are implemented based on the index level to which the paths belong: paths marked as "pending verification" in the critical path index are immediately revalidated and updated; paths marked as "pending verification" in the important path index are added to a delayed update queue for batch processing; paths marked as "pending verification" in the background path index are only verified immediately upon receiving a query request. If verification passes, the path is retained in the index; if verification fails, the path is removed and an alternative path is calculated, generating a hierarchically maintained, real-time, valid path index.
[0132] In another embodiment of the present application, generating a dynamic multi-level causal graph and a real-time effective path index specifically includes:
[0133] The affected area identifier and anomaly intensity level are read, and a resource allocation plan is determined using a three-tiered intelligent computing resource allocation algorithm: the basic resource allocation ratio is set to 15% CPU for the real-time layer, 20% CPU for the quasi-real-time layer, and 10% CPU for the background layer. An adjustment coefficient is calculated based on the anomaly intensity level = anomaly intensity level / 5. The CPU allocation ratio of each layer is dynamically adjusted: real-time layer CPU allocation = 15% + 10% × adjustment coefficient, quasi-real-time layer CPU allocation = 20% + 5% × adjustment coefficient, and background layer CPU allocation = 10% - 5% × adjustment coefficient. This generates a tiered resource allocation table.
[0134] According to the hierarchical resource allocation table, task distribution is performed through a time slice round-robin scheduling strategy: the real-time layer adopts a continuous execution mode with a time slice length of 50 milliseconds to process high-priority causal edge updates; the quasi-real-time layer adopts a scheduled execution mode with an execution interval of 30 seconds to process medium-priority causal edge updates; the background layer adopts a low-frequency execution mode with an execution interval of 5 minutes to process low-priority causal edge updates, and supports a preemptive scheduling mechanism that can interrupt low-priority tasks when new abnormal events are detected;
[0135] Monitor the total CPU usage of the system in real time. When the total CPU usage exceeds the preset load threshold of 50%, the downgrade strategy is automatically triggered: background layer update tasks are suspended to free up computing resources, the quasi-real-time layer execution interval is extended to 45 seconds, and the normal scheduling strategy is restored when the CPU usage drops below the threshold.
[0136] For the hierarchical update task queue, the real-time electricity consumption data stream is read, and incremental weight calculation is performed on the causal edges that need to be updated: new edge weight = old edge weight - (expired data contribution / time window size) + (new data contribution / time window size). At the same time, the number of consecutive updates and the weight error change trend of each edge are recorded. When the number of consecutive updates exceeds 100 times or the weight error rate exceeds 5%, the edge is marked as requiring precision correction and the edge weight is recalculated based on the complete historical data. A dynamic multi-level causal graph and real-time valid path index maintained by three-layer asynchronous scheduling are generated.
[0137] It should be noted that the sequence numbers of the above steps are for convenience of description only and are not intended to limit the specific order. For example, step S32 can be performed after step S23. This results in: S24: Real-time valid path index construction and maintenance: Read the dynamically updated causal graph, construct and maintain the hierarchical path index, and output the real-time valid path index.
[0138] In one embodiment, a user's power consumption anomaly (a sudden increase from a normal 2.5kW to 8.2kW) at 2:30 PM on May 28, 2025, is detected and an explainable causal analysis is provided. It should be noted that this method is generally applied to power consumption in industrial parks or shopping malls. To simplify the description, the data processing process is described using household power consumption.
[0139] Prepare initial data, including smart meter data: 15-minute power time series and historical data from the past 30 days. User equipment list: 3 air conditioners, 1 water heater, 1 washing machine, and 1 refrigerator. Environmental data: Temperature: 32°C, humidity: 85%, sunny.
[0140] Step S1: Multi-source data fusion and multi-time scale causal relationship discovery
[0141] S11. Standardization of multi-source heterogeneous data: Meter raw data P_raw = [2.3, 2.5, 2.4, 2.6, 8.2, 3.1, 2.8] kW; temperature data T_raw = [28, 30, 32, 32, 32, 31, 29] °C; device status S_raw = [AC 1: On, AC 2: Off, AC 3: On, Water heater: On];
[0142] Power normalization P_norm = (P_raw - P_min) / (P_max - P_min) = (8.2 - 2.3) / (8.2- 2.3) = 1.0; temperature normalization T_norm = (32 - 28) / (32 - 28) = 1.0; obtain the synchronization normalization data matrix D_sync[timestamp, P_norm, T_norm, S_norm].
[0143] S12. Parallel calculation of causal strength in multiple time windows
[0144] S121. According to the modified plan, a three-layer time window is constructed. Among them, W1: 1-minute high-frequency response window (obtained by interpolating 15-minute data); W2: 15-minute medium-frequency stability window (directly using collected data); W3: 1-hour low-frequency trend window (aggregated from four 15-minute data);
[0145] W1 data: P1_min = [2.3, 2.4, 2.5, 8.2] kW (interpolated within 1-minute intervals); W2 data: P15_min = [2.5, 8.2, 3.1] kW (15-minute raw data); W3 data: P1_hour = [3.8] kW (1-hour average); obtain the hierarchical time window dataset {W1_data, W2_data, W3_data} and window synchronization marker
[0146] S122, Mutual Information Entropy-Granger Fusion Causal Strength Calculation
[0147] Step 1. Calculate the original indicators: Mutual Information Entropy MI(power, temperature) = 0.73; Granger Causality GC(temperature→power) = 0.81; Temporal Consistency Coefficient TC(power, temperature, t) = 0.65;
[0148] Step 2. Standardization: Based on the historical 30-day data statistics: MI_min = 0.12, MI_max = 0.89, GC_min = 0.08, GC_max = 0.95, TC_min = 0.15, TC_max = 0.88; the standardization process is: MI_norm = (MI - MI_min) / (MI_max - MI_min) = (0.73 - 0.12) / (0.89 - 0.12) = 0.79; GC_norm = (GC - GC_min) / (GC_max - GC_min) = (0.81 - 0.08) / (0.95 - 0.08) = 0.84; TC_norm = (TC - TC_min) / (TC_max - TC_min) = (0.65 - 0.15) / (0.88 - 0.15) = 0.68; where: MI_norm is the normalized mutual information entropy; GC_norm is the normalized Granger causality; TC_norm is the normalized temporal consistency coefficient
[0149] Step 3. Calculate the adaptive weight: Current window stability coefficient = 0.6 (calculated based on variance); Time series correlation strength = 0.7 (based on correlation coefficient); Calculate the adaptive weight α = 0.4 + 0.2 × window stability coefficient = 0.4 + 0.2 × 0.6 = 0.52; β = 0.3 + 0.2 × time series correlation strength = 0.3 + 0.2 × 0.7 = 0.44; γ = 1 - α - β = 1 - 0.52 - 0.44 = 0.04; where: α is the mutual information weight coefficient; β is the Granger causality weight coefficient; γ is the temporal consistency weight coefficient; the window stability coefficient is the inverse of the data variance in the current time window; the time series correlation strength is the absolute value of the Pearson correlation coefficient between variables.
[0150] Step 4. Calculate the fusion strength: comprehensive causal strength K = (α×MI_norm 2 + β×GC_norm 2 + γ×TC_norm 2 )^0.5 = (0.52×0.79 2 + 0.44×0.84 2 + 0.04×0.68 2)^0.5 = (0.52×0.624 +0.44×0.706 + 0.04×0.462)^0.5 = (0.325 + 0.311 + 0.018)^0.5 = 0.81; where: K is the comprehensive causal strength; MI_norm 2 is the square of the normalized mutual information entropy; GC_norm 2 is the square of the standardized Granger causality; TC_norm 2 is the square of the standardized time consistency coefficient; the multidimensional causal strength vector V_causal = [0.81,0.76, 0.68] (corresponding to three time windows) is obtained.
[0151] S123: Causal Stability Score Calculation
[0152] Cross-window consistency verification: stability score = 1 - std(V_causal) / mean(V_causal) = 1 -0.07 / 0.75 = 0.91; obtained causal stability score = 0.91, multi-scale causal strength matrix.
[0153] S13: Hierarchical Causal Graph Construction and Index Generation
[0154] Based on the multi-scale causal strength matrix, a three-layer causal graph is constructed. The real-time layer (critical path): edges with strength > 0.8, including the "temperature → power" edge, with a weight of 0.81; the quasi-real-time layer (important path): edges with strength 0.6-0.8, including the "device status → power" edge, with a weight of 0.76; the background layer (other low-frequency paths): edges with strength < 0.6, including other weakly correlated edges. This yields a multi-layer causal graph G_multi = {G_real, G_quasi, G_back} and a causal relationship base index Index_base.
[0155] Step S2: Dynamic causal graph maintenance and update
[0156] S21: Intelligent identification mechanism of affected areas
[0157] S211: Abnormal Node Rapid Location Algorithm
[0158] Anomaly detection: User historical baseline power P_baseline = 2.5 kW; current power P_current = 8.2 kW; 3σ threshold = P_baseline + 3×std_history = 2.5 + 3×0.3 = 3.4 kW; Anomaly judgment: P_current > 2×P_baseline and P_current > 3σ threshold; 8.2 > 2×2.5 = 5.0 and 8.2 > 3.4; Obtain abnormal node list = ["power node"], anomaly intensity level = 4 (levels 1-5);
[0159] S212: Calculation of local impact propagation range
[0160] Impact propagation calculation: initial intensity I0 = 4 (abnormal intensity level); propagation hop number d = 1, 2, 3;
[0161] Edge weight accumulation_norm = Σ(edge weight_i) / √(path length) = (0.81 + 0.76) / √2 = 1.57 / 1.41 = 1.11; adaptive attenuation coefficient λ = 0.3 + 0.2×(anomaly intensity level / 5) = 0.3 + 0.2×(4 / 5) = 0.46; attenuation adjustment factor = min(1.0, 2.0 / d) = min(1.0, 2.0 / 1) = 1.0; influence range I(d) = initial intensity × e^(-λd) × edge weight accumulation_norm × attenuation adjustment factor = 4×e^(-0.46×1)×1.11×1.0 = 4×0.63×1.11 = 2.80; where: edge weight_i is the weight value of the i-th edge; path length is the number of hops from the abnormal node to the current node; d is the number of propagation distance hops; I(d) is the influence intensity at distance d.
[0162] Calculation of the impact intensity of each hop: d=1: I(1) = 4×e^(-0.46×1)×1.11×1.0 = 2.80; d=2: I(2) = 4×e^(-0.46×2)×0.98×1.0 = 1.56; d=3: I(3) = 4×e^(-0.46×3)×0.87×0.67 = 0.74 (attenuation adjustment factor = 2.0 / 3 = 0.67 when d=3); obtain the affected area identifier = {node 1: 2.80, node 2: 1.56, node 3: 0.74}, and the impact intensity distribution diagram.
[0163] S213. Dynamic impact weight allocation mechanism: Based on the inverse proportional adjustment of impact strength and stability score: Node 1 update priority = 2.80×(1-0.91) = 2.80×0.09 = 0.25; Node 2 update priority = 1.56×(1-0.76) = 1.56×0.24 = 0.37; obtain the weighted impact area map (Node 2 has the highest priority).
[0164] S22: Distributed asynchronous update scheduling mechanism
[0165] S221: Three-tier computing resource intelligent allocation algorithm
[0166] Basic resource allocation: real-time layer: 15% CPU; quasi-real-time layer: 20% CPU; background layer: 10% CPU;
[0167] Abnormality adjustment (abnormality intensity level 4): Adjustment coefficient = abnormality intensity level / 5 = 4 / 5 = 0.8; Resource allocation adjustment: Real-time layer CPU allocation = 15% + 10% × adjustment coefficient = 15% + 10% × 0.8 = 23%; Quasi-real-time layer CPU allocation = 20% + 5% × adjustment coefficient = 20% + 5% × 0.8 = 24%; Background layer CPU allocation = 10% - 5% × adjustment coefficient = 10% - 5% × 0.8 = 6%; where the adjustment coefficient is the ratio of the abnormality intensity level to the maximum level; the CPU allocation percentage is the proportion of total system computing resources occupied. The resulting layered resource allocation table = {Real-time layer: 23%, Quasi-real-time layer: 24%, Background layer: 6%}.
[0168] S222, time slice round-robin scheduling strategy implementation:
[0169] Time slice allocation: Real-time layer: Continuously execute 50ms time slices and immediately process high-priority nodes; Quasi-real-time layer: 30-second interval execution and process medium-priority nodes; Background layer: 5-minute interval execution and process low-priority nodes;
[0170] Current execution queue: high priority queue: [node 2] (priority 0.37); medium priority queue: [node 1] (priority 0.25); low priority queue: [other nodes]; get the hierarchical update task queue and scheduling execution schedule;
[0171] S223, Dynamic load monitoring and adaptive adjustment
[0172] Load monitoring: Current CPU usage = real-time layer 23% + quasi-real-time layer 24% + background layer 6% = 53%;
[0173] Load threshold = 50%; since 53% > 50%, the degradation strategy is triggered: background layer updates are suspended (6% CPU is released); the quasi-real-time layer interval is extended to 45 seconds; and the optimized layer update task queue is obtained;
[0174] S23: Incremental Causal Edge Weight Correction Algorithm
[0175] S231: Sliding window incremental weight update
[0176] Current edge weight update: "Temperature→Power" edge; historical weight W_old = 0.81; window size N = 15 (15 data points); expired data contribution = 0.73 × (1 / 15) = 0.049; new data contribution = 0.89 × (1 / 15) = 0.059;
[0177] Incremental update: New edge weight W_new = Old weight W_old - (Expired data contribution / Window size) + (New data contribution / Window size) = 0.81 - 0.049 + 0.059 = 0.82; where: W_old is the historical edge weight value; Expired data contribution is the contribution of the removed data in the sliding window to the weight; New data contribution is the contribution of the newly added data in the sliding window to the weight; Window size is the number of data points contained in the sliding window; The obtained incremental update weight table = {"Temperature→Power": 0.82}.
[0178] S232, real-time detection mechanism of cumulative error
[0179] Error tracking: Number of consecutive updates for this edge = 87; Current error rate = |0.82-0.81| / 0.81 = 1.2%;
[0180] Inspection conditions: Number of consecutive updates 87 < 100; Error rate 1.2% < 5%; Obtain error monitoring report (this side does not require correction at this time).
[0181] S233: Adaptive precision correction execution
[0182] Other side "Device Status → Power": Continuous update times = 103 times > 100 times, triggering correction;
[0183] Recalculated using complete historical data: Corrected weight = 0.74 (based on full 30-day data); Original weight = 0.71; Corrected error = |0.74-0.71| / 0.71 = 4.2% < 5%; Result: Dynamically updated causal graph (edge weights have been corrected);
[0184] Step S3: Query-driven rapid reconstruction of causal paths
[0185] S31: Query intent analysis and path requirement identification
[0186] User query: "Why did the power suddenly increase to 8.2kW at 2:30 PM?"
[0187] The parsing results include: Query type: Real-time exception explanation; Source node set: ["power node"]; Target node set: ["temperature node", "device status node"]; Query priority: High;
[0188] S32: Hierarchical index dynamic maintenance mechanism
[0189] S321: Construction of three-level path index architecture
[0190] S3211: Quantitative Assessment of Node Importance
[0191] Calculate the importance of the "power node": degree centrality = 5 (connected to 5 edges); access frequency = 120 times / month (historical query statistics); sum of causal strengths = 0.82 + 0.76 + 0.68 + 0.45 + 0.33 = 3.04; node importance = (degree centrality × 0.3) + (access frequency × 0.4) + (sum of causal strengths × 0.3) = (5 × 0.3) + (120 × 0.4) + (3.04 × 0.3) = 1.5 + 48.0 + 0.91 = 50.41. Where: degree centrality is the number of edges connected to the node; access frequency is the monthly number of times the node is involved in historical queries; sum of causal strengths is the cumulative value of the weights of all connected edges. The resulting node importance score table is {"power node": 50.41, "temperature node": 35.62, "device status node": 28.34}.
[0192] S3212: Comprehensive calculation of path importance
[0193] Importance of the path "Temperature→Power": Starting point importance: 35.62, end point importance: 50.41; Path importance = 35.62 × 0.4 + 50.41 × 0.4 = 34.41; Historical query frequency correction coefficient = 1.2; Final path importance = 34.41 × 1.2 = 41.29; Obtain the path importance ranking table;
[0194] S3213: Three-level index hierarchical storage: Importance grading (threshold: critical > 40, important 20-40, background < 20): Critical path index: ["temperature → power"] (importance 41.29); important path index: ["device status → power"] (importance 28.34); background path index: [other low-frequency paths]; obtain the hierarchical path index architecture.
[0195] S322, precise implementation of lazy update strategy
[0196] S3221, Path Timeliness Marking Mechanism: "Temperature → Power" Path Marker: Last Verified Time: 2025-05-28 14:25:30; Involved Edge Identifier: ["edge_temp_power"]; Validity Status: Pending Verification (because the edge weight was updated from 0.81 to 0.82);
[0197] S3222. Hierarchical update strategy execution: Critical path immediate verification: The path "temperature → power" is immediately verified in the critical path index; verification result: edge weight change <10%, the path is still valid; obtain the updated timeliness marked path index;
[0198] S33: Fast Path Reconstruction and Verification Algorithm
[0199] S331. Multi-level degraded path search strategy: First-level search (critical path index, target <50ms): Search for the path from "power node" to "temperature node"; Found the path: ["power"←"temperature"], which takes 32ms; Search successful, no need to enter the second or third level search; Obtain candidate path set = [["power"←"temperature"]], Search duration record = 32ms.
[0200] S332. Parallel verification mechanism for path validity. Verify the path ["power"←"temperature"]: Check edge weight: 0.82 > threshold 0.5; Check connectivity: The edge exists in the current graph; Obtain valid path set = [["power"←"temperature"]].
[0201] S333. Calculation of a comprehensive path quality score. Path ["Power"←"Temperature"] score: Causal strength weight = 0.82; Path length weight = 1.0 / 1 = 1.0 (path length is 1); Historical success rate = 0.95 (based on historical statistics). Path score = (Causal strength weight × 0.4) + (Path length weight × 0.3) + (Historical success rate × 0.3) = (0.82 × 0.4) + (1.0 × 0.3) + (0.95 × 0.3) = 0.328 + 0.300 + 0.285 = 0.913. Here, the causal strength weight is the average edge weights in the path; the path length weight is the inverse of the path length; the historical success rate is the proportion of successful explanations for the path in historical queries. 0.4, 0.3, and 0.3 are the weight coefficients for the three scoring dimensions, respectively. The resulting target causal path set = [["Power"←"Temperature", score 0.913]], along with the path credibility distribution.
[0202] Step S4: Counterfactual reasoning verification and explanation output
[0203] S41. Automatic generation of counterfactual scenarios
[0204] Scenario 1: Remove the "Temperature→Power" causal edge; Scenario 2: The temperature remains at 28°C (does not rise to 32°C). Obtain a set of counterfactual scenarios and the expected range of outcomes.
[0205] S42. Simulation Verification and Credibility Quantification Evaluation
[0206] Scenario 1 simulation: After removing the temperature effect, the predicted power should be 2.8kW; Scenario 2 simulation: When the temperature remains unchanged, the predicted power should be 2.6kW; Actual power: 8.2kW; Consistency comparison: Scenario 1 accuracy = 1-|2.8-8.2| / 8.2 = 0.34; Scenario 2 accuracy = 1-|2.6-8.2| / 8.2 = 0.68; Resulting explanation credibility score = 0.68
[0207] S43. Comprehensive interpretation report generation
[0208] The power usage anomaly analysis results include: Main cause: The ambient temperature increased from 28°C to 32°C, triggering the simultaneous startup of multiple air conditioners; Causal relationship strength: The impact of temperature on power is 0.82 (strong correlation); Impact delay: The power response occurs within 15 minutes of the temperature change; Confidence interval: Based on historical data, the power range at 32°C is [7.8kW, 8.6kW], and the current 8.2kW is within the normal range; Credibility score: 0.68 (moderately reliable);
[0209] Technical indicators: Path search time: 32ms < 50ms target; Causal strength: 0.82 > 0.8 threshold (strong causal relationship); Prediction accuracy: 68% (in line with the expected range).
[0210] Hierarchical lazy index update effect: The traditional method requires updating all path indexes, which takes 150ms. This method only updates the queried key path, which takes 32ms, improving efficiency by 78.7%.
[0211] Local influence propagation update effect: The traditional method of full graph traversal O(n 2 ), n=1000 nodes, requiring 1,000,000 calculations; the 3-hop limit of this method is O(k·logn), k=8 affected nodes, requiring 24 calculations; the computational effort is reduced by 99.998%.
[0212] The effect of three-layer asynchronous scheduling: The traditional synchronous method has a peak CPU load of 85% and a response delay of 200ms; this method has an average CPU load of 53% and a response delay of 32ms; the load is reduced by 37.6% and the response speed is increased by 84%.
[0213] In another embodiment of the present application, edge failure is handled as follows:
[0214] According to one aspect of the present application, a method for handling edge failures in a causal path is as follows: A smart meter monitoring system in an industrial park detects that the air conditioning control system is offline at 9:15 AM on May 29, 2025, causing the causal edge "temperature → air conditioning power" to fail. The system performs the following processing flow:
[0215] Edge Failure Detection and Impact Assessment: The system determined that the edge_temp_ac had a hard failure after failing to obtain air conditioner power data for five consecutive minutes. The historical weight of this edge was 0.76, and its current weight could not be calculated. Analysis of the impact of the failed edge revealed that it involved the critical path ["Temperature" → "Air Conditioner Power" → "Total Power"], impacting the real-time interpretation of energy consumption anomalies. The system identified three alternative paths: Path 1: ["Temperature" → "Device Status" → "Total Power"], with a weight of 0.68; Path 2: ["Temperature" → "Ambient Comfort" → "Air Conditioner Demand" → "Total Power"], with a weight of 0.54; and Path 3: ["External Weather" → "Temperature Change" → "Total Power"], with a weight of 0.41.
[0216] Alternative Path Selection and Reconstruction: The system uses the priority calculation formula (Priority = Path Weight × 0.4 + Response Speed × 0.3 + Historical Success Rate × 0.3) to select alternative paths. Path 1 scores 0.68 × 0.4 + 0.85 × 0.3 + 0.92 × 0.3 = 0.803, Path 2 scores 0.54 × 0.4 + 0.62 × 0.3 + 0.88 × 0.3 = 0.666, and Path 3 scores 0.41 × 0.4 + 0.78 × 0.3 + 0.73 × 0.3 = 0.617. The system selects Path 1 as the primary alternative path. The overall strength of the original path is 0.76 × 0.82 = 0.623, while the overall strength of the alternative path is 0.68 × 0.71 = 0.483, with a strength decay rate of 22.5%. To compensate for the loss of accuracy, the system increases the temporal consistency weight γ from 0.2 to 0.35 and introduces a historical pattern correction factor of 1.15. The corrected strength is 0.483×1.15=0.555.
[0217] Real-time Verification and Performance Monitoring: During a 30-minute continuous verification period, when the temperature rose from 28°C to 32°C, the expected power change on the alternative path was +2.1kW, and the actual power change was +2.4kW, with a prediction accuracy of 87.5%. When a user queried, "Why did the power suddenly increase at 9:30 AM?" the system explained, based on the alternative path, that "the temperature increase caused the device to adjust its status, affecting total power." The response time was 58ms, slightly higher than the normal 45ms but still within the target range of 100ms.
[0218] Automatic recovery and switchover: The system checks the status of the original edge every 60 seconds. At 10:42:15, it detected that the air conditioning control system was back online and data transmission had returned to normal. The edge weight was recalculated to 0.74. The system compared the current alternative path performance of 87.5% with the expected performance of the original path after recovery, which was 91.2%. The switchover benefit of 3.7% exceeded the 3% threshold, triggering a switchover decision. A gradual switchover strategy was implemented, with 50% of queries using the original path and 50% using the alternative path. After a 15-minute observation period, the original path was fully switched back to after verification. This processing method achieved fault detection time of less than 5 minutes, alternative path activation time of less than 2 minutes, and service interruption time of 0 minutes. The interpretation accuracy remained at 88.7%, and compared to traditional methods, availability increased from 95% to 99.7%.
[0219] In another embodiment of the present application, if a real-time effective path is calculated after calculating the causal graph, the process is as follows: when a power anomaly (2.5kW→8.2kW) is detected at 14:30 on May 28, 2025, the system executes an integrated graph update and index construction process.
[0220] Identifying affected areas and allocating resources: The system identified the abnormal node as a power node, with an impact range of three hops forward and three hops backward. The affected edges included "temperature → power," "device status → power," and "power → total power consumption." Based on anomaly severity level 4, resource allocation was adjusted to 23% CPU for the real-time layer, 24% for the quasi-real-time layer, and 6% for the background layer. The weight of the "temperature → power" edge was updated from 0.81 to 0.82, and the error detection was 1.2%, below the 5% threshold and requiring no correction.
[0221] Synchronous real-time valid path index construction: Simultaneously with the graph update, the system performs real-time recalculation of node importance. The sum of the causal strength of the "power node" increased from 3.04 to 3.05, and the importance score was updated from 50.41 to 50.44. The computational overhead was O(k), where k is the number of affected nodes (3), and the execution time was less than 5ms. During the dynamic adjustment of path importance, the endpoint importance of the "temperature→power" path changed, causing the path importance to increase from 34.41 to 34.42. After correction, the path importance was 41.30, but it remained in the critical path index. The computational overhead was O(m), where m is the number of affected paths (2), and the execution time was less than 3ms.
[0222] Real-time maintenance and consistency verification of hierarchical indexes: The system updates the hash table of the key path index, with the key being "power_node" and the value being updated to {path:["power"←"temperature"], weight: 0.82, timestamp: 14:30:23}. The hash table operation has an O(1) computational overhead and executes in less than 1ms. Index consistency verification is performed only on the affected key paths. The "temperature→power" path passes edge existence checks, weight change checks (1.2% less than the 10% threshold), and connectivity checks. The verification result confirms that the path remains indexed. The computational overhead is O(p×e), where p is the number of paths (1) and e is the average path length (1), and the execution time is less than 2ms.
[0223] Performance optimization effect analysis: Under the integrated solution, the execution time of step S2 is 56ms (45ms graph update + 11ms index construction), the execution time of step S3 is 32ms (pure path search), and the total response time is 88ms. Compared with the original solution's 92ms (45ms + 47ms), the performance is improved by 4.3%. In terms of CPU utilization, the adjusted S2 stage is 58% CPU, and the S3 stage is 10% CPU, compared with the original solution's 53% and 15%, achieving smooth resource utilization. It is particularly suitable for high-frequency query scenarios (query frequency greater than 100 times / minute) and application environments with high real-time requirements (response time less than 100ms). Through the integrated processing of graph updates and index maintenance, the overall response performance and resource utilization efficiency of the system are improved.
[0224] It should be noted that when CPU utilization exceeds 70% in the S2 phase, the system automatically activates a downgrade mechanism and reverts to the S3 index building mode to ensure system stability. This integrated solution achieves logical consistency in data updates and index maintenance, avoiding duplicate calculations and providing a more efficient technical solution for real-time maintenance of smart meter causal graphs.
[0225] In another embodiment of the present application, a hybrid strategy may be used for the calculation process of the real-time effective path index. For example, schemes A and B may be set. Scheme A (implemented in S2 ) emphasizes data consistency and query performance. Scheme B (implemented in S32 ) emphasizes modular design and resource efficiency.
[0226] Dynamic selection based on system operating status, as follows:
[0227] During high load periods (query frequency > 100 / minute): Use solution A to pre-build indexes on S2; prioritize query response performance.
[0228] During low load (query frequency < 50 / minute): Use solution B and build on demand in S32; save system resources.
[0229] System startup: Use Plan B to avoid resource contention during startup. Switch to Plan A after the system stabilizes.
[0230] Abnormal recovery phase: Use Plan A to ensure data consistency and quickly respond to user queries.
[0231] In another embodiment of the present application, the calculation process of the window stability coefficient is as follows:
[0232] Step 1: Read the power series data P = [P1, P2, ..., P n ], where n is the window size, and the sample variance σ of the power data is calculated 2 = Σ(P i - P*) 2 / (n-1); where P* is the arithmetic mean of the power data: P*= Σ(P i ) / n;
[0233] Step 2: To eliminate the influence of numerical magnitude on stability assessment, calculate the relative coefficient of variation CV = σ / P*; where σ is the standard deviation, σ = sqrt (σ 2 );
[0234] Step 3: Use the reciprocal transformation to convert the coefficient of variation into a stability coefficient. A larger value indicates greater stability. Window stability coefficient = 1 / (1 + CV). This formula ensures that the stability coefficient ranges from (0, 1). When CV = 0 (completely stable), the coefficient is 1, and when CV → ∞ (extremely unstable), the coefficient approaches 0.
[0235] Example: For the power sequence P = [2.3, 2.5, 2.4, 2.6, 2.4] kW, the calculation process is: average value P* = (2.3+2.5+2.4+2.6+2.4) / 5 = 2.44 kW; variance σ 2 = [(2.3-2.44) 2 + (2.5-2.44) 2 +(2.4-2.44) 2 + (2.6-2.44) 2 + (2.4-2.44) 2 ] / 4 = 0.013; standard deviation σ = sqrt 0.013 = 0.114; coefficient of variation CV = 0.114 / 2.44 = 0.047; window stability coefficient = 1 / (1+0.047) = 0.955;
[0236] Time series correlation strength is used to quantify the degree of time series correlation between variables and guide the dynamic adjustment of Granger causality weights. The specific calculation process is as follows:
[0237] Step 1: Read the normalized power time series data X = [X1, X2, ..., X n ] and temperature time series data Y =[Y1, Y2, ..., Y n ], calculate the Pearson correlation coefficient under different lag periods τ: ρ(τ) = Σ[(X i - X*)(Y i+τ –Y*)] / √[Σ(X i - X*) 2 × Σ(Y i+τ –Y*) 2 ]; where τ is the lag period, ranging from 0 to the maximum lag period T max (Usually set to 5 time points).
[0238] Step 2: Identify the maximum absolute value of the correlation coefficient ρ among all lags max = max{|ρ(0)|, |ρ(1)|,..., |ρ(T max )|}
[0239] Step 3: Considering the continuity of the time series, the weighted average method is used to calculate the time series correlation strength = 0.5 × ρ max + 0.3 × |ρ(1)| + 0.2 × |ρ(2)|; this formula highlights the dominant role of the strongest correlation while taking into account the contribution of short-term lagged correlations.
[0240] Step 4: To avoid the influence of outliers, perform boundary constraints and smoothing on the calculated results: time series correlation strength final = min(max(time series correlation strength × smoothing factor, 0.1), 0.9). The smoothing factor = 0.9 + 0.1 × window stability coefficient, ensuring a high correlation strength when the data is stable.
[0241] For the power series X = [0.3, 0.5, 0.4, 0.6, 0.4] and the temperature series Y = [0.2, 0.4,0.6, 0.6, 0.5]: zero-lag correlation ρ(0) = 0.76; one-lag correlation ρ(1) = 0.82; two-lag correlation ρ(2) = 0.65; maximum correlation ρ max= 0.82; time series correlation strength = 0.5×0.82 + 0.3×0.82 +0.2×0.65 = 0.786; smoothing factor = 0.9 + 0.1×0.955 = 0.996; final time series correlation strength = min(max(0.786×0.996, 0.1), 0.9) = 0.783.
[0242] In summary, this solution solves the traditional O(n 2 ) level of computational complexity. Specifically, when a smart meter detects abnormal power consumption, the traditional method needs to recalculate the relationship between all nodes and edges in the entire causal graph. However, this method uses the influence propagation attenuation formula I(d) = initial intensity × e^(-λd) × edge weight accumulation_norm × attenuation adjustment factor to accurately limit the update range to the forward 3 hops and backward 3 hops of the abnormal node. By taking advantage of the localized nature of abnormal influence in the power consumption system, the computational complexity is reduced from O(n 2 ) is reduced to O(k•logn). Simultaneously, three-layer asynchronous time-slice round-robin scheduling is used to implement layered processing based on the importance and timeliness of causal relationships: the real-time layer handles critical device anomalies (50ms time slices), the quasi-real-time layer handles general status changes (30-second intervals), and the background layer handles historical trend analysis (5-minute intervals). This avoids computational load spikes associated with synchronous batch updates, achieving a 99.998% reduction in computational effort and millisecond-level response times in a 1,000-node smart meter network.
[0243] A hierarchical lazy index update mechanism revolutionizes the traditional full-sync index maintenance strategy, reducing index maintenance overhead from over 30% to under 10%. Specifically, based on the 80 / 20 distribution of smart meter queries, the precomputed paths are categorized into three levels using quantitative node importance assessment: critical path index (importance > 0.8), important path index (importance 0.5-0.8), and background path index (importance < 0.5). Differentiated lazy update strategies are then employed. Critical paths, which carry 80% of the query load, are updated immediately to ensure real-time availability. Important paths utilize delayed batch updates to reduce maintenance frequency. Background paths are validated only when they are actually queried, avoiding unnecessary maintenance of a large number of infrequent paths. A timeliness marking mechanism, combined with the recording of the last path validation time and the state changes of the involved edges, allows for precise control of the update scope, achieving the technical goal of significantly reducing index maintenance overhead while ensuring query performance.
[0244] The preferred embodiments of the present invention are described in detail above. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all fall within the scope of protection of the present invention.
Claims
1. A method for interpretable analysis of smart meter electricity consumption behavior based on causal graph, characterized by: The following steps are involved: Read the raw electricity consumption data of smart meters, and construct a primary multi-level causal graph through multi-source data fusion and multi-time scale causal relationship discovery; When abnormal power consumption is detected, the influence range of the abnormal node in the primary multi-level causal graph is identified, maintained and updated, and a dynamic multi-level causal graph and real-time effective path index are generated; Receive user query requests and search the key and important path indexes in the real-time valid path index in sequence. If no results are found, perform real-time search to obtain the target causal path set. Read the target causal path set, verify and explain the output through counterfactual reasoning, and generate a verified causal explanation report; Among them, the construction of a multi-level causal map includes: Read the original electricity consumption data of smart meters, perform standardization and stratification processing, and generate a stratified time window data set; Based on the hierarchical time window dataset, MI, GC and TC are calculated and fused to generate a multidimensional causal strength vector; Read the multi-dimensional causal strength vector, calculate each causal relationship and verify the stability at different time scales to generate a multi-scale causal strength matrix; Based on the multi-scale causal intensity matrix, causal relationships at different time scales are constructed and stored hierarchically to generate a multi-level causal graph and the corresponding causal relationship basic index; The key and important path indexes in the real-time valid path index are searched sequentially. If not found, a real-time search is performed, including: Respond to user query requests, identify the source node set and target node set through query type classification and key entity extraction, and output them; Read the dynamic multi-level causal graph and divide the pre-calculated paths in the causal relationship basic index into key path index, important path index and background path index to generate a real-time effective path index; For the source node set and the target node set, first search in the key and important path indexes. If not found, perform a real-time search in the background path index. Generate a multidimensional causal strength vector, including: Based on the hierarchical time window data set, the mutual information entropy MI, Granger causality GC and temporal consistency coefficient TC are calculated and normalized respectively; Calculate the dynamic weights α, β, and γ of MI, GC, and TC based on the window stability coefficient and the temporal correlation strength; Read the normalized MI, GC, TC and dynamic weights α, β, γ, and calculate the fusion strength K = (α × MI 2 +β×GC 2 +γ×TC 2 ) 0.5 , generating a multi-dimensional causal strength vector.
2. The method according to claim 1, characterized in that Generate real-time valid path index, including: Combined with multi-level causal graphs, abnormal nodes are identified from the current real-time electricity consumption data stream, the local impact propagation range is calculated, and the affected area identification is generated; Based on the identification of affected areas, distributed asynchronous update scheduling is performed on the real-time layer, quasi-real-time layer, and background layer through intelligent allocation of three-layer computing resources and time slice rotation scheduling strategy, generating an optimized layered update task queue; For the hierarchical update task queue and real-time electricity consumption data stream, weight update and accuracy correction are performed to generate a dynamically maintained multi-level causal graph and a real-time effective path index.
3. The method according to claim 2, characterized in that Generate dynamically maintained multi-level causal graphs and real-time effective path indexes, including: Based on the optimized hierarchical update task queue and real-time electricity consumption data stream, the new edge weight Q is calculated as old weight - (expired data contribution / window size) + (new data contribution / window size). Based on this incremental calculation, the incremental update weight table is obtained. For the incremental update weight table, record the number of consecutive updates and error change trends of each edge. When it exceeds the preset value, mark it as an edge that needs correction; For edges that need to be marked, the edge weights are recalculated and corrected based on complete historical data to generate a dynamically maintained multi-level causal graph and a real-time effective path index.
4. The method according to claim 2, characterized in that Calculate the local impact spread range and generate the affected area identification, including: Read real-time power consumption data streams and multi-level causal graphs, identify nodes where power changes exceed thresholds, and obtain a list of abnormal nodes and abnormal intensity levels. Based on this, the impact propagation formula is used to calculate the impact area and generate an impact intensity distribution map. The influence propagation formula is: Impact range I = initial intensity I0 × e -λd × Edge weight accumulation norm × attenuation adjustment factor; Where: Edge weight accumulation norm = Σ(edge weight i ) / sqrt(path length); d is the number of propagation hops, which is limited to 3 hops forward and 3 hops backward. The adaptive attenuation coefficient λ = 0.3 + 0.2 × (anomaly intensity level / 5).
5. The method according to claim 1, wherein Generate real-time valid path index, including: Read the causal relationship basic index and dynamic multi-level causal graph, calculate the node importance and path importance, and store the pre-calculated paths into the key, important and background path indexes respectively to generate a hierarchical path index architecture; Read the hierarchical path index architecture, add a timestamp and valid flag to each pre-calculated path, update the critical path immediately, delay the update of important paths, and verify the background path query to generate a real-time valid path index.
6. The method according to claim 5, characterized in that First search in the key and important path indexes. If not found, perform a real-time search in the background path index, and also include: Based on the search results, a candidate path set and search time records are formed; For the candidate path set, combined with the dynamic multi-level causal graph, the current causal strength and connectivity of each edge in multiple candidate paths are checked in parallel, and paths containing invalid edges are eliminated to form a valid path set; For each valid path, score and sort the paths to obtain the target causal path set; Where, path score = (causal strength weight × a + (path length weight × b) + (historical success rate × c); a + b + c = 1.
7. The method according to claim 1, characterized in that Use counterfactual reasoning to verify and explain outputs, generating verified causal explanation reports including: Based on the target causal path set and dynamic multi-level causal graph, the engine removes or modifies key causal edges, combines parameter perturbation simulation, and constructs a set of counterfactual scenarios and expected result ranges. Combined with the original electricity consumption data of smart meters, the engine calculates the changes in electricity consumption patterns under each scenario, compares them with historical actual data for consistency, and generates an explanation credibility score and verification result report. For the verification result report, the logical organization of the causal chain and the quantification of technical indicators are used to generate a causal explanation report that includes the causal relationship strength, impact delay and confidence interval.
Citation Information
Patent Citations
Multi-mode general-purpose cooperative causal thinking chain reasoning power anomaly detection method and system
CN119474996A