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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 10-25-2007
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default Statistics: Random Number Streams

I got a question but did not find an answer in the manual or in the command reference.

1. Which Random Number Stream is used, if I use a distribution command and do not define the stream?

Let’s assume I use the following command:
bernoulli(num prob, num succeed-value, num fail-value, num stream)
bernoulli(30,1,2);

So with 30 percent the return of this command is 1 and with 70 percent it is 2.

2. If I use different commands of this kind, is Flexsim using the same Random Number Stream for all of them?

3. Or is Flexsim using different Random Number Streams automatically by just choosing the next not already used Random Number Stream?

I found the following commands
randantithetic(num on/off)
randinit(num stream, num seedvalue)
randnext(num stream)

which I think will be handy if you work with random number streams and take manual care on what you are going to do.

4. How many Random Number Streams are in Flexsim.
I also always get this question from my clients.
I am sure it is a large number, but I do not know the exact number.
I checked it out by using the following command and for me it looks like that there are 112207 Random Number Streams, because 112207 gives new values but 112208 does not.
bernoulli(50,1,2,112207);

5. So am I right? Does Flexsim have 112207 Random Number Streams or is it another number?

In the Command Reference it’s written several times:
"Refer to stochastics documentation for further details."

6. Where can I find this stochastic documentation?

Thanks in advance for any hint, help or answer.

Take care
tom the (A)tom
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."

Last edited by Cliff King; 10-26-2007 at 12:22 PM.
Reply With Quote
The Following 2 Users Say Thank You to Tom David For This Useful Post:
Carsten Seehafer (04-17-2009), Javier Masini (07-21-2010)
  #2  
Old 10-25-2007
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 224
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Tom,

In the old Flexsim user forum, I remembered there is a discussion about this. And Cliff has an explanation about the random streams. Here are my summary notes. Hope it answers at least part of your questions.
  • 100 unique random streams could be used.
  • Default is stream 1.
  • Each stream has a seed value to determine the start position of the first number inthe stream.
  • Seed can be set using randinit command.
  • Seed value will be reset to the same value after reset the model.
  • If "Repeat Random Streams" is checked, same sequence of random numbers will be generated because randinit() command is automatically executed for each of the generators.
Take care,
Alan
Reply With Quote
  #3  
Old 10-26-2007
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: 411
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 Enhancements scheduled for random number stream generators

There are currently 100 random number stream generators numerated 0 through 99.
If you use a random number stream greater than 99, it actually accesses memory that has not been allocated properly for random number stream usage. It may appear fine, but it's really messing with memory that it's not supposed to.

There are changes planned for the next release of Flexsim to provide more capability relating to random number streams as noted in item 73 of the future development list:

http://www.flexsim.com/help/developm...changelist.php
Reply With Quote
  #4  
Old 10-30-2007
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

Okay, what I learned so far is:
  • 100 unique random streams numerated 0 through 99 are in Flexsim
    There are plans with the next release that the user can define the number of streams, which I think is a good thing.
  • Currently, the default stream used by a distribution is number 0 if a stream is not specified by the user.
    There are plans with the next release that the default should assign a new random stream to each distribution in the model. At least give the user the option to define the default in Global Settings.
    I would think it would be nice if you could choose between the two above options, which might be an option in the Global Settings (Use stream X as default. Use a new random stream for each distribution).
So beside my question “6. Where can I find this stochastic documentation?” it seems that my questions are answered. But maybe here are the plans to put this documentation in the help directory of the Flexsim installation with the next release, because this would be the place where I would search for it.
Thank a lot for your help and replies, I really appreciate it.
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."

Last edited by Cliff King; 12-28-2007 at 04:55 PM. Reason: default stream is 0 not 1
Reply With Quote
  #5  
Old 10-30-2007
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: 411
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

We have decided to hold off on implementing any automatic assignment of random number stream generators to the distributions within a model. In version 4.1 we will allow the user to specify how many random number streams they would like to use (currently this is hard-coded at 100). Each random stream generator will generate in excess of 2 billion pseudo-random numbers in its stream before repeating, as is currently the case.

A user already has the ability to manually assign specific streams to any of the stochatic distributions within Flexsim. To automate the process of assigning the same stream to groups of objects and/or distributions within the model, the user may choose to represent the stream parameter as a global variable that can be easily changed as desired.

Using the randinit() command, users may dynamically reset specific random stream generators at any time, and even assign their own reset seed value to the generators.

Using the randantithetic() command, users may also switch random streams to generate numbers between 1 and 0; rather than the default of 0 to 1. This is helpful for determining if random numbers are having a big affect on the results of the model. It's also useful when experimenting with massive models and there isn't sufficient time to run the model for multiple iterations as required for good statistical sampling. The user can choose to do just one regular run and one antithetic run of the model to obtain two diametrically apposed results. These two results can be averaged for an approximation that is somewhat better than if each run of the model used random stream generators without antithetic sampling.

A new command will be added in version 4.1 called randstate() that will allow the user to get the current value of a particular random number generator.

As we receive specific requests from our users for more graphical user interface (GUI) options to manage the random number generators and their assignments to distributions in a model, we will consider them for future releases.
Reply With Quote
  #6  
Old 11-22-2007
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default Random Number Generator

Cliff,

So all can see, how do you properly answer the following question:

"What random number generator engine does Flexsim use?"
Reply With Quote
  #7  
Old 04-17-2009
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

I know, that this is an old thread, but I got the question Kris asked some time ago and here is still no answer to it.


Quote:
Kris Geisberger:
So all can see, how do you properly answer the following question:

"What random number generator engine does Flexsim use?"
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
Reply With Quote
The Following User Says Thank You to Tom David For This Useful Post:
Lydia Franck (04-20-2009)
  #8  
Old 04-18-2009
Markus Bans Markus Bans is offline
Flexsim User
 
Join Date: Aug 2007
Location: D-41199 Moenchengladbach, Germany
Posts: 8
Downloads: 28
Uploads: 1
Thanks: 2
Thanked 15 Times in 4 Posts
Rep Power: 0
Markus Bans will become famous soon enough
Default

This is what I got from tech support in 2008, what likely could be of interest for you, too:

"...but I believe we use the cstdlib.h rand function, which gives you no
access to the state of the random number generator, other than to use
srand to initialize it."

And:

"It is the nature of the C and C++ pseudorandom number generators, which Flexsim uses, to be able to be initialized with a random number seed to make random number streams repeatable. There is no way to access the state of the pseudorandom number generator to save the state and begin where you left off. You can't load a random number generator in the middle in any C or C++ programs. You can reset the random number seed when you start the model run, and you can reset it again when you continue (to make your results repeatable), but they will be different than if you had just run the model all the way through without any interruptions."
Reply With Quote
The Following User Says Thank You to Markus Bans For This Useful Post:
Lydia Franck (04-20-2009)
  #9  
Old 04-18-2009
Markus Bans Markus Bans is offline
Flexsim User
 
Join Date: Aug 2007
Location: D-41199 Moenchengladbach, Germany
Posts: 8
Downloads: 28
Uploads: 1
Thanks: 2
Thanked 15 Times in 4 Posts
Rep Power: 0
Markus Bans will become famous soon enough
Default

Hello,

please open a new, empty model and set it in the 'Statistics' menu to 'Repeat Random Streams'.

1. Open the output console and execute this code in a script window once:

for (int row=1;row<=3;row++)
{
pr;pf(uniform(0,1));
}

Execute it again without resetting the model - the shown random numbers 4 - 6 of the used stream are (of course) different to the random numbers 1 - 3.

Now reset the model, execute the code once, then reset the model again, and execute the code again: In both cases, you see the first 3 random numbers of the used stream.

2. OK, but which stream is used by default?

Reset the model and execute this code in a script window once:

for (int row=1;row<=3;row++)
{
pr;pf(uniform(0,1,0));
}

The shown 3 random numbers are identical as in point 1. So the default random number stream in case nothing has been defined is 0.

3. Reset the model, open the output console and execute this code in a script window once:

for (int row=1;row<=3;row++)
{
pr;pf(uniform(0,1,1));
}

Now, you can see the first 3 random numbers of random number stream 1, which are (of course) different to the ones in stream 0.

4. I used random number streams > 99 in a model, and though having set the model to 'Repeat Random Streams', I couldn't reproduce my results! So you should only use random number streams from 0 to 99, though you could enter higher values.

[BE SURE AND READ ANTHONY JOHNSON'S DESCRIPTION BELOW POSTED 05-19-2009]

Last edited by Cliff King; 02-11-2010 at 11:57 AM. Reason: Wasn't ready yet
Reply With Quote
The Following 2 Users Say Thank You to Markus Bans For This Useful Post:
Jörg Vogel (04-21-2009), shafizad (11-01-2010)
  #10  
Old 04-27-2009
Lydia Franck Lydia Franck is offline
Flexsim User
 
Join Date: Apr 2009
Location: Sankt Augustin, Germany
Posts: 23
Downloads: 0
Uploads: 0
Thanks: 11
Thanked 0 Times in 0 Posts
Rep Power: 135
Lydia Franck is on a distinguished road
Default Another random-number generator?

Quote:
Originally Posted by Markus Bans View Post
This is what I got from tech support in 2008, what likely could be of interest for you, too:

"...but I believe we use the cstdlib.h rand function, which gives you no
access to the state of the random number generator, other than to use
srand to initialize it."
Maybe it should be considered to use another random-number generator. cstdlib can be implemented differently on different systems so we do not know the exact behaviour. Some good generators are offered in boost (http://www.boost.org/doc/libs/1_38_0/libs/random/random-generators.html). Some people even recommend using two generators in parallel because each of them has its weaknesses.

[BE SURE AND READ ANTHONY JOHNSON'S DESCRIPTION BELOW POSTED 05-19-2009]

Last edited by Cliff King; 02-11-2010 at 11:58 AM.
Reply With Quote
  #11  
Old 05-13-2009
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: 734
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

I should clarify some misinformation about the random number generator in Flexsim. Flexsim uses a prime modulus multiplicative linear congruential generator (PMMLCG), as described in Law and Kelton chapter 7. The formula for this generator is:

Zi = (aZi-1) mod m*

We use the values a=630360016 and m*=2^31 - 1, as suggested by Marse and Roberts. You can confirm the algorithm with the following sample code:

Code:
int testz0 = 10000903;
randinit(0, testz0);
uniform(0,1,0);
double z1 = fmod(630360016.0*testz0, pow(2,31)-1.0);
string resultstr = concat("randstate: ", numtostring(randstate(), 0,0),
    "\ncalculated z1: ", numtostring(z1,0,0));
if(z1 == randstate())
    resultstr = concat(resultstr, "\n\nCorrect");
else resultstr = concat(resultstr, "\n\nIncorrect!!!!!");
msg("", resultstr, 1);
You can replace testz0 with any number to get the next value after that seed. Note that it will be incorrect with testz>200,000,000, simply because the flexscript expression 630360016.0*testz0 will lose precision at that point.

The period for this algorithm is just below 2^31. My initial tests show that it's at 2147483645, or 2^31 - 3, as confirmed by the following code (if you run this, be prepared to wait for a while because it takes a long time to reach the cycle).
Code:
randinit(0, 1982384);
int initialstate = randstate(0);
uniform(0,1,0);
int cycle = 0;
while(initialstate != randstate(0))
{
    cycle++;
    uniform(0,1,0);
}
msg("Random Period", concat("Stream cycles at ", numtostring(cycle, 0,0)));
return cycle;
While this algorithm exhibits moderately good pseudo-random number generation, Law and Kelton cites several disadvantages. For the next release we plan to improve the random number generation algorithm by implementing a composite generator.

Also, previously it was stated that you cannot retrieve the current state of the random number stream. You can do this using the randstate() command, as used in the example above. This will allow you to store off the state of the random number stream, and then restore that state using the randinit command.

Also, previously it was stated that the only streams available are streams 0-99. This is the default, but if you call randinit, and pass in a stream above 99, Flexsim will automatically allocate the appropriate memory for all random number streams from 0 to that stream number. For example, if you want to use 10000 random number streams, then when your model opens, call randinit(10000, somenumber), and it will then give you 10000 random number streams. Note that if you want to repeat streams, then you need to manually initialize the seed values for streams 100-10000, because Flexsim only resets streams 0-99 when repeating random streams is on, even if there are 10000 total streams.

Last edited by Anthony Johnson; 05-13-2009 at 03:39 PM.
Reply With Quote
The Following 18 Users Say Thank You to Anthony Johnson For This Useful Post:
AJ Bobo (05-15-2009), Carsten Seehafer (05-14-2009), Cliff King (02-11-2010), Danny Pavan (05-14-2009), Dennis Adams-Smith (05-15-2009), Eike Schulz (07-07-2011), Flavio Brito (03-07-2013), Javier Masini (07-21-2010), Lars-Olof Leven (05-13-2009), Lydia Franck (05-19-2009), Nico Zahn (05-14-2009), Phil BoBo (05-14-2009), Rachid Kolfin (05-19-2009), RalfGruber (05-14-2009), Sebastian Schreiber (07-07-2011), Steven Hamoen (05-14-2009), Sucharith Vanguri (03-10-2011), Tom David (05-14-2009)
  #12  
Old 05-19-2009
Lydia Franck Lydia Franck is offline
Flexsim User
 
Join Date: Apr 2009
Location: Sankt Augustin, Germany
Posts: 23
Downloads: 0
Uploads: 0
Thanks: 11
Thanked 0 Times in 0 Posts
Rep Power: 135
Lydia Franck is on a distinguished road
Default

Anthony, thank you very much for these explanations!
This generator is actually recommended by Law and Kelton.

Kind regards, Lydia.
Reply With Quote
  #13  
Old 10-28-2010
Congshi Wang Congshi Wang is offline
Student
 
Join Date: May 2010
Location: Germany
Posts: 58
Downloads: 2
Uploads: 0
Thanks: 48
Thanked 0 Times in 0 Posts
Rep Power: 124
Congshi Wang is on a distinguished road
Default Use of stream

Hi everyone,

I got a simple question to this topic. What is the use of the stream input. For example I wanna set a exponential distribution for the inter arrival time like this: exponetial(0,20,0). In this case I got a location of zero and a scale of 20 which equals a mean 20 and a standart deviation of 20. But what is the use of the input of stream 0. And which difference makes it if I type a one for stream like this: exponetial(0,20,1)

Thanks a lot!

Congshi
Reply With Quote
  #14  
Old 12-17-2010
Congshi Wang Congshi Wang is offline
Student
 
Join Date: May 2010
Location: Germany
Posts: 58
Downloads: 2
Uploads: 0
Thanks: 48
Thanked 0 Times in 0 Posts
Rep Power: 124
Congshi Wang is on a distinguished road
Default

Hi, annother question.

It it neccessary to define a new stream number for each distribution. For example, I got a source which generates items in statistical distributed interarrival time. It also sets the label number statistically distributed which defines the processing times on the processors later. Is it ok to use the same random number stream (default or zero) or must I use different random number streams (zero and one, for example)?

Thanks
Reply With Quote
  #15  
Old 12-17-2010
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

There's no 'must' involved, but it's generally considered good practice to have random numbers sampled from different streams, both for debugging and variance reduction. However if you're not resetting the streams to the same starting position (via the seed value) for each replication and are using multiple replications, you're further introducing variability and may undo any good work you've done with stream management.

So for example - you could just use the 'zero' stream by not specifying the the stream parameter at all. The problem with that is as soon as you add another sample or change the distribution parameters of an existing one, it will affect the random number progression of all the other samplers you have in the model since they all make the 'zero' stream step through its numbers (each stream is a long fixed sequence of numbers from a pseudo-random number generator)

Given that modelling and simulation is about 'what-if' analysis you're likely to add objects and change values of the random elements, so at the least I'd recommend a stream per object. If you have multiple distributions per object and are studying the sensitivity to parameter changes of those, you could consider splitting those up too and having different streams for each. If you're running multiple replications (almost a given) then I'd recommend managing the seed values of the streams on reset too. For reference look up "Common Random Numbers" (CRN) - Averill Law's book "Simulation Modelling and Analysis" (ISBN:9780071255196) covers the method and its uses.
Reply With Quote
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Congshi Wang (12-17-2010)
  #16  
Old 12-17-2010
Congshi Wang Congshi Wang is offline
Student
 
Join Date: May 2010
Location: Germany
Posts: 58
Downloads: 2
Uploads: 0
Thanks: 48
Thanked 0 Times in 0 Posts
Rep Power: 124
Congshi Wang is on a distinguished road
Default

thanks a lot for this very precise answer. but there's still one question left ;-)

What do you mean with managing the seed values of the streams on reset. First: Is the seed value the same as the initial value of a random number stream?

Is yes, is there a need to start with the same initial value in each replication?

Like in this thread http://www.flexsim.com/community/for...ht=random+seed said, the experimenter will not repeat random numbers, because it's a experimenter and not a repeater. But it still should use the same stream in each replication and scenario, but just starts at a difference place of the same stream.

Please correct me if I'm wrong.

Thanks

Last edited by Congshi Wang; 12-17-2010 at 06:22 AM.
Reply With Quote
  #17  
Old 08-09-2014
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 118
mearjun will become famous soon enough
Default Using uniform distribution to generate stream value

What I did to achieve randomness in the model was to use a different stream value for each line of code.
Basically any place I need to use some distribution function I do this:
bernoulli(1,2,80,20,duniform(0,99));
so that a new stream is used. In addition to this I unchecked the repeat random number streams so that results generated by different distribution functions are as random as possible.
Is this a correct way of doing what I am trying to?
Reply With Quote
  #18  
Old 08-10-2014
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

You're basically using stream zero to define which stream to use - which sometimes will also be zero. You're adding a layer of complexity that may prevent you debugging or understanding the model.

Generally I'd recommend that you use repeat streams and have control over the events for verification and debugging, and different streams for different parts of the model (in a controlled way). The idea is that a change in one part of the model shouldn't effect another part of the model due to shared streams. This is for variance reduction but it may also help you compare and understand the differences.

If at some point you want to use streams other than those starting at zero you can define a global stream offset so you can easily switch the whole set of streams used. Just make sure you set the number of streams in the model settings.

Code:
bernoulli(1,2,80,20,2+streamoffset);
or if this expression is on an object you could in the simplest case use a label to denote the stream:
Code:
bernoulli(1,2,80,20,getlabelnum(current,"stream")+streamoffset);
Again, good practice would mean you make sure the labels are unique values.

Or if all the objects are in the model level you could use rank for fixed resources:

Code:
bernoulli(1,2,80,20,getrank(current)+streamoffset);
and you should again make sure the number of streams is set correctly in model settings.

If you're happy to lose control of the streams you can just go into the preferences and select "initialize streams based on system time".

I hope this isn't why the model in this post isn't repeating....

Last edited by Jason Lightfoot; 08-11-2014 at 05:12 AM. Reason: clarification
Reply With Quote
The Following 3 Users Say Thank You to Jason Lightfoot For This Useful Post:
mearjun (08-11-2014), Phil BoBo (08-11-2014), RalfGruber (08-11-2014)
  #19  
Old 08-11-2014
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 118
mearjun will become famous soon enough
Default

Thank you for this invaluable information. If I use a particular stream value (stored in labels) at each object won't the values generated at that object tend to repeat? What I wanted to know was if I am doing anything conceptually wrong by generating a new stream value for every distribution function. As I wrote above I am looking to randomize value generation as much as possible as I don't want the model to give me similar results with multiple model runs.

And you used the variable streamoffset. I am not sure what are trying to achieve by doing this?

And last but not the least, I had also selected 'Initialize random number streams based on system time' option. Does selecting this means I don't need to specify number streams at all?
Reply With Quote
  #20  
Old 08-12-2014
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've already described why you might want to have the model repeatable. Certainly if you're going to ask for support in debugging a model you should not be submitting a non-repeating model.

Stream offset: Let's say you've got a small model using only 10 streams and a short run with few replications. You might wonder if the section of the streams you're using are biased and so by setting the offset to 10, 20, 30 etc, you can shift the whole set of streams and compare the results. This would be similar to running a different set of replications or initializing the streams with different starting values.

Once you've verified your model and (seemingly) want to have roughly random start points to your streams, you can switch the setting for system time initialization on. If you've followed the advice above, then if you run into trouble you can switch that off and try debugging in a structured way.
Reply With Quote
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post:
mearjun (08-15-2014), RalfGruber (08-13-2014)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:50 PM.


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