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 06-27-2008
Kenny Macleod's Avatar
Kenny Macleod Kenny Macleod is offline
Flexsim Australia
 
Join Date: May 2008
Location: Melbourne, Australia
Posts: 136
Downloads: 114
Uploads: 0
Thanks: 86
Thanked 38 Times in 18 Posts
Rep Power: 176
Kenny Macleod will become famous soon enoughKenny Macleod will become famous soon enough
Default Pseudo Randomness

Each time i run Flexsim, different things happen . . Duh, that's what randomness means!

However, sometimes:
  • i will want the same thing to happen each time
    • to test individual sub sections
    • to see how more than one scenario compares with another, with all else equal
  • or need to be able to replicate results, very important for some situations.
I know of at least one other simulation package that uses pseudo random input, calculated from a seed.

Does anyone know if there is an easy way to do this?

Thanks

Kenny
  #2  
Old 06-28-2008
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default

Flexsim will reset the random streams with the same seed value whenever the model is reset IF you select the "Repeat Random Streams" option under the Statistics menu. If you want to be in control of the seed value, you can explicitly reset a particular stream with a particular seed value of your choosing with the randinit() command.
The Following User Says Thank You to Cliff King For This Useful Post:
Kenny Macleod (06-28-2008)
  #3  
Old 06-28-2008
Kenny Macleod's Avatar
Kenny Macleod Kenny Macleod is offline
Flexsim Australia
 
Join Date: May 2008
Location: Melbourne, Australia
Posts: 136
Downloads: 114
Uploads: 0
Thanks: 86
Thanked 38 Times in 18 Posts
Rep Power: 176
Kenny Macleod will become famous soon enoughKenny Macleod will become famous soon enough
Red face Duh!

Oops! Well i did ask for an easy answer; that was embarassingly easy -

Thanks Cliff
  #4  
Old 06-28-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

I'd recommend using a random seed for initialisation between 1 and 2147483647. You can put the code below on a reset User Event and make sure your User Events folder is at the top of the Tools folder. This will make your replications repeatable should you later wish to run one of them individually.

Code:
int  totalstreams=50;        //the number of streams you want to initialize
int  streambase=100;                //The starting stream offset - could be 0 too
int  firstreplication=getnodenum(node("/project/exec/replications/Current",maintree()));
int  replication=0;
if  (firstreplication==0)
    replication=1;                      //reset button has probably been hit
else
  replication=getnodenum(node("/project/exec/replications/CurrentRunOfScenario",maintree()));
//replication=30;                      // un-comment this line to initialise the streams for a particular replication
randinit(0,replication);              //we'll user stream zero to initialize the other streams' seeds
for (int n=1;n<=totalstreams;n++){
   randinit(streambase+n,duniform(1,2147483647,0));
}
Streams 0-100 (therefore 101 streams) are reset by flexsim so I'm using 101 and higher here (just to be sure )

Last edited by Kris Geisberger; 11-18-2008 at 09:33 AM. Reason: changed User Commands to User Events for Jason
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post:
Kenny Macleod (06-28-2008)
  #5  
Old 06-28-2008
Kenny Macleod's Avatar
Kenny Macleod Kenny Macleod is offline
Flexsim Australia
 
Join Date: May 2008
Location: Melbourne, Australia
Posts: 136
Downloads: 114
Uploads: 0
Thanks: 86
Thanked 38 Times in 18 Posts
Rep Power: 176
Kenny Macleod will become famous soon enoughKenny Macleod will become famous soon enough
Thumbs up Thanks Jason

Thanks Jason

I'm not so strong on C++ yet but that makes sense. I'll definately use this code once i'm up to speed.

Cheers

Kenny

ps - Say Hi to Mike Ellarby, it was him that put me onto Flexsim in the first place - at OR Society SW08. I liked it so much that I sought out the Australian/NZ disrtibutor role.
  #6  
Old 11-11-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

My post above refers to a User Commands folder but it should be User Events.

For some reason I can't edit my posting.



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.