This binary integer program selects each item at most once. Exact optimization is NP-hard; the fractional knapsack problem gives an upper bound and supports a half-approximation algorithm for knapsack.
Assign each item to neither bag or exactly one of two bags, respecting both capacities and maximizing total value. With nonnegative integer capacities , a dynamic programming state indexed by the item prefix and both capacities gives time complexity. Every transition uses the preceding item layer to prevent reuse of an item.
After removing overweight items and handling free items, compare the feasible density-sorted prefix with the best feasible singleton. The fractional knapsack problem optimum is at most the sum of their profits, so the better solution has approximation ratio .
Articles by others on the same topic
There are currently no matching articles.