question

Tomi Kosunen avatar image
0 Likes"
Tomi Kosunen asked Felix Möhlmann answered

executestring and random seed

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;


FlexSim 25.0.4
random seedexecutestring
· 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.

Felix Möhlmann avatar image Felix Möhlmann commented ·

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 0 ·
1743574722410.png (11.6 KiB)
Tomi Kosunen avatar image Tomi Kosunen Felix Möhlmann commented ·

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 0 ·
1743575691134.png (14.1 KiB)
Tomi Kosunen avatar image Tomi Kosunen Felix Möhlmann commented ·
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 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

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


1743577274574.png (11.6 KiB)
1743577343667.png (7.2 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.