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
|
||||
|
||||
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
|
|||
|
|||
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
|
|||
|
|||
Code for use on reset
The code in this post should solve your problem:
http://www.flexsim.com/community/for...=2314#post2314 |
#4
|
||||
|
||||
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
|
|||
|
|||
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
|
|||
|
|||
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. |
#9
|
||||
|
||||
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
__________________
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 |