random numbers, threads and reproducibility

eloy eloy at rabinf50.uco.es
Sat May 19 04:44:08 EDT 2001


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