What is the repeatability like in matlabs genetic algorithm?

2 次查看(过去 30 天)
If I run my code multiple times, everytime the number of generations that the program takes to converge are very different. Without changing anything, the generations are anywhere from 500 to 2700. I know that since the genetic algorithm runs randomly, the solution will be different everytime. But, shouldn't the number of generations be close and not so spread out? Thanks

采纳的回答

Mukul Rao
Mukul Rao 2015-6-22
In my opinion this behavior is expected since the initial population is random. Each time the genetic algorithm (GA) is evoked, the initial population could be located in a part of the domain where the surface geometry could be completely different from the previous GA calls. In some calls, the starting population might be located in a "favorable" region in the sense that the nature of the fitness function surface may be conducive to the tolerances being met faster as the generations progress.
In fact, this behavior is also observed in the documented example "Minimize Rastrigin's Function" with the genetic algorithm.
options = gaoptimset(@ga);
options.Display = 'iter';
[x fval exitflag] = ga(@rastriginsfcn, 2,options)
In the above example, you will notice that the number of iterations required to meet the default tolerances ranges from 50 - 200 iterations.
It seems to me that repeatability can be controlled by changing the mode of random number generation. The documentation page on "Minimize Rastrigin's Function" , suggests changing the random generation to the 'twister' option to improve repeatibility:
The specific command of interest would be:
rng(1,'twister') % for reproducibility
I would also recommend modifying the solver options, such as the stopping criteria to see if it helps improve reproducibility.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by