Documentation

CslibFrontier.Algorithms.Lean.Knapsack.PolyTime

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 #

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.

@[reducible, inline]

The item list is the concatenation of its framed item codes. Each item code is its framed binary weight followed by its binary value.

@[reducible, inline]

The framed item-list encoding followed by the binary capacity.

The knapsack FPTAS runs in polynomial time in the encoded instance and k, given in unary.