How to choose population and generations for GA?
22 views (last 30 days)
Show older comments
vittorio sartoretto
on 23 Nov 2020
Commented: Star Strider
on 23 Nov 2020
Hello everyone,
I would like to know if there is a method to properly define a good number of generations and population for running an optimization with GA? Is there any rule of thumb to choose the correct order of magnitude of those two parameters?
Thank you in advance
0 Comments
Accepted Answer
Star Strider
on 23 Nov 2020
Example —
PopSz = 500;
Parms = 3;
opts = optimoptions('ga', 'PopulationSize',PopSz, 'InitialPopulationMatrix',randi(1E+4,PopSz,Parms).*[1E-3 1E-1 1E+2], 'MaxGenerations',2E3, 'PlotFcn',@gaplotbestf, 'PlotInterval',1);
It is then possible to scale the individual columns of the 'InitialPopulationMatrix' aas I do here, so that it is easier for ga to find an appropriate solution. Providing a relatively large number of rows (individuals) can slightly slow the function, however in my experience it decreases the number of generations required for ga to converge.
6 Comments
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!