Bin packing is one of the most studied problems in computer science. The on-line version proceeds as follows. You are given a suply of unit-size bins, and a sequence of items that need to be packed into these bins. Items have a size in the range 0 to 1. As each item arrives, you need to decide which bin to pack it into, without knowing what items will appear in the future. The items packed into the same bin must not violate the bin capacity, i.e. the sum of their sizes is bounded by 1. Your goal is to use as few bins as possible.
When a new item arrives, first fit scans all the bins that have been used so far from the first to the last, to see if the new item fits in any of them; it is mapped to the first one where it fits. If it does not fit into any available bin, a new bin is started for it.
Best fit is similar; the difference is that it always scans all the current bins, and selects the one in which the fit is snuggest (i.e. the leftover space in the bin will be the smallest).
Two other possible algorithms are worst fit and next fit. Worst fit is the opposite of best fit: it scans all the bins, but chooses the one that leaves the most space available after the allocation. Next fit is more like first fit, except that it treats the bins as a cycle, and always starts with the bin following the one in which the previous allocation was made, instead of starting from bin number 1.
Assignment
Use the following 3 distributions:
The metric to use is the excess capacity requirement (or relative fragmentation), i.e. the ratio of the capacities of all the bins you needed divided by the total sizes of the packed items.
Repeat the measurement several times to note the effect of the random sampling on the results. Make sure that each repetition uses a different seed!
Submit
Submit a single pdf file that contains all the following information:
Please do the exercise in pairs.