We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Show for the example instance, how Knapsack optimization problem can be solved with an
algorithm that solves the Knapsack evaluation problem
Suppose that we have an algorithm Af that solves the maximum value f* of the knapsack (but doesnt output the binary solution vector x*). We show how the solution x* = (x1, ,xn) is determined for the example case below, using the algorithm Af . (This method is a little simpler than the one described in lectures.) Example: n=5 objects with values v=(4, 10, 3, 5, 1) weights w=(6, 8, 4, 2, 3) M = 12 carrying capacity of the knapsack. The solution can be determined in many ways, but here is the easiest: First determine the optimum value f* with algorithm Af. Using algorithm Af, solve the optimum knapsack value for the reduced problems in which each variable xi in turn is set to 0, i.e. find the maximum value f1 if object i is excluded. If f1 = f*, object i does not belong to the optimum knapsack (value f* can be achieved without it). If f1 < f*, object i must be in the optimum knapsack. (It is not necessary to calculate values f2 for x1=1.) Object i Value vi Weight wi
1 4 6
2 10 8
3 3 4
4 5 2
5 1 3
Capacity M = 12 f* = 15 (with objects 2 and 4, though we dont know this yet) Exclude object 1: x1=0. Max value for objects 2,3,4,5 is f1 = 15 = f*
object 1 not taken: x1=0
Exclude object 2: x2=0. Max value for objects 1,3,4,5 is f1 = 12 < f*
object 2 must be in: x2=1
Exclude object 3: x3=0. Max value for objects 1,2,4,5 is f1 = 15 = f*
object 3 not taken: x3=0
Exclude object 4: x4=0. Max value for objects 1,2,3,5 is f1 = 13 < f*
object 4 must be in: x4=1
Exclude object 5: x5=0. Max value for objects 1,2,3,4 is f1 = 15 = f*