| The context weighting algorithm of entropy coding is widely used in images compression. While, this algorithm can not only use more known symbols, but also can reduce the "model cost". In the context weighting algorithm, the weighting coefficients will have directly effect on the probability of symbols which is evaluated by the context models. How to choose the weighting coefficients has became a hot topic in this field. In this paper, the way of choosing weighting coefficients is disused, and then the optimum weighting coefficients is proposed. The optimum weighting coefficients should be the one that can make a known source sequence’s code length to be the minimum. Due to the correlation of source sequence, when using the optimum coefficients to code the current symbol, the current symbol’s code length should be shorter, either.However, there may be more than one group of optimum weighting coefficients in the whole solution space. If the common steepest descent method is chose, it may be trapped in a local optimum. In this paper, the multivariant optimization algorithm has be chose to search for the optimum weighing coefficients. At this time, the objective function of multivariant optimization algorithm is the shortest code length of a known source sequence. If the shortest code length has been found, then the optimum weighting coefficients will be obtained. The multivariant optimization algorithm is a structured algorithm, which has two groups of intelligent search agents, each group is used to accomplish the task of global exploration or the local exploitation. After doing multiple iteration, groups of optimum weighting coefficients will be obtained and at the same time, the algorithm will not be trapped in a local solution space.The experiments show that using the shortest code length to obtain the optimum weighting coefficients has good perform on images compression. In order to improve perform of compression, the weighting coefficients should be updated according to the characteristic of the source sequence. What’s more, the length of the known source sequence should be proper when deciding the optimum weighting coefficients. |