Reducing the Knapsack Problem to the Bin Packing Problem



I just want to confirm my understanding of reducing one problem to
another. In this case, I want to reduce the Knapsack problem to the
Bin Packing problem. Here is the way I would do it.

Let O be the set of objects. If o is in O, then s(o) is its size and
w(o) is its worth. Let K be the size of the knapsack and W the minimum
desired worth. Let f(O, s, w, K, W) be a function that outputs 1 if
there is a subset of O that will fit into the knapsack and have a
total worth of at least W and 0 otherwise.

Now, define a function g(A, B, $) that outputs 1 if there is a way of
packing the set of objects A into B bins and 0 otherwise. Each bin has
a size of 1 and each object a in A has a size $(a) less than or equal
to 1.

Now, I was thinking of implementing f using g as follows:

Let s'(o) = s(o) / K and w'(o) = w(o) / W, o in O.

for each subset O' of O do
// Check if objects O' fit in the knapsack.
if g(O', 1, s') = 1 then
// Check if the objects O' have a worth is greater than W.
if g(O', 1, w') = 0 then
return 1
done
return 0

Hmm...the only problem I see is that I can't check if the worth of the
O' objects is exactly W using g. I could modify g so that it outputs
-1 if there is at least one bin that is not completely filled, 1 if
all the bins are completely filled and 0 otherwise.

What do you think?

.



Relevant Pages

  • Re: FA - GSXR1000k1 - Lozs old bike.
    ... It looks a LITTLE different now Loz. ... It had a BIN of £3,000, which was so far over the top as to ... and looked worth every penny. ... Something's worth what you can sell it for. ...
    (uk.rec.motorcycles)
  • Re: Soldering kit....
    ... Not sure, but just looking at the parts, they are worth more that what ... its at for the BIN, atleast from what I have seen things sell for ...
    (rec.games.pinball)
  • Re: Sound card?
    ... Ordered (BiN). ... For $23 it's worth it just as a test, ... pocket. ... A very rare "pop" if you have too many processes running on the ...
    (sci.electronics.design)
  • Re: Is there a cheap Vectrex multicart?
    ... He has some on ebay right now, VERY worth the $70 BIN. ... I would grab one while you can. ...
    (rec.games.vectrex)