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 11-10-2008
thill's Avatar
thill thill is offline
Travis Hill
 
Join Date: Feb 2008
Posts: 10
Downloads: 23
Uploads: 0
Thanks: 1
Thanked 4 Times in 2 Posts
Rep Power: 151
thill is on a distinguished road
Default Implementing common random numbers?

What would be the best way to utilize common random numbers with the experimenter in Flexsim? I have found the postings talking about random number streams in general and the randinit command, but when I try to use this command the first experimenter run is different from subsequent runs. The subsequent runs are the same.
  #2  
Old 11-11-2008
Matthias Hofmann Matthias Hofmann is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 15
Downloads: 1
Uploads: 0
Thanks: 11
Thanked 0 Times in 0 Posts
Rep Power: 146
Matthias Hofmann is on a distinguished road
Default Same problem

I have the same problem. I think the reason is that you use (as i do) your random numbers in an on reset trigger. I think the on reset trigger of your object with the random numbers is activated after the reset of the random stream. I tried it with no random numbers in on reset events and it worked perfect, but I need them still in the on reset trigger. Therefore my actual and not really satisfying solution is: I run the first scenario twice.

greetings
Matthias
  #3  
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 Code for use on reset

The code in this post should solve your problem:

http://www.flexsim.com/community/for...=2314#post2314

  #4  
Old 11-11-2008
thill's Avatar
thill thill is offline
Travis Hill
 
Join Date: Feb 2008
Posts: 10
Downloads: 23
Uploads: 0
Thanks: 1
Thanked 4 Times in 2 Posts
Rep Power: 151
thill is on a distinguished road
Default

Jason,

I am not exactly sure where this code needs to be put in the model. It sounds like I need to create a script node with this code on it in the Tools folder above the release node. Does this node need to have a specific name to be automatically executed by Flexsim? Otherwise, it would never get executed.
  #5  
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

Sorry I should have added an explanation.

The code goes in a User Event that you create in the normal way (see Help if you've not done this - its via the top menu under Tools>UserEvents). Check the box to execute on Reset.

This creates an object in a UserEvents folder under Model/Tools as described in the linked post above. Its this folder that needs to move to (near) the top off the Tools folder (no need to go above the version, but it should go above any other objects in the tree that might schedule events - particularly through sampling streams)

I noticed that the original post talks about the User Commands folder - while it should refer to the User Events folder.
  #6  
Old 11-14-2008
Matthias Hofmann Matthias Hofmann is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 15
Downloads: 1
Uploads: 0
Thanks: 11
Thanked 0 Times in 0 Posts
Rep Power: 146
Matthias Hofmann is on a distinguished road
Default Common random numbers for scenarios

As I understood will your code reset the randomstreams for each simulation run. But how is it possible to reset it only for each scenario and not each replication. I tried it with the Start of Scneario trigger and this code:

randinit(1,0);

But it only works for the scenarios 2..n and not for the first scenario. Its quite annoying to run each time an extra scenario with all replications to get common random numbers.
  #7  
Old 11-14-2008
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi Matthias,

Try to add randinit(1,0) in the trigger Start of Experimenter.

Lars-Olof
  #8  
Old 11-14-2008
Matthias Hofmann Matthias Hofmann is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 15
Downloads: 1
Uploads: 0
Thanks: 11
Thanked 0 Times in 0 Posts
Rep Power: 146
Matthias Hofmann is on a distinguished road
Default

I tried already to have randint in the start of experiment and start of scenario trigger. But it doesn't work.
  #9  
Old 11-14-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

All,

Here is a model that prints a message at 15 seconds into the run that displays the value of a duniform function. In the Start of scenario the expeimenter uses the RandInit call to set the random number stream.

You will see that the random numbers are the same across scenarios. This means that the first run has the same number for each first run of every scenario the second the same as the second and the third the same as the third.

If you wanted all the numbers to be the same for each run you would put the rand init in the Start of Replication trigger. If you want the experiment to run the same each time then you would put the code in the Start of Experiment trigger.

I wouldn't recommend having more than one randinit call in the model as this could be the cause of the results you are getting.

Let me know if I need to explain this better or if it doesn't answer your question.

Brandon
Attached Files
File Type: zip RandInit.zip (39.3 KB, 231 views)
__________________
thats not normal.
The Following 2 Users Say Thank You to Brandon Peterson For This Useful Post:
Lars-Olof Leven (11-14-2008)

Tags
common random numbers


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
Non Repeating Random Numbers Xavier Jackson Q&A 3 07-30-2008 09:54 AM
real random numbers Vinay Mehendiratta Q&A 1 07-15-2008 10:09 AM
More random random number Paul Dowling Q&A 6 06-01-2008 07:30 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.