executestring and random seed

executestring and random seed

tomi_kosunen
Not applicable
21 Views
4 Replies
Message 1 of 5

executestring and random seed

tomi_kosunen
Not applicable

[ FlexSim 25.0.4 ]

Hi

How executestring(triangular(1,3,2,9)) uses random seed? I tested it and I have a doubt that it doesn't recognize it at all.

Example:

string myDistr = "triangular(1,3,2,9)";

double ret = executestring(myDistr);

return ret;


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

moehlmann_fe
Observer
Observer

I just tested it with two different distributions that use the same stream being executed in different order. I got the results that would be expected: Each distribution generates the same number in each position regardless of which one 'used up' the previous numbers from the stream.

Left side is the triangular distribution from your post, right side is uniform(0, 1, 9).

1743574722410.png

What I did notice though is that different numbers get generated when I open FlexSim and run the code without first resetting. I guess the random number stream is not correctly initialized at at that point (?)

0 Likes
Message 3 of 5

tomi_kosunen
Not applicable

If you run on Script window the code below once, then change the random seed (5) to 6 you will get the same list on numbers as in the first run. Isn't that wrong? It should generate different stream of numbers, right?


string myDistr = "triangular(1,3,2,6)";

for (int i=1; i<=10; i++){

double ret = executestring(myDistr);

print (myDistr,"/",i,"->",ret);

}

print("----");


1743575691134.png

0 Likes
Message 4 of 5

moehlmann_fe
Observer
Observer
Accepted solution

It should and it does so on my end.

1743577274574.png

Again though, only after I reset the model at least once. If I open a fresh FlexSim instance and generate the values without resetting first I get the same results as you.

1743577343667.png

0 Likes
Message 5 of 5

tomi_kosunen
Not applicable
Thanks @Felix Möhlmann . I did not read your first answer carefully enough. Resetting the model is the key. Now it works as it shoul. Thanks.
0 Likes