In pattern matching a basic problem is to determine one or more vectors X that maximize an objective function which is a sum of functions of components of X. When this problem is solved by dynamic programming CPU time and storage requirements grow explosively as the amount of intervariable interaction in the objective function increases. This explosion may be reduced by departing from the traditional dynamic programming method of eliminating successive variables and instead determining a constraint relation between each variable and all others with which it interacts. Discrete relaxation is used to accelerate a backtrack search to find all vectors that satisfy all such constraints. Optimization is achieved by evaluating the objective function for all such vectors. This new method of optimization has been experimentally compared with a classical dynamic programming algorithm running with the same pseudorandomly generated objective functions.