cs209 lab6


http://www.maths.nuigalway.ie/~gettrick/teach/cs209/l6.html




A more general version of the 0/1 Knapsack Problem covered in lectures and in last weeks lab is the Bounded Knapsack Problem. In the Bounded Knapsack Problem, there are a number of copies of each item. In particular, we have n different item types, i=1,2,3,...,n, with q(1), q(2), q(3), ... , q(n) numbers of each item, weights w(1), w(2), w(3), ... , w(n) (kg) and values v(1), v(2), v(3), ... , v(n) (kiloEuro). (So: The total number of actual items is q(1)+q(2)+q(3)+...+q(n)). Write a PYTHON program to "solve" this using the dynamic programming strategy. Your program should build up the table (list of lists) of subsolutions, and not use a recursive function. Instead, just use nested loops.


Note: Run your program on the data:
  1. WEIGHTS: 22,40,28,4,17,19,24,23,31,7,16,18
  2. VALUES: 40,72,41,6,31,37,48,36,51,15,26,37
  3. QUANTITIES: 3,3,2,4,1,2,4,3,3,1,4,5
and bag capacities 50kg, 80kg and 110kg, and submit these 3 answers with your report.

© NUI, Galway