Search code examples
randomdistributionanylogic

Different Random Generators for different processes


I have several delays that are all distributed. These distributions involve random number generation.

I want each processing station to have its own RNG. According to anylogic I can simply create an instance (for example: Random myRNG1 = newRandom(); ) and then use this in the distribution: triangular(5, 10, 25, myRNG1).

Unfortunately, I don't know where exactly I insert the code Random myRNG1 = newRandom();. If I do it in the field "onStartup" in the main agent and then use the generator with triangular(5, 10, 25, myRNG) in the delayblock, I get the following error message: myRNG1 cannot be resolved to a variable.

It seems that the own random generator is not publicly visible. How can I change this?

Thanks in advance!


Solution

  • Drag in a variable, change the type to Random and initialize it as below: enter image description here

    Now, you can refer to it as the RNG to be used, i.e. when calling uniform(0,10, v_MyRNG))