Difference between revisions of "Random state"

From SUMOwiki
Jump to navigationJump to search
 
Line 1: Line 1:
In the <M3> tag there is the following option:
+
In the <SUMO> tag there are the following two options:
  
 
<pre><nowiki>
 
<pre><nowiki>
 
   <Option key="seedRandomState" value="default"/>
 
   <Option key="seedRandomState" value="default"/>
 +
  <Option key="randomStatefile" value=""/>
 
</nowiki></pre>
 
</nowiki></pre>
  
Line 8: Line 9:
 
* default: do nothing, the same seed will be used each time matlab is started
 
* default: do nothing, the same seed will be used each time matlab is started
 
* random: the initial state is initialized randomly
 
* random: the initial state is initialized randomly
* file: load the state from the file <outputDirectory>/randState.dat
+
* file: load the state from the file given in the randomStateFile option
  
If the setting is 'default' you can be 100% certain that the results wil be exactly the same each time you start matlab and run for the first time.
+
If the setting is 'default', the results will be the same each time you start Matlab and run for the first time.
 
So with an example:
 
So with an example:
  
Line 20: Line 21:
 
* exit matlab
 
* exit matlab
  
In both cases the results will be exactly the same as long as you don't change the configuration settings in between of course.
+
In both cases the results will be the same as long as you don't change the configuration settings in between of course.
  
 
So note that the results are NOT the same in this case:
 
So note that the results are NOT the same in this case:
Line 32: Line 33:
  
 
If you also want the same results in this setting you must load the random state from disk.
 
If you also want the same results in this setting you must load the random state from disk.
 +
 +
'''IMPORTANT''':  Since the toolbox employs threading (modeling and sampling occur in parallel as two separate threads) it is impossible to guarantee 100% determinism.  Due to changes in system load, OS scheduling decisions, etc. it is possible that two runs do not give exactly the same results even if the initial random state is the same.  There is nothing we can do about this, the only solution would be to do everything sequentially but that would be far too inefficient.

Revision as of 14:30, 6 February 2008

In the <SUMO> tag there are the following two options:

   <Option key="seedRandomState" value="default"/>
   <Option key="randomStatefile" value=""/>

It determines how the random number generators are seeded. The possible values are:

  • default: do nothing, the same seed will be used each time matlab is started
  • random: the initial state is initialized randomly
  • file: load the state from the file given in the randomStateFile option

If the setting is 'default', the results will be the same each time you start Matlab and run for the first time. So with an example:

  • start matlab
  • run 'go'
  • exit matlab
  • start matlab
  • run 'go'
  • exit matlab

In both cases the results will be the same as long as you don't change the configuration settings in between of course.

So note that the results are NOT the same in this case:

  • start matlab
  • run 'go'
  • run 'go'
  • exit matlab

Here you will get 2 different results!

If you also want the same results in this setting you must load the random state from disk.

IMPORTANT: Since the toolbox employs threading (modeling and sampling occur in parallel as two separate threads) it is impossible to guarantee 100% determinism. Due to changes in system load, OS scheduling decisions, etc. it is possible that two runs do not give exactly the same results even if the initial random state is the same. There is nothing we can do about this, the only solution would be to do everything sequentially but that would be far too inefficient.