public virtual void Mutate( )
{
// mutate
for ( int i = 0; i < size; i++ )
{
// generate next random number and check if we need to do mutation
if ( rand.NextDouble( ) <= mutationRate )
{
// clone the chromosome
IChromosome c = population[i].Clone( );
// mutate it
c.Mutate( );
// calculate fitness of the mutant
c.Evaluate( fitnessFunction );
// add mutant to the population
population.Add( c );
}
}
}