Smart grouping of item, item quantity
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.

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?

c# list parsing grouping mathematical-optimization
add a comment |
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.

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?

c# list parsing grouping mathematical-optimization
There are many many existing methods. Ten seconds with the magic Google answer machine found me this: stackoverflow.com/q/140406/1070452
– Make StackOverflow Good Again
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
add a comment |
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.

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?

c# list parsing grouping mathematical-optimization
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.

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?

c# list parsing grouping mathematical-optimization
c# list parsing grouping mathematical-optimization
edited Dec 31 '18 at 18:20
Rufus L
18.9k31632
18.9k31632
asked Dec 31 '18 at 18:16
David GerstDavid Gerst
64
64
There are many many existing methods. Ten seconds with the magic Google answer machine found me this: stackoverflow.com/q/140406/1070452
– Make StackOverflow Good Again
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
add a comment |
There are many many existing methods. Ten seconds with the magic Google answer machine found me this: stackoverflow.com/q/140406/1070452
– Make StackOverflow Good Again
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
There are many many existing methods. Ten seconds with the magic Google answer machine found me this: stackoverflow.com/q/140406/1070452
– Make StackOverflow Good Again
Dec 31 '18 at 18:22
There are many many existing methods. Ten seconds with the magic Google answer machine found me this: stackoverflow.com/q/140406/1070452
– Make StackOverflow Good Again
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
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 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
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
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
add a comment |
1 Answer
1
active
oldest
votes
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:

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.
1
Thanks. this is essentially what I'm looking for.
– David Gerst
Jan 2 at 17:56
1
Full post - yetanothermathprogrammingconsultant.blogspot.com/2019/01/…
– Royi
Jan 27 at 5:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990308%2fsmart-grouping-of-item-item-quantity%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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:

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.
1
Thanks. this is essentially what I'm looking for.
– David Gerst
Jan 2 at 17:56
1
Full post - yetanothermathprogrammingconsultant.blogspot.com/2019/01/…
– Royi
Jan 27 at 5:25
add a comment |
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:

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.
1
Thanks. this is essentially what I'm looking for.
– David Gerst
Jan 2 at 17:56
1
Full post - yetanothermathprogrammingconsultant.blogspot.com/2019/01/…
– Royi
Jan 27 at 5:25
add a comment |
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:

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.
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:

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.
edited Jan 1 at 19:05
answered Jan 1 at 16:23
Erwin KalvelagenErwin Kalvelagen
5,2192525
5,2192525
1
Thanks. this is essentially what I'm looking for.
– David Gerst
Jan 2 at 17:56
1
Full post - yetanothermathprogrammingconsultant.blogspot.com/2019/01/…
– Royi
Jan 27 at 5:25
add a comment |
1
Thanks. this is essentially what I'm looking for.
– David Gerst
Jan 2 at 17:56
1
Full post - yetanothermathprogrammingconsultant.blogspot.com/2019/01/…
– Royi
Jan 27 at 5:25
1
1
Thanks. this is essentially what I'm looking for.
– David Gerst
Jan 2 at 17:56
Thanks. this is essentially what I'm looking for.
– David Gerst
Jan 2 at 17:56
1
1
Full post - yetanothermathprogrammingconsultant.blogspot.com/2019/01/…
– Royi
Jan 27 at 5:25
Full post - yetanothermathprogrammingconsultant.blogspot.com/2019/01/…
– Royi
Jan 27 at 5:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53990308%2fsmart-grouping-of-item-item-quantity%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown

There are many many existing methods. Ten seconds with the magic Google answer machine found me this: stackoverflow.com/q/140406/1070452
– Make StackOverflow Good Again
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