## Sunday, November 19, 2023

### Grouping items: a difficult combinatorial problem

In , a simple problem is described:

• We have $$n$$ items (or orders) with a certain width.
• We need to combine these items in groups (called patterns) with rather tight limits on the total width. The total length of a pattern (the sum of the lengths of the items assigned to this pattern) must be between 335 and 340.
• As a result, we may not be able to assign all items. The remaining items cannot be formed into valid patterns.
• The objective is to try to place as many items as possible into patterns.
• An indication of the size of the problem: $$n \approx 500$$.

### Data

Instead of immediately working on a full-known $$n=500$$ problem, I generated a random data set with a very manageable $$n=50$$ items. The widths were drawn from a discrete uniform distribution between 30 and 300. The data looks like:

----     15 PARAMETER w  item widths

order1   76.000,    order2  258.000,    order3  179.000,    order4  111.000,    order5  109.000,    order6   90.000
order7  124.000,    order8  262.000,    order9   48.000,    order10 165.000,    order11 300.000,    order12 186.000
order13 298.000,    order14 236.000,    order15  65.000,    order16 203.000,    order17  73.000,    order18  97.000
order19 211.000,    order20 147.000,    order21 127.000,    order22 125.000,    order23  65.000,    order24  70.000
order25 189.000,    order26 255.000,    order27  92.000,    order28 210.000,    order29 240.000,    order30 112.000
order31  59.000,    order32 166.000,    order33  73.000,    order34 266.000,    order35 101.000,    order36 107.000
order37 190.000,    order38 225.000,    order39 200.000,    order40 155.000,    order41 142.000,    order42  61.000
order43 115.000,    order44  42.000,    order45 121.000,    order46  79.000,    order47 204.000,    order48 181.000
order49 238.000,    order50 110.000


I stick to the pattern limits $$\color{darkblue}L=335$$ and $$\color{darkblue}U=340$$.

We need some estimate of the number of patterns to use. We could just guess. But a better approach is the following. An upper bound for the number patterns can be established quite easily: ${\mathit{maxj}} = \left\lfloor \frac{\sum_i \color{darkblue}w_i}{\color{darkblue}L}\right\rfloor$ For our data set this number is:

----     29 PARAMETER maxj                 =       22.000  max number of patterns we can fill


This means we can safely use this number as the number of bins (patterns).