How to choose random output port

How to choose random output port

SRmariog09
Not applicable
173 Views
4 Replies
Message 1 of 5

How to choose random output port

SRmariog09
Not applicable

[ FlexSim 24.2.0 ]

Depending on the case i'd like to choose a random port between 2 numbers. But it is not working, it always choose the same port.


/**Custom Code*/

Object item = param(1);

Object current = ownerobject(c);

/***popup:ValuesByCase:valuestr=Port*/

/**Port By Case*/


Variant value = /***tag:ValueFunc*//**/item.persona/**/;


/***tagex:data*/

if (value == /**/1/**/) {

return /**/1/**/;

}


if (value == /**/2/**/) {

return /**/1/**/;

}


if (value == /**/3/**/) {

return /**/duniform(2,4)/**/;

}


if (value == /**/4/**/) {

return /**/duniform(5,6)/**/;

}


if (value == /**/5/**/) {

return /**/7/**/;

}

/***/


return /***tag:default*//**/1/**/;


What is wrong?

0 Likes
Accepted solutions (1)
174 Views
4 Replies
Replies (4)
Message 2 of 5

moehlmann_fe
Advocate
Advocate
The code is correct. Does the "persona" label actually exist on the item and are its values in the expected range? If not the code would default to sending all items through port 1.

It would be easier to help, if you could upload a model.

0 Likes
Message 3 of 5

SRmariog09
Not applicable
Yes it is, the rest of the cases works good. The problem is that when I reset and start de simulation, the cases with the random port go to the same port always
0 Likes
Message 4 of 5

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

In an express license is randomness deactivated. Only licensed version uses randomness. You can tell then the system to deactivate randomness. Function is called repeat random streams in statistic menu.

0 Likes
Message 5 of 5

SRmariog09
Not applicable
Thank you so much, I can´t believe it was as simple as that
0 Likes