question

Orlando P avatar image
0 Likes"
Orlando P asked Orlando P commented

How to work with function duniform or another to generate random numbers

Tentativa_1.fsm

Hi there,

I'm with a issue where i'm using the function duniform to produce different color boxes (blue, yellow, red and green). In our project we have 4 different sources, we know that the function is duniform (1,4), but in this case we want to remove a color in each source, namely source 1 remove color nr1, in source 2 color nr2, in source 3, color nr3 and at source 4 color nr4.

Any advice ?

FlexSim 21.1.2
agvflexsim 21.1.2
fasf.png (12.3 KiB)
saasd.png (60.6 KiB)
tentativa-1.fsm (81.3 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.

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Orlando P commented

Then you have in each source 3 different attribute values and not 4. But you assign for each attribute value a different set of color, then you can set the color by case. It is a picklist property under visual. This approach is only valid, if there isn’t a direct link between color and attribute value.

If you need always a direct link between color and the attribute value ie Type, then you still have to choose three random values over an array of three changing values. Here is an example for source 2 in FlexScript.

Array TypeRange = [1,3,4];
item.label.assert(“Type”, TypeRange[duniform(1,3,getstream(current)]);
item.color = Color.byNumber(item.Type);
· 1
5 |100000

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

Orlando P avatar image Orlando P commented ·
Thanks for the answer, to help future users I will put the code application
0 Likes 0 ·
random.png (44.0 KiB)