View Single Post
  #20 (permalink)  
Old 08-15-2005, 01:42 AM
Guest
 
Posts: n/a
Default Re: Where can i find GeneticFPGA toolkit

Hi Rob
I undertsand why you are making a point about crossover.I have done
exactly the same thing. I use a special class to compare and sort the
population based on their fitness. Keeping in mind 'elitism',I also
copy the best solution to the new population. Then from a population of
six, I select 4 best values and average out consequent numbers.
Mutation- to randomise mutation process ,I select 4 members after
crossover and either add 1 0r subtract 1 depending on computer clock
ticks.This process is completely random.
Here's a piece of code for the above:

//Elitism - copy the best solution to the next generation
Array.Sort(RepopulationPercentage);
Best = RepopulationPercentage[popsize-1].accessElement;
listBox1.Items.Add("Best = "+Best);

//Crossover
int m=popsize-1;
listBox1.Items.Add("After Crossover");
listBox1.Items.Add(population[0]);
for(i=1;i<popsize-1;i++) //elements
{
population.SetValue((int)((RepopulationPercentage[m].accessElement+RepopulationPercentage[m-1].accessElement)/2),i);
listBox1.Items.Add(population[i]);
m--;
}
if(dt.Ticks%2 == 0)
population[popsize-1]=Best - 1;
else
population[popsize-1]=Best + 1;

//Mutation
listBox1.Items.Add("After Mutation");
listBox1.Items.Add(population[0]);
for(i=1;i<popsize;i=i+2) //elements
{
if(dt.Ticks%2 == 0)
population.SetValue((int)(population[i]+1),i);
else
population.SetValue((int)(population[i]-1),i);
listBox1.Items.Add(population[i]);
}

Eric's psuedo code and a genetic algorithm template from a website
helped me write the code.
Ankit

Reply With Quote