question

A Kamphaus avatar image
0 Likes"
A Kamphaus asked A Kamphaus answered

Can anyone suggest an equivalent to a "next of" or round robin distribution for FlexSim?

I apologize in advance for having to mention another software.... I'm trying to find a way to do a round robin via code. In AutoMod there was such a thing as a nextof distribution so you wrote:

nextof(1,2,3,4) or nextof(red, yellow, blue)

The evaluated value would be whatever came next in the list: 1,2,3,4,1,2,3,4,1...etc. red, yellow, blue, red, yellow, blue, red...

I only want to use this for a very simple operation to cycle colors of items as they come into a manufacturing cell so I can differentiate between batches. I don't expect to round robin through the colors, integers would suffice.

FlexSim 16.1.0
process flowflexscriptdistributionsround robin
5 |100000

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

A Kamphaus avatar image
0 Likes"
A Kamphaus answered

Thank you. I always forget about modular arithmetic... That wasn't exactly what I was looking for but it gave me a good start. Here is what I ended up using:

And I realize I could have done this in a label too.


picture1.png (68.5 KiB)
5 |100000

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

Ben Wilson avatar image
6 Likes"
Ben Wilson answered Ben Wilson edited

In the attached sample model, there is an On Entry trigger in the queue that does a "color round robin" sequence for red, green, and blue:

FlexSim has a great command for setting colors according to some value: colorarray(). The key is to figure out your rotating value.

In this case, you can get a count 1,2,3,1,2,3... by using the modulus of the queue's input.

((getinput(current)-1)%3)+1

This snippet gives you the rotating value that you need. Let's parse what is going on:

First off, the command getinput(current) will return the number of items that have entered the queue. For the first item arriving, the value is one.

We subtract one from the input, so that our rotating counter will start at zero for the first item entering. This is helpful because the modulus command "%" returns the remainder of a division operation. So, zero divide by 3 is 0 remainder 0 - our rotating counter will start at zero.

When the 2nd item arrives, we do (2-1)%3, which gives the value 1. So now we've counted 0, 1.

When the 3rd item arrives, we do (3-1)%3, which gives the value 2. We've now counted 0, 1, 2.

Finally, when the 4th item arrives, we do (4-1)%3 - the remainder is zero, so our count is 0, 1, 2, 0.

And so on...

Because the colorarray() command likes to start with 1, the final part of our equation adds on that last +1. Now we have our rotating counter for 1,2,3,1,2,3...

Sorry I couldn't explain it better. The equation itself is concise and says it much better than I do trying to explain it in sentences :).


5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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