ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
More random random number
Wondering what people think is the best way to generate a more random random number stream (one that doesn't look exactly the same after each compile).
I thought of using a version of the real time to set the stream: eg int temp_no = realtime(2)%100; uniform(1,100,temp_no); But flexsim isn't liking how i'm using modulo? Any comments on syntax and/or methodology appreciated, have only just started looking into the random number topic in any detail. Regards Paul Last edited by Paul Dowling; 05-30-2008 at 12:00 AM. |
#2
|
||||
|
||||
Hi Paul,
use the fmod command for your modulo. double i=realtime(2); int m=fmod(i,100); pt("Stream:"); pd(m); pr(); The % is the operator for the modulo in C and it is also in the Flexsim doc but I could not get it working either. So I guess it should be fixxed or taken out of the doc. Otherwise this is a nice way to randomize you random streams.
__________________
kind regards Nico. |
The Following User Says Thank You to Nico Zahn For This Useful Post: | ||
Paul Dowling (06-01-2008) |
#3
|
|||
|
|||
Environment Settings
Have you tried changing the environment settings to "Initialise Random Number Streams Based on System Time" under File->Global Preferences->Environment?
Might be worth a look to see if it meets your needs. |
The Following 6 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Xavier Jackson (06-23-2008) |
#4
|
|||
|
|||
You are correct in that the % command is currently contained in the documentation and needs to be updated to the fmod command that is used in Flexscript. This is a known problem (with the documentation) that we hope to fix for a future release.
|
#5
|
|||
|
|||
You could also make an On Post-Compile trigger (in Tools>Model Triggers) with something like this:
randinit(0,realtime(1)*realtime(2)); |
The Following User Says Thank You to Alex Christensen For This Useful Post: | ||
Paul Dowling (06-01-2008) |
#6
|
||||
|
||||
The easiest way to do it is, as Jason suggested, by just checking the box in Global Preferences. However, I just checked it, and unfortunately there's a bug there where it doesn't save the preference properly. We'll fix this in the next release. To fix it yourself, execute the following script in a Script window:
Code:
treenode env = node("VIEW:/environment"); nodeinsertinto(env); nodeadddata(last(env), DATATYPE_NUMBER); setname(last(env), "seedbysystemtime"); |
The Following 3 Users Say Thank You to Anthony Johnson For This Useful Post: | ||
RalfGruber (06-05-2008) |
#7
|
|||
|
|||
Thankyou all for your feedback.
The global preferences option works really well and solves my problem. I would suggest documenting such a useful feature, including for example explaining when this initialisation occurs (i'm guessing on compile or on reset?). Kind Regards Paul |
Thread | Thread Starter | Forum | Replies | Last Post |
Statistics: Random Number Streams | Tom David | Q&A | 19 | 08-12-2014 02:02 AM |
Repeat Random Streams | Cliff King | Q&A | 16 | 08-30-2012 10:49 AM |
real random numbers | Vinay Mehendiratta | Q&A | 1 | 07-15-2008 10:09 AM |
Global Table Number Precision | Sung Kim | Tips and Tricks | 8 | 03-27-2008 04:25 PM |
Setting the number of operators | Sung Kim | Q&A | 4 | 02-05-2008 12:31 PM |