3

I'm wondering if there is a reasonable way of solving Multiple Knapsack using DP. I get the point in 0-1 Knapsack Problem. The recurrence is quite straightforward, add item/ not add item.

dp[item][capacity] = max{ value[item] + dp[item - 1][capacity - weight[item]], dp[item - 1][capacity]}

However, I cannot see how to get an recurrence equation for the Multiple Knapsack. Should I extend the recurrence equation to "add item bag 1/ not add item bag 1/ add item bag 2/ not add item bag 2" and so on and so forth? It does not seem a good approach as the number of bags becomes larger and larger.

André Gomes
  • 185
  • 13
  • Do you want to get best value of all the bags combined? or best value of each bag invidivually? – Mohd Jun 21 '17 at 18:05
  • best of all bags combined – André Gomes Jun 21 '17 at 18:10
  • 1
    @AndréGomes there are still two options, and that is whether an item lets say A should be taken or whether it should be dropped. Now assume if adding the item A is going to give the best result then the next question is to which bag it should be added. At this point you should try adding it every bag wherever it is possible to add (i.e. remaining capacity of the bag > weight of the item) and recursively solve the problem for sub-problem and then check the best result. – Roshan Jun 22 '17 at 07:59

0 Answers0