Batch electric charge settlement method and device based on multi-dimensional space-time tensor
By using a batch electricity billing method based on multidimensional spatiotemporal tensors, electricity consumption and price tensors are generated. The rules are described using DSL language and parallel computation is performed on GPU, which solves the problem of low efficiency in existing electricity billing systems and achieves efficient and accurate electricity billing.
Patent Information
- Application Number
- CN202511700082.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-02-24
AI Technical Summary
Existing electricity billing systems are inefficient when faced with multi-dimensional conditions, making it difficult to calculate electricity bills for tens of millions of residential users in a short period of time. They are also prone to errors and cannot unify the electricity billing needs of different regions.
A batch electricity billing method based on multidimensional spatiotemporal tensors is adopted. The method generates an electricity consumption tensor by receiving electricity consumption data, obtains the electricity billing rules to generate a condition mask matrix, performs condition filtering and electricity price tensor calculation, describes the electricity billing rules using DSL language, and performs parallel computing on GPU.
It significantly improves the batch processing performance and real-time response capability of electricity bill settlement, increasing the efficiency of electricity bill settlement by more than 10 times. It supports the differences in electricity bill calculation rules in different regions, realizes heterogeneous electricity price matching under a unified model across regions, and improves the accuracy and real-time performance of calculation.
Smart Images

Figure CN121560940A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power system cost settlement technology, and in particular to a batch electricity cost settlement method and apparatus based on multidimensional spatiotemporal tensors. Background Technology
[0002] In existing electricity billing systems, residential electricity billing rules typically include multi-dimensional conditions, such as time-of-use pricing, tiered pricing, peak-valley pricing, conditional subsidies, and capping / minimum guarantees. These rules are often implemented using manually maintained templates or hard-coded methods. For example, patent text CN117034893A discloses a method, apparatus, system, and medium for processing fee data. The method includes: responding to a template selection instruction, determining the currently selected fee item template, which includes several fee items; parsing the currently selected fee item template, calculating the fee application data based on the parsing results, and obtaining the fee item establishment results for each fee item; and settling the corresponding fee items based on the fee item establishment results during project implementation. However, when faced with multi-dimensional billing rules, the template-based approach is often inefficient. When calculating electricity bills for tens of millions of residential users, it cannot be completed in a short time and is prone to errors, seriously affecting the efficiency of electricity billing. In addition, although the electricity price is the same across different grid provinces, the billing methods differ. For example, some grid provinces implement time-of-use pricing, while others have peak-hour surcharges. The current calculation method makes it difficult to unify the needs of all grid provinces. Summary of the Invention
[0003] This invention provides a batch electricity billing method and apparatus based on multidimensional spatiotemporal tensors to improve the efficiency of electricity bill calculation for a large number of users.
[0004] A batch electricity billing method based on multidimensional spatiotemporal tensors includes: Receive a query request and obtain a batch of electricity consumption data for users to be calculated based on the query request; Generate an electricity consumption tensor based on the electricity consumption data; Obtain the electricity pricing rules for the region where the user to be calculated is located, and the electricity pricing rules are described using DSL language; Generate a conditional mask matrix based on the electricity fee rules; The filtered electricity tensor is obtained by performing conditional filtering based on the electricity consumption tensor and the conditional mask matrix. The electricity pricing rules are parsed to generate an electricity price tensor; The electricity bill tensor of the user to be calculated is obtained by calculating the electricity quantity tensor and the electricity price tensor.
[0005] Furthermore, the electricity consumption tensor is a three-dimensional tensor, including the number of user batches, time resolution, and electricity consumption characteristics.
[0006] Further, generating a condition mask matrix based on the electricity pricing rules includes: Based on the conditional statements in the electricity fee rules, a tensor computation graph is generated according to the corresponding calculation parameters and judgment conditions in the conditional statements. A corresponding condition mask matrix is generated for each branch in the tensor computation graph, and each element in the condition mask matrix is a Boolean value.
[0007] Further, based on the electricity consumption tensor and the conditional mask matrix, conditional filtering is performed to obtain the filtered electricity consumption tensor, including: Align the electricity consumption tensor with the relevant elements in the conditional mask matrix; Perform an element-wise logical AND operation or a conditional selection operation on the aligned three-dimensional tensor of electricity consumption and the conditional mask matrix to obtain the filtered electricity tensor.
[0008] Furthermore, the electricity pricing rules are parsed to generate an electricity price tensor, including: The electricity price calculation rules in the electricity fee rules are parsed into an abstract syntax tree, which includes a root node and electricity price calculation branches that satisfy the corresponding calculation conditions; Traverse the abstract syntax tree, identify the electricity price constants in the abstract syntax tree, arrange the electricity price constants according to the corresponding calculation conditions, and obtain the electricity price tensor.
[0009] Further, the electricity bill tensor for the user to be calculated is obtained by calculating the electricity quantity tensor and the electricity price tensor, including: The electricity cost tensor is obtained by performing matrix multiplication or element-wise multiplication on the electricity quantity tensor and the electricity price tensor.
[0010] Furthermore, after obtaining a batch of electricity consumption data for users to be calculated, the process also includes: Perform a time consistency check on the electricity consumption data; Correct the electricity consumption data that does not meet the time consistency requirement to obtain the corrected electricity consumption data, and generate an electricity consumption tensor based on the corrected electricity consumption data.
[0011] Furthermore, a time consistency check is performed on the electricity consumption data, including: Set a preset duration, and obtain the power consumption data at the start time and the end time of the preset duration; The electricity consumption data at the start time is compared with the electricity consumption data at the end time. If the electricity consumption data at the end time is less than the electricity consumption data at the start time, it is determined that the electricity consumption data does not meet the time consistency requirement. Correcting electricity consumption data that does not meet time consistency requirements, including: Obtain the user's meter number, determine the time point of meter replacement, and sum the user's electricity consumption data before and after meter replacement along the time dimension to obtain the corrected electricity consumption data.
[0012] Furthermore, after acquiring a batch of electricity consumption data of users to be calculated, the electricity consumption data is sliced and loaded onto multiple parallel GPUs, and the generation of the electricity consumption tensor, the generation of the conditional mask matrix, conditional filtering, the generation of the electricity price tensor, and the calculation of the electricity charge tensor are performed on the GPUs.
[0013] A batch electricity billing device based on multidimensional spatiotemporal tensors includes: The data acquisition module is used to receive query requests and acquire a batch of electricity consumption data of users to be calculated based on the query requests. Tensor generation module, used to generate an electricity consumption tensor based on the electricity consumption data; The rule acquisition module is used to acquire the electricity fee rules for the region where the user to be calculated is located. The electricity fee rules are described using DSL language. The matrix generation module generates a conditional mask matrix based on the electricity fee rules; The filtering module is used to perform conditional filtering based on the electricity consumption tensor and the conditional mask matrix to obtain the filtered electricity consumption tensor. The parsing module is used to parse the electricity fee rules and generate an electricity price tensor; The calculation module is used to calculate the electricity bill tensor of the user to be calculated based on the electricity quantity tensor and the electricity price tensor.
[0014] Furthermore, the electricity consumption tensor is a three-dimensional tensor, including the number of user batches, time resolution, and electricity consumption characteristics.
[0015] Furthermore, the matrix generation module generates a conditional mask matrix based on the electricity fee rules, including: Based on the conditional statements in the electricity fee rules, a tensor computation graph is generated according to the corresponding calculation parameters and judgment conditions in the conditional statements. A corresponding condition mask matrix is generated for each branch in the tensor computation graph, and each element in the condition mask matrix is a Boolean value.
[0016] Further, the filtering module performs conditional filtering based on the electricity consumption tensor and the conditional mask matrix to obtain a filtered electricity consumption tensor, including: Align the electricity consumption tensor with the relevant elements in the conditional mask matrix; Perform an element-wise logical AND operation or a conditional selection operation on the aligned three-dimensional tensor of electricity consumption and the conditional mask matrix to obtain the filtered electricity tensor.
[0017] Furthermore, the parsing module parses the electricity pricing rules to generate an electricity price tensor, including: The electricity price calculation rules in the electricity fee rules are parsed into an abstract syntax tree, which includes a root node and electricity price calculation branches that satisfy the corresponding calculation conditions; Traverse the abstract syntax tree, identify the electricity price constants in the abstract syntax tree, arrange the electricity price constants according to the corresponding calculation conditions, and obtain the electricity price tensor.
[0018] Further, the calculation module calculates the electricity bill tensor for the user to be calculated based on the electricity quantity tensor and the electricity price tensor, including: The electricity cost tensor is obtained by performing matrix multiplication or element-wise multiplication on the electricity quantity tensor and the electricity price tensor.
[0019] Furthermore, after acquiring a batch of electricity consumption data for users to be calculated, the data acquisition module further includes: Perform a time consistency check on the electricity consumption data; Correct the electricity consumption data that does not meet the time consistency requirement to obtain the corrected electricity consumption data, and generate an electricity consumption tensor based on the corrected electricity consumption data.
[0020] Furthermore, the data acquisition module performs a time consistency check on the electricity consumption data, including: Set a preset duration, and obtain the power consumption data at the start time and the end time of the preset duration; The electricity consumption data at the start time is compared with the electricity consumption data at the end time. If the electricity consumption data at the end time is less than the electricity consumption data at the start time, it is determined that the electricity consumption data does not meet the time consistency requirement. Correcting electricity consumption data that does not meet time consistency requirements, including: Obtain the user's meter number, determine the time point of meter replacement, and sum the user's electricity consumption data before and after meter replacement along the time dimension to obtain the corrected electricity consumption data.
[0021] Furthermore, after acquiring a batch of electricity consumption data of users to be calculated, the electricity consumption data is sliced and loaded onto multiple parallel GPUs, and the generation of the electricity consumption tensor, the generation of the conditional mask matrix, conditional filtering, the generation of the electricity price tensor, and the calculation of the electricity charge tensor are performed on the GPUs.
[0022] The batch electricity billing method and apparatus based on multidimensional spatiotemporal tensors provided by this invention have at least the following beneficial effects: (1) The user's electricity consumption data, the conditions in the electricity bill rules, and the electricity price are used to generate a multidimensional tensor with spatiotemporal characteristics. Based on the tensor, the batch electricity bill is calculated, which significantly improves the batch processing performance and real-time response capability of electricity bill settlement. Experimental results show that the method provided by this invention can shorten the policy deployment cycle to the hour level and improve the electricity bill settlement efficiency by more than 10 times, which significantly improves the real-time performance and efficiency of electricity bill calculation. (2) In view of the differences in electricity pricing rules in different regions and the inclusion of multi-dimensional conditions, the electricity pricing rules are described using DSL language. After translation, the corresponding condition mask matrix can be obtained to filter the user's electricity consumption data and generate the corresponding electricity price tensor for electricity pricing calculation, which further improves the real-time performance and efficiency of electricity pricing calculation. (3) Supports the differential modeling of electricity pricing rules in different regions (such as some provinces adopting time-of-use pricing and others adopting tiered pricing). It can automatically parse the corresponding electricity price tensor according to the region and perform parallel calculation on the GPU with the electricity tensor by region to achieve heterogeneous electricity price matching under a unified model across regions. (4) Matrix calculations are performed using parallel GPUs to further improve computational efficiency; (5) Perform time consistency verification on the user's electricity consumption data and identify abnormal data during the calculation process to improve the accuracy of the calculation. Attached Figure Description
[0023] Figure 1 This is a flowchart of one embodiment of the batch electricity billing method based on multidimensional spatiotemporal tensors provided by the present invention.
[0024] Figure 2 This is a flowchart of one embodiment of the batch electricity billing method based on multidimensional spatiotemporal tensors provided by the present invention for generating a condition mask matrix.
[0025] Figure 3 This is a flowchart of one embodiment of the batch electricity billing method based on multidimensional spatiotemporal tensors provided by the present invention, which generates an electricity tensor.
[0026] Figure 4 This is a flowchart of one embodiment of the batch electricity billing method based on multidimensional spatiotemporal tensors provided by the present invention for generating an electricity price tensor.
[0027] Figure 5 This is a schematic diagram illustrating the calculation of electricity bill tensors in an application scenario of the batch electricity bill settlement method based on multidimensional spatiotemporal tensors provided by the present invention.
[0028] Figure 6 This diagram illustrates the computational efficiency of the batch electricity billing method based on multidimensional spatiotemporal tensors provided by the present invention in one application scenario.
[0029] Figure 7 This is a schematic diagram of one embodiment of the batch electricity billing device based on multidimensional spatiotemporal tensor provided by the present invention. Detailed Implementation
[0030] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0031] refer to Figure 1 In some embodiments, a batch electricity billing method based on multidimensional spatiotemporal tensors is provided, including: S1. Receive a query request and obtain a batch of electricity consumption data of users to be calculated based on the query request; S2. Generate an electricity consumption tensor based on the electricity consumption data; S3. Obtain the electricity fee rules for the region where the user to be calculated is located. The electricity fee rules are described using DSL language. S4. Generate a conditional mask matrix based on the electricity fee rules; S5. Perform conditional filtering based on the power consumption tensor and the conditional mask matrix to obtain the filtered power consumption tensor; S6. Parse the electricity fee rules to generate an electricity price tensor; S7. Calculate the electricity bill tensor of the user to be calculated based on the electricity quantity tensor and the electricity price tensor.
[0032] Specifically, in step S1, when the electricity bill settlement batch processing task starts, the electricity consumption data is first obtained from the Redis cache service through batch reading.
[0033] In step S2, the returned batch power consumption data is loaded into a GPU-accessible memory area and a power consumption tensor is generated.
[0034] In some embodiments, the electricity consumption tensor is a three-dimensional tensor X[B, T, F], where B represents the number of user batches, T represents the time resolution (e.g., hours), and F represents the number of electricity consumption characteristics (e.g., forward active power, reverse active power, etc.).
[0035] Furthermore, in step S3, the obtained user electricity consumption data may include first-level spatial information (such as province), so the corresponding electricity billing rules can be invoked.
[0036] Electricity pricing rules are described using the DSL language, and support features such as WHEN ... THEN ... ELSE ..., piecewise functions, map / reduce aggregation, and clipping.
[0037] For example, peak-valley electricity pricing can be represented by DSL (Digital Subscription Function) as a price coefficient selected based on time period, and tiered pricing can be represented by a piecewise function.
[0038] Further, refer to Figure 2 In step S4, generating a condition mask matrix based on the electricity fee rules includes: S41. Based on the conditional statements in the electricity fee rules, parse them and generate a tensor calculation graph according to the corresponding calculation parameters and judgment conditions in the conditional statements; S42. Generate a corresponding condition mask matrix for each branch in the tensor computation graph, wherein each element in the condition mask matrix is a Boolean value.
[0039] The condition mask matrix indicates whether the corresponding user meets the current rule conditions in the corresponding time period.
[0040] Specifically, electricity billing rules typically include conditional statements, such as time ranges, electricity consumption intervals, etc. In this embodiment, they are implemented as tensor calculations that can be executed on the GPU.
[0041] For example, the electricity pricing rules are as follows: If electricity consumption occurs during peak hours (8:00 - 11:00, 13:00 - 15:00, 18:00 - 21:00), then the electricity price is A. If the electricity usage time is during the normal hours (6:00 - 8:00, 11:00 - 13:00, 15:00 - 18:00, 21:00 - 22:00), then the electricity price is B; If the electricity consumption time is during off-peak hours (22:00 - 6:00 the next day), then the electricity price is C.
[0042] In the above electricity billing rules, the judgment condition is time, and it includes the corresponding time points. Each time point is treated as a tensor, and each electricity billing rule is operated in parallel as a branch to generate a tensor computation graph.
[0043] Furthermore, a conditional mask matrix is generated for each branch. For example, for peak periods, for each time node, if it belongs to: 8:00 - 11:00, 13:00 - 15:00, 18:00 - 21:00, then the corresponding position is True, otherwise it is False.
[0044] For the normal time period, for each time node, if it belongs to: 6:00 - 8:00, 11:00 - 13:00, 15:00 - 18:00, 21:00 - 22:00, then the corresponding position is True, otherwise it is False.
[0045] For the valley period, for each time node, if it belongs to 22:00 - 6:00 the next day, the corresponding position is True, otherwise it is False.
[0046] Further, refer to Figure 3 In step S5, conditional filtering is performed based on the electricity consumption tensor and the conditional mask matrix to obtain the filtered electricity consumption tensor, including: S51. Align the electricity consumption tensor with the relevant elements in the conditional mask matrix; S52. Perform a logical AND operation or a conditional selection operation on the element-wise AND of the aligned three-dimensional tensor of electricity consumption and the conditional mask matrix to obtain the filtered electricity tensor.
[0047] Taking the electricity pricing rules for different time periods as an example, three conditional mask matrices for different time periods are obtained. These matrices are aligned with the time resolution in the electricity consumption tensor. Then, logical AND operations or conditional selection operations are performed to filter out the electricity consumption belonging to peak, normal, and valley periods.
[0048] Further, refer to Figure 4 In step S6, the electricity fee rules are parsed to generate an electricity price tensor, including: S61. Parse the electricity price calculation rules in the electricity fee rules into an abstract syntax tree, wherein the abstract syntax tree includes a root node and electricity price calculation branches that satisfy the corresponding calculation conditions; S62. Traverse the abstract syntax tree, identify the electricity price constants in the abstract syntax tree, arrange the electricity price constants according to the corresponding calculation conditions, and obtain the electricity price tensor.
[0049] For example, the rules for calculating electricity prices: For monthly electricity consumption ≤ 200 kWh, the first-tier electricity price of 0.5 yuan / kWh will apply; For monthly electricity consumption exceeding 200 kWh, the second-tier electricity price of 0.8 yuan / kWh will apply.
[0050] The above electricity price calculation rule is a piecewise function, which contains two electricity price calculation branches: the part with monthly electricity consumption ≤ 200 kWh and the part with monthly electricity consumption > 200 kWh. The root node is the piecewise function, and the judgment conditions for the two electricity price calculation branches are the comparison operators "≤" and ">". The leaf nodes are constants (200, 0.5, 0.8).
[0051] Furthermore, the abstract syntax tree is traversed. For example, the electricity price constants in the abstract syntax tree, such as 0.5 yuan / kWh and 0.8 yuan / kWh, are identified and arranged according to their corresponding calculation conditions to generate an electricity price tensor.
[0052] Further, in step S7, the electricity bill tensor for the user to be calculated is obtained based on the electricity quantity tensor and the electricity price tensor, including: The electricity cost tensor is obtained by performing matrix multiplication or element-wise multiplication on the electricity quantity tensor and the electricity price tensor.
[0053] Specifically, the electricity bill tensor can include the total electricity bill and the electricity bill under each billing rule.
[0054] Before performing matrix multiplication or element-wise multiplication on the energy quantity tensor and the price quantity tensor, the energy quantity elements in the energy quantity tensor and the price quantity elements in the price quantity tensor are aligned according to the corresponding execution conditions.
[0055] For example, refer to Figure 5 The electricity bill tensor includes the total electricity bill, the levy on major water conservancy projects, the levy on renewable energy, and the levy on agricultural maintenance. The electricity quantity tensor that meets the calculation conditions after screening includes peak-settled electricity quantity, valley-settled electricity quantity, second-order electricity quantity, and third-order electricity quantity. The electricity price tensor obtained after parsing the electricity bill rules includes the peak electricity price, valley electricity price, second-order surcharge, third-order surcharge, the levy price on major water conservancy projects, the levy price on renewable energy, and the levy price on agricultural maintenance. Multiplying the electricity bill tensor and the electricity price tensor yields the costs of each item and the total electricity bill.
[0056] This embodiment also provides a simulation example to illustrate how to complete the rapid electricity bill settlement process for tens of millions of users: Experimental Dataset: The experimental data used in this experiment is a simulated dataset. The subjects are simulated electricity consumption data of residential users in Jiangxi Province and actual electricity prices in Jiangsu Province. The simulated data consists of one million data points in each folder, totaling 15 million data points, i.e., 15 folders. Each folder contains 300,000 users in the first tier, 600,000 users in the second tier, and 100,000 users in the third tier.
[0057] Experiment setup: This experiment is written in Python 3.12, refer to... Figure 6By comparing the time taken by traditional algorithms and the algorithm provided in this embodiment to calculate the same amount of electricity costs, it can be seen from the figure that the method provided in this embodiment can complete the reading and calculation of 15 million data points in less than 20 seconds, which greatly improves the efficiency of batch electricity cost calculation.
[0058] Furthermore, in step S1, after obtaining the batch of electricity consumption data for the users to be calculated, the following steps are also included: Perform a time consistency check on the electricity consumption data; Correct the electricity consumption data that does not meet the time consistency requirement to obtain the corrected electricity consumption data, and generate an electricity consumption tensor based on the corrected electricity consumption data.
[0059] Furthermore, a time consistency check is performed on the electricity consumption data, including: Set a preset duration, and obtain the power consumption data at the start time and the end time of the preset duration; The electricity consumption data at the start time is compared with the electricity consumption data at the end time. If the electricity consumption data at the end time is less than the electricity consumption data at the start time, it is determined that the electricity consumption data does not meet the time consistency requirement. Correcting electricity consumption data that does not meet time consistency requirements, including: Obtain the user's meter number, determine the time point of meter replacement, and sum the user's electricity consumption data before and after meter replacement along the time dimension to obtain the corrected electricity consumption data.
[0060] For example, when checking the time consistency of meter readings at the beginning and end of the month, if the reading at the end of the month is less than the reading at the beginning of the month, it is automatically identified as a "meter replacement event". The system retrieves the old and new meter numbers and their respective readings for the user, concatenates the cumulative electricity consumption of the old and new meters into a tensor, and sums them in the time dimension to generate the corrected electricity consumption.
[0061] In addition, during the calculation process, all intermediate calculation results are dynamically monitored. If zero, negative values or abnormal results exceeding the statistical threshold are found, the tensor correction function or manual verification mark is automatically triggered.
[0062] Furthermore, after acquiring a batch of electricity consumption data of users to be calculated, the electricity consumption data is sliced and loaded onto multiple parallel GPUs, and the generation of the electricity consumption tensor, the generation of the conditional mask matrix, conditional filtering, the generation of the electricity price tensor, and the calculation of the electricity charge tensor are performed on the GPUs.
[0063] By using parallel GPUs, massive-scale electricity bill calculations can be achieved. For example, with a scale of 500 million electricity consumption data (including 200 million first-order, 200 million second-order, and 100 million third-order electricity consumption data), minute-level settlement can be achieved: using a cluster of 4 NVIDIA A100 GPUs, the computing task is broken down into sub-tasks of 100,000 households / batch. The processing time of a single batch is reduced from 12 minutes in CPU mode to 1 minute, and the overall settlement time is shortened from several hours in the traditional method to less than 8 minutes, improving computing efficiency by 12 times.
[0064] refer to Figure 7 In some embodiments, a batch electricity billing device based on multidimensional spatiotemporal tensors is provided, comprising: The data acquisition module 201 is used to receive query requests and acquire a batch of electricity consumption data of users to be calculated based on the query requests; Tensor generation module 202 is used to generate an electricity consumption tensor based on the electricity consumption data; Rule acquisition module 203 is used to acquire the electricity fee rules for the area where the user to be calculated is located, and the electricity fee rules are described in DSL language; Matrix generation module 204 generates a conditional mask matrix based on the electricity fee rules; The filtering module 205 is used to perform conditional filtering based on the power consumption tensor and the conditional mask matrix to obtain the filtered power consumption tensor. Parsing module 206 is used to parse the electricity fee rules and generate an electricity price tensor; The calculation module 207 is used to calculate the electricity bill tensor of the user to be calculated based on the electricity quantity tensor and the electricity price tensor.
[0065] Furthermore, the electricity consumption tensor is a three-dimensional tensor, including the number of user batches, time resolution, and electricity consumption characteristics.
[0066] Further, the matrix generation module 204 generates a conditional mask matrix based on the electricity fee rules, including: Based on the conditional statements in the electricity fee rules, a tensor computation graph is generated according to the corresponding calculation parameters and judgment conditions in the conditional statements. A corresponding condition mask matrix is generated for each branch in the tensor computation graph, and each element in the condition mask matrix is a Boolean value.
[0067] Further, the filtering module 205 performs conditional filtering based on the electricity consumption tensor and the conditional mask matrix to obtain a filtered electricity consumption tensor, including: Align the electricity consumption tensor with the relevant elements in the conditional mask matrix; Perform an element-wise logical AND operation or a conditional selection operation on the aligned three-dimensional tensor of electricity consumption and the conditional mask matrix to obtain the filtered electricity tensor.
[0068] Further, the parsing module 206 parses the electricity fee rules to generate an electricity price tensor, including: The electricity price calculation rules in the electricity fee rules are parsed into an abstract syntax tree, which includes a root node and electricity price calculation branches that satisfy the corresponding calculation conditions; Traverse the abstract syntax tree, identify the electricity price constants in the abstract syntax tree, arrange the electricity price constants according to the corresponding calculation conditions, and obtain the electricity price tensor.
[0069] Further, the calculation module 207 calculates the electricity bill tensor of the user to be calculated based on the electricity quantity tensor and the electricity price tensor, including: The electricity cost tensor is obtained by performing matrix multiplication or element-wise multiplication on the electricity quantity tensor and the electricity price tensor.
[0070] Furthermore, after acquiring a batch of electricity consumption data of the users to be calculated, the data acquisition module 201 also includes: Perform a time consistency check on the electricity consumption data; Correct the electricity consumption data that does not meet the time consistency requirement to obtain the corrected electricity consumption data, and generate an electricity consumption tensor based on the corrected electricity consumption data.
[0071] Furthermore, the data acquisition module 201 performs a time consistency check on the electricity consumption data, including: Set a preset duration, and obtain the power consumption data at the start time and the end time of the preset duration; The electricity consumption data at the start time is compared with the electricity consumption data at the end time. If the electricity consumption data at the end time is less than the electricity consumption data at the start time, it is determined that the electricity consumption data does not meet the time consistency requirement. Correcting electricity consumption data that does not meet time consistency requirements, including: Obtain the user's meter number, determine the time point of meter replacement, and sum the user's electricity consumption data before and after meter replacement along the time dimension to obtain the corrected electricity consumption data.
[0072] Furthermore, after acquiring a batch of electricity consumption data of users to be calculated, the electricity consumption data is sliced and loaded onto multiple parallel GPUs, and the generation of the electricity consumption tensor, the generation of the conditional mask matrix, conditional filtering, the generation of the electricity price tensor, and the calculation of the electricity charge tensor are performed on the GPUs.
[0073] The batch electricity billing method and apparatus based on multidimensional spatiotemporal tensors provided in the above embodiments have at least the following beneficial effects: (1) The user's electricity consumption data, the conditions in the electricity bill rules, and the electricity price are used to generate a multidimensional tensor with spatiotemporal characteristics. Based on the tensor, the batch electricity bill is calculated, which significantly improves the batch processing performance and real-time response capability of electricity bill settlement. Experimental results show that the method provided by this invention can shorten the policy deployment cycle to the hour level and improve the electricity bill settlement efficiency by more than 10 times, which significantly improves the real-time performance and efficiency of electricity bill calculation. (2) In view of the differences in electricity pricing rules in different regions and the inclusion of multi-dimensional conditions, the electricity pricing rules are described using DSL language. After translation, the corresponding condition mask matrix can be obtained to filter the user's electricity consumption data and generate the corresponding electricity price tensor for electricity pricing calculation, which further improves the real-time performance and efficiency of electricity pricing calculation. (3) Supports the differential modeling of electricity pricing rules in different regions (such as some provinces adopting time-of-use pricing and others adopting tiered pricing). It can automatically parse the corresponding electricity price tensor according to the region and perform parallel calculation on the GPU with the electricity tensor by region to achieve heterogeneous electricity price matching under a unified model across regions. (4) Matrix calculations are performed using parallel GPUs to further improve computational efficiency; (5) Perform time consistency verification on the user's electricity consumption data and identify abnormal data during the calculation process to improve the accuracy of the calculation.
[0074] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention. Clearly, those skilled in the art can make various alterations and modifications to the invention without departing from its spirit and scope. Thus, if these modifications and modifications of the invention fall within the scope of the claims and their equivalents, the invention is also intended to include these modifications and modifications.
Claims
1. A batch electricity billing method based on multidimensional spatiotemporal tensors, characterized in that, include: Receive a query request and obtain a batch of electricity consumption data for users to be calculated based on the query request; Generate an electricity consumption tensor based on the electricity consumption data; Obtain the electricity pricing rules for the region where the user to be calculated is located, and the electricity pricing rules are described using DSL language; Generate a conditional mask matrix based on the electricity fee rules; The filtered electricity tensor is obtained by performing conditional filtering based on the electricity consumption tensor and the conditional mask matrix. The electricity pricing rules are parsed to generate an electricity price tensor; The electricity bill tensor of the user to be calculated is obtained by calculating the electricity quantity tensor and the electricity price tensor.
2. The method according to claim 1, characterized in that, The electricity consumption tensor is a three-dimensional tensor, which includes the number of user batches, time resolution, and electricity consumption characteristics.
3. The method according to claim 1, characterized in that, Generate a condition mask matrix based on the electricity pricing rules, including: Based on the conditional statements in the electricity fee rules, a tensor computation graph is generated according to the corresponding calculation parameters and judgment conditions in the conditional statements. A corresponding condition mask matrix is generated for each branch in the tensor computation graph, and each element in the condition mask matrix is a Boolean value.
4. The method according to claim 1, characterized in that, Based on the electricity consumption tensor and the conditional mask matrix, a conditional filtering is performed to obtain the filtered electricity consumption tensor, including: Align the electricity consumption tensor with the relevant elements in the conditional mask matrix; Perform an element-wise logical AND operation or a conditional selection operation on the aligned three-dimensional tensor of electricity consumption and the conditional mask matrix to obtain the filtered electricity tensor.
5. The method according to claim 1, characterized in that, The electricity pricing rules are parsed to generate an electricity price tensor, including: The electricity price calculation rules in the electricity fee rules are parsed into an abstract syntax tree, which includes a root node and electricity price calculation branches that satisfy the corresponding calculation conditions; Traverse the abstract syntax tree, identify the electricity price constants in the abstract syntax tree, arrange the electricity price constants according to the corresponding calculation conditions, and obtain the electricity price tensor.
6. The method according to claim 1, characterized in that, The electricity bill tensor for the user to be calculated is obtained by calculating the electricity consumption tensor and the electricity price tensor, including: The electricity cost tensor is obtained by performing matrix multiplication or element-wise multiplication on the electricity quantity tensor and the electricity price tensor.
7. The method according to claim 1, characterized in that, After obtaining the electricity consumption data of a batch of users to be calculated, the process also includes: Perform a time consistency check on the electricity consumption data; Correct the electricity consumption data that does not meet the time consistency requirement to obtain the corrected electricity consumption data, and generate an electricity consumption tensor based on the corrected electricity consumption data.
8. The method according to claim 7, characterized in that, Perform a time consistency check on the electricity consumption data, including: Set a preset duration, and obtain the power consumption data at the start time and the end time of the preset duration; The electricity consumption data at the start time is compared with the electricity consumption data at the end time. If the electricity consumption data at the end time is less than the electricity consumption data at the start time, it is determined that the electricity consumption data does not meet the time consistency requirement. Correcting electricity consumption data that does not meet time consistency requirements, including: Obtain the user's meter number, determine the time point of meter replacement, and sum the user's electricity consumption data before and after meter replacement along the time dimension to obtain the corrected electricity consumption data.
9. The method according to any one of claims 1-8, characterized in that, After obtaining a batch of electricity consumption data of users to be calculated, the electricity consumption data is sliced and loaded onto multiple parallel GPUs, and the generation of the electricity consumption tensor, the generation of the conditional mask matrix, the conditional filtering, the generation of the electricity price tensor, and the calculation of the electricity charge tensor are performed on the GPUs.
10. A batch electricity billing device based on multidimensional spatiotemporal tensors, characterized in that, include: The data acquisition module is used to receive query requests and acquire a batch of electricity consumption data of users to be calculated based on the query requests. Tensor generation module, used to generate an electricity consumption tensor based on the electricity consumption data; The rule acquisition module is used to acquire the electricity fee rules for the region where the user to be calculated is located. The electricity fee rules are described using DSL language. The matrix generation module generates a conditional mask matrix based on the electricity fee rules; The filtering module is used to perform conditional filtering based on the electricity consumption tensor and the conditional mask matrix to obtain the filtered electricity consumption tensor. The parsing module is used to parse the electricity fee rules and generate an electricity price tensor; The calculation module is used to calculate the electricity bill tensor of the user to be calculated based on the electricity quantity tensor and the electricity price tensor.
Citation Information
Patent Citations
Cost data processing method, device and system and medium
CN117034893A
Cited By
Structured tensor preprocessing method and system for electricity charge data
CN121786235A