[galib] Exception raised by bestIndividual() ?
Chris Chapman
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
problems.
I'll update again if it returns and I discover anything else. Yours,
-- chris
----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
ga.statistics().bestIndividual() genome.
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,
GAAllele::INCLUSIVE);
GARealGenome genome(TOTALGLENGTH, alleles, objective);
GASteadyStateGA::registerDefaultParameters(params); // same problem
with GASimpleGA
params.set(gaNpopulationSize, POPSIZE); // all set from command-line
processing
params.set(gaNpCrossover, PCROSS);
params.set(gaNpMutation, PMUTATE);
params.set(gaNnGenerations, NUMGEN);
params.set(gaNscoreFrequency, SCOREINT);
params.set(gaNflushFrequency, 50);
params.set(gaNselectScores, GAStatistics::AllScores);
params.parse(argc, argv, gaFalse);
GASteadyStateGA ga(genome);
ga.parameters(params);
ga.pReplacement(Preplace);
ga.set(gaNscoreFilename, "bog.dat");
ga.maximize();
cout << "\nRunning GA ...\n";
ga.evolve();
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
way).
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
GAlib code.
Any suggestions? Thanks in advance,
-- chris
_______________________________________________
galib mailing list
galib at mit.edu
http://mailman.mit.edu/mailman/listinfo/galib
More information about the galib
mailing list