random numbers, threads and reproducibility

Neil mac4-devnull at theory.org
Sat May 19 09:41:54 CEST 2001


Requiring a threaded program to be 100% reproducable is a tall order.
There are a lot of factors involved.  If your program simply requires that
each thread gets the same 'random' number sequence, then I would 
implement this by giving each thread its own whrandom instance, which
 is what you sugest below :-)

Neil

In article <Pine.LNX.4.33.0105191023130.3477-100000 at eloy.ayrna.org>,
"eloy" <eloy at rabinf50.uco.es> wrote:

> 
> Greetings!
> 
> 	I am developing a small class framework for Genetic Algorithms in
> Python, and wishing to create some threads, I face a problem:
> 
> 	One of the requirements I want to keep is reproducibility. A
> genetic algorithm is a stochastic (i.e., random) procedure, and I print
> the random seed at the start of each run of a expreriment, so I can
> reproduce the run later and be sure it will reach the same results. But
> threads are not deterministic (I think), so the sequence of calls to the
> whrandom... functions would not be the same.
> 
> 	A possible solution that came to me is to pass a random seed
> (based on a random number) to each thread as it is created, and
> instantiate a different whrandom object in each one.
> 
> 	The question is: is there a better way to do this in Python?
> 
> 	Thanks for your time.
> 
>                                         -- Eloy R. Sanz
> 
> _____________________________________________________________________
> ---- Eloy Rafael Sanz Tapia -- ersanz at uco.es -- ma1satae at uco.es -----
> ------------------ http://www.uco.es/~ma1satae ----------------------
> ----------- GPG ID: 190169A0 / finger eloy at rabinf50.uco.es ----------
> Córdoba _ España _______________ Debian 2.2 GNU/Linux 2.2.19 rabinf50
>



More information about the Python-list mailing list