Change Fitness Metric After n-Generations

20 views
Skip to first unread message

Michael Itzkin

unread,
Mar 29, 2021, 3:08:37 PM3/29/21
to deap-users
Hello,

I am currently getting good results out of my GA by evaluating on just one metric (RMSE) during the model run. I was wondering if it would be possible to have the metric switch after n-generations if the GA is starting to converge;

Basically I am using the GA to replicate a beach profile. I am currently evaluating the fitness function on the whole profile and it is converging on an okay/good result after ~8 generations. I am thinking it would be both neat and (ideally) return better results if I had the fitness function start to only focus on specific subsection of the profile once it starts to converge. So if the RMSE for the full profile remains relatively constant for n-generations than have it switch to evaluating the RMSE for just the beach until that starts to level off.

Is there a simple way to write this kind of a switch into my GA (or a not so simple way)?

Thanks,
Michael

Derek Tishler

unread,
Apr 4, 2021, 11:05:11 AM4/4/21
to deap-users
Can you, in the algo loop, re-register the evaluation function to something that returns a new fitness?
I explain here how to perform an action at generation N for the case of adding something to the pop, you can imagine how in your case you would instead register a new eval function as one approach:
https://groups.google.com/g/deap-users/c/moRTYQJMHek/m/uREkELBmAwAJ

Another method may be to run your algo like eaSimple for n gens and let it finish, then re register a new eval function with the slight changes you need and then run the algo again which will use the existing pop to 'continue' the evolution with the desired changes.

Third option may be to modify the algo and how eval is called, passing along the generation or other info to trigger a difference in logic in the eval function. (need to use source and work with algo locally and modify the map call a little).
Reply all
Reply to author
Forward
0 new messages