-1

I have a situation where I am receiving orders of multiple products of varying quantity that need to ship on multiple trucks. The goal is minimize the number of products per shipment to make product picking more efficient.

Source Item/Quantity Table

Ideally I don't want 6 different items per truck. What I can pretty easily do and don't need help with is just ordering items by quantity descending and streaming them into groups of 24 (truck limit). I'm struggling to find an algorithm to intelligently break the quantity into "smart groups". My first thought is I'm really looking at developing some sort of AI to do this, and not really sure where to start. Does anybody have thoughts or suggestions on how to accomplish this?

Grouping Examples

Rufus L
  • 36,127
  • 5
  • 30
  • 43
David Gerst
  • 53
  • 11
  • There are many many existing methods. Ten seconds with the magic Google answer machine found me this: https://stackoverflow.com/q/140406/1070452 – Ňɏssa Pøngjǣrdenlarp Dec 31 '18 at 18:22
  • It's not clear exactly what you're asking here. Are you just trying to break a set of numbers into groups equal or less than a maximum number? Or do you need to consider the sizes of packages and the volume that different trucks can hold? – Rufus L Dec 31 '18 at 18:22
  • I use Google and search SO all the time for answers to my problems. In all my years of programming and on SO, this is fourth question I've ever asked. I apologize that my searches didn't yield the results I require and that I didn't know how to properly ask this question. The link you provided does help in that it gives me some better pointed search criteria. Thank you. And yes, I'm trying to break a set of numbers into groups of equal or less than a max. number while minimizing the items per set. I don't need to worry if the number is ever equal to or greater than the limit. Thanks – David Gerst Dec 31 '18 at 18:51
  • i do not need to consider size of packages, weight, or volume. It's purely grouping into sets of 24. – David Gerst Dec 31 '18 at 19:22
  • The problem is called a "Packing Problem". The Romans tried solving the problem 2000 years ago and couldn't and it is still not solved. The Romans tried to figure out how to pack the chariots going to war. They wanted to minimize the number chariots they needed and if they over packed the chariots they went slower and tipped over. There are algorithms but none are perfect. Do a search for "Packing Algorithms". – jdweng Dec 31 '18 at 22:08

1 Answers1

0

One way to obtain the minimum number of different items per truck is to minimize the maximum number of different items. I don't think this fits a standard knapsack or packing problem, but we can easily formulate this as a mixed integer programming problem. To develop a mathematical model we can define the following decision variables:

x(i,j) >= 0     : quantity of item i placed in truck j 

y(i,j) in {0,1} : 1 if any item i is placed in truck j
                  0 otherwise

x is a non-negative variable and y is a binary variable. With this we can formulate our model as:

enter image description here

The results can look like:

----     56 PARAMETER results  solution

                truck1      truck2      truck3      truck4

A                                                   20.000
B                                       20.000
C                           20.000
D               14.000
E                            4.000
F                4.000
G                6.000
H                                        1.000       2.000
I                                        3.000
J                                                    2.000
total           24.000      24.000      24.000      24.000
diff.items       3.000       2.000       3.000       3.000

This model can be fed into any MIP solver.

In practice you may want to make the objective a bit more complicated: first minimize the maximum and then minimize the sum of y's. This is to make sure the solution is well-behaved for trucks that do not hit the maximum y. In many practical models we need to add such "regularization" terms. This remains a linear MIP model.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39