A battery pack resistance value assignment method and system based on a macro language
By employing a macro-language-based battery pack resistance allocation method, combined with a greedy strategy and probabilistic acceptance criteria for multi-round iterative optimization, the problem caused by the internal resistance difference between battery clusters was solved, inter-cluster balance was achieved, system efficiency and reliability were improved, and battery management was simplified.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 中汽新能(滁州)电池科技有限公司
- Filing Date
- 2026-04-23
- Publication Date
- 2026-07-21
AI Technical Summary
In existing technologies for large-scale containerized energy storage systems, the random allocation of battery packs leads to significant differences in internal resistance between clusters, resulting in uneven current distribution, severe heat generation, shortened system lifespan, and more complex balancing strategies for the battery management system.
A macro-language-based battery pack resistance allocation method is adopted. An initial clustering scheme is generated through a deterministic greedy strategy, and multiple rounds of iterative optimization are carried out by combining greedy improvement and probabilistic acceptance criteria. A multi-round restart mechanism is used to improve the global exploration capability and robustness of the algorithm.
It achieves inter-cluster internal resistance balancing, improves system efficiency and reliability, simplifies the complexity of the battery management system, extends system life, and reduces dependence on high-performance computing resources.
Smart Images

Figure CN122437191A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of battery pack management technology, and specifically to a method and system for allocating battery pack resistance values based on macro language. Background Technology
[0002] In large-scale containerized energy storage systems, batteries are typically integrated in a two-tiered "cluster-pack" structure. For example, a container may contain six battery clusters, each consisting of eight battery packs connected in series or parallel. The internal resistance of battery packs naturally varies. If randomly distributed during clustering, this can lead to significant differences in the total internal resistance (or average internal resistance) between clusters. Excessive resistance differences between clusters can cause a series of problems: 1) During charging and discharging, uneven current distribution among clusters results in severe overheating of clusters with high internal resistance, affecting system efficiency and safety; 2) It accelerates the degradation of high-resistance clusters, shortening the overall system lifespan; 3) It complicates the balancing strategy of the battery management system (BMS).
[0003] Currently, common allocation methods rely on manual grouping based on operator experience or the use of simple sort-round selection algorithms. Manual grouping is inefficient and struggles to find a globally optimal solution among parameters for up to 48 battery packs (6 clusters × 8 packs). Simple automated algorithms may get stuck in local optima and fail to accurately minimize the maximum inter-cluster impedance under complex combinatorial constraints (such as a fixed number of cells per cluster). Summary of the Invention
[0004] The purpose of this invention is to provide a method and system for assigning battery pack resistance values based on macro language, so as to solve the above-mentioned shortcomings in the prior art.
[0005] To achieve the above objectives, the present invention provides the following technical solution: a battery pack resistance value allocation method based on macro language, wherein the method is executed in a macro language environment and includes the following steps:
[0006] An initial battery pack clustering scheme is generated using a deterministic greedy strategy.
[0007] Starting with the initial battery pack clustering scheme, multiple rounds of random optimization are performed. In each round of iteration, battery packs in different clusters are randomly swapped, and the current scheme is updated based on a criterion that combines greedy improvement and probabilistic acceptance.
[0008] When the optimized inter-cluster internal resistance difference reaches the preset target threshold or meets the iteration termination condition, the final clustering scheme is output and displayed.
[0009] Furthermore, the generation of the initial battery pack clustering scheme using a deterministic greedy strategy includes the following steps:
[0010] S1. Data Input and Parameter Initialization: In the macro language environment, input the internal resistance value array of N battery packs to be assigned, and set the number of battery clusters, the number of battery packs per cluster, the maximum resistance difference threshold between target clusters, the maximum number of iterations, and the optimization convergence threshold, where N is a preset positive integer;
[0011] S2. Generate initial greedy solution: Execute a deterministic greedy algorithm to generate an initial battery pack clustering scheme.
[0012] Furthermore, S2 includes the following steps:
[0013] S2.1, Create M empty clusters;
[0014] S2.2 From the sorted internal resistance value array, take out the current maximum and minimum unassigned battery pack internal resistance values in sequence to generate the current complementary pair;
[0015] S2.3. Assign the current complementary pair to the cluster with the minimum total internal resistance.
[0016] S2.4 Repeat S2.2-S2.3 until all battery packs are allocated, and record the total internal resistance of each cluster at this time. Calculate the range of the total internal resistance of all clusters to generate the initial battery pack clustering scheme.
[0017] Furthermore, the criterion combining greedy improvement and probabilistic acceptance is as follows:
[0018] If the inter-cluster internal resistance range of the new scheme after the exchange is less than the current range, then the exchange is accepted.
[0019] If the new range is greater than or equal to the current range, the exchange is accepted with a probability that is negatively correlated with the degree of range deterioration and decreases with the iteration process.
[0020] Furthermore, the method also includes multiple restart steps:
[0021] If the target threshold is not reached in a round of optimization, the current optimal solution is saved and the initial battery pack clustering scheme is cleared.
[0022] The deterministic greedy strategy is fine-tuned, and the initial battery pack clustering scheme is regenerated using the fine-tuned deterministic greedy strategy. Then, the multi-round iterative random optimization is performed again.
[0023] Furthermore, the criterion combining greedy improvement and probabilistic acceptance also includes:
[0024] Before reaching the preset maximum number of iterations, if within the preset number of consecutive iterations, there exists a new range whose decrease value relative to the current range is less than the preset optimization convergence threshold, then the iteration continues; otherwise, multiple rounds of restart steps are executed.
[0025] Furthermore, the method also includes: setting a maximum inter-cluster impedance threshold and automatically verifying it after calculation; if the inter-cluster impedance of the allocation scheme does not exceed the threshold, the scheme is output; otherwise, a warning is issued.
[0026] A battery pack resistance value allocation system based on macro language includes a data acquisition module, a computer-readable storage medium, a processor module, and an optimization output module;
[0027] The data acquisition module is used to acquire the internal resistance value of each battery pack and store it in the computer-readable storage medium;
[0028] The computer-readable storage medium is also used to store macro programs;
[0029] The processor module is used to load and run the macro program to execute a battery pack resistance allocation method based on macro language;
[0030] The optimized output module is used to output and display the final clustering scheme, verification results, and warning messages.
[0031] Compared with existing technologies, the battery pack resistance allocation method and system based on macro language provided by this invention have the following advantages and technical effects:
[0032] 1) Algorithm efficiency and superiority: It combines the advantages of greedy algorithms in quickly obtaining high-quality initial solutions with the global exploration capability of random optimization (simulated annealing). Compared with pure snake allocation or pure random search, it can approach or find the optimal solution that meets the strict threshold with a higher probability and faster speed.
[0033] 2) Practical value of macro language implementation: Encapsulating advanced optimization algorithms in easy-to-use macros (such as Excel buttons) enables complex combinatorial optimization problems to be easily solved by field engineers without relying on expensive external optimization software or high-performance computing resources.
[0034] 3) Strong robustness and adaptability: The algorithm's ability to handle datasets with different internal resistance distributions is enhanced through a "multi-round restart" mechanism. Parameters (such as T_max, T0) can be easily adjusted in macros according to the problem size, demonstrating strong adaptability.
[0035] 4) Clear goal orientation: The algorithm has a clear goal orientation, with "ΔR ≤ ΔR_target" as one of the direct termination conditions. This ensures that the output solution meets the hard requirements of the project or provides the closest feasible solution for evaluation.
[0036] 5) Improve product consistency and reliability: Achieve inter-cluster equalization from the source of battery pack assembly, laying a physical foundation for the consistency of the battery system, reducing the complexity of subsequent BMS management, and improving the long-term operational reliability and lifespan of the entire energy storage container. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0038] Figure 1 This is a schematic diagram of the method steps provided in an embodiment of the present invention;
[0039] Figure 2 This is a system structure block diagram provided for an embodiment of the present invention. Detailed Implementation
[0040] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.
[0041] Exemplary embodiments will be described more fully below with reference to the accompanying drawings; however, these exemplary embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will enable those skilled in the art to fully understand the scope of this disclosure.
[0042] Where there is no conflict, the various embodiments of this disclosure and the features thereof in the embodiments may be combined with each other.
[0043] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.
[0044] The embodiments described herein can be described with reference to plan views and / or cross-sectional views using the ideal schematic diagrams of this disclosure. Therefore, the example illustrations can be modified according to manufacturing techniques and / or tolerances. Therefore, the embodiments are not limited to those shown in the drawings, but include modifications to configurations formed based on manufacturing processes. Therefore, the areas illustrated in the drawings are schematic in nature, and the shapes of the areas shown in the figures illustrate specific shapes of areas of an element, but are not intended to be limiting.
[0045] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having the same meaning as they have in the context of the relevant art and this disclosure.
[0046] Please see Figure 1 A method for equalizing resistance distribution among battery pack clusters based on macro language includes the following steps:
[0047] S1: Data Input and Parameter Initialization: In the macro language environment (ExcelVBA), input the internal resistance array R of the N (N is a preset positive integer) battery packs to be assigned, and set the number of battery clusters M, the number of battery packs per cluster K, the maximum resistance difference threshold ΔR_target between target clusters (e.g., 0.3mΩ), the maximum number of iterations T_max, and the optimization convergence threshold ε.
[0048] S2: Generate an initial greedy solution: Execute a deterministic greedy algorithm to generate a high-quality initial allocation scheme, Solution_current. Specifically:
[0049] S2.1: Create M empty clusters.
[0050] S2.2: From the sorted R, extract the current maximum and minimum unassigned battery pack internal resistance values in sequence.
[0051] S2.3: Assign these two values (one large and one small) as a "complementary pair" to the cluster with the lowest current total internal resistance. This strategy greedily utilizes the complementarity of extreme values to quickly balance the sum of each cluster.
[0052] • S2.4: Repeat S2.2-S2.3 until all battery packs are allocated. Record the total internal resistance of each cluster under this scheme and calculate its range ΔR_current.
[0053] S3: Greedy randomized optimization iteration:
[0054] •S3.1: Set the iteration counter t=0.
[0055] • S3.2: Random perturbation: Based on Solution_current, randomly select two battery packs belonging to different clusters, attempt to swap their positions, and generate a new neighborhood solution Solution_new.
[0056] •S3.3: Greedy evaluation and acceptance criteria: Calculate the inter-cluster internal resistance range ΔR_new under Solution_new.
[0057] If ΔR_new < ΔR_current, then always accept the new solution and let Solution_current = Solution_new, ΔR_current = ΔR_new (greedy improvement).
[0058] · If ΔR_new >= ΔR_current, then accept this exchange (random jump) with a probability P that decays over time, where P = exp(-(ΔR_new - ΔR_current) / Temperature(t)), and Temperature(t) is a simulated annealing temperature function that decreases as the iteration number t increases. For example, Temperature(t) = T0*(0.95)^t. This allows the algorithm to have a certain probability of jumping out of the local optimum in the early stage.
[0059] · S3.4: Threshold judgment: If ΔR_current ≤ ΔR_target, then jump to S5 and output a success signal and the solution.
[0060] · S3.5: Loop judgment: Let t = t + 1. If t < T_max and the decrease in ΔR_current in consecutive iterations is less than ε, then return to S3.2 to continue the iteration; otherwise, enter S4.
[0061] S4: Multi-round restart step (optional enhancement): If the target is not reached in the first iteration, then save the current optimal solution, clear the allocation, return to S2, regenerate the initial solution using a different random seed or fine-tune the greedy strategy (such as changing the selection order of "complementary pairs"), and perform the optimization iteration of S3 again. This mechanism can further avoid falling into the sub-optimal solution region.
[0062] S5: Result output and application: The macro program outputs the final optimized solution, including the specific battery pack IDs and their internal resistance values included in each battery cluster, the total internal resistance / average internal resistance of each cluster, and the final inter-cluster internal resistance range ΔR_best. The operator installs the specific battery packs at the corresponding physical positions of the battery clusters according to the allocation solution list output by the macro program.
[0063] The present invention also provides a battery pack inter-cluster balanced resistance allocation system based on a macro language, including:
[0064] · Data acquisition module: Used to obtain the internal resistance data of the battery packs and input it into a computer-readable storage medium;
[0065] · Computer-readable storage medium: Also used to store the macro program and various allocation algorithms;
[0066] · Processor module: Used to load and run the macro program and execute a battery pack resistance allocation method based on a macro language;
[0067] · Optimization output module: Used to output and display the final clustering solution, verification result, and warning information.
[0068] In one embodiment, the invention is applied to a containerized energy storage system having 6 clusters of batteries, each cluster containing 8 battery packs, for a total of 48 battery packs.
[0069] Step 1: Data Preparation
[0070] Prepare 48 product testing data points, each corresponding to a unique barcode identifier. Store the barcodes in Excel worksheets A1:A48, and the data in B1:B48.
[0071] Step 2: Initialize parameters
[0072] Total data volume N = 48
[0073] Number of target groups M = 6
[0074] The number of data sets per group is K = 8
[0075] Maximum number of iterations T = 5000
[0076] Step 3: Perform optimized grouping
[0077] Implement steps S2-S4 using VBA macros.
[0078] Step 4: Output Results
[0079] Generate a result table containing the following:
[0080] 1. Group Details Table: Displays detailed information for each group of 8 data points.
[0081] 2. Grouped statistical tables: Statistics for each group include the sum, mean, range, etc.
[0082] 3. Overall Statistical Table: Distribution of Components and Means (Steps)
[0083] Step 5: Performance Evaluation
[0084] The grouping effect was evaluated using the following indicators:
[0085] • Between-group variance: 0.0234 (the smaller the value, the more balanced the grouping)
[0086] • Difference between the maximum group sum and the minimum group sum: 1.25
[0087] • Standard deviation of group means: 0.045
[0088] If the result does not meet the requirements, the operator can choose to run a more powerful "iterative optimization" macro. This macro will start from the serpentine allocation result, randomly select two battery packs from two different clusters to try swapping. If the swap reduces ΔR, the swap is retained. This process is repeated thousands of times until ΔR can no longer be optimized or the iteration limit is reached, and the final solution is output.
[0089] The foregoing has only described certain exemplary embodiments of the present invention by way of illustration. Undoubtedly, those skilled in the art can modify the described embodiments in various ways without departing from the spirit and scope of the present invention. Therefore, the foregoing drawings and descriptions are illustrative in nature and should not be construed as limiting the scope of protection of the claims of the present invention.
Claims
1. A method for assigning battery pack resistance values based on macro language, characterized in that, The method is executed in a macro language environment and includes the following steps: An initial battery pack clustering scheme is generated using a deterministic greedy strategy. Starting with the initial battery pack clustering scheme, multiple rounds of random optimization are performed. In each round of iteration, battery packs in different clusters are randomly swapped, and the current scheme is updated based on a criterion that combines greedy improvement and probabilistic acceptance. When the optimized inter-cluster internal resistance difference reaches the preset target threshold or meets the iteration termination condition, the final clustering scheme is output and displayed.
2. The method for allocating battery pack resistance values based on macro language according to claim 1, characterized in that, The method of generating an initial battery pack clustering scheme using a deterministic greedy strategy includes the following steps: S1. Data Input and Parameter Initialization: In the macro language environment, input the internal resistance value array of N battery packs to be assigned, and set the number of battery clusters, the number of battery packs per cluster, the maximum resistance difference threshold between target clusters, the maximum number of iterations, and the optimization convergence threshold, where N is a preset positive integer; S2. Generate initial greedy solution: Execute a deterministic greedy algorithm to generate an initial battery pack clustering scheme.
3. The method for allocating battery pack resistance values based on macro language according to claim 2, characterized in that, S2 includes the following steps: S2.1, Create M empty clusters; S2.2 From the sorted internal resistance value array, take out the current maximum and minimum unassigned battery pack internal resistance values in sequence to generate the current complementary pair; S2.
3. Assign the current complementary pair to the cluster with the minimum total internal resistance. S2.4 Repeat S2.2-S2.3 until all battery packs are allocated, and record the total internal resistance of each cluster at this time. Calculate the range of the total internal resistance of all clusters to generate the initial battery pack clustering scheme.
4. The method for assigning battery pack resistance values based on macro language according to claim 1, characterized in that, The criterion that combines greedy improvement and probabilistic acceptance is as follows: If the inter-cluster internal resistance range of the new scheme after the exchange is less than the current range, then the exchange is accepted. If the new range is greater than or equal to the current range, the exchange is accepted with a probability that is negatively correlated with the degree of range deterioration and decreases with the iteration process.
5. The method for battery pack resistance allocation based on macro language according to claim 1, characterized in that, The method also includes a multi-round restart step: If the target threshold is not reached in a round of optimization, the current optimal solution is saved and the initial battery pack clustering scheme is cleared. The deterministic greedy strategy is fine-tuned, and the initial battery pack clustering scheme is regenerated using the fine-tuned deterministic greedy strategy. Then, the multi-round iterative random optimization is performed again.
6. The battery pack resistance allocation method based on macro language according to claim 5, characterized in that, The criterion, which combines greedy improvement with probabilistic acceptance, also includes: Before reaching the preset maximum number of iterations, if within the preset number of consecutive iterations, there exists a new range whose decrease value relative to the current range is less than the preset optimization convergence threshold, then the iteration continues; otherwise, multiple rounds of restart steps are executed.
7. The method for assigning battery pack resistance values based on macro language according to claim 1, characterized in that, The method further includes: setting a maximum inter-cluster impedance threshold and automatically verifying it after calculation; if the inter-cluster impedance of the allocation scheme does not exceed the threshold, the scheme is output; otherwise, a warning is issued.
8. A battery pack resistance value allocation system based on macro language, used to execute the battery pack resistance value allocation method based on macro language according to any one of claims 1-7, characterized in that, It includes a data acquisition module, a computer-readable storage medium, a processor module, and an optimized output module; The data acquisition module is used to acquire the internal resistance value of each battery pack and store it in the computer-readable storage medium; The computer-readable storage medium is also used to store macro programs; The processor module is used to load and run the macro program to execute the battery pack resistance allocation method based on macro language as described in any one of claims 1-7. The optimized output module is used to output and display the final clustering scheme, verification results, and warning messages.