tags:

views:

29

answers:

1

I have a warehouse in which I keep goods. Each article occupies given volume of warehouse space and costs give amount of dollars.

Now, because warehouse is full and I'm expecting new delivery, I have to free some space - no less than the new delivery will occupy, but I also have to minimize my loses. In other words, I have to empty at least X cubic meters of warehouse space by throwing out some articles, making sure that value of those articles is the minimum value possible.

Example: If X=10m3, then I prefer to throw out item that occupies 20m3 and is worth 1000$ than item that occupies exactly 10m3 but is worth 2000$. Of course in the real calculation it will be necessary to throw out more than one item, probably 5, 10 or maybe even 20.

What I'm thinking of is to represent the above problem as a tree, with nodes representing volume of emptied space and edges representing lost value, then searching for nodes that have value greater or equal to X and then choosing the node that has the lowest lost value along the edges from tree root to that node.

What I'm not sure if this is good approach because for e.g. 100 items in warehouse full tree would have 100 nodes on first depth level, 100*99=9900 nodes on second level etc, so this quickly starts to be prohitibive.

Is there better approach, or maybe even some proven algorithm (that I'm not aware of) for such kind of problems?

+1  A: 

This is known as the Knapsack problem.

Change your problem a little to make it compliant with the knapsack: list all the items you have in the warehouse + all the items you wish to add. Search for the best bang for the buck.

Well, in this case it means you would not try to clear space in your warehouse for junk, which I don't think is too stupid.

Ah, in case you didn't follow the link, it NP-complete, so you're in for a word of hurt if you want the best solution :)

Matthieu M.
Thank you, perfect answer!
Tomasz Zielinski