A wireless sensor network data intelligent compression method

The method enhances data compression in wireless sensor networks by optimizing dictionary updates in the LZW algorithm based on character frequency and preference, improving efficiency and compression rates.

CN117376429BActive Publication Date: 2024-12-17JIANGSU XINGYU XINLIAN ELECTRONIC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311303843.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-10
Publication Date
2024-12-17
Estimated Expiration
2043-10-10

AI Technical Summary

Technical Problem

The LZW algorithm used in wireless sensor network data compression results in low data coding efficiency and poor compression rates due to the inclusion of low-frequency strings in the dictionary, leading to inefficient data transmission.

Method used

A method for intelligently compressing wireless sensor network data using an initial dictionary construction based on character type frequency and allocatable degree, updating the dictionary with character strings based on conditional frequency and preference, and encoding data until all data is compressed.

Benefits of technology

Improves data compression efficiency and rate by optimizing dictionary updates, ensuring higher retrieval rates and better encoding effects through comprehensive analysis of character string importance during the LZW algorithm process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117376429B_ABST
    Figure CN117376429B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data encoding and compression, and in particular to a method for intelligent compression of wireless sensor network data. The method obtains an initial dictionary according to the number of types of transmission data, obtains the distributability of each type of character according to the remaining space of the initial dictionary and the frequency of occurrence of each type of character; performs LZW algorithm encoding on the transmission data to obtain a character string to be added; obtains a conditional frequency according to the frequency of occurrence of the first character in the character string to be added, the remaining data volume of the transmission data and the relative frequency of the character string to be added, and obtains the preferred degree of the character string to be added in combination with the distributability of the first character in the character string to be added; updates the initial dictionary according to the preferred degree, continues to perform LZW algorithm encoding to continuously update the initial dictionary, until all transmission data are encoded, and obtains compressed data. The present invention optimizes the dictionary update process in the LZW algorithm, improves the compression efficiency of data, and achieves a better compression effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of data coding compression, and in particular to a method for intelligently compressing data in a wireless sensor network. Background Art

[0002] Through the data transmission of wireless sensor networks, real-time data monitoring, remote control and intelligent decision-making can be achieved, bringing higher efficiency, reliability and sustainable development to various industries. Wireless sensor networks are widely used in industrial automation, agriculture and environmental monitoring, construction and smart home, health care and logistics and supply chain management. However, wireless sensor network data often has a large amount of data, which will cause the data to consume a lot of transmission bandwidth during network transmission and reduce the transmission speed. Therefore, data compression processing is extremely important in wireless sensor network data transmission.

[0003] In wireless sensor network data, since the data that needs to be monitored often has a large concentration, most of the data has little or no change over time, resulting in a large amount of duplicate data in the data. In existing coding and compression technologies, the LZW algorithm is often used for lossless coding compression. However, in the existing encoding process using the LZW algorithm, due to the diversity of wireless sensor network data, some low-frequency strings are not only added to the dictionary for coding and compression, which not only leads to low data coding efficiency, but also makes the LZW algorithm have a low compression rate for the data, and the final compression effect is poor. Summary of the invention

[0004] In order to solve the technical problem that the data encoding efficiency in the prior art is low, the LZW algorithm has a low compression rate for data, and the final compression effect is poor, the purpose of the present invention is to provide a wireless sensor network data intelligent compression method, and the technical solution adopted is as follows:

[0005] The present invention provides a method for intelligently compressing wireless sensor network data, the method comprising:

[0006] Acquire transmission data; obtain an initial dictionary corresponding to the transmission data according to the number of types of characters in the transmission data; obtain the allocatable degree of each type of character according to the remaining space size of the initial dictionary and the frequency of occurrence of each type of character in the transmission data;

[0007] In the process of LZW algorithm encoding the transmission data through the initial dictionary, the dictionary update position and the corresponding character string to be added are obtained; the conditional frequency of the character string to be added is obtained according to the occurrence frequency of the first character in the character string to be added and the relative frequency of the character string to be added, and the data volume of the transmission data after the corresponding dictionary update position; the preference degree of the character string to be added is obtained according to the conditional frequency of the character to be added and the distributability of the first character in the character string to be added;

[0008] According to the preference of the character string to be added, the initial dictionary of the dictionary update position is updated; the transmission data after the dictionary update position is encoded by the updated initial dictionary using the LZW algorithm to obtain a new dictionary update position, and the initial dictionary is updated until all the transmission data are encoded to obtain compressed data.

[0009] Furthermore, the method for obtaining the initial dictionary includes:

[0010] Count the number of character types in the transmitted data, and obtain the size of the initial dictionary according to the number of types;

[0011] The frequency of each type of character in the transmitted data is used as the appearance frequency of each type of character. The corresponding characters are added to the initial dictionary in descending order of appearance frequency, and the codes corresponding to each type of character are generated to obtain the initial dictionary.

[0012] Furthermore, the specific expression for obtaining the size of the initial dictionary is:

[0013]

[0014] In the formula, S represents the size of the initial dictionary, n represents the number of categories, and log represents the logarithmic function. Represents a ceiling function.

[0015] Furthermore, the method for obtaining the allocatable degree includes:

[0016] The difference between the size of the initial dictionary and the number of categories is taken as the remaining space size of the initial dictionary; the product of the frequency of occurrence of each category of characters and the size of the remaining space is rounded down to obtain the assignability of each category of characters.

[0017] Furthermore, the method for obtaining the conditional frequency includes:

[0018] Counting the amount of data transmitted after the dictionary update position, obtaining the amount of data to be encoded, calculating the ratio of the amount of data to be encoded to the total amount of data transmitted, and using the negative correlation mapped and normalized ratio as the encoding adjustment value; using the frequency of the character string to be added in the transmitted data after the dictionary update position as the relative frequency of the character string to be added;

[0019] Obtaining the adjustment frequency of the character string to be added according to the encoding adjustment value and the relative frequency of the character string to be added;

[0020] The ratio of the adjustment frequency of the string to be added to the occurrence frequency of the first character in the string to be added is calculated to obtain the conditional frequency of the string to be added.

[0021] Furthermore, the specific expression of the adjustment frequency of the character string to be added is:

[0022]

[0023] In the formula, Pw represents the adjustment frequency of the string to be added, Ps represents the relative frequency of the string to be added, D represents the total amount of transmitted data, Du represents the amount of data to be encoded, Norm() represents the normalization function, a represents the preset adjustment parameter, and the preset adjustment parameter is greater than 0 and less than 1.

[0024] Furthermore, the initial dictionary update of the dictionary update position according to the preference of the character string to be added includes:

[0025] The ratio of the remaining space size of the initial dictionary to the number of types of transmitted data is used as the optimal threshold;

[0026] When the preference degree of the character string to be added is greater than the preference threshold, the character string to be added is added to the initial dictionary, and a code corresponding to the character string to be added is generated to obtain an updated initial dictionary.

[0027] Furthermore, the updated initial dictionary is used to encode the transmission data after the dictionary update position using the LZW algorithm to obtain a new dictionary update position, and the initial dictionary is updated until all the transmission data is encoded to obtain compressed data, including:

[0028] During the LZW algorithm encoding process, when the first retrieved string is not in the updated initial dictionary, the corresponding encoding position is used as the new dictionary update position; the initial dictionary is updated at the new dictionary update position;

[0029] Using the last updated initial dictionary, the transmission data after the last new dictionary update position is encoded using the LZW algorithm to obtain compressed encoded data corresponding to the transmission data;

[0030] All the strings in the initial dictionary after the last update are combined into a string sequence; the compressed encoded data, the string sequence and the initial dictionary that has not been updated are used as compressed data of the transmission data.

[0031] Furthermore, the method for obtaining the degree of preference includes:

[0032] The product of the conditional frequency of the character to be added and the assignability of the first character in the character string to be added is calculated to obtain the preference degree of the character string to be added.

[0033] Furthermore, in the process of performing LZW algorithm encoding on the transmission data through the initial dictionary, obtaining the dictionary update position and the corresponding character string to be added includes:

[0034] During the LZW algorithm encoding process, when a character string is retrieved for the first time and is not in the initial dictionary, the corresponding encoding position is used as the dictionary update position; and the character string corresponding to the dictionary update position and not in the initial dictionary is used as the character string to be added.

[0035] The present invention has the following beneficial effects:

[0036] The present invention obtains an initial dictionary according to the number of types of transmission data, obtains the allocable degree of each type of character according to the remaining space of the initial dictionary and the frequency of occurrence of each type of character, and uses the allocable degree to reflect the number of different types of character strings that can be added to the dictionary of the LZW algorithm, so as to facilitate the subsequent analysis of the importance of the character string to be added. The transmission data is further encoded by the LZW algorithm through the initial dictionary, and considering the different usage frequencies of each character string that needs to be added to the initial dictionary in the transmission data, the dictionary update position before the character string needs to be added to the initial dictionary is analyzed to obtain the dictionary update position and the corresponding character string to be added. Considering the data volume of the transmission data that has not been encoded after the dictionary update position, and the proportion of the character string to be added to all the character strings corresponding to the first character, the importance of the character string to be added is analyzed from two aspects, and the conditional frequency of the character string to be added is obtained by the frequency of occurrence of the first character in the character string to be added, the data volume of the transmission data after the corresponding dictionary update position and the relative frequency of the character string to be added, and the usage frequency of the character string to be added is analyzed more comprehensively and accurately. Further considering the size of the space that can be allocated to the character string to be added, that is, the allocable degree of the first character in the character string to be added, the preferred degree of the character string to be added is obtained to reflect the importance of the character string to be added. Finally, the initial dictionary is updated according to the degree of optimization to obtain a better dictionary, so that the dictionary retrieval rate in the encoding is higher and the encoding effect is better. The LZW algorithm encoding is continued for the remaining transmission data, and the initial dictionary is continuously updated until all the transmission data are encoded to obtain compressed data. The present invention makes the dictionary construction better and improves the encoding compression efficiency of the data by analyzing the importance of the character string when updating the dictionary in the LZW algorithm, so that the data compression degree is higher and the final compression effect is better. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0038] Figure 1 A flow chart of a method for intelligently compressing wireless sensor network data provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0039] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation method, structure, features and effects of a wireless sensor network data intelligent compression method proposed by the present invention in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0040] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0041] The specific scheme of the wireless sensor network data intelligent compression method provided by the present invention is described in detail below with reference to the accompanying drawings.

[0042] See also Figure 1 , which shows a flow chart of a wireless sensor network data intelligent compression method provided by an embodiment of the present invention, the method comprising the following steps:

[0043] S1: Acquire transmission data; obtain an initial dictionary corresponding to the transmission data according to the number of character types in the transmission data; obtain the assignability of each type of character according to the remaining space size of the initial dictionary and the frequency of occurrence of each type of character in the transmission data.

[0044] Wireless sensor network data mainly includes sensor data, location data, energy data, network topology data and event data. Sensor data is usually the environmental parameters of the location, such as temperature, humidity, light intensity, pressure, sound, etc.; sensor location data, such as the location coordinates of sensor nodes; sensor energy, such as the energy consumption of sensor nodes; sensor network topology data, such as the connection relationship and routing information between sensor network nodes; sensor event data, such as specific times that wireless sensors can detect, such as fires and earthquakes. The main purpose of collecting this data is to obtain real-time information and status of the environment, equipment or system for monitoring, analysis and decision-making. By analyzing the data characteristics of the collected sensor network data and predicting the data, actual scenarios such as energy, resources and environment can be optimized.

[0045] In wireless sensor network data, the amount of collected data is large and contains many types of characters, but the collected data belongs to monitoring data, which is highly concentrated and has high repetitiveness. Therefore, the LZW algorithm is usually used for encoding and compression, which can achieve better compression effect. First, the collected data that needs to be compressed is used as transmission data. The LZW algorithm achieves compression by establishing a string table, that is, a dictionary, and replacing long strings with shorter codes. Therefore, the encoding and compression of the transmission data requires the construction of an initial dictionary first. In an embodiment of the present invention, the dictionary space prepared in advance by the computer is a fixed array space obtained according to the number of types, so that the dictionary can be optimized later according to the usage of the space.

[0046] Preferably, the number of types of characters in the transmission data is counted, and the size of the initial dictionary is obtained according to the number of types. The size of the initial dictionary is the maximum number of character strings that can be stored in the dictionary. The specific expression for obtaining the size of the initial dictionary is:

[0047]

[0048] In the formula, S represents the size of the initial dictionary, n represents the number of categories, and log represents the logarithmic function. Represents a ceiling function.

[0049] in, It is expressed as the maximum encoding length obtained according to the number of categories. For example, when the number of categories is 5, the encoding length is 4, and then the size of the initial dictionary is 16 according to the power of 2. The size of the initial dictionary is the size of the space prepared in advance. Even if the initial dictionary is not filled with data, its space size will not change.

[0050] The frequency of occurrence of each type of character in the transmission data is obtained, and the frequency of occurrence is the probability of each type of character appearing in the transmission data. The characters are added to the initial dictionary in order of frequency of occurrence from large to small, and the codes corresponding to each type of character are generated to obtain the initial dictionary. It should be noted that the order of arrangement from large to small ensures that when performing dictionary retrieval, characters with higher frequencies can be quickly retrieved, thereby improving the efficiency of encoding compression. The codes corresponding to each type of character are generated and filled in according to the order of natural numbers from small to large. The encoding process of constructing the dictionary as the LZW algorithm is a technical means well known to those skilled in the art and will not be elaborated here.

[0051] In the transmission data, the higher the frequency of occurrence of a character, the higher the frequency of the string headed by this type of character may be. When the initial dictionary is subsequently updated due to the addition of strings, the string headed by this high-frequency character may occupy more space. Therefore, according to the remaining space size of the initial dictionary and the frequency of occurrence of each type of character in the transmission data, the allocability of each type of character is obtained. The allocability reflects the degree to which the string headed by each type of character can be allocated in the remaining space.

[0052] Preferably, the difference between the size of the initial dictionary and the number of categories is used as the remaining space size of the initial dictionary, and the product of the frequency of occurrence of each category of characters and the remaining space size is rounded down to obtain the assignability of each category of characters. In the embodiment of the present invention, the specific expression of the assignability of the characters is:

[0053]

[0054] In the formula, Al i is the assignability of the i-th character, S is the size of the initial dictionary, n is the number of categories, P i It is represented by the frequency of occurrence of the i-th type of characters, It is expressed as a floor function, which ensures that the remaining space can be fully allocated to each type of character by rounding down.

[0055] At this point, the initial analysis of the transmitted data is completed, and an initial dictionary that can be encoded is obtained, as well as the assignability of each type of character for analyzing the frequency of use of character strings.

[0056] S2: In the process of encoding the transmission data by LZW algorithm through the initial dictionary, the dictionary update position and the corresponding character string to be added are obtained; according to the frequency of the character string to be added and the first character in the character string to be added, and the amount of transmission data that has not been encoded at the corresponding dictionary update position, the conditional frequency of the character string to be added is obtained; according to the conditional frequency of the character to be added and the distributability of the first character in the character string to be added, the preference degree of the character string to be added is obtained.

[0057] According to the initial dictionary, the transmission data can be encoded by the LZW algorithm. The LZW algorithm encoding process is a well-known technical means well known to those skilled in the art, and will not be described in detail here. During the encoding process, the LZW algorithm directly adds the character strings to the dictionary in the order in which the character strings appear, without taking into account the frequency of use of the character strings. This will cause some extremely low-frequency character strings to occupy a large number of positions in the dictionary, increase the subsequent dictionary retrieval time, and make the dictionary easy to be filled up quickly, resulting in a long compression time of the algorithm, low compression efficiency, and low compression degree. Therefore, the embodiment of the present invention mainly analyzes the importance of a new character string when it is added to the dictionary. If the character string does not meet the selection conditions, the character string will not be added to the dictionary.

[0058] First, in the process of LZW algorithm encoding the transmission data through the initial dictionary, the dictionary update position and the corresponding character string to be added are obtained. In one embodiment of the present invention, in the LZW algorithm encoding process, when the character string is not in the initial dictionary for the first time, the corresponding encoding position is used as the dictionary update position, and the character string not in the initial dictionary at the dictionary update position is used as the character string to be added. For example, for a set of data abcabaa, all of which are unencoded data, the character string not in the dictionary detected for the first time is ab, that is, the character string to be added is ab, and the first character in the character string to be added is a, then the corresponding encoding position, that is, the dictionary update position, is the position before the first character a in the character string ab.

[0059] As the encoding progresses, due to the reduction of the data to be encoded, the data to be encoded is the unencoded transmission data, that is, the transmission data after the dictionary update position, and the impact on the relative frequency of the string to be added will increase. For example, in the two cases where the remaining amount of data to be encoded is 10 and the remaining amount of data is 5, the importance of the string to be added when the number of occurrences is 2 is different. The string to be added is more important when the remaining amount of data is 5 because it accounts for a higher proportion. The less the remaining data to be encoded, the more the frequency of the string to be added is affected. At the same time, as the encoding progresses, the remaining allocated space of the string to be added in the initial dictionary will also decrease. Therefore, according to the relative frequency of the string to be added and the frequency of occurrence of the first character in the string to be added, and the number of unencoded transmission data at the corresponding dictionary update position, the conditional frequency of the string to be added is obtained.

[0060] Preferably, the amount of data transmitted after the dictionary update position is counted as the amount of data to be encoded, the ratio of the amount of data to be encoded to the total amount of data transmitted is calculated, the negative correlation is mapped and the ratio is normalized to obtain the encoding adjustment value, and the importance of the relative frequency of the string to be added is reflected by the proportion of the amount of data not encoded. The frequency of the string to be added in the transmission data after the dictionary update position is taken as the relative frequency of the string to be added. Since the string to be added is a new string that has not been added to the dictionary, calculating its frequency after the dictionary update position can better reflect the usage frequency of the string to be added.

[0061] According to the encoding adjustment value and the relative frequency of the string to be added, the adjustment frequency of the string to be added is obtained. The specific expression of the adjustment frequency is:

[0062]

[0063] In the formula, Pw represents the adjustment frequency of the string to be added, Ps represents the relative frequency of the string to be added, D represents the total amount of data of the transmission data, Du represents the amount of data to be encoded, and a represents a preset adjustment parameter, which is greater than 0 and less than 1. Norm() represents a normalization function. It should be noted that normalization is a technical means well known to those skilled in the art. The selection of the normalization function can be linear normalization or standard normalization, etc. The specific normalization method is not limited here.

[0064] in, It is expressed as a coding adjustment value. When the amount of data to be coded is smaller, that is, the less the transmission data that is not coded is, the more important the character string to be added is, the larger the coding adjustment value is. In the embodiment of the present invention, the preset adjustment parameter a is set to 0.8, the purpose of which is to prevent the relative frequency from being adjusted too much and affecting the subsequent analysis of the importance.

[0065] After adjusting the relative frequency of the string to be added according to the amount of data that has not been encoded, it is further adjusted according to the frequency of occurrence of the first character in the string to be added. Since the allocated space for each type of character has been basically determined, the larger the proportion of the string to be added in the same type of string, that is, the larger the proportion of the string to be added in the string with the same first character, the more efficient the encoding compression will be after the string to be added is added to the dictionary.

[0066] Therefore, preferably, the ratio of the adjustment frequency of the string to be added to the occurrence frequency of the first character in the string to be added is calculated to obtain the conditional frequency of the string to be added. In the embodiment of the present invention, the specific expression of the conditional frequency is:

[0067]

[0068] Where Cf represents the conditional frequency of the string to be added, Pw represents the adjustment frequency of the string to be added, and P i It is represented as the frequency of occurrence of the i-th type character as the first character in the string to be added.

[0069] The greater the conditional frequency, the greater the frequency of use of the character string to be added in subsequent data. Adding the corresponding character string to be added to the dictionary will improve the encoding compression rate. At the same time, taking into account the assignability of the first character in the character string to be added, the higher the assignability of the first character, the higher the possibility that the character string to be added can be added. Therefore, the preference degree of the character string to be added is obtained based on the conditional frequency of the character to be added and the assignability of the first character in the character string to be added.

[0070] Preferably, the product of the conditional frequency of the character to be added and the assignability of the first character in the character string to be added is calculated to obtain the preference degree of the character string to be added. The preference degree reflects the importance of the character string to be added. In the embodiment of the present invention, the specific expression of the preference degree is:

[0071] Pd=Cf×Al i

[0072] In the formula, Pd represents the preference of the string to be added, Cf represents the conditional frequency of the string to be added, and Al i It is expressed as the assignability of the first character in the string to be added being a character of the i-th category.

[0073] Because the allocatability reflects the size of the allocated space for each type of character, the larger the allocated space, the greater the possibility that the string to be added can be added to the dictionary, and the smaller the allocated space, the less likely the string to be added is to be considered for inclusion in the dictionary. The conditional frequency reflects the usage frequency of the string to be added. The greater the usage frequency, the greater the possibility that the string to be added can be added to the dictionary, and the smaller the usage frequency, the less likely the string to be added is to be added to the dictionary.

[0074] At this point, the analysis of the importance of the character string to be added is completed, and the preference of the character string to be added in the encoding process is obtained.

[0075] S3: according to the preference of the character string to be added, the initial dictionary of the dictionary update position is updated; the transmission data after the dictionary update position is encoded by the updated initial dictionary using the LZW algorithm to obtain a new dictionary update position, and the initial dictionary is updated until all the transmission data are encoded to obtain compressed data.

[0076] In the embodiment of the present invention, the preferred threshold is set to determine whether the character string to be added can be added to the dictionary, that is, the initial dictionary update of the dictionary update position is performed according to the preferred degree of the character string to be added. The selection of the preferred threshold will affect the filling of the dictionary. When the preferred threshold is too large, the number of added characters is small, which not only makes it impossible to fill a large amount of space in the dictionary, but also makes the encoded data obtained by encoding more, and the ideal compression rate cannot be achieved. When the preferred threshold is too small, the space in the dictionary will be filled too early, and the space of the dictionary needs to be updated, which increases the amount of encoding compression calculation.

[0077] Therefore, in order to obtain a more reasonable optimal threshold, in one embodiment of the present invention, the ratio of the remaining space size of the initial dictionary and the number of types of transmitted data is used as the optimal threshold.

[0078] Furthermore, when the preference degree of the string to be added is greater than the preference threshold, it indicates that the string to be added is relatively important, and adding the string to the dictionary makes the subsequent encoding compression more efficient, and the string to be added is added to the initial dictionary, and the encoding corresponding to the string to be added is generated to obtain an updated initial dictionary. It should be noted that in the embodiment of the present invention, the encoding corresponding to the string to be added is generated by adding one to the encoding natural number corresponding to the previous string data in the dictionary, and the specific encoding generation process in the LZW algorithm is a well-known technology well known to those skilled in the art, and will not be described in detail here.

[0079] In an embodiment of the present invention, if the preference degree of the character string to be added is less than or equal to the preference threshold, the initial dictionary is not updated, so the character string to be added is directly encoded according to the character string already in the initial dictionary. For example, for a set of data abcacaa, if the character string ab to be added cannot update the initial dictionary, the character a is directly encoded, and the character b needs to be further judged based on the search status of bc in the dictionary. If the character string to be added is abc and the initial dictionary cannot be updated, it means that ab is already in the dictionary. The character string ab is directly encoded, and the character c needs to be further judged based on the search status of ca in the dictionary. The encoding process here refers to the LZW algorithm encoding process, and its encoding process is a public technical means, which will not be further described here.

[0080] The transmission data after the dictionary update position is encoded by the updated initial dictionary using the LZW algorithm, and the process of step S2 is repeated. During the LZW algorithm encoding process, when the character string is not found in the updated initial dictionary for the first time, the corresponding encoding position is used as the new dictionary update position. After the new dictionary update position is obtained, the initial dictionary of the new dictionary update position is updated, and the updating is stopped until all the transmission data are encoded. The transmission data after the last new dictionary update position is encoded by the last updated initial dictionary using the LZW algorithm, and the compressed encoding data corresponding to the transmission data is obtained. The compressed encoding data is the compression result of the lossless compression of the transmission data.

[0081] During the decoding process of the LZW algorithm, it is necessary to rebuild the dictionary based on the compressed coded data. In order to ensure that the compressed coded data can be decoded, the unupdated initial dictionary needs to be used as the corresponding compressed data. The unupdated initial dictionary is the initial dictionary obtained in step S1, and the initial dictionary only contains various characters and corresponding codes. At the same time, all the strings in the initial dictionary after the last update are composed into a string sequence. The string sequence is a string that can be added to the dictionary. During the process of decoding and constructing the dictionary, it can be judged whether the string is added to the dictionary, so that the dictionary constructed by decoding can be consistent with the encoding process. It should be noted that the decoding process of the LZW algorithm is a public technical means well known to those skilled in the art, and will not be described in detail here.

[0082] Finally, the compressed encoded data, the string sequence and the unupdated initial dictionary are used as the compressed data of the transmission data.

[0083] In summary, the present invention obtains an initial dictionary by the number of categories, obtains the allocable degree of each category of characters according to the remaining space of the initial dictionary and the frequency of occurrence of each category of characters, and the allocable degree is used to reflect the degree to which different categories of strings can be added to the dictionary of the LZW algorithm. Further, the transmission data is encoded by the LZW algorithm through the initial dictionary, and considering the different usage frequencies of each string that needs to be added to the initial dictionary in the transmission data, the dictionary update position before the string needs to be added to the initial dictionary is analyzed to obtain the string to be added at the dictionary update position, and considering the importance of the amount of transmission data that is not encoded after the dictionary update position on the relative frequency of the string to be added, and considering the influence of the proportion of all strings that may correspond to the first character of the string to be added in the string to be added, the conditional frequency of the string to be added is obtained by the frequency of occurrence of the first character in the string to be added, the amount of transmission data after the corresponding dictionary update position, and the relative frequency of the string to be added, and the usage frequency of the string to be added is analyzed more comprehensively and accurately. At the same time, considering the size of the space that can be allocated to the string to be added, that is, the allocable degree of the first character in the string to be added, the preferred degree of the string to be added is obtained. Finally, the initial dictionary is updated according to the degree of optimization, so that the initial dictionary has a higher retrieval rate and a better encoding effect. The remaining transmission data continues to be encoded by the LZW algorithm, and the initial dictionary is continuously updated until all transmission data are encoded to obtain compressed data. The present invention analyzes the character strings in the dictionary update process of the LZW algorithm to make the dictionary construction more optimal, the data encoding efficiency is high, the data compression rate is improved, and the final compression effect is better.

[0084] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0085] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

Claims

1. A wireless sensor network data intelligent compression method, It is characterized in that The method comprises: Acquire transmission data; obtain an initial dictionary corresponding to the transmission data according to the number of types of characters in the transmission data; obtain the allocatable degree of each type of character according to the remaining space size of the initial dictionary and the frequency of occurrence of each type of character in the transmission data; In the process of LZW algorithm encoding the transmission data through the initial dictionary, the dictionary update position and the corresponding character string to be added are obtained; the conditional frequency of the character string to be added is obtained according to the occurrence frequency of the first character in the character string to be added and the relative frequency of the character string to be added, and the data volume of the transmission data after the corresponding dictionary update position; the preference degree of the character string to be added is obtained according to the conditional frequency of the character to be added and the distributability of the first character in the character string to be added; According to the preference degree of the character string to be added, the initial dictionary of the dictionary update position is updated; the transmission data after the dictionary update position is encoded by the updated initial dictionary, a new dictionary update position is obtained, and the initial dictionary is updated until all the transmission data is encoded, thereby obtaining compressed data; The method for obtaining the initial dictionary includes: Count the number of character types in the transmitted data, and obtain the size of the initial dictionary according to the number of types; The frequency of each type of character in the transmitted data is used as the appearance frequency of each type of character, and the corresponding characters are added to the initial dictionary in descending order of appearance frequency, and the codes corresponding to each type of character are generated to obtain the initial dictionary; The method for obtaining the allocatable degree includes: The difference between the size of the initial dictionary and the number of categories is used as the size of the remaining space of the initial dictionary; the product of the frequency of occurrence of each category of characters and the size of the remaining space is rounded down to obtain the assignability of each category of characters; The method for obtaining the conditional frequency includes: Counting the amount of data transmitted after the dictionary update position, obtaining the amount of data to be encoded, calculating the ratio of the amount of data to be encoded to the total amount of data transmitted, and using the negative correlation mapped and normalized ratio as the encoding adjustment value; using the frequency of the character string to be added in the transmitted data after the dictionary update position as the relative frequency of the character string to be added; Obtaining the adjustment frequency of the character string to be added according to the encoding adjustment value and the relative frequency of the character string to be added; Calculate the ratio of the adjustment frequency of the string to be added to the occurrence frequency of the first character in the string to be added to obtain the conditional frequency of the string to be added; The specific expression of the adjustment frequency of the character string to be added is: Wherein, Pw represents the adjustment frequency of the string to be added, Ps represents the relative frequency of the string to be added, D represents the total amount of data transmitted, Du represents the amount of data to be encoded, Norm() represents the normalization function, a represents the preset adjustment parameter, and the preset adjustment parameter is greater than 0 and less than 1; The initial dictionary update of the dictionary update position according to the preference of the character string to be added includes: The ratio of the remaining space size of the initial dictionary to the number of types of transmitted data is used as the optimal threshold; When the preference degree of the string to be added is greater than the preference threshold, the string to be added is added to the initial dictionary, and a code corresponding to the string to be added is generated to obtain an updated initial dictionary; The method for obtaining the preference degree includes: The product of the conditional frequency of the character to be added and the assignability of the first character in the character string to be added is calculated to obtain the preference degree of the character string to be added.

2. According to claim 1, a wireless sensor network data intelligent compression method, It is characterized in that The specific expression for obtaining the size of the initial dictionary is: In the formula, S represents the size of the initial dictionary, n represents the number of categories, and log represents the logarithmic function. Represents a ceiling function.

3. According to claim 1, a method for intelligently compressing wireless sensor network data, It is characterized in that The method of encoding the transmission data after the dictionary update position by the updated initial dictionary using the LZW algorithm to obtain a new dictionary update position, updating the initial dictionary, and stopping when all the transmission data are encoded to obtain compressed data includes: During the LZW algorithm encoding process, when the first retrieved string is not in the updated initial dictionary, the corresponding encoding position is used as the new dictionary update position; the initial dictionary is updated at the new dictionary update position; Using the last updated initial dictionary, the transmission data after the last new dictionary update position is encoded using the LZW algorithm to obtain compressed encoded data corresponding to the transmission data; All the strings in the initial dictionary after the last update are combined into a string sequence; the compressed encoded data, the string sequence and the initial dictionary that has not been updated are used as compressed data of the transmission data.

4. According to claim 1, a method for intelligently compressing wireless sensor network data, It is characterized in that In the process of performing LZW algorithm encoding on the transmission data through the initial dictionary, obtaining the dictionary update position and the corresponding character string to be added includes: During the LZW algorithm encoding process, when a character string is retrieved for the first time and is not in the initial dictionary, the corresponding encoding position is used as the dictionary update position; and the character string corresponding to the dictionary update position and not in the initial dictionary is used as the character string to be added.

Citation Information

Patent Citations

  • Database security encryption method and system based on data coding

    CN116663069A

  • Graphene heating wall surface temperature intelligent monitoring system

    CN116827351A