[galib] Exception raised by bestIndividual() ?
cnchapman at msn.com
Sun Jan 28 19:22:53 EST 2007
I wanted to give an update; the problem appears to be resolved for now.
What happened is this: I noticed in other code that the GARandomInt()
function was returning 0 for all calls. I had set gaconfig.h to use the
RAN3 generator instead of the default RAN2. I'm not sure why RAN3 was doing
that (all I changed was the compiler flag to use RAN3), but I switched that
to RAN2 and rebuilt the library.
At that point, the longer runs and larger populations started working fine
(have tried up to 250000 generations with population of 100) . Not sure
whether the random functions could have led to the memory leak (assuming
that's what it was). Or perhaps there was some more fundamental build
problem with the library, where changing to RAN2 and rebuilding solved both
I'll update again if it returns and I discover anything else. Yours,
----Original Message Follows----
From: "Chris Chapman" <cnchapman at msn.com>
To: galib at mit.edu
Subject: [galib] Exception raised by bestIndividual() ?
Date: Thu, 25 Jan 2007 14:03:02 -0800
Hi all --
I've run into problems with scaling up a solution. I've got code for a
GARealGenome model that runs fine for runs of 10000 or 20000 generations.
However, when I scale it to run for 100000 generations, I often (not always)
get an exception error after evolution, when attempting to access the
I've seen this same problem posed on the GAlib archives, but no solution.
I'm hoping someone out there will have an answer!
The code is quite long, but here are some of the key sections from main().
I'm compiling this under MSVS 2005 (where all the examples, and some other
code I've done run fine).
GARealAlleleSet alleles(0.0, 1.0, 0.01, GAAllele::INCLUSIVE,
GARealGenome genome(TOTALGLENGTH, alleles, objective);
GASteadyStateGA::registerDefaultParameters(params); // same problem
params.set(gaNpopulationSize, POPSIZE); // all set from command-line
params.parse(argc, argv, gaFalse);
cout << "\nRunning GA ...\n";
cout << "Finished!\n"; // works fine up to here ...
genome = ga.statistics().bestIndividual();
cout << "Best individual found\n"; // ... but this line never prints
(for *some* runs)
cout << "\nThe GA generated: (" << genome.score() << ", " << bestgen <<
")\n" << genome << endl;
As noted in the comments, what happens is that the "Finished!" message
prints, and then the exception occurs when accessing bestIndividual().
Unfortunately, I haven't been able to debug into exactly where it's
occurring in the library (for various reasons: primarily because of how long
it takes to run into this occasional problem using non-optimized debug code,
and also because of the complexity of the library, where I'm just finding my
In terms of parameters, I see it frequently (not always) with generations of
50000 or more, and population sizes of 20 or more. More generations and
larger populations cause the problem more frequently. So it *looks* like a
potential allocation, overflow, or memory leak problem somewhere in the
Any suggestions? Thanks in advance,
galib mailing list
galib at mit.edu
More information about the galib