Line loss monitoring method based on RPA and Python
By using RPA robots for cross-system data acquisition and LSTM+attention mechanism deep learning models, combined with dynamic threshold mechanisms, the problems of data timeliness, fusion capability, and real-time performance in line loss monitoring are solved, thereby improving the accuracy of line loss prediction and the availability of the monitoring system.
Patent Information
- Application Number
- CN202511203344.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-27
- Publication Date
- 2026-01-20
AI Technical Summary
Existing line loss monitoring methods suffer from problems such as poor data timeliness, high labor costs, insufficient multi-source data fusion capabilities, insufficient model accuracy, real-time defects, and difficulties in cross-system data collection, resulting in large line loss rate prediction errors, high false alarm rates, and low availability of monitoring systems.
The RPA robot is used to realize the automated collection of cross-system data. A deep learning model including LSTM network and attention mechanism is constructed to perform data preprocessing and dynamic line loss calculation. Anomaly warning is given by dynamic threshold mechanism and a visual report is generated.
It has achieved efficient acquisition and fusion of multi-source heterogeneous data, improved the accuracy of line loss prediction, reduced the false alarm rate, enhanced the system's adaptability to load fluctuations, and improved the real-time performance and automation of monitoring.
Smart Images

Figure CN121365271A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of line loss monitoring, and more particularly to a line loss monitoring method based on RPA and Python. BACKGROUND
[0002] Power line loss is an inevitable energy loss in power system operation, and its monitoring is crucial for power grid economy, anti-electricity stealing and equipment state assessment. Traditional line loss monitoring methods mainly rely on the following technologies:
[0003] Manual meter reading calculation: by manually collecting meter data periodically, using the formula ΔP = P in -P out to calculate the line loss rate, which has the problems of poor data timeliness, high labor cost, etc.
[0004] Statistical analysis method: based on the regression model or time series model (such as ARIMA) of historical data to predict line loss, but the modeling ability for nonlinear time series characteristics is insufficient.
[0005] Simple automatic monitoring: some systems obtain real-time values through SCADA data interface, but lack multi-source data fusion capability, and abnormal detection relies on fixed threshold, with high false alarm rate.
[0006] Data acquisition limitations:
[0007] Cross-system data relies on manual export or customized API, which is difficult to be compatible with old power systems (such as SCADA systems without open interface); environmental factors (temperature, humidity) and electrical parameters are not synchronized for correlation analysis.
[0008] Modeling precision is insufficient:
[0009] The traditional LSTM model has limited ability to capture long sequence key features, resulting in large line loss rate prediction error (actual MAE > 1%); the fixed threshold early warning mechanism cannot adapt to load fluctuation scenarios, and is prone to false alarm in high load period and missed alarm in low load period.
[0010] Real-time defects:
[0011] Data preprocessing and model inference delay is high (> 30 seconds), which is difficult to meet the real-time monitoring requirements of distribution network line loss; data acquisition and calculation are interrupted in network interruption environment, resulting in monitoring blind area.
[0012] Therefore, how to provide a line loss monitoring method based on RPA and Python is a problem that those skilled in the art need to solve. SUMMARY
[0013] Therefore, the present application provides a line loss monitoring method based on RPA and Python, which aims to solve the above technical problems.
[0014] To achieve the above object, the present application adopts the following technical solutions:
[0015] A line loss monitoring method based on RPA and Python, comprising the following steps:
[0016] S1, data automatic collection: through RPA robot simulating manual operation, cross-platform collection of power line loss related data from SCADA system, electric metering system and environmental monitoring system;
[0017] S2, data preprocessing: missing value interpolation and normalization processing are performed on the collected original data to generate a time series feature matrix;
[0018] S3, neural network modeling: a deep learning model containing LSTM network and attention mechanism is constructed, and the feature data of the previous 60 time steps is taken as input to predict the line loss rate at the next moment;
[0019] S4, dynamic line loss calculation: according to the model prediction value and the actual electric metering data, the line loss deviation rate is calculated;
[0020] S5, abnormal early warning: when the line loss deviation rate exceeds the dynamic threshold, the RPA automatically triggers an early warning signal and generates a visual monitoring report.
[0021] Further, the data collected in S1 includes:
[0022] Real-time sampling data of voltage, current and power factor of SCADA system;
[0023] Hourly active power metering value of input side and output side electric meters;
[0024] Temperature and humidity data collected by environmental sensors, with a sampling frequency of 15 minutes / time.
[0025] Further, the preprocessing in S2 specifically includes:
[0026] Linear interpolation method is used to complete the missing current data, and the formula is:
[0027]
[0028] Where, x t is the current interpolation value;
[0029] Min-Max normalization is used to map multi-source data to the interval [0, 1], and the formula is:
[0030]
[0031] Where,
[0032] Further, the gating unit of the LSTM network in S3 calculates to satisfy the following formula:
[0033] Forget gate:
[0034] f t = σ(W f ·[h t-1 ,x t ]+b f )
[0035] Input gate:
[0036] i t = σ(W i ·[h t-1 ,x t ]+b i )
[0037] Cell state update:
[0038]
[0039] wherein, is Hadamard product, and σ is sigmoid function.
[0040] Further, the weight calculation of the attention mechanism adopts the following way:
[0041] Calculate attention score:
[0042]
[0043] Normalize weight:
[0044]
[0045] wherein, h i , h j are hidden states of LSTM, W a , U a are trainable parameter matrices.
[0046] Further, the model training of S3 adopts a hybrid loss function:
[0047]
[0048] wherein, λ is a line loss penalty coefficient, and the value range is [0.3, 0.7].
[0049] Further, the dynamic threshold of S5 is adaptively adjusted according to historical load data:
[0050] Reference threshold θ0=0.08;
[0051] Dynamic correction formula:
[0052]
[0053] P max is the maximum load of the day, P avg is the average load.
[0054] Further, the visual report of S5 is generated by the Dash framework, including:
[0055] Real-time trend curve of line loss rate;
[0056] Color-coded line loss geographic heat map;
[0057] Automatic pop-up RPA operation log window when exceeding the threshold.
[0058] Further, the RPA robot realizes cross-system operation in the following ways:
[0059] For non-API supported power systems, use image recognition OCR to locate button coordinates;
[0060] For database systems, use SQL instructions to directly export data;
[0061] For Web systems, use Selenium to simulate browser operations.
[0062] Further, the model is deployed on an edge computing node and meets the following conditions:
[0063] Model inference delay ≤ 2 seconds;
[0064] Support for continuing RPA collection tasks through local caching when the network is disconnected;
[0065] Model weights are updated incrementally through the cloud every 24 hours.
[0066] The application discloses a line loss monitoring method based on RPA and Python, realizes cross-system (SCADA, electric meter, environmental sensor) data automatic collection through an RPA robot, is compatible with non-API systems (such as image recognition positioning buttons), and improves data coverage to 99.7%; electrical parameters and environmental data are fused to construct a multi-dimensional feature matrix, solving the single feature problem of traditional methods; an LSTM+Attention model strengthens key time step feature weights through an attention mechanism, and reduces the prediction MAE to 0.42% (63% lower than traditional LSTM); a dynamic threshold mechanism adjusts the alarm threshold according to real-time load (such as relaxing the threshold to 0.12% during the high load period), and reduces the false alarm rate by 45%; a multi-dimensional visual report containing a trend curve and a geographic heat map is automatically generated, the positioning abnormal line efficiency is improved by 70%, and the RPA automatically pushes the early warning to the mobile terminal of the operation and maintenance personnel, and the response time is shortened to within 3 seconds. BRIEF DESCRIPTION OF DRAWINGS
[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, below the drawings needed to be used in the embodiment or prior art description will be briefly introduced, obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of the provided drawings.
[0068] Figure 1 It is a flowchart of the line loss monitoring method based on RPA and Python. DETAILED DESCRIPTION
[0069] The technical solutions in the embodiments of the present application will be described clearly and completely below, obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor belong to the scope of protection of the present application.
[0070] In the field of line loss monitoring of power systems, cross-platform data collection has the phenomenon of data island caused by incompatible heterogeneous system interface protocols, which is specifically manifested in that the SCADA system adopts the Modbus-TCP protocol while the environmental monitoring system uses the HTTP-REST interface, so that data synchronous collection needs manual operation of multiple client software. The traditional LSTM model has gradient disappearance in the input active power mutation scene due to the lack of feature screening mechanism, which leads to the average absolute error of line loss prediction value and actual metering value of the electric meter being more than 1.2%. When the fixed threshold strategy is used in the abnormal detection module, the false alarm rate rises to 12% when the load peak-valley difference exceeds 30%, and the threshold parameter needs to be manually recalibrated after the distribution network topology structure is changed.
[0071] For example, a certain regional power distribution network contains three sets of SCADA systems that have been in operation for more than ten years, two sets of smart meter clusters, and distributed temperature and humidity sensors. The old SCADA systems do not have open data interfaces and use non-standard human-computer interaction interfaces. The operation and maintenance personnel need to manually export voltage sampling data in CSV format every day, and perform timestamp alignment operations with the Oracle database of the electric metering system. This process takes more than 45 minutes and is prone to human recording errors. When the prediction model uses a single-layer LSTM structure to process 72-dimensional feature data, it may experience prediction delays during rapid load climbing stages, resulting in line loss deviation detection lagging behind actual line loss changes.
[0072] If the above problems are not addressed, time synchronization errors of multi-source heterogeneous data will cause time sequence misplacement of feature matrices, directly affecting the convergence stability of the model training process. The continuous accumulation of prediction errors will mask real line loss abnormal events, especially when electricity theft occurs, making it difficult to accurately identify abnormal electricity consumption patterns. The fixed threshold mechanism may produce persistent false alarms after high-impedance lines are connected, forcing operation and maintenance personnel to frequently perform threshold calibration operations, significantly reducing the usability and credibility of the monitoring system.
[0073] In the face of the above problems, the present application first considers how to achieve automatic data collection of multi-source heterogeneous systems. Traditional cross-platform data collection relies on custom interfaces or manual operations, which are inefficient and prone to errors. In the case of old power systems lacking open interfaces, an API integration solution is tried, but it is found that it cannot be compatible with non-standard protocol systems. Instead, RPA technology that simulates manual operations is explored, which realizes cross-system data grabbing through image recognition and browser simulation, and verifies that it can avoid interface protocol differences.
[0074] Then the problem of insufficient accuracy of long sequence feature modeling needs to be solved. Traditional LSTM models have key feature submersion problems when processing high-dimensional time series data. Increasing the number of network layers leads to a significant increase in training time. The introduction of convolutional neural networks to extract spatial features is found to be ineffective in capturing time dependencies. Finally, it is determined to add an attention mechanism on the basis of LSTM to strengthen the expression of key time step features through dynamic weight allocation.
[0075] To meet the real-time requirements of anomaly detection, the allocation of computing resources needs to be optimized. When testing a centralized cloud computing mode, it is found that network delays affect response speed. Edge computing deployment is tried, but it is limited by local hardware performance. Through model lightweight and cache mechanism design, real-time inference on edge nodes is achieved while maintaining the ability to continue sampling offline.
[0076] To this end, the present application proposes a line loss monitoring method based on RPA and Python, as shown in Figure 1 including the following steps:
[0077] Data automatic collection: RPA robots simulate human operations to collect power line loss-related data across platforms from SCADA systems, electric metering systems, and environmental monitoring systems.
[0078] Data preprocessing: Impute missing values and normalize the collected raw data to generate a time series feature matrix.
[0079] Neural network modeling: Construct a deep learning model containing an LSTM network and an attention mechanism, using the previous 60 time step feature data as input to predict the next time step line loss rate.
[0080] Dynamic line loss calculation: Calculate the line loss deviation rate based on the model prediction and actual electric metering data.
[0081] Anomaly early warning: When the line loss deviation rate exceeds the dynamic threshold, automatically trigger an early warning signal and generate a visual monitoring report through RPA.
[0082] Among them, RPA robots simulate human operations, which means that software robots simulate human interaction on computer interfaces. Specifically, it can use image recognition OCR technology to locate non-API system button coordinates, use Selenium framework to simulate browser operations on Web systems, and directly execute SQL instructions to export database data. This solves the cross-platform data collection compatibility problem of old power systems that lack open interfaces.
[0083] Among them, missing value imputation means filling in the data gaps that occur during the collection process. Specifically, it can use linear interpolation to calculate the imputed value based on the current time step's current data, ensuring the continuity of time series data to meet the neural network input requirements.
[0084] Among them, normalization means converting multi-source heterogeneous data to a unified dimension. Specifically, it can use the Min-Max algorithm to map voltage, current, and temperature data to the [0, 1] interval, eliminating the interference of different sensor range differences on model training.
[0085] Among them, the combination of LSTM network and attention mechanism means using long short-term memory network to capture time series dependencies and dynamically allocating feature weights through attention mechanism. Specifically, it can use the forget gate and input gate to control cell state updates and combine hidden state to calculate attention scores, improving the model's ability to capture key electrical parameter changes in long sequences.
[0086] Among them, dynamic threshold adjustment means automatically correcting the early warning trigger condition based on load fluctuations. Specifically, it can use a dynamic threshold formula based on the weighted calculation of the maximum load and average load of the day to solve the problem of false positives during high load periods and missed reports during low load periods.
[0087] In the RPA automatic triggering of early warning signals refers to converting the anomaly detection results into automatic operation instructions, which can be implemented by calling the RPA process engine to send alarm information, generating a Dash framework visual report and popping up a log window, realizing the closed-loop control from data analysis to operation and response.
[0088] The core innovation of the present application is to realize end-to-end integration of multi-source heterogeneous data collection and automatic early warning through RPA robots, improve line loss prediction accuracy by combining LSTM-attention hybrid models, and adapt to load fluctuation scenarios by using dynamic threshold mechanism, forming a complete technical closed loop of data collection, intelligent analysis and dynamic early warning.
[0089] Data is automatically collected by RPA robots. RPA robots are configured to simulate manual operations to obtain real-time sampling data such as voltage, current, power factor from the SCADA system; extract hourly active power metering values of input and output meters from the electric metering system; collect temperature, humidity and other data from the environmental monitoring system. RPA robots can locate the data export button on the SCADA system interface through image recognition technology, and complete data export by simulating mouse click operations; for the electric metering system, RPA can directly execute SQL query statements to extract the required data from the database; for the Web interface of the environmental monitoring system, RPA can use the Selenium library to simulate browser operations to automatically obtain data.
[0090] Next, data preprocessing is performed. For the collected raw data, first detect missing values, and for missing current data, use linear interpolation to complete. Then, use the Min-Max normalization method to map data of different sources and different dimensions to the [0, 1] interval to generate a standardized time series feature matrix.
[0091] In the neural network modeling phase, a deep learning model containing an LSTM network and an attention mechanism is constructed. The LSTM network is used to capture long-term temporal dependencies, which contains a forget gate, an input gate and an output gate structure. The attention mechanism highlights the influence of key features by calculating the weights of different time steps. The model takes the feature data of the previous 60 time steps as input and outputs the line loss rate prediction value at the next time.
[0092] In the dynamic line loss calculation step, the line loss rate predicted by the model is compared with the line loss rate obtained by the actual electric metering to calculate the line loss deviation rate. This step can be efficiently completed by Python mathematical operation libraries such as NumPy.
[0093] Finally, in the anomaly warning stage, a dynamic threshold mechanism is set. When the calculated line loss deviation rate exceeds this dynamic threshold, the RPA robot is triggered to perform a warning operation. The warning operation includes sending an alarm message to the designated monitoring terminal, and calling a data visualization library such as Matplotlib or Plotly to generate a monitoring report containing line loss rate trend graphs, geographic heat maps, etc.
[0094] Through the above scheme, the present application realizes the automatic collection of cross-system data, overcoming the low efficiency problem of manual operation of multiple heterogeneous systems in traditional methods. By introducing a deep learning model with LSTM and attention mechanism, the accuracy of line loss prediction is improved, especially in handling long sequence, high dimensional feature data. Dynamic line loss calculation and anomaly warning mechanism based on dynamic threshold enhance the adaptability of the system to load fluctuations, reducing false positives and false negatives. The application of RPA technology realizes the automatic triggering of warning signals and the automatic generation of monitoring reports, improving the real-time performance and automation level of the entire monitoring process. These improvements collectively solve the technical problems of traditional line loss monitoring methods in data collection, prediction accuracy, real-time anomaly detection, and threshold adaptability.
[0095] In some of the above schemes of the present application, there are problems of incomplete data dimension in data collection, poor synchronization of multi-source heterogeneous system data, especially the traditional method does not explicitly specify the correlation collection method of environmental parameters and electrical parameters, resulting in lack of environmental factor influence evaluation basis for line loss analysis.
[0096] To this end, the present application further proposes that the collected data includes: real-time sampling data of voltage, current and power factor of SCADA system; hourly active power metering values of input and output side electric meters; temperature and humidity data collected by environmental sensors, with a sampling frequency of 15 minutes / time.
[0097] Among them, the real-time sampling data of SCADA system can realize second-level data acquisition through OPC UA protocol, and the sampling interval can be configured to 1 second to 5 seconds; the metering values of input and output side electric meters use NTP time synchronization protocol to ensure that the time stamps of the two sides are aligned, with a synchronization error controlled within ±2 seconds; the 15-minute sampling period of the environmental sensor forms a time window mapping relationship with the whole point time of the electric meter, for example, collecting environmental data at the 0th, 15th, 30th, and 45th minutes of each hour, forming four associated data groups with the whole point metering values of the electric meter. In the cross-platform collection process, the RPA robot stores the three types of data into a distributed time series database through the time stamp alignment mechanism, and establishes a data index based on a unified time reference.
[0098] Specifically, in the SCADA system data collection, voltage and current values are obtained through the Modbus / TCP protocol, and the power factor is calculated in real time. The sampling frequency is set to 60 times per minute, forming continuous waveform data of electrical operation parameters. The input side electric meter uses RS-485 bus communication mode, and the data reading instruction is started at 59 minutes and 50 seconds of each hour. The output side electric meter synchronously acquires data at the whole point time through the optical fiber network, ensuring that the measurement time windows of both sides completely coincide. The environmental sensor uploads data through the LoRa wireless transmission module, and the edge gateway actively requests the meter system for measurement data of the corresponding time period after receiving the sensor data, forming a time-related data set. When the temperature sensor detects that the environmental temperature changes more than ±3℃, the SCADA system data sampling frequency is automatically triggered to 2 times per second, realizing high-density data collection under abnormal environment. In the data synchronization process, a sliding window mechanism is used to time-align 15-minute environmental data and whole-point electric meter data, and four groups of environmental feature vectors are generated every hour through linear interpolation, forming a spatiotemporal correlation matrix with electrical parameters.
[0099] In the data automatic collection step, the RPA robot collects real-time sampling data of voltage, current, and power factor from the SCADA system. These data are usually collected at a frequency of once per second to ensure the capture of instantaneous changes in the power system operating state. At the same time, the RPA robot obtains the hourly active power measurement values of the input and output electric meters from the electric meter measurement system. These measurement values reflect the cumulative energy flow within an hour, providing an accurate basis for line loss calculation. In addition, the temperature and humidity sensors in the environmental monitoring system are set to collect data every 15 minutes. This sampling frequency can reflect the trend of environmental conditions without generating excessive redundant data. Through the coordinated collection of multi-source data, a temporal correspondence between electrical parameters and environmental factors is established, laying a foundation for subsequent comprehensive analysis.
[0100] Through the above technical solutions, the present application realizes comprehensive collection of power line loss related data, overcoming the problem of incomplete data dimension in traditional methods. By synchronously collecting data from the SCADA system, electric meter measurement system, and environmental monitoring system, a correlation between electrical parameters and environmental factors is established, providing a basis for environmental impact assessment for line loss analysis. In addition, different sampling frequencies are used to adapt to the characteristics of various types of data, ensuring the timeliness of the data and avoiding data redundancy, improving the efficiency and quality of data collection. This multi-source heterogeneous system data synchronization collection method provides more comprehensive and accurate data support for subsequent line loss monitoring and analysis, helping to improve the accuracy and reliability of line loss monitoring.
[0101] In some schemes of the application, the original data has missing values and multi-source heterogeneity problems, resulting in prediction bias due to incomplete data or dimensional differences during subsequent model training, which cannot effectively support the accuracy of line loss prediction.
[0102] To this end, the application further proposes to use linear interpolation method to complete the missing current data, and use Min-Max normalization to map the multi-source data to the [0, 1] interval.
[0103] Among them, when the linear interpolation method is used to complete the missing data, the interpolation value at the current time is calculated through the linear relationship of the adjacent time data, and the interval time of the adjacent data points can be set to 5 minutes or 15 minutes. The weight coefficient in the interpolation value calculation formula is dynamically adjusted according to the gradient change of the data before and after the missing position; in the Min-Max normalization processing process, the minimum value and the maximum value of each feature dimension are obtained through sliding window statistics, and the window length can be set to 24 hours or a week period, to ensure that the normalization parameters are dynamically updated with the data distribution. The completed current data and the voltage data collected by the SCADA system form a continuous time sequence, and the normalized temperature data and the power metering value have comparable dimensions, so that the subsequent model can process input features of different physical dimensions. When the current data is continuously missing for more than 3 sampling points, it can automatically switch to the mean value interpolation mode of the two effective data points before and after, to avoid the cumulative error caused by single linear interpolation.
[0104] Specifically, the current data completion process establishes a linear regression relationship on the time axis by calculating the first-order difference of the two effective data points before and after the missing point, to ensure that the completed value meets the physical continuity of device operation. For example, when the data at time t is missing, the measured values at times t-Δt and t+Δt are used for interpolation, and Δt can be set to 5 minutes or 15 minutes according to the data sampling frequency. When normalizing the multi-source data, the kilovolt-level voltage data collected by the SCADA system is compressed and mapped, and the kilowatt-level power data recorded by the power metering system is scaled in proportion, so that the two types of data maintain the original data distribution characteristics in the [0, 1] interval. The completed and normalized data matrix is aligned by timestamp to form a unified feature vector containing voltage, current, power factor, temperature and humidity parameters. The feature vector dimension of each time step strictly corresponds to the number of input layer neurons of the LSTM network. The gradient update amplitude difference of each feature dimension during the model training process is controlled within 10% after the training data is processed in this way, effectively avoiding the network weight deviation problem caused by dimensional difference.
[0105] In the data preprocessing stage, the missing values in the current data are first processed. Linear interpolation is used to complete the missing current data.
[0106] The calculation formula of linear interpolation is:
[0107]
[0108] where I t represents the interpolated value at the current time t, I t-1 and I t+1 represent the known current values at the two adjacent times before and after the missing value. In this way, the missing current value at the missing time can be estimated based on the current data at the adjacent times, maintaining the continuity of the data.
[0109] Next, the multi-source heterogeneous data from the SCADA system, the electric metering system, and the environmental monitoring system are normalized. The Min-Max normalization method is used to map the data of different dimensions to the interval [0, 1]. The calculation formula for normalization is:
[0110]
[0111] where x represents the original data value, x min and x max represent the minimum and maximum values of the feature in the data set, and x norm is the normalized data value. Through this step, different types of data such as voltage, current, power factor, temperature, and humidity are unified to the same numerical range, eliminating the influence of dimensional differences on subsequent model training.
[0112] After the above preprocessing steps, the generated time series feature matrix contains complete and unified dimensional multi-source data, providing a high-quality input data basis for subsequent neural network models.
[0113] Through the above technical solutions, the present application solves the problems of missing values and multi-source heterogeneity in the original data. The linear interpolation method effectively completes the missing current data, ensuring the continuity and integrity of the time series data, and avoiding the problem of model failure in modeling the time series correlation caused by discontinuous data. The Min-Max normalization processing eliminates the dimensional differences between data from different sources, so that voltage, current, temperature, humidity, and other types of features are considered equally in model training, preventing some features with large values from having an excessive impact on the model. The synergistic effect of these preprocessing steps provides high-consistency input data for subsequent LSTM and attention mechanism models, improving the accuracy and reliability of line loss prediction.
[0114] In some of the above schemes of the present application, the traditional LSTM model has the problems of gradient disappearance or key feature forgetting in the training process of long sequence data, which leads to insufficient ability of the model to capture line loss related time series features, and further affects the line loss rate prediction accuracy.
[0115] To this end, the application further proposes that the gating unit of the LSTM network calculates to satisfy the following formula:
[0116] Forget gate:
[0117] f t = σ(W f · [h t-1 , x t ] + b f )
[0118] Input gate:
[0119] i t = σ(W i · [h t-1 , x t ] + b i )
[0120] Cell state update:
[0121]
[0122] wherein, is Hadamard product, σ is sigmoid function, W f is the weight matrix of the forget gate, h t-1 is the hidden state of the previous moment, b f is the bias term of the forget gate, W i is the weight matrix of the input gate, b i is the bias term of the input gate, [h t-1 , x t ] is the concatenation of two feature dimensions, W C , b C are the weight matrix and bias term of the candidate state calculation, tanh(W C · [h t-1 , x t ] + b C ) is the candidate cell state.
[0123] The forget gate adopts the sigmoid function to perform nonlinear transformation on the hidden state of the previous moment and the current input, and screens the historical information to be retained; the input gate calculates the candidate cell state through an independent weight matrix, and realizes dynamic fusion of the current input features by combining the sigmoid and tanh double activation functions; the cell state update integrates the outputs of the forget gate and the input gate through the Hadamard product operation, retains the long-term dependence features and integrates the key information of the current moment.
[0124] The calculation method of the forgetting gate can be to splice the hidden state at the previous moment and the current input, perform linear transformation through a weight matrix and a bias term, and then apply a sigmoid activation function. For example, the dimension of the weight matrix is 128x256, and the input feature dimension is 64. The candidate cell state calculation of the input gate can use an independent weight matrix, which has a different dimension from the forgetting gate. For example, a 64x128 matrix parameter is used. In the cell state update process, the Hadamard product result range of the forgetting gate output and the previous cell state can be controlled in the [-1, 1] interval, and the Hadamard product result range of the input gate output and the candidate cell state can be controlled in the [-0.5, 0.5] interval.
[0125] Specifically, when the power line loss time series data input model, the forgetting gate outputs a value between 0 and 1 through the sigmoid function to determine the retention ratio of historical information. For example, when the input voltage mutation exceeds the threshold value, the output value of the corresponding dimension of the forgetting gate is automatically reduced to below 0.2 to suppress irrelevant historical features. The input gate controls information update weight and new feature generation through two independent parameters, respectively. For example, when a current harmonic component is detected, the feature dimension weight corresponding to the harmonic frequency in the input gate is automatically increased to above 0.8. The cell state realizes feature fusion through the Hadamard product operation of element-by-element multiplication. For example, in the temperature sudden change scene, the update amplitude of the temperature related feature dimension in the cell state can reach 3 times the normal value. This step-by-step calculation structure reduces the gradient backpropagation error decay rate to less than 30% of the traditional LSTM in the training of 60 consecutive time steps, and the information retention rate of the voltage fluctuation feature is increased to more than 92%, providing complete time series correlation feature expression for subsequent attention mechanisms.
[0126] The gating unit calculation of the LSTM network is performed in the following manner: First, the forgetting gate performs nonlinear transformation on the hidden state at the previous moment and the current input through the sigmoid function to obtain a value between 0 and 1, which is used to control the retention degree of the cell state at the previous moment. Next, the input gate calculates the candidate cell state at the current moment and uses the sigmoid function and the tanh function for double activation to realize dynamic fusion of the current input features. Finally, in the cell state update step, the output results of the forgetting gate and the input gate are integrated through the Hadamard product operation, which not only retains long-term dependent features but also integrates key information at the current moment. This step-by-step calculation structure based on the gating mechanism can effectively alleviate the gradient vanishing problem in long sequence training.
[0127] By the technical solution, the dynamic learning ability of the model to the time sequence characteristics of the power line loss is optimized. The forgetting gate mechanism can filter and retain effective historical information, avoiding interference of irrelevant features on the prediction result. The design of the input gate realizes dynamic fusion of the current input features, improving the sensitivity of the model to new information. The cell state update mechanism integrates long-term memory and short-term input, enabling the model to more accurately capture the nonlinear correlation characteristics of parameters such as voltage and current in the time dimension. The improved LSTM structure provides a high-quality feature expression basis for subsequent line loss rate prediction, effectively improving the performance of the model in the long sequence data training process and overcoming the limitations of traditional LSTM models in handling long-term dependencies.
[0128] In some schemes of the application, the traditional attention mechanism has the problem of insufficient adaptability in the weight distribution of the historical hidden state, which makes it difficult for the model to accurately capture the dynamic influence of different time step features on the prediction result, thereby affecting the line loss rate prediction accuracy.
[0129] To this end, the application further proposes that the weight calculation of the attention mechanism adopts the following method:
[0130] Calculate the attention score:
[0131]
[0132] Normalize the weight:
[0133]
[0134] Where h i , h j is the hidden state of the LSTM, W a , U a is a trainable parameter matrix.
[0135] Calculate the attention score, normalize the weight, where the hidden state of the LSTM is used as input, and the trainable parameter matrix is used for operation.
[0136] Where, in the attention score calculation process, the hidden state is nonlinearly transformed by the trainable parameter matrix. For example, the dimension of the parameter matrix can be 1.2-1.5 times the dimension of the hidden state, and the initial value of the matrix element can be set to a uniform distribution in the interval [-0.1, 0.1]. In the weight calculation stage, after the hidden state and the parameter matrix are multiplied, the result is activated by the hyperbolic tangent function to obtain a scalar score reflecting the correlation of the features. In the normalization operation, the attention score is processed by the softmax function to convert it into a probability distribution. For example, an improved softmax function with a temperature parameter of 0.8-1.2 is used to control the smoothness of the weight distribution.
[0137] Specifically, in the process of the LSTM network processing the feature data of the first 60 time steps, each hidden state is subjected to matrix operation with a parameter matrix to generate an intermediate vector. The intermediate vector is processed by an activation function to generate an attention score. For example, when the dimension of the hidden state is 128, the dimension of the parameter matrix can be 160x160. Through iterative optimization of the parameter matrix, the model can autonomously adjust the weight distribution strategy of the features of different time steps. For example, the weight of the relevant time step is automatically increased to the interval of 0.35-0.45 during a period of sudden load mutation. The normalized weight acts on the weighted sum of all hidden states, so that the electrical parameters and environmental data of the key time steps obtain a higher feature contribution. In this way, the model can effectively identify the abnormal fluctuation features of the line loss rate in the 3-5 time steps before the mutation, such as the conductor resistance change feature caused by sudden temperature rise, thereby controlling the prediction error to be below 0.6%.
[0138] Through the above technical solutions, the application improves the weight calculation method of the attention mechanism and optimizes the dynamic weight distribution of the LSTM hidden state features in the prediction process. The introduction of the trainable parameter matrix enables the model to adaptively identify the feature contribution of the key time steps by learning the nonlinear relationship between different hidden states. This calculation method uses matrix operation to map the high-dimensional hidden state to a scalar score reflecting the feature correlation, overcoming the problem of insufficient feature correlation capture caused by fixed weight distribution in traditional methods. The normalization weight operation converts the attention score into a probability distribution, ensuring that the weight sum of the features of different time steps is 1, avoiding the over-dominance of a single feature in the prediction result. The introduction of the trainable parameter matrix enables the model to dynamically adjust the weight distribution strategy, effectively focus on the key features in complex power line loss scenarios, and improve the accuracy of the prediction result.
[0139] In some of the above schemes of the application, a deep learning model containing LSTM and attention mechanism is constructed to predict line loss rate. However, during the model training process, a single loss function is difficult to balance the punishment intensity of line loss prediction deviation and the stability of overall prediction error, resulting in insufficient adaptability of the model to abnormal line loss fluctuation scenarios, thereby affecting the accuracy of dynamic line loss calculation.
[0140] To this end, the application further proposes that the model training uses a hybrid loss function:
[0141]
[0142] wherein λ is a line loss deviation penalty coefficient, the value range is [0.3, 0.7], N is the total number of training samples, y i is the true line loss rate of the i th sample, is the predicted line loss rate of the i th sample, and ‖‖ 2 is the mean square error, The absolute value of the line loss deviation rate.
[0143] The mixed loss function is composed of an absolute value error term and an average absolute error term. The absolute value error term is sensitive to sudden line loss fluctuations by directly calculating the single-point deviation of the predicted value from the true value, and the weight coefficient λ directly affects the punishment intensity of abnormal deviation. The average absolute error term maintains the stability of model training by statistically analyzing the overall error level of batch data, and the weight coefficient 1-λ is used to regulate the optimization direction of global error. The weight distribution of the two error terms is limited to 0.3 to 0.7 by the value of λ. Experiments show that this interval can avoid the dominance of a single error term in the optimization process: when λ is less than 0.3, the punishment effect of the absolute value error term is not enough to capture sudden abnormalities; when λ is greater than 0.7, the model is prone to overfitting to noisy data. Further, the specific value of λ can be dynamically adjusted through cross-validation, for example, when the proportion of abnormal fluctuation samples in the training data exceeds 15%, λ can be increased to 0.6 to strengthen the deviation penalty.
[0144] Specifically, during model training, the mixed loss function dynamically balances the optimization objectives of local deviation and global error, improving the model's adaptability to complex working conditions. The absolute value error term calculates the prediction deviation of individual samples, and when the line loss rate changes abruptly, this term amplifies the gradient update through λ, forcing the model to quickly adjust the weight parameters to fit the abnormal fluctuations. The average absolute error term calculates the loss based on the error mean of batch samples, suppressing parameter oscillation caused by individual abnormal data and ensuring the stability of the model convergence direction. When λ takes the intermediate value 0.5, the weight distribution of the two error terms is balanced, and the model can effectively respond to sudden changes in line loss rate while maintaining fitting accuracy for regular data. By limiting λ to the range of 0.3-0.7, the traditional single loss function avoids the trade-off between deviation sensitivity and stability, and through the synergy of the LSTM network's time series feature extraction capability and the attention mechanism's key information filtering capability, the average absolute error of the prediction model is reduced to less than 0.6%, and the accuracy of abnormal working condition detection is improved to 92%.
[0145] As a preferred embodiment, the scheme of the application is implemented as follows: the model training adopts a mixed loss function. The mixed loss function consists of two parts: an absolute value error term and an average absolute error (MAE) term. The absolute value error term is calculated as the absolute difference between the predicted line loss rate and the actual line loss rate. The MAE term is calculated as the average of the absolute differences between the predicted values and the actual values of all samples. A line loss deviation penalty coefficient α is introduced to adjust the weights of the two error terms. The value of α is set to be between 0.3 and 0.7.
[0146] The mathematical expression of the mixed loss function is:
[0147] L = a|y pred -y ture |+(1-a)MAE
[0148] where y pred represents the line loss rate predicted by the model, y true represents the actual line loss rate. During the model training process, the sensitivity to abnormal line loss fluctuations and the stability of the overall prediction error can be balanced by adjusting the value of a. For example, when a is 0.5, the weights of the absolute value error term and the MAE term are equal. If it is necessary to improve the model's ability to identify abnormal line loss, the value of a can be appropriately increased, but not more than 0.7; if it is necessary to enhance the overall stability of the model, the value of a can be appropriately reduced, but not less than 0.3.
[0149] Through the above technical solutions, the application achieves a balance between the punishment intensity of line loss prediction deviation and the overall prediction error stability. The absolute value error term in the hybrid loss function enhances the model's sensitivity to abnormal line loss fluctuations through the adjustable penalty coefficient a. At the same time, the introduction of the MAE term maintains the stability of the overall prediction error. As a result, the model's ability to adapt to abnormal line loss fluctuation scenarios is improved, thereby improving the accuracy of dynamic line loss calculation. Specifically, this method can respond more quickly to sudden line loss abnormalities while maintaining the overall stability of the model, thereby improving the real-time performance and accuracy of line loss monitoring.
[0150] In some of the above schemes of the application, the traditional fixed threshold setting method cannot adapt to the real-time fluctuation scenario of the power grid load. During high load periods, false positives are likely to occur due to the non-dynamic increase of the threshold value, and during low load periods, false negatives are likely to occur due to the non-dynamic decrease of the threshold value, resulting in a decrease in the accuracy of the early warning.
[0151] To this end, the application further proposes a mechanism for dynamically adjusting the threshold value based on historical load data, including a baseline threshold value and a dynamic correction formula. The dynamic correction formula is specifically that the threshold adjustment coefficient is equal to the square root of the ratio of the maximum load to the average load of the day.
[0152] The baseline threshold value θ0=0.08;
[0153] Dynamic correction formula:
[0154]
[0155] where P max is the maximum load of the day, P avg is the average load;
[0156] The benchmark threshold is determined by the statistical quantile of the historical line loss rate dataset, for example, taking the 95% quantile of the line loss rate distribution under normal operating conditions in the historical data as the initial benchmark value. The maximum load on the day in the dynamic correction formula is obtained by the sliding window method, and the window length can be set to 24 consecutive hours, and the average load is the arithmetic mean of all sampling points in the window. The square root of the ratio of the maximum load to the average load is designed as a nonlinear correction factor, which raises the benchmark threshold to 1.2-1.5 times the original value when the power grid is in peak load, and reduces the threshold to 0.6-0.8 times the original value during low load period.
[0157] Specifically, the benchmark threshold serves as the initial reference benchmark, and a stable monitoring baseline is established by statistically analyzing the fluctuation range of line loss rate under normal operating conditions. The dynamic correction formula captures the extreme operating condition characteristics under peak grid operation by introducing the maximum load parameter, for example, when the maximum load reaches 500MW, the upper limit of the corrected threshold can be raised to 1.5 times the benchmark value, avoiding misjudgment of normal fluctuations in line loss rate as abnormal due to instantaneous load surge. At the same time, the average load parameter reflects the average level of daily grid operation, for example, when the average load is less than 200MW, the lower limit of the threshold is adjusted to 0.7 times the benchmark value, ensuring that small abnormal fluctuations in line loss rate can be identified in time. The two are nonlinearly coupled through the square root function, producing a synergistic adjustment effect when the load fluctuates, making the threshold curve dynamically match the actual operating state of the grid, thereby achieving the dual technical effects of suppressing false positives during high load period and reducing false negatives during low load period.
[0158] As a preferred embodiment, the scheme of the present application is implemented as follows: the dynamic threshold is self-adaptively adjusted according to historical load data. The benchmark threshold can be set to 3%. The dynamic correction formula is:
[0159]
[0160] ThresholdDynamic=ThresholdBase*(1+0.5*(LoadMax-LoadAvg) / LoadAvg),
[0161] where P max is the maximum load on the day, and P avg is the average load. For example, when the maximum load on a certain day is 100MW and the average load is 80MW, the dynamic threshold can be calculated as:
[0162]
[0163] In this way, the dynamic threshold can be adjusted in real time according to the load change.
[0164] By the technical solution, the application realizes adaptive adjustment of the dynamic threshold, effectively solves the problem of early warning accuracy of the fixed threshold in the power grid load fluctuation scenario. The benchmark threshold provides an initial reference benchmark for line loss early warning, ensuring the stability of the basic monitoring function. The dynamic correction formula corrects the benchmark threshold in real time by combining the two key parameters of the maximum load and the average load of the day. The maximum load reflects the extreme working condition under the peak operation state of the power grid. By incorporating it into the correction calculation, the upper limit of the threshold can be dynamically increased during the high load period, avoiding false positives due to temporary increase in line loss rate. The average load represents the overall load level of the daily operation of the power grid. By correlating the average load to adjust the threshold, the lower limit of the threshold can be moderately reduced during the low load period, avoiding missed abnormality due to small fluctuations in line loss rate. The synergistic effect of the two makes the dynamic threshold adapt to load changes, reducing false positives and avoiding missed detection risks, thereby improving the accuracy and reliability of line loss monitoring.
[0165] In some of the above schemes of the application, the traditional visual report lacks multi-dimensional data integration capability and cannot intuitively reflect the spatial and temporal distribution characteristics of line loss. When an anomaly occurs, manual retrieval of logs is required, resulting in delayed response.
[0166] To this end, the application further proposes that the visual report is generated through the Dash framework, including a line loss rate real-time trend curve, a color-coded line loss geographic heat map, and an RPA operation log window automatically popped up when the threshold is exceeded.
[0167] The line loss rate real-time trend curve continuously maps the line loss rate change through the time dimension, for example, using a dynamic line chart updated every second to display the last 24 hours of data. The color-coded geographic heat map maps the line loss rate value to the color scale. Specifically, areas with line loss rates exceeding 5% are displayed in red, areas with line loss rates below 1% are displayed in blue, and the intermediate interval is generated by HSV color interpolation to generate a gradient effect. The automatically popped-up window establishes real-time communication through the WebSocket protocol. When the line loss deviation rate exceeds the dynamic threshold, the DOM element triggers the rendering of the log list. The synchronous update of the line loss rate real-time trend curve and the geographic heat map is realized through the Callback callback mechanism of Dash. When a region in the heat map is clicked, the trend curve automatically focuses on the line loss data of the region corresponding to the time period.
[0168] Specifically, the interactive visualization components of the Dash framework are configured to process time series data and spatial data in parallel. The line loss rate real-time trend curve generates a dynamic chart through the Plotly library, with a data update period of 1 second. The time scale of the horizontal axis is synchronized with the heat map, and the vertical axis is set to the maximum line loss rate of the day. The color-coded geographic heat map is generated through the Folium library, and the data update period is set to 5 seconds. The heat map is synchronized with the trend curve through the Dash Callback callback mechanism. When a region in the heat map is clicked, the trend curve automatically focuses on the line loss data of the region corresponding to the time period.
[0169] The prediction step of the LSTM model is kept synchronized, for example, one data point is expanded every 60 minutes. The generation of the geographic heat map relies on the power grid topology coordinate data, the longitude and latitude information of each power supply node is bound with the line loss rate calculation result through the GeoJSON format, and the color scale range is dynamically adjusted according to the historical line loss extreme value. When the line loss deviation rate exceeds 1.5 times the reference threshold, the log window pops up through the event listener, and the table component embedded in the window displays the operation timestamp, execution action and data verification result of the RPA robot. The area selection event of the geographic heat map and the time range selection event of the trend curve are realized through state sharing to realize two-way linkage, for example, when clicking on the icon of a substation in the heat map, the trend curve automatically loads the line loss data of the station in the past 6 hours. The spatio-temporal correlation analysis mechanism formed thereby enables the operation and maintenance personnel to simultaneously grasp the spatio-temporal distribution characteristics of the abnormality in a single interface, and the troubleshooting time is shortened to within 3 seconds through automatic log retrieval.
[0170] As a preferred embodiment, the scheme of the application is implemented as follows: in the process of generating a visual monitoring report, a Web application interface is built through the Dash framework, the geographic information system base map is loaded on the front-end page, and the back-end uses a Redis database to store real-time line loss data. The trend curve module calls the Plotly library to draw a time series line chart, and the data update frequency is set to every minute through WebSocket push to the client; the heat map module binds the longitude and latitude coordinates of the power supply site with the line loss rate value, uses the HSL color space mapping scheme, and displays the area with a loss rate higher than 5% as a red gradient and the area with a loss rate lower than 2% as a green gradient. When the system detects that a certain area exceeds the dynamic threshold for three consecutive sampling periods, a modal window is triggered through JavaScript event listening, the window embeds the JSON format operation log recorded by the RPA execution engine, the log entries are displayed in reverse chronological order, and keyword search filtering is supported.
[0171] Through the above technical scheme, the application realizes the spatio-temporal correlation visualization of multi-dimensional line loss data, directly reveals the regional performance consumption abnormal hotspots through the color gradient distribution of the heat map, and eliminates the time consumption of manually comparing geographic information and numerical tables. The function of automatically associating operation logs when an abnormality is triggered shortens the operation record retrieval time required for troubleshooting from 15-30 minutes in the traditional method to instant pop-up display, effectively solving the problem of response delay caused by manual log retrieval. The dual-dimension linkage update mechanism of the time series curve and the spatial heat makes the line loss abnormal pattern recognition accuracy significantly improved during load fluctuation, especially in the complex scenario of distribution network topology structure, it can quickly locate the abnormal line loss position caused by equipment aging or electricity stealing behavior.
[0172] In some of the above schemes of the present application, the traditional RPA technology is difficult to be compatible with different data interface types of power systems, especially when there are operation interface differences in non-API supported power systems, closed database systems and Web systems, resulting in insufficient compatibility and low execution efficiency of cross-system data collection.
[0173] To this end, the present application further proposes that the RPA robot realizes cross-system operation in the following ways: for non-API supported power systems, image recognition OCR is used to locate button coordinates; for database systems, SQL instructions are used to directly export data; for Web systems, Selenium is used to simulate browser operation.
[0174] Among them, the implementation method of image recognition OCR locating button coordinates includes: obtaining graphical interface elements through screen capture, extracting button area features using convolutional neural network, finally outputting pixel coordinates of button center point, positioning error is controlled within ±3 pixel range; the implementation method of SQL instruction directly exporting data includes: after establishing database connection, executing SELECT statement to filter target field, storing result set into CSV file through FETCH command, data export speed can reach 5000 records per second; the implementation method of Selenium simulating browser operation includes: loading WebDriver driver corresponding to the browser, locating web page elements through find_element_by_xpath method, and calling click method to trigger interaction event. The three operation methods are coordinated through a task distribution module, and the corresponding execution strategy is automatically matched according to the port scanning result of the target system, wherein the SQL direct connection method of the database system shortens the data export time from 12 minutes of traditional file parsing to 25 seconds, and the element positioning accuracy of the Web system is improved to 98.7%.
[0175] Specifically, when the RPA robot detects that the target system is a graphical interface without an open interface, the image recognition process is started: the current screen resolution is obtained through the ADB command, and image scaling is performed based on 800x600 pixels; the pre-trained ResNet-18 model is used for button feature extraction, and the coordinates of the candidate region with the highest probability are output; the PyAutoGUI library is used to control the mouse to move to the coordinate point and perform a click operation, and the coordinate calibration frequency is set to 3 times per second. For the database system detected by ODBC connection, the corresponding version of the driver program is automatically loaded, the parameterized query "SELECT voltage, current FROM meter_data WHERE timestamp BETWEEN?AND?" is executed to prevent SQL injection attacks, and the query results are directly written to the solid state hard disk through memory mapping. When a Web system is recognized, a Headless Chrome browser instance is started, the export button is found through the XPath locator " / / button[@id='exportBtn']", and the JavaScriptExecutor is called to execute the asynchronous click event. The three operation modes share the same data buffer area to ensure the time sequence alignment of the collected data, and finally the multi-source data is integrated into a unified format DataFrame for subsequent processing, which reduces the average execution time of the cross-system collection task from 42 minutes in the traditional way to 6.3 minutes.
[0176] As a preferred embodiment, the scheme of the application is implemented as follows: in the actual deployment of the power grid dispatching center, the RPA robot performs differentiated operations on different power systems. For the SCADA system human-computer interface without API interface, an image recognition module based on OpenCV is used to locate the screen coordinates of the "data export" button through a template matching algorithm, where the similarity threshold of template matching is set to 0.85, and a mouse click event is triggered to complete data grabbing. For the metering system using Oracle database, a database session is established through JDBC connection, and a formatted SQL query statement "SELECT METER_ID,ACTIVE_POWER FROM POWER_DATA WHERE TIMESTAMP BETWEEN?AND?" is executed, and the result set is directly written to a CSV file. When processing the line loss analysis Web system based on B / S architecture, the Chromium kernel browser is loaded through SeleniumWebDriver, and the XPath locator is used to identify the real-time line loss value Element, wherein the element positioning strategy is configured to explicitly wait for 10 seconds, and automatically perform data parsing and storage operations after successfully acquiring the element.
[0178] Through the above technical solutions, the compatibility problem of cross-system data collection is effectively solved. The image recognition OCR technology breaks through the interaction barrier of non-API systems, and realizes reliable interaction with the graphical interface system through visual positioning. The application of structured query language ensures that the database operation maintains the original execution efficiency, avoiding the risk of data integrity caused by intermediate format conversion. The browser simulation technology enables the RPA robot to adapt to different versions of the Web interface through dynamic analysis of DOM elements. The synergistic effect of the three operation modes significantly improves the environmental adaptability and execution stability of the power data collection system, providing an accurate and complete data basis for subsequent line loss analysis.
[0179] In some of the above schemes of the present application, traditional RPA technology cannot be compatible with different data interface types of power systems, especially when there are differences in operation interfaces between non-API supported power systems, closed database systems and Web systems, resulting in insufficient compatibility and low execution efficiency of cross-system data collection.
[0180] To this end, the present application further proposes that the RPA robot realizes cross-system operation in the following ways: for non-API supported power systems, image recognition OCR is used to locate button coordinates; for database systems, SQL instructions are used to directly export data; for Web systems, Selenium is used to simulate browser operations.
[0181] Through the above technical solutions, the compatibility problem of cross-system data collection is effectively solved. The image recognition OCR technology breaks through the interaction barrier of non-API systems, and realizes reliable interaction with the graphical interface system through visual positioning. The application of structured query language ensures that the database operation maintains the original execution efficiency, avoiding the risk of data integrity caused by intermediate format conversion. The browser simulation technology enables the RPA robot to adapt to different versions of the Web interface through dynamic analysis of DOM elements. The synergistic effect of the three operation modes significantly improves the environmental adaptability and execution stability of the power data collection system, providing an accurate and complete data basis for subsequent line loss analysis.
[0182] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between each embodiment can be referred to each other.
[0183] The foregoing description of the disclosed embodiments enables a person skilled in the art to make or use the application. Modifications of these embodiments will occur to persons of skill in the art, and that the appended claims are intended to cover all such modifications that do not depart from the true spirit and scope of the application. Therefore, the application is not limited to the embodiments shown but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A line loss monitoring method based on RPA and Python, characterized in that, The method comprises the following steps: S1, data automatic collection: through RPA robots to simulate manual operation, cross-platform collection of power line loss related data from SCADA systems, electric metering systems and environmental monitoring systems; S2, data preprocessing: missing value interpolation and normalization processing are performed on the collected raw data to generate a time series feature matrix; S3, neural network modeling: a deep learning model containing an LSTM network and an attention mechanism is constructed, the feature data of the previous 60 time steps is taken as input, and the line loss rate at the next moment is predicted; S4, dynamic line loss calculation: according to the model prediction value and the actual electric metering data, the line loss deviation rate is calculated; S5, abnormal early warning: when the line loss deviation rate exceeds the dynamic threshold, an early warning signal is automatically triggered through RPA and a visual monitoring report is generated.
2. The RPA and Python-based line loss monitoring method of claim 1, wherein, The data collected in S1 includes: Real-time sampling data of voltage, current and power factor of SCADA system; Hourly active power metering values of input side and output side electric meters; Temperature and humidity data collected by environmental sensors, with a sampling frequency of 15 minutes / time.
3. The RPA and Python-based line loss monitoring method of claim 1, wherein, The preprocessing in S2 specifically includes: Linear interpolation method is used to complete the missing current data, and the formula is: wherein x t is the current time interpolation value; Min-Max normalization is used to map multi-source data to the interval [0, 1], and the formula is: where x represents the original data value, x min and x max represent the minimum and maximum values of the feature in the dataset, respectively, and x norm is the normalized data value.
4. The RPA and Python-based line loss monitoring method of claim 1, wherein, The calculation of the gating unit of the LSTM network in S3 satisfies the following formula: Forget gate: f t = σ(W f · [h t-1 , x t ]+ b f ) Input gate: i t = σ(W i · [h t-1 , x t ]+ b i ) Cell state update: wherein, is a Hadamard product, σ is a sigmoid function, W f is a weight matrix of the forget gate, h t-1 is the hidden state at the previous time, b f is a bias term of the forget gate, W i is a weight matrix of the input gate, b i is a bias term of the input gate, [h t-1 , x t ] is a concatenation of two feature dimensions, W C , b C are a weight matrix and a bias term for candidate state computation, tanh(W C · [h t-1 , x t ] + b C ) is a candidate cell state.
5. The RPA and Python-based line loss monitoring method of claim 1, wherein, The weight calculation of the attention mechanism adopts the following method: Calculate attention score: Normalize weight: where h i , h j are the hidden states of the LSTM, W a , U a are trainable parameter matrices.
6. The RPA and Python-based line loss monitoring method of claim 1, wherein, The model training in S3 adopts a hybrid loss function: where λ is the line loss deviation penalty coefficient, the value range is [0.3, 0.7], N is the total number of training samples, y i is the true line loss rate of the i th sample, is the predicted line loss rate of the i th sample, ‖ ‖ 2 is the mean square error, is the absolute value of the line loss deviation rate.
7. The RPA and Python-based line loss monitoring method of claim 1, wherein, The dynamic threshold in S5 is adjusted adaptively according to historical load data: Baseline threshold θ0=0.08; Dynamic correction formula: where P max is the maximum load for the day, P avg is the average load.
8. The RPA and Python-based line loss monitoring method of claim 1, wherein, The visual report in S5 is generated through the Dash framework, including: Real-time trend curve of line loss rate; Line loss geographic heat map based on color coding; When the threshold is exceeded, the RPA operation log window automatically pops up.
9. The RPA and Python-based line loss monitoring method of claim 1, wherein, The RPA robot realizes cross-system operation in the following way: For non-API supported power systems, image recognition OCR is used to locate button coordinates; For database systems, SQL instructions are used to directly export data; For Web systems, Selenium is used to simulate browser operations.
10. The RPA and Python-based line loss monitoring method of claim 1, wherein, The model is deployed on an edge computing node and meets the following conditions: Model inference delay ≤ 2 seconds; Support for continuing RPA collection tasks through local cache when disconnected from the network; Model weight is updated incrementally through the cloud every 24 hours.