# Patent

## Title
PPM-based data compression

## Abstract

Techniques are disclosed that reduce the computational complexity of PPM-based data compression through use of certain simplifying assumptions that permit faster search for a close-to-optimal PPM model than conventional techniques. The disclosed techniques permit the cost of the computationally-expensive model building task to be amortized over many compression/decompression cycles by maintaining a PersistentModel class, accessible to both the coder and decoder side of the system. This allows the computationally-expensive model building task to be performed only occasionally, as opposed to each time a message is coded. Furthermore, the model-building task is preferably scheduled to run at non-busy times, such that it minimizes user-perceptible service disruptions.

## Background
CROSS-REFERENCE TO RELATED APPLICATION
This application claims priority from U.S. Provisional Patent Application Ser. No. 60/284,003, entitled COMPRESSION METHOD, by inventors McAuliffe and Joerg, filed Apr. 16, 2001, which prior application is incorporated herein by reference.


FIELD OF THE INVENTION
The present invention relates generally to lossless data compression techniques and, more particularly, to data compression techniques based on Prediction by Partial Matching (“PPM”) methods.
BACKGROUND OF THE INVENTION
Data compression is widely used in modern data communication, transmission, and storage systems. The basic aim of data compression is to encode (or compress) a message into an equivalent, but shorter, compressed message. The compressed message can then be transmitted or stored using fewer bits and, when need, can be decoded (or uncompressed) to recreate the original message.
At the most fundamental level, data compression methods are characterized into two distinct classes: (i) lossless compression and (ii) lossy compression. In lossless compression, the process of encoding, then decoding, a message will always produce a perfect recreation of the original message—i.e., there is no data loss, hence the name lossless compression. With lossy compression, on the other hand, the process of encoding, then decoding a message, will not always produce an exact copy of the original message. Instead, the compression/decompression process may result in certain errors, or data loss. Such errors are typically small, and hopefully imperceptible by the user of the data. MP3 is a good example of lossy compression: Although the process of encoding, then decoding, a song using the MP3 standard will significantly alter the original bit stream, the user will not perceive a problem, since the song still “sounds” the same. Generally speaking, lossy data compression is used for sound and image files, whereas lossless data compression is used for text and data files.
In data compression, the term “compression ratio” refers to the ratio of the compressed message size to the uncompressed message size. Thus, a compression ratio of 0.5 implies that the compressed message is half the size of the original message.
The basic idea behind all data compression algorithms is to identify and exploit patterns in the data to be compressed, and to apply the greatest compression to the most commonly appearing patterns. For example, if the data to be compressed is ASCII text that represents written English, most people would realize that the most commonly appearing character is “e,” whereas characters like “x” and “z” are relatively uncommon. ASCII represents all characters using 7-bit patterns. While 7 bits represents the fewest number of bits that can be used to assign fixed-length codes to all characters, one can achieve better compression of English text by varying code lengths, and assigning shorter codes to the most common characters (e.g., 2 or 3 bits for an “e”) and longer codes to the least common characters (e.g., 9 or 10 bits for an “x” or “z”). Utilizing the well-known Huffman algorithm to optimally assign variable-length codes to ASCII characters results in a compression ratio of about 0.59 for English text. This, however, is still far from optimal, since the best known compression algorithm achieve compression ratios of about 0.2 for English text.
To key parts of any data compression algorithm are: (i) the model and (ii) the coder. The model component predicts the likelihood that a given symbol (e.g., a character) will appear in the message. In the ASCII English text example discussed above, the model was “context independent” because, for example, it predicts that “e” will be the most likely character, regardless of where one is in the text. More complex and powerful data models are “context dependent” because they may consider the context (e.g., what character(s) immediately precede the current character) in predicting what the next character will most likely be. For example, if one is encoding English text, a context dependent model would predict that the most likely character to follow a “q” would be “u,” rather than “e.”
In the data compression field, context dependent models are typically characterized as “first order,” “second order,” “third order,” and so on. A first order model is one that considers the preceding symbol in predicting the current symbol. A second order model considers the last two symbols. And a third order model considers the last three symbols. (Note, a “zero order” model is the same as a context independent model.) Because computational complexity grows super-exponentially with the order of a model, low-order data models (e.g., second or third order) are typically used in practice.
With a data model in place, the coder component then uses the symbol probabilities predicted by the data model to assign a code to each possible symbol. Here, the well-known Huffman algorithm can be used to produce an optimal assignment of codes (i.e., shortest codes for most common symbols, etc.) for a given data model. Alternatively, one can employ well-known arithmetic coding techniques, which are often superior for highly repetitive data streams.
Over the past decade, so-called PPM-based algorithms have achieved the best overall compression performance (i.e., lowest compression ratios). However, PPM-based algorithms tend to be slow. An “order-k” PPM algorithm uses an order-k context dependent data model, but with a twist. The twist occurs when the algorithm encounters a k-length context that it has never been seen before; in this case, it attempts to match the shorter (k−1)-length sub-context using a (k−1)-order data model. Attempts at this “partial matching” continue, using successively lower-order data models, until either (i) a sub-context is partially matched or (ii) a zero-order (i.e., context independent) data model is used.
The speed problem with PPM-based algorithms stems from the fact that the number of potential order-k PPM data models grows as the powerset of k. Hence, even for a modest value of k, choosing an appropriate PPM data model from among the vast number of alternatives can pose a computationally intractable task. Traditional PPM algorithms compute a new data model for each message to be encoded, thus not allowing the cost of the computationally-expensive model building task to be amortized over many compression/decompression cycles.
In light of the above, there exists a present need for improved methods, apparatus, articles-of-manufacture, and coded data signals that reduce the computational complexity of PPM-based data compression. And there exists a present need for such improved methods, apparatus, articles-of-manufacture and coded data signals that permit the cost of the computationally-expensive model building task to be amortized over many compression/decompression cycles and/or scheduled such that it minimizes user-perceptible service disruptions. The invention, as described below and in the accompanying figures, addresses these needs.
SUMMARY OF THE INVENTION
In light of the above, one aspect of the invention relates to improved methods, apparatus, articles-of-manufacture, and coded data signals that reduce the computational complexity of PPM-based data compression through use of certain simplifying assumptions that permit faster search for a close-to-optimal PPM model than conventional techniques.
Another aspect of the invention relates to improved methods, apparatus, articles-of-manufacture, and coded data signals, for use in a PPM-based data compression system, that permit the cost of the computationally-expensive model building task to be amortized over many compression/decompression cycles by maintaining a PersistentModel class, accessible to both the coder and decoder side of the system.
Still another aspect of the invention relates to improved methods, apparatus, articles-of-manufacture, and coded data signals, for use in a PPM-based data compression system, that permit the computationally-expensive model building task to be performed only occasionally, as opposed to each time a message is coded.
And yet another aspect of the invention relates to improved methods, apparatus, articles-of-manufacture, and coded data signals, for use in a PPM-based data compression system, that permit the computationally-expensive model building task to be scheduled such that it minimizes user-perceptible service disruptions.
Accordingly, generally speaking, and without intending to be limiting, one form of the invention may comprise methods, systems, articles-of-manufacture, or coded data signals characterized by: (a) providing a string to be compressed; (b) selecting an approximately optimal PPM model for the string by: (i) providing an objective function that measures the desirability of proposed PPM models; (ii) starting with i=1, determining an order-i PPM model for the string; (iii) determining an order-(i+1) PPM model for the string; (iv) using the objective function to determine whether the order-(i+1) PPM model is more desirable than the order-i PPM model; and (v) if the order-(i+1) PPM model is less desirable than the order-i PPM model, selecting the order-i PPM model as the approximately optimal PPM model for the string, otherwise, increasing the value of i by one, and repeating steps (iv)-(v); and (c) using the approximately optimal PPM model to compress the string. The invention may further be characterized by: (d) providing additional strings to be compressed; and (e) using the approximately optimal PPM model to compress the additional strings; and/or (d) storing the selected, approximately optimal PPM model as a persistent model; and/or (e) providing additional strings to be compressed; and (f) using the stored persistent to compress the additional strings. Providing an objective function that measures the desirability of proposed PPM models may involve providing an objective function that considers at least one, two or more of: (1) the entropy of proposed PPM models; (2) the number of states of proposed PPM models; and/or (3) the compressed string length for proposed PPM models. And determining an order-i PPM model may involve performing a constrained search of prospective order-i PPM models and selecting the prospective order-i PPM model that minimizes (or maximizes) the objective function; and determining an order-(i+1) PPM model involves performing a constrained search of prospective order-(i+1) PPM models and selecting the prospective order-(i+1) PPM model that minimizes (or maximizes) the objective function.
Again, generally speaking, and without intending to be limiting, another form of the invention may comprise methods, systems, articles-of-manufacture, or coded data signals characterized by: (a) a compressor adapted to utilize a persistent PPM model to compress strings to produce compressed strings; (b) a decompressor adapted to utilize the persistent PPM model to decompress compressed strings; (c) a model optimizer, invoked occasionally (i.e., substantially less frequently than once every compression/decompression cycle), to update the persistent PPM by: (i) utilizing a current string-to-be compressed to select an approximately optimal PPM model for the current string-to-be-compressed; and (ii) replacing the persistent PPM model with the selected, approximately optimal PPM model for the current string-to-be-compressed. On average, the model optimizer may be invoked less than once for every ten strings that the compressor compresses, less than once for every hundred strings that the compressor compresses, or less than once every thousand strings that the compressor compresses. The model optimizer may also be invoked on a periodic basis, or selectively invoked at time(s) when its operation is not likely to create customer-perceptible disruptions in service quality. This form of the invention may further be characterized by: (d) a performance monitor adapted to track the compression ratio for strings compressed using the persistent PPM model, wherein the model optimizer is invoked in respond to changes in the tracked compression ratio for strings compressed using the persistent PPM model. The model optimizer may include an objective function computation module that evaluates the desirability of candidate PPM models by considering at least one, two, or more of: (1) the entropy of candidate PPM models; (2) the number of states of candidate PPM models; and/or (3) the compressed string length for candidate PPM models. The model optimizer may also includes a candidate model generator module that produces approximately optimal candidate PPM models using a constrained exponential search process. Such model generator may, starting with order-1, produce successively higher-order candidate PPM models.
Again, generally speaking, and without intending to be limiting, another form of the invention may comprise methods, systems, articles-of-manufacture, or coded data signals characterized by software that, when executed, causes a computer to: compress strings using a persistent PPM model; monitor compression performance of the persistent PPM model; and occasionally update the persistent PPM model by substituting a new, approximately optimal PPM-model computed using recently-acquired contextual information. This form of the invention may be further characterized by the presence of computer-executable code that corresponds, in material part, to the code disclosed in FIGS. 1A-H, 2A-J, 3A-S, 4A-B, 5A-F, 6A-D, 7A-B, 8A-B, 9A-L, and/or 10A-D.
Further forms of the invention relate to improved PPM-based methods, systems, articles-of-manufacture, or coded data signals that comprise alternative combinations of the features, aspects and limitations of the illustrative embodiment described below, and exemplified in the accompanying figures.



DESCRIPTION OF THE FIGURES
The accompanying figures, which are intended to be exemplary rather than limiting, depict an illustrative embodiment of the invention, as follows:
FIGS. 1A-H depict source code for a PPM model optimizer used in connection with an illustrative embodiment of the invention;
FIGS. 2A-J depict source code for a Model class, and associated methods, used in connection with an illustrative embodiment of the invention;
FIGS. 3A-S depict source code for a ModelNode class, and associated methods, used in connection with an illustrative embodiment of the invention;
FIGS. 4A-B depict source code for a ModelWalker class, and associated methods, used in connection with an illustrative embodiment of the invention;
FIGS. 5A-F depict source code for a PersistentModel class, and associated methods, used in connection with an illustrative embodiment of the invention;
FIGS. 6A-D depict source code for a TraceCountNode class, and associated methods, used in connection with an illustrative embodiment of the invention;
FIGS. 7A-B depict source code for a TraceCounts class, and associated methods, used in connection with an illustrative embodiment of the invention;
FIGS. 8A-B depict source code for a TraceCountWalker class, and associated methods, used in connection with an illustrative embodiment of the invention;
FIGS. 9A-L depict source code for a CompressedStringResource class used in connection with an illustrative embodiment of the invention;
FIGS. 10A-D depict source code for CompressedStringResource methods used in connection with an illustrative embodiment of the invention; and,
FIG. 11 depicts an illustrative embodiment of the invention.



DESCRIPTION OF AN ILLUSTRATIVE EMBODIMENT OF THE INVENTION
The illustrative embodiment, the source code of which is disclosed in FIGS. 1-10, seeks to find the (approximately) best prediction-by-partial-match model of a string. A model is comprised of a set of contexts and each context's corresponding probabilities for the subsequent symbol. Specifically, given a symbol sequence s=<s—1 s—2 . . . s_n> of 8_bit ASCII characters and a maximum context length k, we determine the exclusion-blending order-k PPM model M* which approximately minimizes

f(M, s)=b(M)+e(M)*|s|

where b(M) is the number of bits required to represent M, e(M) is the entropy of M (in bits/symbol), and |s|=n is the length of s. Note e(M)*|s| is the entropy-theoretic lower bound on the coded size of s using M, which bound we can in fact achieve via arithmetic coding but never beat on average (Shannon's noiseless source channel theorem). Also note that e(M) is just a weighted average of the entropies in each context, with weights equal to the context occurrence probabilities.

An exclusion-blending order-k model predicts the next symbol based on the previous k symbols a=<a—1 a—2 . . . a_k> by choosing the longest context present in the model that is a suffix of a (hence “prediction by partial match”). That is, if the matching order-k context c was included in the chosen model, then that context's probabilities are used, ignoring all lower-order sub-contexts of c (all of which also suffix-match a); otherwise, a matching order-(k−1) context is used, etc. (There is always a match at order zero.) The “blending” of all matching contexts' probabilities in a PPM model thus amounts to giving weight 1 to the highest-order matching context and 0 to all others; thus the name “exclusion-blending order-k model.”
The exclusion technique entails that the addition of a context c to a model M (giving a new model M′) changes, for each symbol x predicted by c, the symbol probability of x in the highest-order sub-context of c that has non-zero prediction probability for x. This change in probabilities in turn implies that the contribution of the sub-contexts to the model entropy changes as well. Thus, regrettably, e( ) fails in general to have the property

e(M′)=p—c*e(c)+(1—p—c)*e(M)

where p_c is the probability of the context occurring in s. It would certainly simplify the optimization if this property held.

The number of distinct contexts used in M is unconstrained—if f(M′, s) is less than f(M, s), then we choose M′ over M, even if it uses more contexts. The set of all distinct contexts up to order k over a q-ary alphabet has size

1+q+q^2+ . . . +q^k=(q^(k+1)—1)/(q —1)  (1.1) 

The set of all possible order-k PPM models is the powerset of this set, so that the model space we mean to search is super-exponential in q and k. Obviously, we are going to add some serious assumptions to constrain the search. In particular:
(1) If a context is never encountered in s, it is not considered for inclusion in the model. This is necessary (because there is no way to estimate probabilities for such contexts), highly expedient(because it rules out the vast majority of higher-order contexts), and harmless (by assumption, we are only using our model on the same string s against which it is fit, so ignoring contexts which never occur in s can never increase model entropy).
(2) Consider the two models M*_(i−1) and M*_i which minimize f(M, s) over all models having (i−1) and i contexts, respectively. We can write the difference d(i)=[f(M*_(i−1), s)−f(M*_i, s)] as

|s|[e(M*_(i−1))−e(M*—i)]−[b(M*—i)−b(M*_(i−1))]=d—code(i)−d—state(i)

which illustrates the trade-off between the relative sizes of the two models, d_state(i), and the relative lengths of their codings of s, d_code(i). If d(i) is positive, then it is better to use the best i-context model than to use the best (i—1)—context model.

Generally, we would expect d_code(i) to decrease monotonically in i, approaching zero as e(M*_i) nears the best possible order-k PPM entropy, while d_state(i) should increase monotonically in i. If this were true, it would imply that d(i) can cross zero at most once. Practically speaking, d(i) will cross zero exactly once, so that for some unique i*

d(i)>0 when i<=i*,

 d(i)<0 when i>i*

If d(i) had this property, then we could minimize f(M, s) exactly by sequentially determining the best model with 1, 2, 3, . . . , i, . . . , contexts, then stopping when we discovered i*. (Recall that i is bounded above by equation 1.1.) In fact, we just assume d(i) behaves this way and conduct such a search, stopping the first time d(i)<0. (Note that this is still an exponential amount of work, since we study an exponential number of candidate contexts each time we determine M*_i. However, if |s| is relatively small, we're likely to find d(i)<0 for a small value of i, which is at least an improvement over the unconstrained search.}
(3) We make the rather strong assumption that the set of i contexts which comprise M*_i contains as a subset the set of (i−1) contexts which comprise M*_(i−1). This imposes a simple hierarchical structure on the models examined for each i as we let i grow from 1, which makes the optimization vastly more manageable (though still exponential in k).

## Claims

1. A method of compressing data comprising:
(a) providing a string to be compressed; 
(b) selecting an approximately optimal PPM model for the string by: 
(i) providing an objective function that measures the desirability of proposed PPM models; 
(ii) starting with i=1, determining an order-i PPM model for the string; 
(iii) determining an order-(i+1) PPM model for the string; 
(iv) using the objective function to determine whether the order-(i+1) PPM model is more desirable than the order-i PPM model; and, 
(v) if the order-(i+1) PPM model is less desirable than the order-i PPM model, selecting the order-i PPM model as the approximately optimal PPM model for the string; otherwise, increasing the value of i by one, and repeating steps (iv)-(v); 

(c) using the approximately optimal PPM model to compress the string.

2. A method of compressing data, as defined in claim 1, further comprising:
(d) providing additional strings to be compressed; and, 
(e) using the approximately optimal PPM model to compress the additional strings.

3. A method of compressing data, as defined in claim 1, further comprising:
(d) storing the selected, approximately optimal PPM model as a persistent model.

4. A method of compressing data, as defined in claim 3, further comprising:
(e) providing additional strings to be compressed; and, 
(f) using the stored persistent to compress the additional strings.

5. A method of compressing data, as defined in claim 1, wherein:
providing an objective function that measures the desirability of proposed PPM models involves providing an objective function that considers at least two of: 
(1) the entropy of proposed PPM models; 
(2) the number of states of proposed PPM models; and, 
(3) the compressed string length for proposed PPM models.

6. A method of compressing data, as defined in claim 1, wherein:
providing an objective function that measures the desirability of proposed PPM models involves providing an objective function that considers at least: 
(1) the entropy of proposed PPM models; 
(2) the number of states of proposed PPM models; and, 
(3) the compressed string length for proposed PPM models.

7. A method of compressing data, as defined in claim 1, wherein:
determining an order-i PPM model involves performing a constrained search of prospective order-i PPM models and selecting the prospective order-i PPM model that minimizes the objective function; and, 
determining an order-(i+1) PPM model involves performing a constrained search of prospective order-(i+1) PPM models and selecting the prospective order-(i+1) PPM model that minimizes the objective function.

8. A PPM-based data compression system comprising:
(a) compression means for utilizing a persistent PPM model to compress strings to produce compressed strings; 
(b) decompression means for utilizing the persistent PPM model to decompress compressed strings; 
(c) optimization means, invoked occasionally, for updating the persistent PPM by: 
(i) utilizing a current string-to-be compressed to select an approximately optimal PPM model for the current string-to-be-compressed; and, 
(ii) replacing the persistent PPM model with the selected, approximately optimal PPM model for the current string-to-be-compressed.

9. A PPM-based data compression system, as defined in claim 8, wherein:
the optimization means is, on average, invoked less than once for every ten strings that the compression means compresses.

10. A PPM-based data compression system, as defined in claim 8, wherein:
the optimization means is, on average, invoked less than once for every hundred strings that the compression means compresses.

11. A PPM-based data compression system, as defined in claim 8, wherein:
the optimization means is invoked on a periodic basis.

12. A PPM-based data compression system, as defined in claim 8, wherein:
the optimization means is selectively invoked at time(s) when its operation is not likely to create customer-perceptible disruptions in service quality.

13. A PPM-based data compression system, as defined in claim 8, further comprising:
(d) an performance monitor adapted to track the compression ratio for strings compressed using the persistent PPM model; and, 
wherein the model optimizer is invoked in respond to changes in the tracked compression ratio for strings compressed using the persistent PPM model.

14. A PPM-based data compression system, as defined in claim 8, wherein the model optimizer includes:
a objective function computation module that evaluates the desirability of candidate PPM models by considering at least two of: 
(1) the entropy of candidate PPM models; 
(2) the number of states of candidate PPM models; and, 
(3) the compressed string length for candidate PPM models.

15. A PPM-based data compression system, as defined in claim 8, wherein the optimization means includes:
a objective function computation module that evaluates the desirability of candidate PPM models by considering at least: 
(1) the entropy of candidate PPM models; 
(2) the number of states of candidate PPM models; and, 
(3) the compressed string length for candidate PPM models.

16. A PPM-based data compression system, as defined in claim 14, wherein the optimization means further includes:
a candidate model generator module that produces approximately optimal candidate PPM models using a constrained exponential search process.

17. A PPM-based compression system, as defined in claim 16, wherein the candidate model generator successively produces higher-order candidate PPM models.

18. An article-of-manufacture comprising a computer-readable medium, for use in connection with a computer, the computer-readable medium including software that, when executed causes the computer to:
compress strings using a persistent PPM model; 
monitor compression performance of the persistent PPM model; and, 
occasionally update the persistent PPM model by substituting a new, approximately optimal PPM-model computed using recently-acquired contextual information.

19. An article-of-manufacture, as defined in claim 18, further comprising computer-executable code corresponding to FIGS. 1-8.