1

I have following data :

item   weight   value   value/weight
1      5        40      8
2      2        10      5
3      6        30      5
4      1        12      12
5      2        18      9

Capacity is 10. How to proceed with calculating upper bound for node 0? I'm calculating upper bound for node 0 as follows :

ub = v + [W-w] * [v/w]
ub = 0 + [10] * [8] = 80

Or do I need to sort the items in decreasing order of their value/weight as 12,9,8,5,5? and then calculate for upper bound? Or I'm doing it right, without sorting, calculating the upper bound and proceeding with next item?

In the method without sorting I'll not be getting the maximum upper bound at node 0, i think so.

ub = 0 + [10] * [12] = 120 // if sorted

Thanks already for your help.

Dangling Cruze
  • 3,283
  • 3
  • 32
  • 43
  • 1
    I'm assuming this is 0-1 knapsack you're trying to solve? How are you calculating your upper bound? (there are many bounding heuristics - some it'll lead to performance improvements if the items are sorted, others it won't) – Andy Jones Dec 12 '13 at 16:36
  • 1
    Yes it is a 0-1 knapsack. I pick an item or i don't. The upper bound that i'm calculating solely depends on what item i am going to pick next and how much value will i have if i multiply that with the capacity remaining in the bag. I figured that out, that a sorted list of items will give me a large upper bound at initial checks and then i can proceed with other items based on those upper bounds. Thanks btw. – Dangling Cruze Dec 15 '13 at 17:20

1 Answers1

0

The upper bound for node zero is the greedy solution to the fractional knapsack. Just take the element with highest value/weight ratio and keep inserting it until no space is left or you have inserted it completely. And repeat the process.

Felipe Sulser
  • 1,185
  • 8
  • 19