Bin Allocation from a Lot based on set of rules

Bala216

New Member
Joined
Jun 12, 2020
Messages
8
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi There,

Here is the screen shot of my problem scenario and output required....

Forum experts help is highly appreciated to solve this problem...

Thank you...

Box Number Generator Problem Description.xlsx
ABCDEFGHIJKLMNOPQRSTUVW
1Box Number Generator
2
3Technical Terms used:
41. Lot Number
52. Size
63. Pairs
74.Box Number
8
9Scenario:
101. A lot number is a 5 digit unique identity number given for a group of pairs from different sizes.
112. A lot will have minimum 18 Pairs and maximum of 144 pairs in different sizes and multiples of 18 pairs (eg. 18,36,54,72,90,108,126,144)
123. Each size will have minimum zero pairs and maximum of 144 pairs and will be always multiple of 3. (eg. 0, 3, 6,9,12,15………max of 144)
134. Minimum size is 2.5 and increases with an increment of 0.5 and maximum would be 12.
14
15Picotral Representation of a typical scenario:
16Sizes / Pairs
17Lot Number:2.533.544.555.566.577.588.599.51010.51111.512Total Pairs
181234536912152436363144
196789015339121531272
20789013333333333636
21
22
23Objective:
24
251.When a size run is filled up for a lot number, then these sizes has to be split/ grouped into sum of 12 pairs.
262. Each group of pairs (called Box ) will be assigned a box number starting from 1 to maximum of 12.
273. A full box will have maximum of 12 pairs and minmum of 3 pairs and always be either 3 or 6 or 9 or 12.
284. Sizes more than 12 pairs are split into multiples of 12 and assigned box number
295. Sizes less than 12 are grouped with other sizes to make up 12 pairs if possible to form a box.
306. 3 can join only with 9, if this option is not available then the second option is to join with 6 & 3 . Simillarly 6 can join only with 6 or 3 & 3. 9 can join with 3
317. A box can have minimum one size and maximum of 4 sizes
32
33A typical grouping of size / pairs into Box numbers for the above 3 lot numbers is as follows:
34
35Lot No.12345
36Box Number123456789101112
37Size2.53.54.55.56.56.57777.57.57.5
38Pairs(1-3)(1-6)(1-12)(1-12)(1-12)(13-24)(1-12)(13-24)(25-36)(1-12)(13-24)(25-36)
39
40Size45.5
41Pairs(1-9)(13-15)
42
43Size10.5
44Pairs(1-3)*
45
46Size
47Pairs
48
49Lot No.67890
50Box Number123456789101112
51Size333.555.58.5
52Pairs(1-12)(13-15)(1-3)(1-12)(1-12)(1-12)
53
54Size4.54
55Pairs(1-9)(1-3)
56
57Size5.5
58Pairs(13-15)
59
60Size7
61Pairs(1-3)
62
63Lot No.78901
64Box Number123456789101112
65Size3.55.57.5
66Pairs(1-3)(1-3)(1-3)
67
68Size468
69Pairs(1-3)(1-3)(1-3)
70
71Size4.56.58.5
72Pairs(1-3)(1-3)(1-6)
73
74Size57
75Pairs(1-3)(1-3)
76
Problem Description
Cell Formulas
RangeFormula
V18:V20V18=SUM(B18:U18)
 
Thanks for the explanation. The approach I posted follows this same method: Anytime a new partial is needed, the search begins at the left and follows priority order, unless it is the first entry into a new bin. For the first entry into a new bin, the first available partial box is used. Let me know if this form is okay...it is not the same output structure as your original suggestion, but because of the iterative nature, I found it necessary to spread the partials out by size across a row and to track the evolution of them as they are selected to fill the constructed bins. If you need a different final output form, then this table would need to be processed further to construct a new table from it.
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
If you get a chance, have a look at this hypothetical case, as it illustrates a couple of things:
MrExcel_20200613.xlsx
BCDEFGHIJKLMNOPQRSTUVW
8test3333366639999978
Box Generator
Cell Formulas
RangeFormula
W8W8=SUM(C8:V8)

1. My earlier statement that you would need at most 10 bins for combining all of the partials is not correct. In some cases, like shown above, when there are many partials of 9 remaining, they cannot be combined any further, so it is conceivable that as many as 20 bins (a partial of 9 for each size) could be needed. To cover that possibility, the computation table would need to be extended for a total of 20 computation blocks.
2. One more addition to the rule set may be needed. If you process the example above, everything seems to work fine until the 6th bin of partials is being filled. At that moment, there are partials of 6-3-9 remaining, and they appear in that order. Following the rules to begin at the left, the 6 is first placed in the 6th bin, and then a search follows for a 6, and if another 6 is not found, then a 3 is searched for. The three is found and added to the 6th bin. At that point, there are no more qualifying partials for completing this bin. So the 6th bin consists of a partials 6-3, and the leftover partial of 9 goes into a 7th bin. This is the only issue I've encountered. At the very end of the process, you might consider looking at any bins that are not complete and then deciding whether they can be recombined to form a complete bin of 12. In this case, we could take the 3 and 9 from the incomplete 6th and 7th bins to form a complete 6th bin, with only the partial of 6 left alone...although this last step is not consistent with the rule set.
 
Upvote 0
Here is a further refinement of the file that better defines the initial full boxes that are readily identified (see AE17:AH68). The boxes constructed from partials are shown in W17:AC58. As mentioned previously, an entire computation block (e.g., C19:AC22) can be copied and pasted below the partials section to extend the number of boxes that need to be constructed from partials. The box numbering is slightly different from your original post in that box numbering begins with the initial full boxes, and then once they are all accounted for, the numbering continues with the constructed boxes of partials. Be sure to pull the formulas down far enough to capture all of the boxes, and confirm that the first constructed box numbers is one greater than the last "initial full box"...that is a quick check to confirm that the box numbering formulas do not need any range adjustments to ensure that they are looking at all of the data. Since the file is too large to post with XL2BB, here is a DropBox link:
 
Upvote 0
Hi there...

It is becoming more and more interesting by the evolution of this thread with your thoughts and inputs...

1. Yes I agree the worst case scenario will be all 20 sizes having a partials of 9 pairs each which would require more than 10 bins for partials alone if the maximum pairs per lot is not limited.
But in my actual application, as I mentioned in my point-2 of problem scenario, I always have a lot only with minimum of 18 pairs and maximum of 144 pairs and that too sizes are exploded only in multiples of 18 pairs as mentioned in point-2. Means at the most we may have 16 partial bins with 9 pairs each which already accounts for 144 pairs. So we shall restrict to maximum of 16 bins instead of 10 bins for partials.

2. Regarding, the case you have mentioned in point-2, I agree that we shall combine 3 & 9 and leave 6 as a partial bin.

3. As a further extension of your thought, also, we might end up with a scenario where two 9 pairs partials are left out. In that case one nine has to break up as 3, 6 and 3 has to combine with 9 and leave 6 as partial bin. Also how about a scenario of remaining partials 9 and 6 where 6 shall break into 3,3 and one 3 combines with 9 to form a full box and another 3 remains as a partial.

Is it possible to incorporate point 2 and point 3 in the condition loops as well? Give a thought for it..

Mean time let me work out and test your latest revised file and come back if there is any doubt...
 
Upvote 0
Thanks for the added commentary. I had forgotten about the upper limit on pairs, but as you've described, those types of constraints can be used to confirm that enough computation blocks are included to accommodate all of the partials. Another quick check is to examine the last rows of the computation blocks to confirm that they are all 0's, which means that all partials have been allocated to boxes, either complete boxes or partial boxes.

I didn't realize that subdividing a set of partials (e.g., a partial of 9) into smaller components (either a 3-6, or 3-3-3) is permissible. If it is, then I I would propose that that occur as a last step. If that is done, then the solution above works (I think) all the way up to the point where the last complete box is constructed from non-subdivided partials using the original rule set. One would then perform two more steps: 1) examine the last set of partials remaining after the last "complete" box is constructed from partials and determine if any of them can be recombined in any order (without subdividing any of them) to form a complete set of 12, and 2) repeat the last step with the additional flexibility of subdividing partials where necessary. These steps will probably involve looking at the constructed box pair sums and finding the location of the last "Complete" constructed box...and then using that location to get a snapshot of the remaining partials. That snapshot of sizes/partials would be copied into a different computation block where the new rule set would be applied. I'll think about how to do that.
 
Upvote 0
Here is an update about the issue raised in our last conversation. Recall that the original rule set required that multiple partials should be combined to form full bins of 12, but importantly, that the search for partials begin at the left (smaller sizes) and proceed toward the right. These constraints could lead to instances where a partial would be added to a bin, and then the ensuing search would find no partials that could be used as a complement to complete the sum (i.e., to form a complete bin of 12). In some cases, after this partial was removed from consideration--that is, it was committed to an incomplete bin--the next step to form a new bin beginning with the next larger size might result in a complete bin. The final result was that numerous partials might be left trapped, assigned to incomplete bins.

Consequently, a new rule was added that reexamined these incomplete bins to determine if they could be recombined to form a complete bin of 12, and if not, then could the partials be subdivided even further and recombined to construct a bin of 12. This revision attempts to accomplish all of this in a series of steps.

Table I shows the full boxes that can be easily identified initially because a shoe size has 12 or more pairs...so each group of 12 form a complete bin/box and assigned a box number. Any partials (quantities of 3, 6, or 9) are then examined with the original rule to use the lowest size partial available and always attempt to fill the constructed bin by searching for candidates from the left (smaller-to-larger sizes). Table II shows the bins that are constructed from partials following this rule. Any bins in Table II that are described as "Complete" with a bin/box number are final. Any partial bins in Table II are then reinstated in the next step and a new attempt is made to recombine them or subdivide them if necessary to form new complete bins of 12. This occurs below Table II, and the results are shown in Table III. Any bins in Table III that are described as "Complete" with a bin/box number are final. Any remaining partials are left in the "Final Partial" bin, which must also be considered.

The new rules developed for use in Table III are complex, resulting in messy formulas with nested IF statements. Preference is given to using larger partials before the smaller partials, and searches are made of all available partials to form complete bins of 12. Any partials that remain are then subject to a subdivision procedure to create complete bins from subdivided partials, giving preference to subdividing the fewest number of sizes. For example, if a partial of 9 in size 10 can be subdivided into 3-3-3 to complete bins for three other partials of 9, then that is preferred over subdividing two partials of 6. On the other hand, if faced with partials of 9-9-9-6, the preference is given to splitting the 6 to form bins of 9-3, 9-3, 9 rather than splitting a 9 to form bins of 9-3, 9-3, 3-6. The logic to apply these preferences is found in the formulas. There may be better or more efficient ways to accomplish it, but this seems to work in all cases that I've tested.

A final tally of all categorized pairs and the number of boxes among which they are distributed is shown in a summary table (shaded purple in AA12:AC15).

Please let me know if you encounter any issues.
 
Upvote 0
Kirk, I'm not sure that I fully understand all the rules, but I've had a go at formulating this problem as a Mixed Integer Program.
Where it is possible to form a full box from one size, then the model does so. Otherwise, it will mix and match as necessary to minimise the number of boxes used.
For the case Test6, your solution requires 17 boxes. The attached solution requires 16 boxes.
Is this an acceptable solution? If not, then what have I not accounted for?

test6solution.png
 
Upvote 0
Hi @i_nth, thanks for having a look at this. You've probably seen that there have been clarifications and additions to the rule set to address issues that emerged. I'll try to summarize the problem and rules as I understand them. I visualize the problem statement like this: Suppose we have a "lot" of shoes of various sizes. As expected, each unit of shoes is a "pair". The lot size is some multiple of 18 pairs, and between 18 to 144 pairs, inclusive (I've ignored the lot size limit for testing purposes). The number of pairs of shoes of any given size is always some multiple of 3 pairs. For convenience, the shoes are arranged in order of their size, from a minimum of size 2.5 to a maximum of 12 in size increments of 0.5 (so we have a total of 20 shoe sizes).

We wish to organize the lot of shoes into bins of manageable size (i.e., quantity), so each bin is ideally filled to capacity with 12 pairs of shoes subject to certain rules. For any group of "n" pairs of shoes of one size, INT(n/12), gives the number of bins that can be readily filled completely with shoes of that size, which will require a total of 12*INT(n/12) pairs. And n-12*INT(n/12), or n(mod 12) tells us the residuals of that size. Due to the constraints above, the residuals (which I often refer to as "partials") for each shoe size will be either 0, 3, 6, or 9 pairs.

I have imagined the rule set as consisting of three phases.

Phase 1:
Determine INT(n/12) and n(mod 12) for each size, and assign each full set of 12 pairs to a bin, homogeneous in that shoe size. Any residuals form the set of partials of various sizes that will be examined in the next phases.

Phase 2:
Search the partials beginning at the left (smallest shoe size available). The first available partial (we'll call p1) is committed to a new bin. Then we need 12-p1 to fill the current bin. Begin the search again from the left, and without subdividing any partial quantity, find the next partial to commit to the current bin, p2, such that p2<=(12-p1). At this point, we need 12-p1-p2 to fill the current bin. Repeat the search algorithm to find p3 if necessary, and then repeat the algorithm again to find p4 if necessary. The two critical rules here are that searches always begin at the left and proceed to the right (small-to-large size) and that partials are not to be subdivided.

These two constraints lead to non-optimal solutions if minimizing the number of bins were the objective. The problem with the two constraints is that it can lead to certain partials becoming "trapped" or committed to a bin for which there are no complementary components...that is, there are no more partials available that can be added to the bin. Depending on the magnitude of the partials and their distribution across shoe sizes, the same set of partials could produce different results, with one distribution efficiently filling all bins, while a different distribution might produce several incomplete bins with trapped partials. This observation led to the introduction of some clean-up rules that I've dubbed Phase 3.

Phase 3:
In Phase 3, any partials in incomplete bins from Phase 2 are reinstated for consideration, and then attempts are made to form full sets of 12 following a different set of rules. Phase 3 abolishes the left-to-right search constraint, and instead looks for any combinations of reinstated partials that can be combined in any order without subdividing to form complete bins of 12. After exhausting those possibilities, any remaining partials can be subdivided and recombined to form complete bins of 12.

In the original problem statement, subdividing partials was not permitted, so I have guessed that the preference is to not subdivide the partials if at all possible. So I would augment the Phase 3 rule set to reflect that there are two objectives: 1) minimize the number of partials that need to be subdivided while forming complete bins of 12, and 2) minimize the number of sets of subdivided partials in incomplete bins. This last objective may not be clear, so an example may help:

Suppose partials available are 9-9-9-6. It would be preferred to subdivide just one partial (the 6) into 3-3 and use those components entirely to form complements for two of the 9's, which leaves just one non-subdivided partial of 9 in an incomplete bin. Another option would be to split one partial (a 9) into 6-3 and use those components entirely to form complements for the 6 and a 9, leaving just one non-subdivided partial of 9 in an incomplete bin. Another non-preferred option would be to split one partial (a 9) into 3-3-3 and use two of those components to form complements for two of the 9's, leaving a residual 3 (from the subdivided 9) and the original 6...this isn't preferred because the components of the subdivided 9 are not entirely assigned as complements. I'm not sure which of the first two options would be preferred. I think the logic in my formulas should produce the first one, but I'm not sure if that would happen consistently.
******

In the first table below, I've summarized the results of my most recent post, which is a 16 bin (not 17) solution formed according to these rules. I've added some horizontal dividing lines in the table to illustrate where the different phases occur. Phase I quickly allocates the first five bins. Then Phase II leads to the formation of eight more bins consisting of non-subdivided partials but of heterogeneous shoe sizes. If you follow the progression in the table, you'll see evidence of the smallest shoe size being committed and then the next available complement being added (in a new search conducted from left-to-right...i.e., size 2.5 to size 12). I'll call attention to box 13. You'll see at that point, that the next available partial was a 9 in size 8, but there were no other partials of 3 available, so the partial of 9 in size 8 became trapped in an incomplete bin. In Phase III, the trapped and uncommitted partials are reexamined and recombined in whole in any combination (so the partial of 9 in size 8 became part of the set considered in Phase III). In the example here, it was not possible to recombine any of partials to form a set of 12 without subdividing, so subdivision was considered next, with the objective to minimize the number of subdivided partials. Since partials available were a 9-9-9-6, the algorithm subdivided just one partial (the 6) into 3-3 to form complements for two of the 9's. If partials available were a 9-9-9-9-6, then it would be better to split a 9 into 3-3-3 to form complements for the other 9's, and the original 6 would be left. In the particular case shown in the table, two complete bins are formed and one incomplete bin of 9 remains in Phase III.

In your solution (also a 16 bin solution) shown in the second table below, there are seven splits of partials, which is probably not ideal, although @Bala216 is the real authority on this and could weigh in on the importance of that consideration (I've shown the split, or subdivided, partials in bold red font at the top of the tables). I am very curious about how you approached this. Is your solution arrived at through a VBA optimization routine that you could post? I'm wondering if there might be some way to modify the algorithm and constraints to reflect this rather complex set of constraints and decision rules?

Bala216_ver2.xlsx
BCDEFGHIJKLMNOPQRSTUVW
158Split Partials (S)S
159Sizes2.533.544.555.566.577.588.599.51010.51111.512
160Box \ Pairs1818661599669696936181569
16111212
16221212
16331212
16441212
16551212
16666612
16776612
16883912
16999312
170106612
171119312
172126612
173136612
174149312
175159312
1761699
1771818661599669696936181569
178
179Split Partials (S)SSSSSSS
180Sizes2.533.544.555.566.577.588.599.51010.51111.512
181Box \ Pairs1818661599669696936181569
18219312
18326612
184333612
18541212
18651212
187633612
18873912
189863312
19099312
191106612
192111212
193123912
194131212
195141212
1961533612
197163339
1981818661599669696936181569
Box Generator
Cell Formulas
RangeFormula
C181:V181,C160:V160C160=INDEX(C$5:C$8,MATCH($B$11,$B$5:$B$8,0))
W182:W197,W161:W176W161=SUM(C161:V161)
C198:V198,C177:V177C177=SUM(C161:C176)
 
Upvote 0
Thanks for your detailed explanation.
An example model is available at https://www.i-nth.com/images/files/BinPackingModel.xlsx
The model would use the Solver Add-in, except that the model size is too large, so the OpenSolver add-in required instead.
I've discounted much of the problem description on the basis that the requirements seem to combine elements of what is required with potential solution strategies. Therefore, it is not clear to me what is really required for an acceptable solution.
The attached model's objective is to minimise the number of boxes, while filling a box with a single size where possible. There may well be other requirements that the model doesn't take into account.
 
Upvote 0
Thanks for the link. I haven't had much luck with OpenSolver on other integer optimization problems, but this might be interesting to investigate further. I had a look at your Formulation/Notes and think your assessment of the number of sizes per bin (<=4) is correct: the number of partials is either 0, 3, 6, or 9--and since 0 is moot, one cannot have more than 4 sizes in a bin. So your point about not needing enforcement of that constraint is spot on.

I have to apologize for messing up the description of the rules...unfortunately, I forgot to mention a critical point: after the first partial is added to a bin and the search begins for the next partial, priority is given to using a 9 over a 6 or 3, and to using a 6 over a 3. Other than this detail, the rest of my description is consistent with earlier posts offered by @Bala216.

I'll recap the Phase 1 and Phase 2 rules because they illustrate something important:

Phase 1:
  1. Allocate to individual bins all sets of 12 pairs (homogeneous sizes) that are readily apparent in the original list.
Phase 2:
  1. Searches always begin at the left and proceed to the right (small-to-large size)---this applies to the first partial added to a bin and any subsequent partials.
  2. The first partial added is always the smallest size available, and any other partials are added in the order they are encountered while first honoring the priority to use larger partials before smaller partials if the situation allows. This means that if we have a new bin and the smallest shoe size partial is a quantity of 3 (so it is added first), then the partials are searched left-to-right for a 9, and if none, then for a 6, and if none, then for another 3. If multiple 9's are encountered in this example, the first one would be added. Similarly, if multiple 6's are encountered and no 9's are available, then the first 6 would be added, and so on if 3's were present and no 9's or 6's were available...the first encountered would be added.
  3. Partials are not to be subdivided.
  4. For any given bin that is being filled, after searching for suitable partials and finding none, the bin is set aside and treated as an incomplete bin, and a new bin is begun.
The important take-away from the Phase 1 and Phase 2 rules is that they are completely deterministic. This part of the problem does not lend itself to optimization.

Once the partials remaining in incomplete bins are reinstated and the stringent rules for forming sets of 12 are lifted, as is done in Phase 3, that would lend itself to an optimization strategy. In that case, there is considerable latitude in combining the remaining partials and subdividing them if necessary. I believe the primary objective in that case would be to minimize the number of bins, and if there are multiple solutions, then preference would be given to those that minimize the number of sets of partials that need to be subdivided. Even then, more clarity would be needed to choose a preferred solution since there may be multiple solutions with those characteristics. With that said, it's not clear to me either where the threshold is for an acceptable solution...I think this comes close, but some details are still lacking.
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,861
Members
449,472
Latest member
ebc9

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top