I have a production line where some resources create batches of pieces. The number of pieces created by the "source" block and the number of batches are parameters. For example, if you set 48 pieces created and 4 batches, each batch closes when resources complete 12 pieces. The problem arises when I have for example 51 pieces and 4 batches, in this case I should have batches of different sizes like 12, 12, 12 and the last one with 15 pieces. Is there any way to solve this problem? Thanks for your advices
Following this Sample Model. Assuming all your parts arrive at the same time you just need to update the batchSize "On exit" at the source block with:
batchSize = numberOfParts/numberOfBatches;
batchparts.set_batchSize(batchSize);
And then, update it again "On exit" on the batch block:
if(queue.size()<2*batchSize){
batchSize=batchSize+(queue.size()%batchSize);
}
batchparts.set_batchSize(batchSize);
Note (queue.size()%batchSize) is the MOD function and gives you the additional number of parts needed to be batched in the last batch.
If the parts don't arrive at the same time, you can create a variable batchNumber that will let you know which number of batch you will do next (1 to numberOfBatches, initialized in 1).
Then, you just need to update it on the "On exit" of the batch block as follows:
//If the next batch is the last one, batch all the
//remaining quantity until completing the total number of parts
if(batchNumber+1=numberOfBatches){
batchSize=batchSize+(numberOfParts%batchSize);
batchparts.set_batchSize(batchSize);
batchNumber=1;
}
batchNumber=batchNumber+1;
I hope this helps.