Cancel
Showing results for 
Search instead for 
Did you mean: 

Generate different random numbers

Experimenter
Experimenter

Hello community,

I am using uniform distribution to generate a random time to release a certain truck.
Always I start a simulation, it is released at the same.

Example:

-> code:


is

  releaseTime : time;

do
  releaseTime := z_uniform(1, 6000, 12000); -- a time between 6000 seconds and 12000 seconds
  print to_str(releaseTime);
end;


-> console:

 

init...
8000
reset...

init...
8000
reset...

init...
8000
reset... 

 

Can anyone explain me how to generate different random numbers to every time I run the simulation?

 

Thanks in advance!

4 REPLIES

Re: Generate different random numbers

Legend
Legend

First of all..the console should not show the times in seconds. It shows it in the time format you chose in the preferences. Well you just had one event so the method is executed once so only one random no. is gererated. 

If you still just want to run the method once and expect the no. to change please change the random no. stream in every run. 

Sachin

Re: Generate different random numbers

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

What triggers me is why you would use a script to do something like this. To generate moving units, we normally use the Source object.


Gert Nomden
Senior Consultant | Tecnomatix Product Manager
cardsplmsolutions.com

Re: Generate different random numbers

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hello Leonardo,

The Eventcontroller has settings to change your random number seed (Eventcontroller -> Tools). If you tick 'increment variant on reset', then you'll get different results. There you can also change the seed to a value you want.

Best regards,

Nick Peeters

Consultant
cards PLM Solutions

Nick Peeters
Simulation Consultant
www.cardsplmsolutions.com

Re: Generate different random numbers

Experimenter
Experimenter

Hello Nick,

 

Thank you for the solution. I could not imagine it is so simple.