question

Brandon Tondreault avatar image
0 Likes"
Brandon Tondreault asked Brandon Tondreault commented

Need help with Batch Process

I am trying to figure out how to create a batch process where 15% of the time , the batch goes to Port 2 and the rest of the time goes to Port 1. By doing 'By Percentage' it only moves part of the batch to Port 2 and not the whole batch. Can you help?

FlexSim 7.7.4
batch processing
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Philip Diem avatar image
0 Likes"
Philip Diem answered Brandon Tondreault commented

Maybe you could try this. It`s not elegant but it works:

Put a numlabel on the queue that produces the batch and call it e.g. "path"

On the OnEndCollection Trigger you just write this:

// Produce a uniform distributed random number between 0 an 100 
double randomNumber = uniform(0,100);

// Write the path for the batch accoring to the randomnumber you got
if (randomNumber < 15) setlabel(current,"path",1);
else if (randomNumber >= 15) setlabel(current,"path",2);

This sends the batch in 15% of the cases to port 1 and in 85% to port 2.

To make this work you just use the label at the the Send To Port trigger


sendtoport.png (21.3 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mischa Spelt avatar image Mischa Spelt commented ·

Actually you can replace your whole code with

setlabel(current, "path", bernoulli(15, 1, 2));
0 Likes 0 ·
Philip Diem avatar image Philip Diem Mischa Spelt commented ·

Oh yes you`re absolutely right. Thanks! The more you know :)

0 Likes 0 ·
Brandon Tondreault avatar image Brandon Tondreault commented ·

Thanks guys. This worked in my simulation. It saved me some time trying to figure this one out.

0 Likes 0 ·