0

I want to load items into an optimal number of containers.

Each item is defined by its volume and priority and the containers are defined by their volumes.

I want to prioritize the items with the highest priorities.

I wrote a best fit, a first fit and a branch&bound algorithms to solve this problem after sorting the items from the highest priority to the lowest. But, I guess this is not an effective method, so I thought about using the linear aggregation method of the multi-objective bin packing problem.

I chose to use a wheight λ= 0.5 for both objective functions (which is relative to their importance). So that makes the problem a mono-objective one whith an objective function = 0.5*f1 +0.5*f2 .

SO, what I would like to know is how can I apply this to my code?

This is what I wrote (I am really not sure if I am right)

 if (currentSize + ((0.5*item.getVolume())+(0.5*item.getPriority())) <= volume) { 
    packedItems.add(item); 
                currentSize += item.getVolume(); 
                return true; //item fits
            } else {
                return false; // item didn't fit
            }

Can anyone explain to me how to do it? or has a useful document about it? Thank you

AIR
  • 73
  • 1
  • 9
  • This sounds an awful lot like the knapsack problem. In which case getting the optimal solution as you probably know is NP-hard. I see you're doing some type of heuristic to get a "best fit" which is all you can really do in these types of probelms. But I don't understand your question. It seems like you already know what you're doing but having trouble with the code? It should just be an easy translation from the mathematics to java. Once you've implemented it, try a few sample cases to see if what you wrote returns the results you want. – Eugen Hotaj Apr 01 '16 at 15:12
  • Yeah it's like a knapsack problem mixed with a bin packing one. I know the mathmatical equation to solve the multi-objective problem but I am not sure how to interpret it in my code. Do I have to multiply the `currentSize` of the container by 0.5 too? Yes, I will execute the code and see what it returns. Thank you! – AIR Apr 01 '16 at 15:25

0 Answers0