eaSimple and elitism

35 views
Skip to first unread message

Ozéas Carvalho

unread,
Apr 30, 2023, 3:52:20 AM4/30/23
to deap-users
Greetings,

I've seen some posts about this question, but I couldn't conclude.

During selection, I'd like to select the k best individuals and then perform tournament selection "len(pop) - k" times, so the size of the intermediate population remains the same.

I tried using "selBest" and "selTournament" but couldn't set the parameters right. I got the error "multiple values for argument". I also tried a solution suggested here about registering a separate function that returns "selBest" + "selTournament", but got the same errors, so I must be missing something.

here's the relevant code:

I know that elitism increases the selection pressure, but that is intended. I usually use my own GA implementations and have successfully applied elitism. This time I'm doing GP and decided to use DEAP to help my case. Great tool, by the way.

Many thanks,


 

Rupert Young

unread,
May 1, 2023, 7:05:55 AM5/1/23
to deap-users
Your code is for registering the selection function, so, as I understand it, takes three arguments, not four

toolbox.register("select", tools.selTournament, tournsize=3)

I use tournament selection, the population size stays the same.

Ozéas Carvalho

unread,
May 1, 2023, 11:59:16 AM5/1/23
to deap-users
So the following is enough do perform elitism with eaSimple, keeping the same population size?

toolbox.register("best", tools.selBest, k=1)
toolbox.register("select", tools.selTournament, tournsize=7)

Thanks,

Rupert Young

unread,
May 5, 2023, 7:49:24 AM5/5/23
to deap-users
As I understand you are registering the selction method with the keyword "select". I don't know what "best" is. Is that a keyword? What are you expecting it to do?
Reply all
Reply to author
Forward
0 new messages