[galib] 1DArrayAlleleGenome not evolving

Soeren.Meyer-Eppler Soeren.Meyer-Eppler at buschnick.net
Sat Jan 8 07:20:49 EST 2005


Hello everybody,
I have a problem where an allele set isn't evolving at all. The genome 
just remains static without any variation whatsoever. I have attached a 
simple example program illustrating the problem. It sets up a 
1DArrayAlleleGenome with 4 allelesets, each defining an integer range. 
The objective function just returns the sum of all genes, which I'd 
expect leads to a maximization of the genes. Instead the Genome remains 
static at (3,0,0,3) - the initial values.

I'd be very grateful for any hints or tips.

I'm using:
galib 245
stlport 4.6.2
MSVC7.1 (on Windows of course)
boost 1.32.0

The code from example program number 21 exhibits the same behaviour, so 
I suspect a problem with my setup, not my code. Binary String genomes 
work fine. My guess is that some template instantiations don't work out 
or something?



float
EvolutionObjective( GAGenome & GenomeIn )
{
	GA1DArrayAlleleGenome< int > & Genome = (GA1DArrayAlleleGenome< int > 
&) GenomeIn;

	int Return = 0;
	for ( int i = 0; i<Genome.length(); ++i )
		Return += Genome.gene( i );

	return (float)Return;
}


void
Evolution()
{
	GAAlleleSetArray< int > AlleleSetArray;
	AlleleSetArray.add( 3, 21 );	// MeanSize
	AlleleSetArray.add( 0, 255 );	// Threshold
	AlleleSetArray.add( 0, 512 );	// MinArea
	AlleleSetArray.add( 3, 21 );	// EntropySize

	GA1DArrayAlleleGenome< int > Genome( AlleleSetArray, EvolutionObjective );

	GASteadyStateGA GA( Genome );
	GA.populationSize( 100 );
	GA.nGenerations( 10 );
	GA.selectScores((int)GAStatistics::AllScores );
	GA.pMutation( 0.01f );
	GA.pCrossover( 0.6f );
	GA.evolve(123456);	// random seed

	Genome = GA.statistics().bestIndividual();
	std::cout
		<< "\nthe ga found an optimum at the point ("
		<< Genome.gene( 0 ) << ", "
		<< Genome.gene( 1 ) << ", "
		<< Genome.gene( 2 ) << ", "
		<< Genome.gene( 3 ) << ")" << std::endl;
}


More information about the galib mailing list