Hello, so I'm new to pyevolve and I'm trying to implement a binary coded rastring minimization GA with roulette wheel selection.
As the roulette only accepts maximization, I have to change the calculated fitness value of the chromossome to maxfitness - fitness.
I'm trying to do this with this function as setcallback:
def calculateRealFitness(ga_engine):
best = ga_engine.bestIndividual()
bestfitness = best.getFitnessScore()
population = ga_engine.getPopulation()
for i in xrange(10): #10 is the size of the population in this case
population[i].fitness = bestfitness - population[i].fitness
ga_engine.internalPop = population
return False
Unfortunately, it doesn't change anything. What is wrong with my code? What's the best way to do it?