[galib] Exception raised by bestIndividual() ?

Chris Chapman 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 
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





More information about the galib mailing list