1

I'm using DEAP library in python for a genetic programming maximization problem.

I have used eaSimple algorithm to create populations with 60% probability of crossover and 30% probability of mutation.

The fitness of the best individual in populations is increasing but the average fitness of populations is sometimes decreasing (e.g. the average fitness of the first population is more than the last population's average fitness).

Is this normal or something is wrong with the settings?

Another thing to mention is that I have set the worst fitness to zero and the populations do include individuals with zero fitness value (population size is 1000).

Farnoosh
  • 31
  • 7
  • What problem is being solved and what is the representation of your solutions? What selection algorithm do you use? Do you use elitism? It's next to impossible to provide any answer whatsoever without this kind of info. Also, why are you interested in the average fitness? Usually the best individual int he population or the best-so-far individual is what is interesting, not the average. – zegkljan Jul 24 '19 at 09:44
  • I'm using GP for feature construction in a classification problem and I have used the tree representation. Tournament selection with size of 7 is used. As far as I found Deap does not provide elitism option, but 10% is the probability of reproduction. I'm also looking for the best individual but seeing the average fitness decreasing seemed like something is not right. – Farnoosh Jul 24 '19 at 10:09
  • By representation I meant what the trees represent. I suppose they are mathematical expressions. Are you sure you use the fitness correctly? Minimization/maximization is handled by setting the weights when creating the fitness type. – zegkljan Jul 24 '19 at 11:17
  • Yes they are mathematical expressions including +, -, *, / (protected division) operators. I have given +1 weight to make it a maximization problem. The fitness function was the accuracy of a decision tree using the constructed feature (each individual), but in order to only include small trees, I set the fitness values of trees having greater height than a specific value to zero. I checked now and it seems this part is making the fluctuations in average fitnesses. – Farnoosh Jul 24 '19 at 12:07
  • I suggest playing around with the parameters, e.g. with the size of the tournament. The bigger you set it, the more greedy the algorithm should be and therefore the average fitness should go up too. If that does not happen, there is probably some oher problem. – zegkljan Jul 24 '19 at 14:10
  • I'll try that. Thank you. – Farnoosh Jul 24 '19 at 14:59

1 Answers1

0

The eaSimple algorithm uses the varAnd strategy on all of the individuals of the initial population, and no selection is done. Therefore, the eaSimple algorithm explores the feature space but does not do much for optimizing. If you do want to use this algorithm, I recommend using a HallOfFame object to remember the best object that was found during exploration.


From the pseudo-code in the documentation describing what eaSimple does,

population = select(population, len(population))

means that all of the elements in the population are taken. For instance, if your select function is tools.SelBest, then you have selected the n best individuals with n being the size of the population.

Then the varAnd strategy is used (documentation), where parent individuals are paired up based on their index in the population and mated. The two generated offspring have a fixed probability of replacing the two original parents.

usernumber
  • 1,958
  • 1
  • 21
  • 58
  • You wrote "no selection is done... the eaSimple algorithm explores the feature space but does not do much for optimizing". This is contrary to what the docs say: "First, it evaluates the individuals with an invalid fitness. Second, it enters the generational loop where the selection procedure is applied to entirely replace the parental population. The 1:1 replacement ratio of this algorithm requires the selection procedure to be stochastic and to select multiple times the same individual, for example, selTournament() and selRoulette()." – dolphin Jun 10 '20 at 11:15