MATLAB: GA generates duplicate initial populations

genetic algorithminitial population

I am using Genetic Algorithms for inverse problems (a large number of variables, i.e. more than 1000). I use the supercomputers provided by my university to run my models. In order to check how efficient my GA model is, I need to run one model a couple of times (e.g. 10 times) and see how many times it converges to an acceptable solution. The problem is that for all the trials of a specific model, Matlab generates exactly the same set of initial populations. This rsults in exactly the same answers for all the trials. I manually generated initial populations to overcome this issue, however, the model did not converge to a solution since it was very complicated and manually generated initial populations did not lead to convergence. In the model, I have upper and lower bounds without any constraint. Is it possible for Matlab to generate timely randomised initial populations (automatically by Matlab through options maybe, not by manually defining initial populations)? This will help with generating different initial populations for different runs of the same model. Your help is much appreciated.

Best Answer

The issue is related to the random number generation of MATLAB. Before writing GA sentences (e.g. options, ga() function, etc), the command rng('shuffle') has to be added to the code so that each time the code is run, a new initial population is randomly generated. For more information, visit the follwoing link. Trung VO DUY wrote this in comments for me - thank you Trung VO DUY.