GARandomSeed

Matthew Wall mbwall_NO_SPAM at mit.edu
Mon Nov 16 09:45:25 EST 1998


>I'm unable to create several identical runs within GALib (version 242).
>
>>From the name, use in examples and in the user manual, I'm
>assuming that the function GARandomSeed, with an unsigned int as
>input parameter, is supposed to set the seed.  However, when I use
>GARandomSeed to set the seed to the same value in different runs
>I get differents initial populations for example.  So either I'm missing
>something or there is a problem here.
>
>Thanks in advance for any suggestions concerning this,
>
>Ole J. Mengshoel.

If you specify a seed like this:

  unsigned int seed = 6;
  ga.evolve(seed);

then you will get the same results each time you run the program.

but i think you are asking the following:

  unsigned int seed = 5;
  ga.evolve(seed);  // first run
  ga.evolve(seed);  // second run
  ga.evolve(seed);  // third run

galib currently ignores attempts to set the seed to a previous value - this
was a feature to keep people from accidently doing the same runs time after
time.

if you want to change this behavior, modify the GARandomSeed function in
garandom.C.  simply remove the second clause in the if statement:

else if(s != 0 && seed != s) {

becomes

else if(s != 0) {

a better way would be to define your own 'reset rng function' such as this:
(you must put this in garandom.C with an appropriate declaration in
garandom.h)

GAResetRNG(unsigned int s) {
  seed = s;
  _GA_RND_SEED (seed);
  bitseed(seed);
}

i will add this function to GAlib for the 2.4.4 release.

thank you,

matthew



Matthew Wall
mbwall_NO_SPAM at mit.edu
http://mit.edu/mbwall







More information about the galib mailing list