From what I can tell one of the biggest differences between evolutionary and genetic algorithms is that evolutionary employs a mutate function to generate a new population while a genetic used a crossover function.
I found an evolutionary algorithm that trys to generate a target string through mutations like this:
private static double newMutateRate(){
return (((double)perfectFitness - fitness(parent)) / perfectFitness * (1 - minMutateRate));
}
private static String mutate(String parent, double rate){
String retVal = "";
for(int i = 0;i < parent.length(); i++){
retVal += (rand.nextDouble() <= rate) ?
possibilities[rand.nextInt(possibilities.length)]:
parent.charAt(i);
}
return retVal;
}
I wrote this crossover function to replace the mutation function:
private static String crossOver(String parent)
{
String newChild = "";
for(int i = 0; i < parent.length(); i++)
{
if(parent.charAt(i) != target.charAt(i))
newChild += possibilities[rand.nextInt(possibilities.length)];
else
newChild += parent.charAt(i);
}
return newChild;
}
Which works great. But I'm wondering if its a valid crossover function. I feel like, from my experience with genetic algorithms, that the crossover function should be generating more random populations than what I have written in other words knowing exactly which bit not to change seems almost like cheating.