High-energy-efficiency Huffman coding method and system

By constructing left or right LMT greening trees to adjust the Huffman tree and optimizing the difference in codeword energy consumption, the problem of low energy efficiency of traditional Huffman encoding is solved, and the significant reduction in encoding energy consumption and improvement of energy efficiency is achieved.

CN120301434APending Publication Date: 2025-07-11HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510289056.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-12
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

Traditional Huffman encoding fails to effectively consider the energy difference between 0 and 1 codewords, resulting in low energy efficiency, especially in the new generation of wireless communication ultra-wideband ultra-high frequency and future massive data environments.

Method used

By constructing a left-heavy or right-heavy LMT greening tree, the construction method of the Huffman tree is adjusted according to the transmission power of codeword 0 and codeword 1, so that the leaf weights of the left subtree or right subtree meet specific conditions, thereby optimizing the encoding energy consumption, increasing the probability of low-energy codewords, and reducing the probability of high-energy codewords.

Benefits of technology

While maintaining the advantages of the prefix code and average encoding length of the Huffman code, the average energy consumption of encoding is significantly reduced and the energy efficiency is improved, especially in the new generation of wireless communication ultra-wideband ultra-high frequency and future massive data environments, energy consumption is reduced by about 10%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120301434A_ABST
    Figure CN120301434A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of signal coding, and discloses a high-energy-efficiency Huffman coding method and system, and the method comprises the steps: carrying out the statistics of the occurrence probability of each character in an input character string; taking each character and the probability thereof as a leaf node, creating a priority queue, and sorting according to the probability from small to large; leaf nodes in the priority queue are constructed into a Huffman tree; when a traditional Huffman tree is constructed and two nodes with the minimum probability are combined into the minimum heap, the left-right sequence of the two nodes is not required, however, in the method, the left-right positions of the two nodes are determined according to the size relation of the transmitting power of the code word 0 and the transmitting power of the code word 1, and when the transmitting power of the code word 0 is smaller than the transmitting power of the code word 1, the node with the large weight is placed on the left; otherwise, the nodes with the small weights are placed on the left side, and the Huffman tree constructed in this way is called an LMT greening tree; and starting from a root node of the LMT greening tree, distributing 0 to the left and distributing 1 to the right to obtain a code of each character. According to the invention, the energy efficiency of traditional Huffman coding can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of signal coding, and more specifically, relates to an energy-efficient Huffman coding method and system. Background Art

[0002] In the new generation of information technology based on artificial intelligence, one of the most important operations is the coding and decoding of the massive information relied on by the new generation of artificial intelligence, and its core goal is to support fast, efficient, green and energy-saving data processing.

[0003] Huffman coding is widely used due to its shortest average coding length. The traditional Huffman coding with the weight of the left being smaller than that of the right is the commonly used Huffman coding with relatively low energy efficiency at present. However, Huffman coding does not consider the difference in the transmission energy of 0 and 1 codewords, and the energy efficiency is not the highest. In fact, there are generally differences in the energy consumption of using 0 and 1 codewords. For example, in digital communication modulation, two signals with different amplitudes (ASK) or different frequencies (FSK) are used to represent 0 and 1, and there must be obvious differences in the energy required to transmit 0 and 1 due to the differences in amplitude and frequency. Another example is that the amplitudes of different code points in QAM (quadrature amplitude modulation) will cause energy differences in coding. Especially in the new generation of ultra-wideband and ultra-high frequency wireless communication, the energy consumption differences of codes are even greater, and in the future massive data environment, it is very necessary to consider the energy differences of transmitting different codewords to achieve energy-saving coding. Summary of the Invention

[0004] In view of the above defects or improvement requirements of the prior art, the present invention provides an energy-efficient Huffman coding method and system, aiming to reduce the average energy consumption of coding.

[0005] To achieve the above object, the present invention provides an energy-efficient Huffman coding method, including:

[0006] Count the probability of each character appearing in the input string; use each character and its probability as leaf nodes, create a priority queue to store the leaf nodes, and sort them in ascending order of probability;

[0007] Construct a Huffman tree from the leaf nodes in the priority queue; when the transmission power of codeword 0 is less than that of codeword 1, convert the Huffman tree into a left-heavy LMT greening tree; wherein, the left-heavy LMT greening tree satisfies that the sum of the weights of all leaf nodes in the left subtree is not less than the sum of the weights of all leaf nodes in the right subtree; the weight of the leaf node is consistent with its corresponding probability, and the transmission power sizes of codeword 0 and codeword 1 are determined based on the signal modulation method and fading after the string is encoded;

[0008] Perform Huffman coding on the left-heavy LMT greening tree to obtain the coding of each character.

[0009] Further, it further includes: when the transmission power of codeword 0 is greater than or equal to the transmission power of codeword 1, converting the Huffman tree into a right-heavy LMT greening tree; wherein, the right-heavy LMT greening tree satisfies that the sum of the weights of all leaf nodes in the left subtree is not greater than the sum of the weights of all leaf nodes in the right subtree.

[0010] Perform Huffman coding on the right-heavy LMT greening tree to obtain the code of each character.

[0011] Further, performing Huffman coding on the left-heavy LMT greening tree or the right-heavy LMT greening tree to obtain the code of each character includes:

[0012] Starting from the root node of the LMT greening tree, allocate codeword 0 to the left and codeword 1 to the right.

[0013] The code of each character is composed of the path from the root node to its corresponding leaf node, and the codewords 0 and 1 encountered on the path are arranged in the order from the lowest bit to the highest bit; wherein, the LMT greening tree is the left-heavy LMT greening tree or the right-heavy LMT greening tree.

[0014] The present invention provides an energy-efficient Huffman coding method, including:

[0015] S1. Statistically analyze the probability of each character appearing in the input string; use each character and its probability as leaf nodes, create a priority queue to store the leaf nodes, and sort them in ascending order of probability.

[0016] S2. Take out two leaf nodes with the smallest probabilities from the priority queue; create a new internal node, the probability of which is the sum of the probabilities of the two leaf nodes taken out from the priority queue, and use the two leaf nodes as the child nodes of the new internal node; wherein, when the transmission power of codeword 0 is less than the transmission power of codeword 1, the Huffman tree obtained after using the two leaf nodes as the child nodes of the new internal node satisfies that the sum of the weights of all leaf nodes in the left subtree is not less than the sum of the weights of all leaf nodes in the right subtree, so that the Huffman tree is a left-heavy LMT greening tree; the weight of the leaf node is consistent with its corresponding probability, and the transmission power magnitudes of codeword 0 and codeword 1 are determined based on the signal modulation method and fading after the string is encoded.

[0017] S3. Add the new internal node to the priority queue, and repeat S1 until there is only one node left in the priority queue, and this node is the root node of the left-heavy LMT greening tree.

[0018] S4. Perform Huffman coding on the left-heavy LMT greening tree to obtain the code of each character.

[0019] Further, in S2, when the transmission power of codeword 0 is greater than or equal to that of codeword 1, the Huffman tree obtained by taking the two leaf nodes as the children nodes of the new internal node satisfies that the sum of the weights of all leaf nodes in the left subtree is not greater than the sum of the weights of all leaf nodes in the right subtree, so that the Huffman tree is a right-heavy LMT greening tree;

[0020] In S3, the only remaining node in the priority queue is the root node of the right-heavy LMT greening tree;

[0021] In S4, perform Huffman coding on the right-heavy LMT greening tree to obtain the code of each character.

[0022] Further, performing Huffman coding on the left-heavy LMT greening tree or the right-heavy LMT greening tree to obtain the code of each character includes:

[0023] Starting from the root node of the LMT greening tree, assign codeword 0 to the left and codeword 1 to the right;

[0024] The code of each character is composed of the path from the root node to its corresponding leaf node, and the codewords 0 and 1 encountered on the path are arranged in the order from the lowest bit to the highest bit; wherein, the LMT greening tree is the left-heavy LMT greening tree or the right-heavy LMT greening tree.

[0025] The present invention also provides an energy-efficient Huffman coding system, including a computer-readable storage medium and a processor;

[0026] The computer-readable storage medium is used to store executable instructions;

[0027] The processor is used to read the executable instructions stored in the computer-readable storage medium and execute the energy-efficient Huffman coding method described in any one of the above.

[0028] The present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the energy-efficient Huffman coding method described in any one of the above.

[0029] The present invention also provides a computer program product, including a computer program, and when the computer program runs on a computer, it causes the computer to execute the energy-efficient Huffman coding method described in any one of the above.

[0030] Generally speaking, through the above technical solutions conceived by the present invention, the following beneficial effects can be achieved:

[0031] (1) The encoding method of the present invention proposes the influence of the energy consumption difference between the 0 and 1 codewords on the energy efficiency. That is, on the premise of maintaining the advantages of Huffman coding prefix code, variable-length coding, and the shortest average coding length, the present invention considers the energy difference of transmitting different codewords and can optimize the energy efficiency. Specifically, in the scenario where the power of transmitting the codeword 0 is small and the power of transmitting the codeword 1 is large, a left-heavy LMT tree is adopted. At this time, the sum of the leaf weights of the left subtree of the root is not less than the sum of the leaf weights of the right subtree, that is, the sum of the probabilities of transmitting the codeword 0 is not less than the sum of the probabilities of transmitting the codeword 1. In this way, the occurrence probability of low-energy-consuming codewords is increased in the encoding, and the occurrence probability of high-energy-consuming codewords is reduced, thereby reducing the average energy consumption of the encoding. Especially in the new generation of wireless communication ultra-wideband ultra-high frequency and future massive data environment, the encoding method of the present invention can greatly reduce the average energy consumption of the encoding and improve the economic benefits.

[0032] (2) Further, in the case where the transmission power of the codeword 1 is less than or equal to the transmission power of the codeword 0, a right-heavy LMT tree is adopted. At this time, the sum of the leaf weights of the right subtree of the root is not less than the sum of the leaf weights of the left subtree, that is, the sum of the probabilities of transmitting the codeword 1 is not less than the sum of the probabilities of transmitting the codeword 0, so as to ensure that the occurrence probability of low-energy-consuming codewords is increased in the encoding, and the occurrence probability of high-energy-consuming codewords is reduced, thereby reducing the average energy consumption of the encoding.

[0033] All in all, when constructing the traditional Huffman tree, when the two nodes with the smallest probabilities are merged into the minimum heap, the left and right order of the two nodes is not required. However, in the present invention, the left and right positions of the two nodes are determined by the magnitude relationship between the transmission powers of the codewords 0 and 1. When the transmission power of the codeword 0 is less than that of the codeword 1, the node with the larger weight is placed on the left. Otherwise, the node with the smaller weight is placed on the left. The Huffman tree constructed in this way is called the LMT greening tree. Starting from the root node of the LMT greening tree, 0 is assigned to the left and 1 is assigned to the right, and the encoding of each character can be obtained. The encoding method of the present invention can greatly improve the energy efficiency of the traditional Huffman coding and proves that the LMT coding can minimize the average energy consumption of the Huffman coding. Performance analysis shows that when the energy consumption difference between the codewords 0 and 1 is large, the average energy consumption of the LMT coding is about 10% lower than that of the traditional Huffman coding. Brief Description of the Drawings

[0034] Figure 1 It is the flowchart of the left-heavy LMT tree encoding method in the embodiment of the present invention;

[0035] Figure 2 It is the flowchart of the high-energy-efficient Huffman coding method in the embodiment of the present invention;

[0036] Figure 3 It is a left-heavy LMT tree constructed in the embodiment of the present invention, which can be used for the lowest energy consumption coding when the power of transmitting the codeword 0 is small;

[0037] Figure 4 A right-heavy LMT tree constructed in the embodiment of the present invention can be used for the lowest energy consumption coding when the power of transmitting codeword 1 is small;

[0038] Figure 5 The average energy consumption ratio between the LMT coding and the right-heavy Huffman coding (traditional left-small-right-large Huffman coding) in the embodiment of the present invention;

[0039] Figure 6 The average energy consumption ratio between the LMT coding and the Huffman coding in the embodiment of the present invention. Detailed implementation manners

[0040] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0041] Embodiment 1

[0042] As Figure 1 、 Figure 2 shown, the embodiment of the present invention provides an energy-efficient Huffman coding method, which mainly includes:

[0043] i) Statistical character transmission probability: The probability of each character appearing in the input string is statistically calculated. The higher the probability of a character, the smaller the coding length in the coding, so that the overall average coding length is minimized. In the embodiment of the present invention, the input string is a text string.

[0044] ii) Construct a priority queue: Use the statistically obtained characters and their probabilities as leaf nodes, create a priority queue to store each leaf node, and sort them in ascending order of probability.

[0045] iii) Construct an improved Huffman tree - LMT greening tree: Based on the leaf nodes stored in the priority queue, construct a Huffman tree; if the power of transmitting codeword 0 is small and the power of transmitting codeword 1 is large after the current string is encoded, convert the constructed Huffman tree into a left-heavy LMT greening tree, so that the converted left-heavy LMT greening tree satisfies: the sum of the weights of all leaf nodes in the left subtree is not less than the sum of the weights of all leaf nodes in the right subtree; wherein, the weight of a leaf node is the same as its corresponding probability;

[0046] Conversely, if the power of the transmitted codeword 0 is larger and the power of the transmitted codeword 1 is smaller, the constructed Huffman tree is transformed into a right-heavy LMT greening tree, such that the transformed right-heavy LMT greening tree satisfies that the sum of the weights of all leaf nodes in the left subtree is not greater than the sum of the weights of all leaf nodes in the right subtree.

[0047] Alternatively, another way to construct the LMT greening tree in the embodiments of the present invention is to directly construct the LMT greening tree based on each leaf node stored in the priority queue. Specifically, it includes:

[0048] Take out two leaf nodes with the smallest probabilities from the priority queue; create a new internal node, whose probability is the sum of the probabilities of these two leaf nodes, and use these two leaf nodes as the children of the new internal node; among them, when using these two leaf nodes as the children of the new internal node, if the power of the transmitted codeword 0 is smaller and the power of the transmitted codeword 1 is larger, it is necessary to satisfy that the sum of the weights of all leaf nodes in the left subtree is not less than the sum of the weights of all leaf nodes in the right subtree, so that the finally constructed LMT greening tree is a left-heavy LMT greening tree; conversely, if the power of the transmitted codeword 0 is larger and the power of the transmitted codeword 1 is smaller, it is necessary to satisfy that the sum of the weights of all leaf nodes in the left subtree is not greater than the sum of the weights of all leaf nodes in the right subtree, so that the finally constructed LMT greening tree is a right-heavy LMT greening tree.

[0049] Add the new internal node to the priority queue, and repeat the above steps until there is only one node left in the priority queue, and this node is the root node of the LMT greening tree.

[0050] Among them, the power magnitudes of transmitting codewords 0 and 1 are determined according to the modulation mode and fading of the encoded signal.

[0051] Adaptive coding method: If the 0-1 energy efficiency ratio is reversed due to factors such as system dynamic adjustment of the modulation mode and transmission power, only the 0-1 allocation method needs to be changed.

[0052] iv) Allocate binary codes: Perform Huffman coding on the constructed LMT greening tree to obtain the code of each character. Specifically, starting from the root node of the LMT greening tree, allocate 0 to the left and 1 to the right. The code of each character consists of the path from the root node to its corresponding leaf node, and the 0 and 1 encountered on the path are arranged in the order from the lowest bit to the highest bit.

[0053] The decoding process is similar to binary Huffman decoding. Starting from the root node of the LMT greening tree, traverse the tree to the left or right until reaching the leaf node. Concatenate the characters encountered during the traversal in order to restore the original data.

[0054] The encoding method of the present invention takes into account the energy difference of transmitting different codewords while maintaining the advantages of Huffman encoding, such as prefix code, variable-length encoding, and the shortest average encoding length, and can optimize the energy efficiency. Specifically, when the power of transmitting codeword 0 is small and the power of transmitting codeword 1 is large, a left-heavy LMT tree is adopted. At this time, the sum of the leaf weights of the left subtree of the root is not less than the sum of the leaf weights of the right subtree, that is, the sum of the probabilities of transmitting codeword 0 is not less than the sum of the probabilities of transmitting codeword 1. Similarly, when the power of transmitting codeword 1 is small and the power of transmitting codeword 0 is large, a right-heavy LMT tree is adopted. At this time, the sum of the leaf weights of the right subtree of the root is not less than the sum of the leaf weights of the left subtree, that is, the sum of the probabilities of transmitting codeword 1 is not less than the sum of the probabilities of transmitting codeword 0. In this way, the occurrence probability of low-energy-consuming codewords is increased in the encoding, and the occurrence probability of high-energy-consuming codewords is reduced, thereby reducing the average energy consumption of the encoding. Especially in the new generation of wireless communication ultra-wideband ultra-high frequency and future massive data environment, the encoding method of the present invention can greatly reduce the average energy consumption of the encoding and improve the economic benefits.

[0055] In an embodiment of the present invention, for a Huffman tree, if the condition is satisfied: for any internal node, the sum of the weights of all leaf nodes in its left subtree (the weight of the left child node) is not less than the sum of the weights of all leaf nodes in the right subtree (the weight of the right child node), then this Huffman tree is a left-heavy LMT tree.

[0056] If the condition is satisfied: for any internal node, the sum of the weights of all leaf nodes in its left subtree (equal to the weight of the left child node) is not greater than the sum of the weights of all leaf nodes in its right subtree (equal to the weight of the right child node), then this Huffman tree is a right-heavy LMT tree.

[0057] In an embodiment of the present invention, the right-heavy LMT tree and the left-heavy LMT tree are collectively referred to as the LMT greening tree. The Huffman encoding performed on the LMT greening tree is the LMT encoding.

[0058] The following further illustrates the encoding method of the present invention with a specific example.

[0059] Suppose the probabilities of the six characters ABCDEFGH appearing are as follows: A: 0.07, B: 0.19, C: 0.02, D: 0.06, E: 0.32, F: 0.03, G: 0.21, H: 0.10; in practical applications, this is obtained by statistically analyzing the character transmission frequency, and over time, this probability distribution becomes more and more accurate; now assume that a certain modulation method of the encoded signal, such as frequency modulation or amplitude modulation, makes the energy consumption of transmitting codeword 1 large and the energy consumption of transmitting codeword 0 small. LMT encoding needs to be performed according to this probability distribution and the transmission power consumption characteristics.

[0060] First, construct a priority queue. Take the statistically obtained characters and their probabilities as leaf nodes, create a priority queue, and sort them in ascending order of probability. C: 0.02, F: 0.03, D: 0.06, A: 0.07, H: 0.10, B: 0.19, G: 0.21, E: 0.32;

[0061] Secondly, construct an LMT greening tree:

[0062] 1) Take out the two nodes with the smallest probabilities from the priority queue. C: 0.02, F: 0.03;

[0063] 2) Create a new internal node with a probability equal to the sum of the frequencies of these two nodes, which is 0.05, and use these two nodes as its child nodes. For example, assume that a certain modulation method results in a relatively large energy consumption for transmitting 1 and a relatively small energy consumption for transmitting 0. According to the above construction method, it is necessary to ensure that the sum of the weights of all leaf nodes in the left subtree is not less than that of all leaf nodes in the right subtree. That is, construct a left-heavy LMT tree; convert all weights to integers, and the construction is as follows:

[0064]

[0065] 3) Add the new node I (the parent node of CF): 0.05 to the priority queue: I (the parent node of CF): 0.05, D: 0.06, A: 0.07, H: 0.10, B: 0.19, G: 0.21, E: 0.32;

[0066] 4) Repeat the above steps until there is only one node left in the priority queue. This node is the root node of the LMT greening tree. Finally, construct a left-heavy LMT tree (each leaf node in the tree represents a character), as Figure 3 shown.

[0067] Finally, assign binary codes for LMT encoding. Starting from the root node of the LMT greening tree, assign 0 to the left and 1 to the right. The code for each character consists of the path from the root node to its corresponding leaf node, and the 0s and 1s encountered on the path are arranged in the order from the lowest bit to the highest bit. The encoding results are shown in Table 1 below:

[0068] Table 1 Encoding results of the left-heavy LMT tree

[0069] Character Probability Encoding A 0.07 0101 B 0.19 11 C 0.02 01111 D 0.06 0110 E 0.32 00 F 0.03 01110 G 0.21 10 H 0.10 0100

[0070] Correspondingly, if the energy consumption for transmitting codeword 0 is relatively large and the energy consumption for transmitting codeword 1 is relatively small, then finally construct a right-heavy LMT tree, as Figure 4 shown; the converted LMT encoding results are shown in Table 2:

[0071] Coding results of the right-heavy LMT tree in Table 2

[0072] Character Probability Encoding A 0.07 1010 B 0.19 00 C 0.02 10000 D 0.06 1001 E 0.32 11 F 0.03 10001 G 0.21 01 H 0.10 1011

[0073] It is easy to verify that the left-heavy LMT tree is suitable for coding when the power of transmitting 1 is relatively large, while the right-heavy LMT tree (traditional Huffman coding with left small and right large) is suitable for coding when the power of transmitting 0 is relatively large, as shown below:

[0074] Assume that the energy consumption of transmitting codewords 0 and 1 are respectively: P0 = 1, P1 = 2, and the average power of the left-heavy LMT tree coding is:

[0075] P left =(0.6P0 + 0.4P1)+[(0.32P0 + 0.28P1)+(0.21P0 + 0.19P1)]

[0076] +(0.17P0 + 0.11P1)+[(0.10P0 + 0.07P1)+(0.06P0 + 0.05P1)]

[0077] +(0.03P0 + 0.02P1)=1.49P0 + 1.12P1 = 3.73

[0078] The average power of the right-heavy LMT tree coding (consistent with the traditional Huffman coding with left small and right large) is:

[0079] P right =(0.6P1 + 0.4P0)+[(0.32P1 + 0.28P0)+(0.21P1 + 0.19P0)]

[0080] +(0.17P1 + 0.11P0)+[(0.10P1 + 0.07P0)+(0.06P1 + 0.05P0)]

[0081] +(0.03P1 + 0.02P0)=1.49P1 + 1.12P0 = 4.1

[0082] It can be seen that P left <P right . That is, when the power of transmitting 1 is relatively large, the average power based on the left-heavy LMT tree coding is less than that of the right-heavy LMT tree coding.

[0083] Next, the energy efficiency of the LMT coding in the embodiments of the present invention is analyzed theoretically.

[0084] The present invention discovers that equivalent Huffman trees can only be obtained by exchanging the left and right subtrees of several internal nodes. For a Huffman tree of n characters, the total number of different equivalent Huffman trees is: 2 n-1-1. Since when constructing a Huffman tree, the only choices that can lead to different Huffman trees in the future are the left and right placement positions of the left and right child nodes (or subtrees) of the internal nodes. Conversely, for a constructed Huffman tree, swapping the left and right subtrees of any number of internal nodes is equivalent to making different choices during the original construction, resulting in an equivalent Huffman tree. For a Huffman tree of n characters, there are n - 1 internal nodes, and the total number of ways to swap is:

[0085] This conclusion can also be proved as follows. Arrange the n - 1 internal nodes in a sequence of 00…0, ~, 11…1 in a certain order, that is, 0 to 2 n-1 -1. If a certain bit is 0, it means the subtrees of the corresponding internal node are not swapped, and if it is 1, it means they are swapped. Then, 00…0 (all 0s) corresponds to the original Huffman tree, and the remaining 2 n-1 -1 are all its equivalent Huffman trees, and all 1s correspond to the mirror image of the original Huffman tree. For example, now encoding n = 1024 characters. If using equal - length binary encoding, 10 bits are required. If using Huffman encoding - variable - length encoding, the average code length is less than 10 bits. However, there are 2 1024-1 equivalent Huffman trees. If using the exhaustive method, the time complexity is O(2 n )! Especially in the new generation of wireless communication, ultra - wideband, very high frequency, and future massive data environments, it is basically impossible to obtain the optimal encoding method by using the exhaustive method among such a large number of swapping methods.

[0086] In the present invention, let the power of the transmitted codeword 0 be P0 and the power of the transmitted codeword 1 be P1. The binary encoding method is allocated as follows: starting from the root node, 0 is allocated to the left and 1 is allocated to the right. When P1 > P0, the LMT greening tree adopts a left - heavy LMT tree. When P1 < P0, the LMT greening tree adopts a right - heavy LMT tree. In this way, the LMT encoding corresponding to the established LMT greening tree is the Huffman encoding with the lowest average energy consumption.

[0087] The proof is as follows:

[0088] According to the lemma, equivalent Huffman trees can only be obtained by swapping the left and right subtrees of several internal nodes. Therefore, it only needs to be proved that swapping the left and right subtrees of any node in the LMT greening tree cannot reduce the average energy consumption.

[0089] Suppose the transmission probability of the k - th character is Pro k , without loss of generality, assume P1 > P0 and adopt a left - heavy LMT tree. The average energy consumption for transmitting a character is:

[0090]

[0091] Among them, The number of 0s in the encoding of the k-th character, The number of 1s in the encoding of the k-th character. Obviously, k max represents the total number of strings.

[0092] where j k is the number of bits in the encoding of the k-th character, represents the j-th codeword of the k-th character.

[0093]

[0094] Then the average energy consumption for transmitting a character can be expressed as:

[0095]

[0096] By exchanging the summation order, we get:

[0097]

[0098] Further transforming equation (3) gives (4):

[0099]

[0100] An equivalent form of (4) is to calculate the energy sum of each bit according to each layer of the binary tree:

[0101]

[0102] For the first bit j = 1, since the constructed tree is a left-heavy LMT tree, the sum of the leaf weights of the left subtree of the root is not less than the sum of the leaf weights of the right subtree:

[0103]

[0104] From the assumption P0 < P1, then P0 - P1 < 0. Multiplying both sides of equation (6) by (P0 - P1), we can easily get:

[0105]

[0106] The right side of the inequality corresponds to the average power for transmitting the first bit after exchanging the left and right subtrees of the root. Therefore, exchanging the left and right subtrees of the root will not reduce the average power.

[0107] For j = 2, when transmitting the second bit, in the left and right subtrees respectively, repeating the above analysis, exchanging the left and right subtrees of the roots of the left and right subtrees will not reduce the power either. Then analyzing the third bit, …, until the last bit. In short, for any node, it is impossible to reduce the power by exchanging the left and right subtrees. And the equivalent Huffman tree can only be obtained by exchanging the left and right subtrees.

[0108] Therefore, the LMT code is the Huffman code with the minimum average energy consumption.

[0109] When P1 < P0, the case of using the right-heavy LMT tree can be proven in a completely similar manner.

[0110] Analyzing the above example, let the energy consumption ratio of the 1-0 codeword Figure 5 Comparing with the Huffman code corresponding to the Huffman tree with smaller weights on the left and larger weights on the right during construction, which is commonly used, when the power of transmitting the codeword 1 is relatively large, it is the Huffman code with the worst energy efficiency. When the energy consumption ratio of the 1-0 codeword is 2, the energy consumption of the LMT code in the embodiment of the present invention is reduced by about 10% compared with this code.

[0111] Calculate the average energy consumption of the general Huffman code using the median value of the average energy consumption of the best and worst Huffman codes: (P left + P right ) / 2;

[0112] The average energy consumption of the LMT code: min{P left , P right};

[0113] The ratio of the average energy consumption of the LMT code to the Huffman code is:

[0114] ρ = min{P left , P right} / {(P left + P right ) / 2}

[0115] From Figure 6 it can be seen the relationship between the ratio of the average energy consumption of the LMT code to the Huffman code and the energy consumption ratio of the 1-0 codeword. Whether the 1-0 energy consumption ratio is greater than 1 or less than 1, the average energy consumption of the LMT code is always smaller than that of the Huffman code, and the greater the 1-0 energy consumption ratio, the more the average energy consumption of the LMT code is reduced.

[0116] In summary, the coding method in the embodiment of the present invention considers the energy consumption difference between the two codewords 0 and 1, and by increasing the usage probability of the codeword with low energy consumption and reducing the usage probability of the codeword with high energy consumption in the coding, the average energy consumption of the coding is minimized.

[0117] The LMT code in the embodiment of the present invention can greatly improve the energy efficiency of the traditional Huffman code. The above proves that the LMT code can minimize the average energy consumption of the Huffman code. And through performance analysis, it is found that when the energy consumption difference between 0 and 1 is relatively large, the average energy consumption of the LMT code is about 10% lower than that of the traditional Huffman code.

[0118] Embodiment 2

[0119] An embodiment of the present invention provides an energy-efficient Huffman coding system, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the energy-efficient Huffman coding method in the above-mentioned Embodiment 1 are implemented.

[0120] The related technical solutions are the same as above and will not be elaborated here.

[0121] Embodiment 3

[0122] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the energy-efficient Huffman coding system method in the above-mentioned Embodiment 1 are implemented.

[0123] Specifically, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0124] The related technical solutions are the same as above and will not be elaborated here.

[0125] Embodiment 4

[0126] An embodiment of the present application provides a computer program product, including a computer program. When the computer program runs on a computer, the computer is enabled to execute the steps of the energy-efficient Huffman coding system method in the above-mentioned Embodiment 1.

[0127] The related technical solutions are the same as above and will not be elaborated here.

[0128] Those skilled in the art can easily understand that the above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. A high-energy-efficient Huffman coding method, characterized in that, Including: Statistically analyze the probability of occurrence of each character in the input string; Take each character and its probability as leaf nodes, create a priority queue to store the leaf nodes, and sort them in ascending order of probability; Construct the Huffman tree from the leaf nodes in the priority queue; when the transmission power of codeword 0 is less than that of codeword 1, transform the Huffman tree into a left-heavy LMT greening tree; wherein, the left-heavy LMT greening tree satisfies that the sum of the weights of all leaf nodes in the left subtree is not less than the sum of the weights of all leaf nodes in the right subtree; the weight of the leaf node is consistent with its corresponding probability, and the transmission power of codeword 0 and codeword 1 is determined based on the signal modulation method and fading after the string is encoded; Perform Huffman coding on the left-heavy LMT greening tree to obtain the code of each character.

2. The high energy efficiency Huffman coding method according to claim 1, wherein, Also including: When the transmission power of codeword 0 is greater than or equal to that of codeword 1, transform the Huffman tree into a right-heavy LMT greening tree; wherein, the right-heavy LMT greening tree satisfies that the sum of the weights of all leaf nodes in the left subtree is not greater than the sum of the weights of all leaf nodes in the right subtree; Perform Huffman coding on the right-heavy LMT greening tree to obtain the code of each character.

3. The high energy efficiency Huffman coding method according to claim 1 or 2, characterized in that, Performing Huffman coding on the left-heavy LMT greening tree or the right-heavy LMT greening tree to obtain the code of each character, including: Starting from the root node of the LMT greening tree, assign codeword 0 to the left and codeword 1 to the right; The code of each character consists of the path from the root node to its corresponding leaf node, and the codewords 0 and 1 encountered on the path are arranged in the order from the lowest bit to the highest bit; wherein, the LMT greening tree is the left-heavy LMT greening tree or the right-heavy LMT greening tree.

4. A high-energy-efficient Huffman coding method, characterized in that, Including: S1. Statistically analyze the probability of occurrence of each character in the input string; take each character and its probability as leaf nodes, create a priority queue to store the leaf nodes, and sort them in ascending order of probability; S2. Take out two leaf nodes with the smallest probabilities from the priority queue; create a new internal node, whose probability is the sum of the probabilities of the two leaf nodes taken out from the priority queue, and use the two leaf nodes as the children of the new internal node; wherein, when the transmission power of codeword 0 is less than that of codeword 1, the Huffman tree obtained after using the two leaf nodes as the children of the new internal node satisfies that the sum of the weights of all leaf nodes in the left subtree is not less than the sum of the weights of all leaf nodes in the right subtree, so that the Huffman tree is a left-heavy LMT greening tree; the weight of the leaf node is consistent with its corresponding probability, and the transmission power of codeword 0 and codeword 1 is determined based on the signal modulation method and fading after the string is encoded; S3. Add the new internal node to the priority queue, and repeat S2 until there is only one node left in the priority queue, and this node is the root node of the left-heavy LMT greening tree; S4. Perform Huffman coding on the left-heavy LMT greening tree to obtain the code of each character.

5. The high energy efficiency Huffman coding method according to claim 4, characterized in that In S2, when the transmission power of codeword 0 is greater than or equal to that of codeword 1, the Huffman tree obtained by taking the two leaf nodes as the child nodes of the new internal node satisfies that the sum of the weights of all leaf nodes in the left subtree is not greater than the sum of the weights of all leaf nodes in the right subtree, so that the Huffman tree is a right-heavy LMT greening tree; In S3, the only remaining node in the priority queue is the root node of the right-heavy LMT greening tree; In S4, perform Huffman coding on the right-heavy LMT greening tree to obtain the code of each character.

6. The high energy efficiency Huffman coding method according to claim 4 or 5, characterized in that, Performing Huffman coding on the left-heavy LMT greening tree or the right-heavy LMT greening tree to obtain the code of each character includes: Starting from the root node of the LMT greening tree, assign codeword 0 to the left and codeword 1 to the right; The code of each character is composed of the path from the root node to its corresponding leaf node, and the codewords 0 and 1 encountered on the path are arranged in the order from the least significant bit to the most significant bit; wherein, the LMT greening tree is the left-heavy LMT greening tree or the right-heavy LMT greening tree.

7. An energy-efficient Huffman coding system, characterized in that, Comprising a computer-readable storage medium and a processor; The computer-readable storage medium is used to store executable instructions; The processor is used to read the executable instructions stored in the computer-readable storage medium and execute the energy-efficient Huffman coding method according to any one of claims 1-6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the energy-efficient Huffman coding method according to any one of claims 1-6.

9. A computer program product, characterized in that, Comprising a computer program, when the computer program runs on a computer, the computer is caused to execute the energy-efficient Huffman coding method according to any one of claims 1-6.