An algorithm for the computation of knapsack functions

Knapsack problems have been studied in [l]-[4]. See these references for physical applications. Modified dynamic programming algorithms are given in [3] and [4]. The algorithm in [3], presented in a complicated theoretical context, is difficult to conceptualize. The algorithm in [4] is presented in a network context of considerable complexity. Both algorithms compute the knapsack function for all arguments. From the work presented here it is evident that the problem can be solved as a relatively simple enumeration with a very simple algorithm. We define the knapsack function in terms of an equality constraint, without the use of a slack variable. An enumeration is then made for only feasible arguments of the knapsack function. A major computational advantage is thereby gained. Our algorithm has another computational advantage by being a single pass algorithm. Backtracking is optional. Equality constraint problems can be solved without restrictions on the constants using our algorithm. The method in [4] requires a unity coefficient in the constraint. Thus we obtain greater generality. The algorithm presented here should be thought of as replacing the basic algorithms in [3] and [4]. The important theoretical work developed in [3] and [4] should be used to calculate the knapsack function for large arguments. The knapsack problem is defined as: find xi , j = l,..., n that