A method for dynamically compensating metering errors of an electric energy meter
The dynamic compensation method for electricity meter measurement error, which utilizes principal component analysis, wavelet transform, and a two-level optimization model, solves the problem of insufficient adaptability of measurement error in traditional methods, and achieves high-precision measurement and stable operation of electricity meters in complex environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-24
AI Technical Summary
Traditional methods for compensating for metering errors in electricity meters cannot adapt to complex and ever-changing environmental conditions, resulting in insufficient metering accuracy and failing to meet the ever-growing demand for high precision.
Principal component analysis and wavelet transform are used to process the electricity meter data, a dynamic compensation circuit is constructed, and error compensation is performed through a two-level optimization model to adjust the metering parameters in real time to adapt to environmental changes.
It has enabled high-precision metering of electricity in complex environments and operating conditions, ensuring fair electricity billing and stable system operation, and optimizing the allocation of electricity resources.
Smart Images

Figure CN121388485B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electric energy metering, in particular to a dynamic compensation method for metering errors of an electric energy meter. BACKGROUND
[0002] As an indispensable key device in the power system, the electric energy meter shoulders the important mission of measuring the amount of electricity used by users. In daily life, from the electricity used by various appliances in the home, to the lighting and equipment operation electricity in commercial places, to the power consumption of large machines in the industrial field, all need to be accurately measured by the electric energy meter. The data provided by it is the fundamental basis for electricity billing, ensuring the fairness and justice of electricity settlement between power supply enterprises and users. At the same time, these data are also an important reference for the allocation of electric power resources, helping the power department to rationally plan electric power production and transmission and ensure the stable operation of the power system. For example, during the summer peak period, the power department allocates electric power resources according to the electricity consumption of each region calculated by the electric energy meter, and preferentially meets the needs of key areas and livelihoods to avoid power shortages or waste. Once the electric energy metering deviates, it will have a serious negative impact on both user rights and the economic operation and rational allocation of resources of the power system. Therefore, it is of great significance to ensure the high accuracy of electric energy metering.
[0003] Environmental conditions have an undeniable effect on the metering of electric energy meters. Changes in temperature can cause the parameters of internal electronic components of the electric energy meter to change. For example, when the ambient temperature rises, the resistance value may increase, affecting the measurement accuracy of current and voltage, leading to metering errors. In a high-temperature industrial production environment, the internal electronic components of the electric energy meter may gradually degrade over time, causing the metering results to deviate from the true value. Humidity is also an important factor. Excessive humidity can cause electronic components to be damp, causing short circuits or electrical leakage, and interfering with the normal operation of the electric energy meter. In a strong electromagnetic interference environment, such as near a substation, the electromagnetic field around the electric energy meter may interfere with the signal transmission and processing inside the electric energy meter, causing the measured current and voltage signals to deviate, and thus affecting the accuracy of electric energy metering.
[0004] From the perspective of the internal structure of an electricity meter, the ratio error and phase angle error of the current transformer are among the important causes of measurement errors. When the current transformer converts large currents and high voltages into small currents and low voltages suitable for the electricity meter's measurement, an inaccurate transformation ratio will directly lead to measurement errors. The stability of the voltage reference is also crucial. If the voltage reference drifts, the voltage value measured based on it will inevitably be inaccurate, ultimately affecting the calculation of electrical energy. Furthermore, during long-term use, the internal components of the electricity meter gradually age and their performance degrades. For example, the capacitance may change, affecting the circuit's time constant; the amplification factor of the transistor may also change, leading to deviations in signal processing. These component aging issues all contribute to the gradual increase of the electricity meter's measurement error, affecting its accuracy and reliability.
[0005] Traditional error compensation methods have many limitations. Taking static calibration as an example, this method typically calibrates the electricity meter under specific standard conditions, such as specified temperature, humidity, and electromagnetic fields. However, in actual use, the environment in which the electricity meter operates is complex and variable, making it difficult to maintain a consistently standard environment. When environmental conditions such as temperature and humidity change, the previously calibrated parameters become unsuitable for the new environment, resulting in the electricity meter's inability to adjust its measurement error in real time and effectively compensate for dynamically changing errors. Single-parameter adjustment methods also have problems. Because the measurement error of an electricity meter is a complex situation caused by the combined effects of multiple factors, adjusting only one parameter cannot comprehensively address the complex error situation caused by multiple factors. When faced with the simultaneous influence of temperature and electromagnetic interference, adjusting only the temperature-related parameter cannot eliminate the impact of electromagnetic interference on the measurement error, resulting in a still relatively large measurement error in actual use, failing to meet the ever-increasing demand for high-precision measurement. Summary of the Invention
[0006] The purpose of this invention is to provide a dynamic compensation method for electricity meter metering errors, so as to solve the problems mentioned in the background art.
[0007] To achieve the above objectives, the present invention provides a method for dynamic compensation of metering errors in electricity meters, the method comprising:
[0008] Collect raw metering data during the operation of the electricity meter, and perform principal component analysis on the raw metering data to obtain the electricity meter metering principal component sequence;
[0009] Wavelet transform is performed on the principal component sequence of the electricity meter to obtain approximation coefficients and detail coefficients. A dynamic compensation circuit is composed of resistors and reactors. The approximation coefficients are used as the metering reference values. The detail coefficients are distributed within the dynamic compensation circuit to obtain the distribution coefficients.
[0010] Based on the allocation coefficient, a two-layer optimization model for electricity meter metering error compensation is constructed, which includes an upper-layer optimization model and a lower-layer optimization model.
[0011] The constraints of the upper-level optimization model and the lower-level optimization model are determined, the allocation coefficients are input into the upper-level optimization model and the lower-level optimization model, and gradient descent is performed according to the constraints to obtain the electricity meter measurement error compensation parameters.
[0012] Dynamic error compensation is performed on the electricity meter based on the metering error compensation parameters.
[0013] Preferably, the step of performing principal component analysis on the raw metering data to obtain the electricity meter metering principal component sequence includes: acquiring the raw metering data stream in real time using a sliding window mechanism; standardizing the data within each window to eliminate dimensional differences; calculating the covariance matrix of the window data and obtaining eigenvalues and eigenvectors through eigenvalue decomposition; dynamically selecting the number of principal components based on the magnitude of the eigenvalues, retaining the principal component directions whose cumulative variance contribution rate exceeds a preset threshold; projecting the standardized data onto the principal component directions, and outputting the real-time updated electricity meter metering principal component sequence.
[0014] Preferably, the step of performing wavelet transform processing on the principal component sequence of the electricity meter to obtain approximation coefficients and detail coefficients includes: selecting an adaptive wavelet basis function to perform multi-scale decomposition of the principal component sequence of the electricity meter; extracting low-frequency approximation coefficients and high-frequency detail coefficients through low-pass and high-pass filters respectively; automatically determining the optimal decomposition level based on the signal energy distribution; and reconstructing the coefficients at each scale to obtain approximation coefficients representing trend components and detail coefficients representing fluctuation components.
[0015] Preferably, the allocation of the detail coefficients within the dynamic compensation circuit to obtain allocation coefficients includes: analyzing the frequency characteristics and amplitude distribution of the detail coefficients; designing a fuzzy logic controller to dynamically calculate the allocation weights; compensating for low-frequency detail components using resistors and high-frequency detail components using reactors; and integrating the weighted detail coefficients to generate allocation coefficients for model input.
[0016] Preferably, the construction of the two-layer optimization model for electricity meter measurement error compensation based on the allocation coefficient includes: minimizing the dispersion of the deviation between the electricity meter measurement value and the true value to minimize the measurement error fluctuation; and maximizing the efficiency of the compensation circuit by setting the maximum ratio of the output active power to the input active power. The upper-layer optimization model takes minimizing the measurement error fluctuation as its objective function, while the lower-layer optimization model takes maximizing the efficiency of the compensation circuit as its objective function. A data interaction channel is established between the upper-layer and lower-layer optimization models. The allocation coefficient is used as a shared variable to connect the two models. The model decision variables are defined to include compensation parameters and circuit configuration parameters.
[0017] Preferably, determining the constraints of the upper-level optimization model and the lower-level optimization model includes: setting the constraint of the upper-level optimization model as the allowable deviation range of measurement error; setting the constraint of the lower-level optimization model as the safe operating parameters of circuit components; defining coupling constraints to ensure the consistency of solutions of the upper-level optimization model and the lower-level optimization model; and introducing slack variables to handle constraint conflict problems.
[0018] Preferably, the step of inputting the allocation coefficients into the upper-level optimization model and the lower-level optimization model and performing gradient descent solution according to the constraints includes: initializing the parameter vector of the two-level optimization model; calculating the gradient direction of the objective function with respect to the parameters; adjusting the parameter update step size using an adaptive learning rate; using the projection gradient method to ensure that the updated parameters meet the constraints; iteratively solving until the objective function converges, and outputting the electricity meter metering error compensation parameters.
[0019] Preferably, the dynamic error compensation of the energy meter based on the energy meter metering error compensation parameters includes: converting the energy meter metering error compensation parameters into digital control signals; driving the resistors and reactors in the dynamic compensation circuit to adjust their impedance values; acquiring the energy meter metering output values in real time and calculating the instantaneous error; and dynamically adjusting the control signals based on the instantaneous error to achieve closed-loop error compensation.
[0020] Preferably, the method further includes: monitoring the compensated metering data and calculating error statistics; comparing the changes in error distribution before and after compensation and evaluating the compensation effect; automatically adjusting the metering error compensation parameters of the electricity meter according to the evaluation results; and recording the compensation process data for model optimization and fault diagnosis.
[0021] Preferably, the method further includes: periodically updating the original metering database, retraining the principal component analysis model and wavelet transform model; adjusting the parameters of the two-layer optimization model according to the new data; realizing the self-learning and adaptive functions of the compensation system; and ensuring the metering accuracy and stability of the electricity meter during long-term operation.
[0022] Compared with the prior art, the beneficial effects of the present invention are:
[0023] In the data processing stage, principal component analysis (PCA) is performed on the raw metering data collected during the operation of the electricity meters. During actual operation, electricity meters are affected by various complex factors, resulting in a large amount of redundant information in the collected raw data. This redundancy not only increases the difficulty and computational load of data processing but may also interfere with the judgment of the true metering status. PCA effectively extracts key information from the data, removes redundancy, and transforms the high-dimensional raw data into a low-dimensional principal component sequence of electricity meter measurements. This process is like clearing a path through a complex information jungle, allowing us to more accurately grasp the changing characteristics of the electricity meter's metering status. Subsequently, wavelet transform is performed on the principal component sequence of electricity meter measurements to obtain approximation coefficients and detail coefficients. The approximation coefficients reflect the low-frequency trend of the signal, representing the stable components in the electricity meter measurement data, while the detail coefficients contain high-frequency variation information of the signal, corresponding to the fluctuations and abrupt changes in the electricity meter measurement data. This wavelet transform process can effectively separate different features in the electricity meter data, further improving the ability to understand and analyze the data, and providing a more reliable basis for subsequent error compensation.
[0024] The design of the dynamic compensation circuit is a major highlight of this invention. This circuit, composed of resistors and reactors, can allocate coefficients based on approximation and detail coefficients. In actual power consumption scenarios, power load changes are complex and diverse, and the operating state of the electricity meter also changes accordingly. The dynamic compensation circuit of this invention can flexibly respond to different power consumption scenarios and electricity meter operating states based on the stable metering reference value represented by the approximation coefficient and the metering data fluctuations reflected by the detail coefficient. When encountering a sudden increase or decrease in power load, the dynamic compensation circuit can promptly adjust the allocation coefficients to quickly compensate for potential metering errors, ensuring accurate metering under various complex operating conditions. This flexibility and adaptability make the electricity meter's metering more stable and reliable, greatly improving its performance in practical applications.
[0025] The construction of a two-layer optimization model provides strong support for achieving accurate error compensation. This model comprises an upper-layer optimization model and a lower-layer optimization model, which work together to comprehensively consider various constraints that may affect the metering error of the electricity meter. The upper-layer optimization model, from a macroscopic perspective, comprehensively considers factors such as the overall operating environment of the electricity meter, long-term metering trends, and some basic requirements of the power system, and makes preliminary plans and settings for error compensation. The lower-layer optimization model focuses on the microscopic level, making fine adjustments and optimizations for real-time data changes, short-term metering fluctuations, and sudden interference situations during the specific operation of the electricity meter. By inputting the allocation coefficients into the upper-layer and lower-layer optimization models and solving them using gradient descent based on predetermined constraints, accurate electricity metering error compensation parameters can be obtained. Compared with traditional single-model or simple parameter adjustment methods, this two-layer optimization approach can more comprehensively and deeply consider the impact of various factors on metering errors, thereby effectively reducing metering errors and improving the metering accuracy of the electricity meter.
[0026] The method of this invention achieves dynamic error compensation for electricity meters, enabling them to maintain high metering accuracy under complex environments and varying operating conditions. Whether in harsh environments such as high temperature and humidity, or in industrial production scenarios with frequent changes in electricity load, the electricity meter can accurately measure the user's electricity consumption. This not only ensures fair and equitable electricity billing and avoids disputes between users and power supply companies due to metering errors, but also provides strong support for the efficient and stable operation of the power system. Accurate electricity metering data helps power departments to more precisely grasp the production and consumption of electricity, thereby rationally allocating power resources, optimizing the operation and scheduling of the power system, reducing power losses, and improving the economic benefits and operational efficiency of the power system. For power companies and users, reliable electricity metering data is the foundation for economic accounting, helping both parties to more scientifically formulate electricity consumption plans and cost budgets, achieving rational resource utilization and maximizing economic benefits. Attached Figure Description
[0027] Figure 1 This is a schematic diagram illustrating the working principle of the dynamic compensation method for electricity meter metering errors described in this invention.
[0028] Figure 2 A flowchart for principal component analysis processing of raw econometric data;
[0029] Figure 3 A flowchart for wavelet transform processing of principal component sequences in electricity meter readings;
[0030] Figure 4 The gradient descent iterative convergence plot for the metering error compensation parameters of the electricity meter;
[0031] Figure 5 This is a comparison chart showing the electricity meter's metering error before and after dynamic compensation. Detailed Implementation
[0032] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0033] Please see Figure 1 This invention provides a dynamic compensation method for electricity meter metering errors. The method includes: achieving precise dynamic adjustment of electricity meter metering through integrated data analysis and circuit compensation technologies. The dynamic compensation method for electricity meter metering errors comprises multiple collaborative steps, starting with the acquisition of raw metering data during electricity meter operation. The acquired raw metering data undergoes principal component analysis (PCA) to extract the electricity meter metering principal component sequence. PCA effectively reduces data dimensionality while retaining key features. The electricity meter metering principal component sequence is then subjected to wavelet transform processing, which decomposes the sequence into approximation coefficients and detail coefficients. The approximation coefficients represent the metering trend component, and the detail coefficients represent the fluctuation component. The dynamic compensation circuit consists of resistors and reactors. The approximation coefficients serve as metering reference values, and the detail coefficients are allocated within the dynamic compensation circuit to generate allocation coefficients. The allocation coefficients are used to construct a two-layer optimization model for electricity meter metering error compensation, which includes an upper-layer optimization model and a lower-layer optimization model. The constraints of the upper and lower optimization models are clearly defined. Assignment coefficients are input into both models, and the energy meter metering error compensation parameters are calculated using a gradient descent algorithm based on these constraints. Specifically, an adaptive learning rate is used to adjust the parameter update step size. The adaptive learning rate algorithm dynamically scales based on the historical gradient magnitude, with the initial learning rate set to an empirical value to avoid oscillations or stagnation during the optimization process. The projection gradient method ensures that the updated parameters satisfy the constraints. The projection operation maps the parameters to the feasible region defined by inequality constraints. The projection algorithm iteratively calculates the Lagrange multipliers to ensure the parameters are within physical constraints. The iterative solution is executed repeatedly, calculating the gradient, adjusting the learning rate, updating the parameters, and projecting in each iteration. Convergence conditions are checked for changes in the objective function or the gradient norm. The iteration log records the parameter history and objective function values until the energy meter metering error compensation parameters are output. The solution process is integrated into an embedded system, with real-time synchronization with the energy meter sampling period. The energy meter metering error compensation parameters are ultimately applied to the dynamic error compensation stage of the energy meter, achieving real-time improvement in metering accuracy.
[0034] The implementation of dynamic compensation methods for electricity meter metering errors relies on efficient data processing workflows and hardware circuitry. The raw metering data originates from a real-time monitoring system during electricity meter operation, with the data acquisition module acquiring raw voltage and current signals at high frequency. In the principal component analysis (PCA) processing stage, statistical learning methods are used to map the high-dimensional raw metering data to a low-dimensional space, eliminating redundant information and highlighting key variation patterns. In the wavelet transform processing stage, multi-resolution analysis tools are used to decompose the electricity metering principal component sequence in the time-frequency domain. Approximation coefficients capture low-frequency steady-state components, while detail coefficients capture high-frequency noise components. The dynamic compensation circuit is designed as an adjustable impedance network; resistors adjust the active component, reactors adjust the reactive component, and the allocation coefficients achieve energy distribution through circuit parameter adjustments. The dual-layer optimization model for electricity meter metering error compensation is constructed as a hierarchical decision framework. The upper-layer optimization model focuses on minimizing errors, while the lower-layer optimization model optimizes circuit efficiency. The dual-layer structure is coordinated through shared variables. Constraints define physical limitations and performance boundaries, and the gradient descent algorithm iteratively searches the optimal solution space. The metering error compensation parameters of the electricity meter are converted into control signals to drive the dynamic compensation circuit, forming a closed-loop compensation system that continuously corrects the electricity meter output.
[0035] Example 1: See Figure 2In the dynamic compensation method for electricity meter metering errors, the sliding window mechanism used in the principal component analysis processing stage captures the raw metering data stream from the electricity meter data bus at fixed time intervals. The raw data stream includes instantaneous voltage and current sample values. The data buffer is configured in a ring structure, with new data points overwriting older ones to achieve continuous rolling updates. The time interval of the sliding window mechanism is synchronized with the electricity meter's power frequency cycle. Each window accommodates an integer number of cycles of waveform data, and the window width is dynamically adjusted according to the system's processing capacity, typically covering two hundred sampling points. The pointer management of the data buffer uses modular arithmetic technology, with write and read pointers moving alternately to maintain the integrity and timing consistency of the data stream, preventing data loss or out-of-order processing. After the raw metering data stream enters the buffer, a preprocessing procedure is triggered. This procedure detects and removes obvious outliers based on statistical thresholds; for example, data points exceeding three standard deviations are marked and replaced with the mean of adjacent points. The raw metering data within each window undergoes standardization processing. Standardization calculates the arithmetic mean and sample standard deviation of all data points within the window. The arithmetic mean represents the data center location, and the sample standard deviation represents the data dispersion. The standardization formula subtracts the arithmetic mean from each original data value and divides by the sample standard deviation, generating a standardized dataset with a mean of zero and a standard deviation of one, eliminating numerical imbalances caused by differences in voltage and current dimensions. The standardized data is stored in a temporary array with a length matching the window size, and data elements are converted to floating-point format to ensure computational accuracy. The covariance matrix of the window data is constructed using linear algebra operations. The covariance matrix is a symmetric square matrix with dimensions equal to the number of variables within the window. Matrix elements are used to calculate the covariance values between data points at different time points. The covariance matrix calculation uses a vectorized operation method, converting the standardized data array into a design matrix. The transpose of the design matrix is multiplied by itself, and the result is divided by the degrees of freedom correction coefficient to obtain the unbiased covariance estimate.
[0036] Eigenvalue decomposition (EVD) is applied to the covariance matrix. EVD solves for the eigenvalues and eigenvectors of the covariance matrix. Eigenvalues represent the distribution magnitude of the data variance along the principal component directions, and eigenvectors indicate the principal component directions. EVD employs the Jacobi iterative algorithm, which diagonalizes the covariance matrix through a series of rotations. Off-diagonal elements converge to zero iteratively, and the diagonal elements are the eigenvalues. Eigenvectors are extracted from the transformation matrix, with each eigenvector corresponding to an eigenvalue. Eigenvalues are arranged in descending order of value, and the eigenvectors are rearranged accordingly. The number of principal components is dynamically selected based on the cumulative variance contribution rate (CRR), calculated as the ratio of the sum of the first k eigenvalues to the sum of all eigenvalues. A preset threshold of 95% is set. When the CRR first exceeds 95%, the corresponding k value is selected as the number of principal components, and the first k eigenvectors are retained to form the projection matrix. Standardized data is projected onto the principal component direction. The projection operation multiplies the standardized data matrix and the projection matrix. The projection matrix is formed by concatenating the first k eigenvectors column-wise. The multiplication result generates the dimensionality-reduced principal component sequence of the electricity meter readings. The electricity meter principal component sequence is a k-dimensional time series, with each dimension representing a principal component. The sequence length is the same as the number of data points in the window, and the sequence elements contain the main variance information. The projection process is executed in real time. After the new window of data is processed, the electricity meter principal component sequence is updated immediately, and the sequence data is output to a shared memory area for wavelet transform processing. The storage format of the electricity meter principal component sequence adopts a timestamp-aligned structure, with each data point marked with its acquisition time to maintain temporal relationships and facilitate subsequent multi-scale analysis.
[0037] The sliding window mechanism relies on the system clock interrupt service routine. The clock interrupt triggers data acquisition and buffer update operations, and the interrupt handler's priority is configured higher than that of normal tasks. Data flow management employs double buffering, allocating two buffers of equal size: one for receiving new data and the other for background processing. The buffer pointers are switched within the interrupt service routine. The arithmetic mean and sample standard deviation calculations for standardization use a recursive algorithm. This algorithm dynamically updates the cumulative sum and sum of squares based on new data points, avoiding full-window recalculation and improving efficiency. The eigenvalue decomposition of the covariance matrix is optimized to a block-based computation version, decomposing large matrices into sub-matrices for parallel processing, utilizing a multi-core processor architecture to reduce computational latency. The principal component selection logic integrates a configurable threshold interface, with preset thresholds set via system parameters to adapt to the accuracy requirements of different energy meter models. The projection matrix maintenance uses an incremental update strategy; when data distribution changes slowly, the projection direction is adjusted only for newly added data, avoiding global recalculation and saving computational resources. The output interface of the energy meter's principal component sequence provides data compression functionality. Lossless compression algorithms reduce storage space usage, and differential encoding is used for sequence transmission to reduce bandwidth requirements. The hardware support for the principal component analysis (PCA) processing stage includes a high-precision ADC module and a digital signal processor (DSP). The ADC module's sampling rate is set to several kilohertz, satisfying the Nyquist sampling theorem. The DSP has a built-in floating-point unit to accelerate matrix operations and eigenvalue decomposition calculations, and processor caching optimizes data locality. The software modules adopt a modular design, with data acquisition, standardization, covariance calculation, eigenvalue decomposition, and projection functions independently encapsulated. Modules communicate with each other via message queues. An error handling mechanism detects numerical calculation anomalies, such as matrix singularities or convergence failures. In case of anomalies, a degradation processing mode is triggered, continuing operation using historical parameters. Performance monitoring of the PCA processing stage records processing latency and memory usage; the monitoring data is used for system optimization and fault diagnosis.
[0038] The quality assessment of the principal component analysis (PCA) sequence of electricity meter readings includes signal-to-noise ratio (SNR) calculation. The SNR assesses the energy ratio of the retained signal to the noise in the principal components. When the SNR falls below a threshold, parameter recalibration is triggered. The stationarity of the sequence is tested using the unit root test. Specifically, the PCA sequence is evaluated for time series stationarity. The unit root test determines the presence of a unit root by analyzing the difference results of the sequence; the presence of a unit root indicates non-stationarity. This testing process is integrated into the subsequent stages of PCA processing. The PCA sequence serves as input data, and the unit root test calculates the autoregressive model parameters of the sequence. The hypothesis testing principle is used to compare the test statistic with a preset critical value. Non-stationary sequences indicate changes in data characteristics, requiring adjustments to the sliding window size or the number of principal components. The PCA processing is linked to the electricity meter calibration program. Standard data provided by the calibration program is used to verify the correctness of the principal component directions. When the direction deviation exceeds the tolerance, the model is retrained. Long-term operational data accumulation is used for adaptive optimization of the PCA model. Model parameters are periodically updated to adapt to device aging and environmental changes, maintaining the long-term effectiveness of the dynamic compensation method for electricity meter reading errors.
[0039] Example 2: See Figure 3 In the dynamic compensation method for electricity meter metering errors, the wavelet transform processing stage receives the principal component sequence of the electricity meter measurement from the principal component analysis stage. The wavelet transform processing stage selects adaptive wavelet basis functions to perform multi-scale decomposition on the input sequence. The selection of adaptive wavelet basis functions is based on the local characteristic analysis of the principal component sequence of the electricity meter measurement; the stationarity, spectral density, and singular point distribution of the sequence are included in the evaluation scope. The Daubechies and Symlets wavelet families are used as candidate basis function libraries. The basis function selection algorithm calculates the matching degree between each candidate wavelet and the signal segment. The matching degree is quantified by the correlation coefficient and energy concentration measure, and the optimal wavelet basis function is dynamically determined as the basis function with the highest matching degree. Multi-scale decomposition is implemented through an iterative filter bank. Each decomposition stage decomposes the signal into low-frequency approximation coefficients and high-frequency detail coefficients. The number of decomposition stages is determined by the signal length and the Nyquist frequency.
[0040] The design of low-pass and high-pass filters corresponds to the scaling function and wavelet function of the selected wavelet basis function. Filter coefficients are pre-calculated and stored in a lookup table. Convolution operations are applied to the principal component sequence of the electricity meter. The low-pass filter outputs approximation coefficients, which capture the macroscopic trend and slowly changing components of the signal. The high-pass filter outputs detail coefficients, which capture the microscopic fluctuations and rapidly changing components of the signal. The filter bank adopts a polyphase structure to improve computational efficiency. Downsampling operations follow the Mallat algorithm specification, and the number of data points is halved after each decomposition stage. Signal energy distribution calculation is performed throughout the decomposition process. The sum of squares of the detail coefficients at each scale serves as the energy representation for that scale, and the energy proportion curve is used to guide the determination of the optimal number of decomposition layers. When the energy contribution of a newly added decomposition layer is lower than a preset threshold, the decomposition process terminates to avoid over-decomposition leading to information redundancy. The reconstruction process uses a dual filter bank. Approximation coefficients and detail coefficients are synthesized step by step after upsampling and filtering, and the reconstructed signal maintains time-frequency characteristics alignment with the original signal. The approximation coefficients represent the trend components in electricity metering, which reflect the long-term variation of the load and basic power demand. The detail coefficients represent the fluctuation components in electricity metering, which contain information about transient events, noise interference, and harmonic distortion. The reconstructed approximate coefficient sequence is transmitted to the compensation circuit as a metering reference value, and the detail coefficient sequence enters the allocation process.
[0041] The frequency characteristics of the detail coefficients were analyzed using short-time Fourier transform. The spectrum plots show the frequency distribution of the detail coefficients at different scales, and the amplitude distribution was modeled using a probability density function. The fuzzy logic controller was designed as a dual-input, single-output system. The input variables were the center frequency and root-mean-square amplitude of the detail coefficients, and the output variable was the weighting distribution between the resistor and reactor. The fuzzification interface converted precise input values into fuzzy sets. The membership function used a hybrid triangular and trapezoidal form, and the fuzzy rule base contained dozens of conditional statements based on domain knowledge. The inference engine used the Mamdani min-max inference method. Specifically, the fuzzy logic controller processed the center frequency and root-mean-square amplitude of the detail coefficients as input variables. The input variables were converted into fuzzy sets through the fuzzification interface. The membership function of the fuzzy sets used a hybrid triangular and trapezoidal form to define the degree to which the variable belonged to different fuzzy levels. The defuzzification stage used the centroid method to calculate the precise weighting values. Specifically, the centroid method calculates the centroid position of the synthesized output fuzzy set. The centroid position is determined by weighted averaging of the membership values of all possible output points. The weighted averaging process uses the membership value of each output point as a weight, calculates the sum of the products of the output point value and its corresponding membership value, and then divides by the sum of the membership values to obtain the precise assigned weight value. Resistors compensate for low-frequency detail components, which correspond to the long-scale components in the detail coefficients. Resistor impedance adjustment is achieved by changing the equivalent resistance of the parallel resistor network, providing energy-dissipating compensation to smooth low-frequency fluctuations. Reactors compensate for high-frequency detail components, which correspond to the short-scale components in the detail coefficients. Reactor inductive reactance adjustment is achieved by changing the equivalent reactance through a switched capacitor array, providing energy-exchange compensation to suppress high-frequency oscillations. The weighted detail coefficients are then vector-synthesized, with the synthesis operation considering phase alignment. The assigned coefficients serve as the final output after amplitude and phase adjustments. The assigned coefficients are encapsulated as a data structure containing frequency band information, amplitude gain, and phase compensation values, directly driving the parameter configuration of the dynamic compensation circuit.
[0042] Hardware acceleration for wavelet transform processing relies on a dedicated digital signal processor (DSP). The processor integrates convolution operation instructions and high-speed memory, and filter bank calculations employ a parallel pipeline architecture. The adaptive wavelet basis function selection module monitors signal statistical characteristics in real time, triggering a reselection process when signal characteristic changes exceed a threshold. Hierarchical management of multi-scale decomposition uses dynamic memory allocation, with coefficients at each level stored in an independent buffer. Buffer address mapping is uniformly scheduled by the memory management unit. The energy distribution calculation module integrates a hardware multiplier-accumulator, cyclically updating and comparing energy values. The decomposition termination judgment logic is implemented using hardware interrupts. The optimization of the reconstruction algorithm focuses on computational precision control. Floating-point operations adopt the IEEE 754 standard, and rounding errors are compensated using the Kahan summation algorithm. Specifically, the Kahan summation algorithm introduces an error accumulation variable to track and correct rounding errors generated by each addition operation. During algorithm initialization, an accumulation variable and an error compensation variable are set. The accumulation variable stores the current sum value, and the error compensation variable captures the rounding error of the previous addition. Each addition operation first adds the input value to the error compensation variable to obtain a temporary sum. The temporary sum is then subtracted from the accumulated variable to calculate the current rounding error. The error compensation variable is updated to the current rounding error value, and the accumulated variable is finally updated to the temporary sum. The fuzzy logic controller for the detailed coefficient allocation stage is implemented using a combination of lookup tables and linear interpolation. The fuzzy rule table is pre-compiled into binary code, and real-time inference is completed through address indexing and interpolation calculations. The control interfaces for resistors and reactors receive the allocated coefficients. The digital-to-analog converter converts the coefficients into analog voltage signals, which drive the adjustable resistor array and variable reactor. The impedance adjustment response time is controlled at the microsecond level, maintaining synchronization with the electricity meter's metering cycle. The fault tolerance mechanism in the wavelet transform processing stage includes coefficient overflow detection and filter stability monitoring. Abnormal conditions trigger coefficient saturation processing or filter coefficient reloading. Timestamp management during processing ensures strict alignment of multi-scale coefficients with the original data, and timestamp information is embedded in the coefficient header for subsequent verification. Boundary effects in the principal component sequence of electricity meter readings are suppressed using a symmetric extension method. Specifically, to address boundary effects in the principal component sequence, the symmetric extension method extends the sequence length by mirroring the values near the sequence endpoints. This extension operation is performed simultaneously at the start and end of the sequence, with the mirror symmetry axis set as the endpoint position. The extended sequence forms a continuous and smooth boundary transition. The extension length is adaptively determined based on the filter length. A dynamic computational resource allocation algorithm adjusts the processing thread priority according to signal complexity, ensuring that scales with high real-time requirements are processed first.
[0043] Data exchange between the wavelet transform processing stage and the upper-level optimization model utilizes a dual-port memory. An interrupt signal is generated after the allocated coefficients are written to memory, triggering the optimization model to read the interrupt and restart computation. Processing performance monitoring records the decomposition time and resource utilization at each scale; long-term running data is used for algorithm parameter tuning. The wavelet basis function library supports online updates; new basis functions are added to the candidate library after passing security checks, enhancing system adaptability. The detailed coefficient allocation weight learning function records historical allocation effects, and the weight coefficients are slowly adjusted to optimize long-term performance, forming a closed-loop learning system.
[0044] Example 3: The construction of a two-layer optimization model for electricity meter measurement error compensation is based on allocation coefficients. Specifically, it is initiated after the wavelet transform processing stage, with the detail coefficients output by the wavelet transform stage serving as input data for the allocation process. The detail coefficients contain multi-scale high-frequency component information of the electricity meter's principal component sequence, reflecting transient changes and noise characteristics in the measurement signal. The allocation process first analyzes the frequency distribution characteristics of the detail coefficients, which are obtained through Fast Fourier Transform (FFT). Spectral analysis determines the dominant frequency range of each scale's detail coefficients. The allocation coefficients originate from the output of the wavelet transform processing stage and carry the frequency domain and amplitude information of the detail coefficients. The minimum dispersion of the deviation between the electricity meter's measured value and the true value is used to minimize the measurement error fluctuation, while the maximum ratio of the output active power to the input active power of the compensation circuit is used to maximize the efficiency of the compensation circuit. The upper-layer optimization model uses minimizing the measurement error fluctuation as the objective function. The measurement error fluctuation is defined as the variance of the error sequence, calculated using statistical methods. The error sequence originates from the deviation between the electricity meter's output and the reference value. The lower-level optimization model aims to maximize the efficiency of the compensation circuit, which is the ratio of output power to input power, reflecting energy conversion efficiency. The upper-level and lower-level optimization models are connected via a data exchange channel, which uses a shared memory region or message passing interface. Allocation coefficients are used as shared variables for synchronization between the models. Model decision variables include compensation parameters and circuit configuration parameters. Compensation parameters include proportional gain and integral time, while circuit configuration parameters include resistance and reactance. The objective function of the upper-level optimization model is mathematically expressed as minimizing the error variance, as shown in the following formula:
[0045] ;
[0046] in: This represents the objective function value of the upper-level optimization model; Indicates the first The normalized value of the metering error at each sampling time point is obtained by dividing the actual error by the reference value, and has one dimension. This represents the total number of sampling time points. Objective function value. The calculation is based on an error sequence, which is updated in real time. The optimization process seeks to optimize the decision variables. minimize.
[0047] The objective function of the lower-level optimization model is mathematically expressed as maximizing circuit efficiency, defined as the ratio of the output active power to the input active power of the compensation circuit. The decision variable vector includes continuous and discrete variables; continuous variables include simulation adjustment parameters, and discrete variables include switch states. A data interaction channel enables bidirectional communication: the upper-level optimization model transmits optimized compensation parameters to the lower level, and the lower-level optimization model feeds back the circuit state to the upper level. Shared variable allocation coefficients serve as a connecting link, influencing the constraints and objective values of both models. The model construction employs a mathematical programming framework, with a two-level structure simulating a Stackelberg game, where the upper level is the leader and the lower level is the follower. The constraints of the upper-level optimization model are set as the allowable deviation range of metering errors, determined according to the accuracy class of the energy meter; for example, the absolute value of the error should not exceed one percent of the full scale. The constraints are expressed as inequalities, and the error value satisfies boundary limits at each sampling point. The constraints of the lower-level optimization model are set as safe operating parameters for circuit components, including maximum allowable current, maximum allowable voltage, and maximum operating temperature. Constraints are based on component datasheets: current constraints prevent overload, voltage constraints prevent breakdown, and temperature constraints prevent thermal damage. Coupling constraints define the consistency of solutions between the upper and lower optimization models. Consistency requires that the lower response variables adjust accordingly when the upper decision variables change. Coupling constraints are expressed as equality or inequality relationships. Relaxation variables are introduced to handle constraint conflicts, transforming hard constraints into soft constraints. Penalty terms are added to the optimization objective to handle constraint violations.
[0048] The solution environment for the two-layer optimization model for electricity meter metering error compensation is configured as an embedded system. The system integrates an optimization solution library, which provides linear and nonlinear programming algorithms. Model parameters are initialized based on historical data or default values, and these initial values affect the convergence speed. The data exchange frequency between the upper and lower optimization models is synchronized with the electricity meter sampling period, and data packet encapsulation with timestamps ensures timing alignment. The storage structure of the shared variable allocation coefficients includes amplitude, frequency, and phase fields, which are parsed and mapped to decision variables. Compensation parameters adjust circuit behavior, and circuit configuration parameters change impedance characteristics, with optimization objectives working together to reduce error fluctuations and improve efficiency. Constraint handling employs the effective set method, which simplifies the solution process by identifying active constraint sets. Active constraints are those that are in a boundary state or active at the current iteration point, directly affecting the optimization direction of the objective function. The effective set method identifies active constraints. Relaxed variables are assigned non-negative values; their magnitude reflects the degree of constraint violation, and penalty coefficients balance the objective function with constraint satisfaction. The Jacobian matrix of coupled constraints is used to calculate partial derivatives, which indicate variable sensitivity. The numerical stability of the model is monitored by the condition number; regularization is triggered when the condition number is too large. Constraint violations are recorded during the optimization iteration process; the solution is reinitialized when the violation exceeds a threshold. Real-time performance of the two-layer optimization model for electricity meter metering error compensation is ensured through algorithm optimization, which includes reducing computational complexity and memory usage. The gradient calculation of the objective function in the upper-layer optimization model uses automatic differentiation, which provides accurate differentiation and avoids the difficulties of sign differentiation. The concavity / convexity of the objective function in the lower-layer optimization model is analyzed, and this concavity / convexity determines the choice of solution method. The communication protocol for the data interaction channel adopts a lightweight design, minimizing protocol overhead to ensure low latency. Shared variable access synchronization mechanisms prevent data contention, and mutexes or semaphores manage concurrent operations.
[0049] Boundary checks for model decision variables are integrated into the solution loop, with variable values projected onto the feasible region using Euclidean distance minimization. Compensation parameters physically correspond to circuit gain, while circuit configuration parameters physically correspond to impedance magnitudes. The impact of allocation coefficients is quantified through sensitivity analysis, with sensitivity coefficients guiding model adjustments. The structural flexibility of the bi-level optimization model supports modular expansion, allowing for easy addition of new constraints or objectives. A visual log of the solution process records the iteration history, used for debugging and performance analysis. The bi-level optimization model for electricity meter metering error compensation interfaces with the hardware circuit, converting optimization parameters into control signals. These control signals drive a digital-to-analog converter (DAC), which generates analog voltage regulating resistors and reactors. Circuit response time is incorporated into model constraints, with response time delay compensation achieved through a predictive correction algorithm. The model self-calibration function periodically re-estimates parameters, updating the objective function with the latest error data. Long-term operational adaptability is achieved through model parameter learning, using algorithms such as stochastic gradient descent to adjust internal weights. A dynamic constraint adjustment mechanism responds to changes in the operating environment, such as temperature fluctuations or sudden load changes. The relaxation strategy for coupling constraints loosens conditions during conflicts, and the priority setting of the relaxation strategy ensures safe operation. The convergence proof of the collaborative optimization between the upper and lower optimization models adopts the fixed-point theorem, and the convergence condition verifies the iterative stability. The implementation code of the two-layer optimization model for electricity meter metering error compensation is optimized into fixed-point arithmetic, which improves the efficiency of the embedded system. Model validation is achieved through simulation testing, with test cases covering typical working scenarios.
[0050] The maintenance of the dual-level optimization model for electricity meter metering error compensation includes parameter backup and recovery, with backup data stored in non-volatile memory. A fault recovery mechanism detects model anomalies, such as numerical overflow or iterative divergence, and resets the model state. Performance monitoring metrics include solution time and resource usage; alarms are triggered when metrics exceed limits. The user interface provides model parameter configuration, including constraints, boundaries, and penalty coefficients. Integration testing of the dual-level optimization model ensures compatibility with existing systems, and compatibility testing verifies data formats and protocols. Upgrades to the dual-level optimization model support online updates, with update package signatures verifying security and integrity. Version management records model changes, and change logs are audited and tracked. The long-term stability of the dual-level optimization model is evaluated through aging tests, which accelerate its lifespan. A documentation generation tool automatically generates model specifications, including formula definitions and parameter meanings. The deployment process for the dual-level optimization model is standardized, with automated installation steps via process scripts.
[0051] Example 4: In the dynamic compensation method for electricity meter metering errors, the parameter vector of the two-layer optimization model is initialized in the gradient descent solution stage. The parameter vector contains all decision variables of the upper and lower optimization models, such as the compensation gain coefficient and circuit impedance value. The initial values are set based on historical running data or default configuration. The parameter vector is stored in a floating-point array, with the array dimension matching the number of variables. The initialization process calls a random number generator or a deterministic algorithm to assign initial values, and the range of initial values is limited by physical constraints. The gradient direction of the objective function with respect to the parameters is calculated using numerical differentiation or automatic differentiation techniques. The gradient vector indicates the direction of the fastest descent of the function, and the gradient calculation is based on the current parameter values and input data. The adaptive learning rate adjusts the parameter update step size. The initial value of the learning rate is set to an empirical value, and the learning rate is dynamically adjusted according to the historical gradient magnitude to avoid oscillation or stagnation in the optimization process. The projected gradient method ensures that the updated parameters meet the constraints. The projection operation maps the parameters to the feasible region, which is defined by inequality constraints. The iterative solution is executed repeatedly. In each iteration, the gradient is calculated, the learning rate is adjusted, the parameters are updated, and projection is performed. The convergence condition checks the change of the objective function or the gradient norm. Gradient descent is implemented on an embedded processor, whose built-in floating-point unit accelerates matrix computation, and dynamic memory management is used for parameter vector memory allocation. During initialization, a parameter configuration file is loaded and stored in non-volatile memory in key-value pairs or binary blocks. Gradient calculation uses the central difference method to approximate partial derivatives. Specifically, in the gradient descent solution, the central difference method estimates the partial derivatives by calculating the difference in function values at symmetrical positions near the parameter points. For each parameter dimension, the central difference method selects a small step size offset, calculates the function value of the objective function as the parameter vector increases and decreases in step size, and divides the difference between the two function values by twice the step size to obtain an approximate value of the partial derivative of that parameter. The difference step size is adaptively varied to balance accuracy and computational cost. Automatic differentiation is implemented through a computation graph that records variable dependencies, and the backpropagation algorithm efficiently calculates the derivative. The adaptive learning rate algorithm uses a variant of AdaGrad, where the learning rate is divided by the square root of the sum of squared gradients, and a momentum term is incorporated into the parameter update formula to suppress oscillations. The projection gradient method is used to solve quadratic programming problems. The projection operation uses Euclidean projection onto a set of polyhedra, and the projection algorithm iteratively calculates the Lagrange multipliers.
[0052] The iterative process monitors convergence metrics, with the convergence threshold set at a relative change of less than 0.02% or the number of iterations exceeding the maximum limit. Iteration logs record parameter history and objective function values; log data is used for debugging and performance analysis. Real-time time constraints are enforced, with the maximum allowable time synchronized with the electricity meter sampling period. An anomaly handling mechanism detects numerical overflow or infinite loops, triggering a solution restart or degradation mode. Gradient descent solvers output electricity meter error compensation parameters, standardized into a structure containing all optimized variable values. These parameters are applied to the dynamic error compensation stage, converted into digital control signals using a digital-to-analog converter or pulse-width modulation (PWM). The digital control signals drive resistors and reactors in the dynamic compensation circuit; resistors use digital potentiometers or adjustable resistor networks, and reactors use variable inductors or switched capacitor arrays. Real-time acquisition of the electricity meter output value is achieved through an analog-to-digital converter, with the sampling rate synchronized with the power line frequency. Instantaneous error calculation compares the output value with a reference value derived from an approximation coefficient or standard source. The error signal is input to the control loop, which is designed as a proportional-integral-derivative controller. The controller outputs a dynamic adjustment control signal.
[0053] Dynamic error compensation forms a closed-loop system, with closed-loop feedback continuously correcting compensation parameters. System stability is ensured through frequency domain analysis. The digital control signal generation module is integrated into a field-programmable gate array (FPGA), achieving a signal update rate up to the kilohertz level. Impedance adjustment response times for resistors and reactors are in the microsecond range, and an impedance value mapping table stores pre-calibration data. The real-time acquisition circuit incorporates an anti-aliasing filter, with the filter cutoff frequency set higher than the highest signal frequency. Instantaneous error calculation uses an arithmetic logic unit (ALU), and error values are normalized to prevent overflow. Control loop parameter tuning is based on the Ziegler-Nichols method. Specifically, the Ziegler-Nichols method automatically tunes the proportional gain, integral time, and derivative time parameters based on system response characteristics. The tuning process begins by setting the proportional gain to an initial value and gradually adjusting it until the system output exhibits a critical oscillation state. Characteristics of the critical oscillation state, such as amplitude oscillations in the output waveform, are used to identify the system's dynamic characteristics. The tuning process is automated.
[0054] Refer to Table 1 for error statistics of the compensation effect monitoring record. Error statistics include root mean square error and peak error. The statistical data is used for adaptive adjustment. Hardware protection circuits prevent overvoltage and overcurrent, with a response time in the nanosecond range. The dynamic error compensation stage interacts with the upper-level optimization model, which periodically updates the compensation parameters. Long-term operational data accumulation is used to improve the compensation algorithm, and machine learning algorithms optimize the control strategy.
[0055] Table 1: Initialization table for gradient descent solution parameters
[0056]
[0057] The software implementation of the gradient descent solution adopts a modular design, with modules including parameter initialization, gradient calculation, learning rate adjustment, projection operation, and convergence checking. The parameter initialization module reads configuration data, verifies data validity, and allocates memory space. The gradient calculation module processes multiple variables in parallel, utilizing a single instruction multiple data instruction set for acceleration. The learning rate adjustment module maintains a gradient history buffer, the size of which is configurable. The projection operation module integrates a numerical optimization library, whose functions handle linear and nonlinear constraints. The convergence checking module compares the difference between the current iteration and previous iterations, using a relative error formula. Specifically, applied in the convergence checking module of the gradient descent solution, the convergence checking module evaluates the convergence status of the optimization process by comparing the difference between the objective function values of the current iteration and previous iterations. The relative error formula calculates the absolute difference between the objective function value of the current iteration and the objective function value of the previous iteration, and then performs a ratio operation on this absolute difference to the absolute value of the objective function value of the previous iteration. The ratio result represents the relative magnitude of the change in the objective function.
[0058] The electricity meter's metering error compensation parameter conversion module converts floating-point parameters into a hardware-readable format, such as a fixed-point or integer ratio. The digital control signal generation module generates pulse-width modulation waveforms, with the waveform duty cycle linearly related to the parameter values. The resistor drive circuit uses a digital potentiometer interface with I2C or SPI protocols. The reactor drive circuit controls the switching elements, with the switching frequency set higher than the signal frequency to avoid interference. The real-time acquisition module synchronizes with the grid's zero-crossing point, and the sampling clock is generated by a phase-locked loop circuit. The instantaneous error calculation module is implemented in a digital signal processor, with the processor's instruction set optimizing arithmetic operations. The calibration process for the dynamic error compensation stage uses standard instruments, and calibration data is stored in encrypted memory. Compensation performance evaluation is based on long-term operating data, recording error distribution and the number of compensation cycles. The system's self-diagnostic function detects component faults, and fault indications trigger maintenance alarms. The integration test of the gradient descent solution stage and the dynamic error compensation stage covers extreme operating conditions, with test cases including load surges and noise injection.
[0059] The real-time performance of the dynamic compensation method for electricity meter metering errors is ensured through task scheduling, with gradient descent solving prioritized over dynamic error compensation. Memory management uses static allocation to avoid fragmentation and cache optimization to reduce access latency. The power management module reduces power consumption, and a sleep mode preserves critical data. The communication interface supports remote monitoring, with monitoring data uploaded to the cloud platform. Security mechanisms prevent unauthorized access, and parameter modifications require authentication. Algorithm upgrades in the gradient descent solving stage support online updates, with update packages verified by digital signatures. Adaptive training for the dynamic error compensation stage uses reinforcement learning, with training data derived from actual operation. Long-term operation and maintenance include parameter backup and recovery, with a backup cycle of once daily. Performance degradation detection compares historical performance metrics, such as solution time and error convergence speed. Hardware aging compensation adjusts parameter boundaries, with boundary values adaptively changing with temperature. The user interface provides parameter visualization, displaying optimization process curves. A documentation generation tool automatically generates technical reports, including parameter configurations and performance logs. The overall integration of the dynamic compensation method for electricity meter metering errors ensures data consistency between modules, with consistency checks based on timestamps and serial numbers.
[0060] See Figure 4 This graph, with the number of iterations on the horizontal axis and parameter values on the vertical axis, visually presents the iterative convergence process of the gradient descent algorithm in solving for electricity meter metering error compensation parameters. The solid blue line represents the compensation gain coefficient, the dashed purple line represents the resistance adjustment parameter, and the dotted orange line represents the reactance adjustment parameter. All three curves start from relatively high initial values and gradually converge to a stable region close to 0 as the number of iterations increases. This demonstrates the core role of the gradient descent algorithm: by calculating the gradient direction of the objective function, adaptively adjusting the learning rate step size, and combining the projection gradient method to ensure that the parameters meet physical constraints, the compensation parameters ultimately converge to the global optimum. This process is a key technical step in inputting the allocation coefficients into the upper and lower layer optimization models and solving for the electricity meter metering error compensation parameters through gradient descent. It visually verifies the convergence and stability of the algorithm in multi-parameter collaborative optimization scenarios, providing a reliable parameter basis for the precise control of dynamic compensation circuits and ensuring the real-time performance and accuracy of dynamic compensation for electricity meter metering errors.
[0061] Example 5: In the dynamic compensation method for electricity meter metering errors, monitoring the compensated metering data is achieved through a high-precision data acquisition system. This system records instantaneous values of voltage, current, and power at a rate of thousands of times per second. A specific example is monitoring the dynamic response of a three-phase electricity meter in a commercial building when the air conditioning units are started. The metering data includes voltage sags and current harmonic characteristics. An error statistics calculation module is integrated into the electricity meter firmware. This module periodically calculates the average error, standard deviation, and peak error. The average error reflects system deviation, the standard deviation characterizes the fluctuation amplitude, and the peak error captures extreme cases. The comparison of error distribution changes before and after compensation uses statistical hypothesis testing methods, such as the Kolmogorov-Smirnov test to compare the cumulative error distribution function. The change in distribution quantifies the compensation effect. The evaluation results automatically adjust the compensation parameters through a parameter self-tuning algorithm. This algorithm dynamically adjusts the proportional-integral-derivative controller parameters based on the error indicators.
[0062] Long-term operational data is stored in an embedded database, which uses a circular buffer structure to store the most recent 100,000 records. The raw metering database is updated periodically through an automatic data cleaning and archiving process, with an update cycle set every 24 hours. The principal component analysis model and wavelet transform model are retrained using incremental learning algorithms. Incremental learning fine-tunes model parameters using new data, avoiding global retraining. New data is used to adjust the parameters of the two-layer optimization model through online optimization technology, which continuously absorbs real-time data to update the objective function weights. Self-learning and adaptive functions enable the intelligent evolution of the compensation system. The system establishes a performance feedback loop, and compensation parameters are adaptively adjusted as equipment ages. A specific case study of the monitoring system deployment is a smart meter network in an industrial park, containing 500 electricity meters, each configured with a monitoring agent. After collecting metering data, the monitoring agent calculates error statistics, which are uploaded to the central server via a communication module. A comparative case study of error distribution changes shows that the error distribution before compensation exhibits a bimodal characteristic, while the distribution after compensation approaches a normal distribution, verifying the compensation effect. An example of automatic adjustment of compensation parameters is shown: when the error standard deviation is continuously exceeded, the system automatically increases the proportional gain coefficient to improve response speed.
[0063] The metering raw database update mechanism suspends updates during peak load periods to avoid system overload. Retraining the principal component analysis and wavelet transform models is triggered by data distribution drift detection, which utilizes statistical process control charts. New data adjustment of the two-layer optimization model parameters employs a rolling time window, with the time window containing the most recent 1000 sampling points. A self-learning and adaptive function implementation example is the self-adjustment of electricity meters under seasonal temperature fluctuations; the system identifies the correlation between temperature and error and adjusts compensation parameters in advance. The monitored and compensated metering data storage format includes timestamps, meter numbers, RMS voltage values, RMS current values, and active power values. Error statistics are calculated using a sliding window statistical method, specifically by defining a fixed-length data window that slides across the time series to calculate error statistics in real time. The window size matches the load variation cycle. The comparison of error distribution changes before and after compensation is visualized as an overlap graph of probability density functions, with the overlap area quantifying the degree of improvement. The evaluation results automatically adjust compensation parameters. The rule base contains hundreds of empirical rules, built based on operational and maintenance knowledge. The periodic update process for the metering raw database includes a data verification step, with verification rules detecting outliers and data loss. The principal component analysis (PCA) and wavelet transform (WCT) models are retrained using a distributed computing framework that leverages multi-core processors for parallel training. New data is used to adjust the two-layer optimization model parameters, integrating sensitivity analysis to analyze the impact of parameter changes on the objective function. The self-learning and adaptive architecture includes a model pool and a selector, which selects the optimal model based on the current operating conditions.
[0064] Long-term operational data from the dynamic compensation method for electricity meter metering errors is used for reliability analysis, and the analysis results guide preventative maintenance. Version management of the original metering database records each update, and a version rollback mechanism handles update failures. Cross-validation is used to validate the retrained principal component analysis and wavelet transform models. Specifically, cross-validation evaluates the model's generalization ability by dividing the original metering dataset into multiple mutually exclusive subsets. The implementation process begins by randomly shuffling the time series order of the original metering data to eliminate time-series dependencies and ensure the independence of subset data. A stratified sampling strategy is used for data partitioning to maintain the distribution ratio of electricity meter operating states and load types in each subset, avoiding bias. Cross-validation ensures the model's generalization ability. The process of adjusting the parameters of the two-layer optimization model with new data is logged, and the log audits the parameter change history. Accelerated aging testing is used to evaluate the performance of self-learning and adaptive functions, simulating ten years of operating conditions.
[0065] The monitoring system's specific technologies include fiber optic communication for transmitting metrological data, with the transmission protocol adopting high-reliability industrial standards. The error statistics calculation module integrates anomaly detection algorithms, specifically identifying sensor fault data by analyzing the statistical characteristics of the metrological data. Algorithms identify sensor fault data. A report comparing the error distribution changes before and after compensation is automatically generated, with the report format conforming to metrological certification requirements. The evaluation results automatically adjust compensation parameters, and the interface supports remote manual intervention, with intervention records encrypted and stored. Regular updates to the original metrological database include digital signature verification to prevent data tampering. Quality control for retraining the principal component analysis and wavelet transform models includes model complexity checks to avoid overfitting. New data adjustments to the bi-layer optimization model parameters and convergence monitoring use the Lyapunov index, specifically evaluating system stability by analyzing the evolution trajectory of the parameter vector. The implementation process begins by recording the changes in parameters during iteration; the change sequence includes the parameter update values after each gradient descent solution, and the sequence length is determined based on the system's dynamic characteristics. The index judges system stability. Self-learning and adaptive functions display the learning progress on the human-machine interface, with a progress bar visualizing the training status. The overall integrated testing of the dynamic compensation method for electricity meter metering errors includes electromagnetic compatibility testing, and the testing standards follow international norms.
[0066] Long-term operation and maintenance case studies show that after 10,000 hours of continuous system operation, performance degradation is less than 2%, and degradation compensation is eliminated through parameter fine-tuning. The metering raw database compression algorithm reduces storage space usage by 70%, and the compression algorithm uses lossless encoding. The automated pipeline for retraining the principal component analysis model and wavelet transform model includes data preprocessing, feature extraction, and model validation stages. The new data adjustment uses a two-layer optimization model parameter parallel processing architecture that utilizes a graphics processor to accelerate computation. Self-learning and adaptive functions achieve a response time of less than 100 milliseconds under sudden load changes, meeting real-time compensation requirements. The implementation effect of the dynamic compensation method for electricity meter metering errors is demonstrated through a long-term error trend chart, showing that the error fluctuation range gradually converges. Monitoring data is used for user energy efficiency analysis, and analysis reports guide energy-saving retrofits. The metering raw database supports advanced query functions, allowing query statements to retrieve data for specific time periods. The trigger frequency for retraining the principal component analysis model and wavelet transform model is adaptively adjusted, reducing the training frequency during periods of stable load. The robustness handling of the new data adjustment dual-layer optimization model parameters includes outlier filtering. The filtering algorithm is based on statistical outlier detection. Specifically, it is applied in the parameter adjustment stage of the dual-layer optimization model for the dynamic compensation method of electricity meter metering errors. The outlier filtering algorithm identifies and removes outliers in the metering data through statistical outlier detection, ensuring the robustness of the model parameter adjustment. The self-learning and adaptive functions ultimately enable the electricity meter to maintain metering accuracy throughout its entire lifespan, meeting the accuracy requirements of national metrological regulations.
[0067] See Figure 5This graph, with time on the horizontal axis and error value on the vertical axis, visually demonstrates the core effectiveness of the dynamic compensation method for electricity meter measurement errors. The red curve represents the error before compensation, reflecting the significant randomness and large fluctuations in measurement error caused by the coupling effects of multiple factors such as ambient temperature, humidity, electromagnetic interference, and aging of internal components when the meter is uncompensated. The green curve represents the error after compensation, which fluctuates stably within a small range. This difference stems from the collaborative technology across the entire process: first, principal component analysis is used to extract key features of the measurement data; then, wavelet transform is used to separate trend and fluctuation components; subsequently, a two-layer optimization model combined with gradient descent algorithm is used to solve for precise compensation parameters; finally, the dynamic compensation circuit composed of resistors and reactors is adjusted in real time, achieving efficient error suppression. This graph clearly verifies the effectiveness of the method under complex operating conditions, providing intuitive technical evidence for the long-term high-precision measurement of electricity meters.
[0068] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0069] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for dynamic compensation of metering error in an electricity meter, characterized in that, include: Collect raw metering data during the operation of the electricity meter, and perform principal component analysis on the raw metering data to obtain the electricity meter metering principal component sequence; Wavelet transform is performed on the principal component sequence of the electricity meter to obtain approximation coefficients and detail coefficients. A dynamic compensation circuit is composed of resistors and reactors. The approximation coefficients are used as the metering reference values. The detail coefficients are distributed within the dynamic compensation circuit to obtain the distribution coefficients. Based on the allocation coefficient, a two-layer optimization model for electricity meter metering error compensation is constructed, which includes an upper-layer optimization model and a lower-layer optimization model. The constraints of the upper-level optimization model and the lower-level optimization model are determined, the allocation coefficients are input into the upper-level optimization model and the lower-level optimization model, and gradient descent is performed according to the constraints to obtain the electricity meter measurement error compensation parameters. Dynamic error compensation is performed on the energy meter based on the energy meter metering error compensation parameters. The process of allocating the detail coefficients within the dynamic compensation circuit to obtain allocation coefficients includes: analyzing the frequency characteristics and amplitude distribution of the detail coefficients; designing a fuzzy logic controller to dynamically calculate the allocation weights; compensating for low-frequency detail components using resistors and high-frequency detail components using reactors; and integrating the weighted detail coefficients to generate allocation coefficients for model input.
2. The method for dynamic compensation of metering error in an electricity meter according to claim 1, characterized in that, The process of performing principal component analysis on the raw metering data to obtain the electricity metering principal component sequence includes: acquiring the raw metering data stream in real time using a sliding window mechanism; standardizing the data within each window to eliminate dimensional differences; calculating the covariance matrix of the window data and obtaining eigenvalues and eigenvectors through eigenvalue decomposition; dynamically selecting the number of principal components based on the magnitude of the eigenvalues, retaining the principal component directions whose cumulative variance contribution rate exceeds a preset threshold; projecting the standardized data onto the principal component directions, and outputting the real-time updated electricity metering principal component sequence.
3. The method for dynamic compensation of metering error in an electricity meter according to claim 1, characterized in that, The step of performing wavelet transform processing on the principal component sequence of the electricity meter to obtain approximation coefficients and detail coefficients includes: selecting an adaptive wavelet basis function to perform multi-scale decomposition of the principal component sequence; extracting low-frequency approximation coefficients and high-frequency detail coefficients through low-pass and high-pass filters respectively; automatically determining the optimal decomposition level based on the signal energy distribution; and reconstructing the coefficients at each scale to obtain approximation coefficients representing trend components and detail coefficients representing fluctuation components.
4. The method for dynamic compensation of metering error in an electricity meter according to claim 1, characterized in that, The construction of a two-layer optimization model for electricity meter measurement error compensation based on the allocation coefficient includes: the upper-layer optimization model takes minimizing measurement error fluctuation as the objective function, and the lower-layer optimization model takes maximizing the efficiency of the compensation circuit as the objective function; a data interaction channel is established between the upper-layer optimization model and the lower-layer optimization model; the allocation coefficient is used as a shared variable to connect the two models; and the model decision variables are defined, including compensation parameters and circuit configuration parameters.
5. The method for dynamic compensation of metering error in an electricity meter according to claim 1, characterized in that, The determination of the constraints of the upper-level optimization model and the lower-level optimization model includes: setting the constraint of the upper-level optimization model as the allowable deviation range of measurement error; setting the constraint of the lower-level optimization model as the safe operating parameters of circuit components; defining coupling constraints to ensure the consistency of the solutions of the upper-level optimization model and the lower-level optimization model; and introducing slack variables to handle constraint conflict problems.
6. The method for dynamic compensation of metering error in an electricity meter according to claim 1, characterized in that, The step of inputting the allocation coefficients into the upper-level optimization model and the lower-level optimization model and performing gradient descent solution according to the constraints includes: initializing the parameter vector of the two-level optimization model; calculating the gradient direction of the objective function with respect to the parameters; adjusting the parameter update step size using an adaptive learning rate; using the projection gradient method to ensure that the updated parameters meet the constraints; iteratively solving until the objective function converges, and outputting the electricity meter metering error compensation parameters.
7. The method for dynamic compensation of metering error in an electricity meter according to claim 1, characterized in that, The dynamic error compensation of the energy meter based on the energy meter metering error compensation parameters includes: converting the energy meter metering error compensation parameters into digital control signals; driving the resistors and reactors in the dynamic compensation circuit to adjust their impedance values; acquiring the energy meter metering output values in real time and calculating the instantaneous error; and dynamically adjusting the control signals according to the error signals to achieve closed-loop error compensation.
8. The method for dynamic compensation of metering error in an electricity meter according to claim 7, characterized in that, The method further includes: monitoring the compensated measurement data and calculating error statistics; comparing the changes in error distribution before and after compensation and evaluating the compensation effect; automatically adjusting the compensation parameters based on the evaluation results; and recording the compensation process data for model optimization and fault diagnosis.
9. The method for dynamic compensation of metering error in an electricity meter according to claim 1, characterized in that, The method also includes: periodically updating the original metering database, retraining the principal component analysis model and wavelet transform model; adjusting the parameters of the two-layer optimization model based on the new data; realizing the self-learning and adaptive functions of the compensation system; and ensuring the metering accuracy and stability of the electricity meter during long-term operation.
Citation Information
Patent Citations
Intelligent electric energy meter operation error monitoring system
CN115166619A
Ammeter adaptive error compensation method, system and device based on multi-physical coupling and hidden variable modeling, and storage medium
CN120871015A