ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 05-29-2008
Paul Dowling Paul Dowling is offline
Flexsim User
 
Join Date: Aug 2007
Location: Sydney, Australia
Posts: 42
Downloads: 14
Uploads: 0
Thanks: 12
Thanked 4 Times in 4 Posts
Rep Power: 161
Paul Dowling is on a distinguished road
Default 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  
Old 05-30-2008
Nico Zahn's Avatar
Nico Zahn Nico Zahn is offline
Flexsim User
 
Join Date: Sep 2007
Location: Bingen am Rhein, Germany
Posts: 179
Downloads: 19
Uploads: 4
Thanks: 66
Thanked 60 Times in 32 Posts
Rep Power: 201
Nico Zahn has a spectacular aura aboutNico Zahn has a spectacular aura about
Default

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  
Old 05-30-2008
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default 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  
Old 05-30-2008
Dustin Derrick Dustin Derrick is offline
FlexSim Consultant
 
Join Date: Jul 2007
Posts: 17
Downloads: 23
Uploads: 0
Thanks: 20
Thanked 35 Times in 7 Posts
Rep Power: 223
Dustin Derrick is a jewel in the roughDustin Derrick is a jewel in the roughDustin Derrick is a jewel in the roughDustin Derrick is a jewel in the rough
Default

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  
Old 05-30-2008
Alex Christensen Alex Christensen is offline
Flexsim Technical Support
 
Join Date: Nov 2007
Location: Provo, UT
Posts: 96
Downloads: 41
Uploads: 8
Thanks: 29
Thanked 141 Times in 56 Posts
Rep Power: 298
Alex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to behold
Default

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  
Old 05-30-2008
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

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");
Once you've done that, go back to Global Preferences, check the box, apply the change, then close Flexsim, and it should be saved the next time you open Flexsim.
The Following 3 Users Say Thank You to Anthony Johnson For This Useful Post:
RalfGruber (06-05-2008)
  #7  
Old 06-01-2008
Paul Dowling Paul Dowling is offline
Flexsim User
 
Join Date: Aug 2007
Location: Sydney, Australia
Posts: 42
Downloads: 14
Uploads: 0
Thanks: 12
Thanked 4 Times in 4 Posts
Rep Power: 161
Paul Dowling is on a distinguished road
Default

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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.