The knapsack dynamic program and FPTAS run in polynomial time #
The dynamic program by profit (Cslib.Algorithms.Lean.Knapsack.profitDP) is pseudo-polynomial:
with the profits encoded in unary, and each profit at most the length of its item's encoding, it
is computable in polynomial time (Cslib.Algorithms.Lean.Knapsack.computableInPolyTime_profitDP).
One step of the table maps two padded copies of the table through the choice of the lighter
entry. Every entry is none or a subsequence of the items, and the table has one entry per
profit up to the total profit, so the encoded table stays polynomially bounded
(Cslib.Algorithms.Lean.Knapsack.TableSpec). The selection scan keeps a subsequence of the items.
The FPTAS rounds the values to at most n * k, computed in unary from k in unary, so its
dynamic program runs in time polynomial in the encoded instance and k
(Cslib.Algorithms.Lean.Knapsack.computableInPolyTime_fptas). Weights, capacities and the
original values stay in binary.
Main results #
Cslib.Algorithms.Lean.Knapsack.computableInPolyTime_profitTable,Cslib.Algorithms.Lean.Knapsack.computableInPolyTime_profitDP: the dynamic program by profit is pseudo-polynomial.Cslib.Algorithms.Lean.Knapsack.computableInPolyTime_profitDP_unary: the exact dynamic program on(weight, value)items with the values in unary is polynomial-time.Cslib.Algorithms.Lean.Knapsack.computableInPolyTime_fptas: the FPTAS is polynomial-time in the encoded instance andk.
References #
The profit table is pseudo-polynomial: with the profits in unary, and each profit at most the length of its item's encoding, it is computable in polynomial time.
The dynamic program by profit is pseudo-polynomial: with the profits in unary, and each profit at most the length of its item's encoding, it is computable in polynomial time.
The exact dynamic program on (weight, value) items with the values in unary is
polynomial-time.
The knapsack FPTAS runs in polynomial time in the encoded instance and k, given in
unary.