[galib] Exception raised by bestIndividual() ?
cnchapman at msn.com
Thu Jan 25 17:03:02 EST 2007
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,
More information about the galib