genetic algorithm does not return best arguments

5 views (last 30 days)
Hi, I'm trying to use the ga as a tool, I do not know much of the theory behind it.
Each iteration I am displaying and also plotting the population arguments (x) found and the corresponding fitness value (fval). My fitness function gives values 0 to 1. and I can see several fval below 0.15 which I would be satisfied with. The problem is, when the algorithm stops, the final x and fval returned are for fitness over 0.2, which was obviously not the best 'available'. I tried modifying a bunch of things (including setting tolfun and tolcon to 0 as that's the exit flag) but no luck. Why does this happen?
Thanks Cristina
The options object : options = gaoptimset('UseParallel', true,... 'Vectorized', 'off','FitnessLimit',0.05,... 'PlotFcns', @gaplotbestf);
  1 Comment
Geoff Hayes
Geoff Hayes on 15 Nov 2014
Cristina - can you post your options object (created with gaoptimset) so that we can see how you have set up your genetic algorithm? It may be that you are doing a replacement on every member of the population at each generation/iteration of the algorithm and so "good" members are being replaced with "poorer" ones. Also, what version of MATLAB are you using?

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 15 Nov 2014
Cristina - depending upon your version of MATLAB, you could try using the EliteCount option which specifies how many members of the current generation will survive to the next generation. Try doing the following
options = gaoptimset('UseParallel', true,...
'Vectorized', 'off','FitnessLimit',0.05,...
'EliteCount', 2, ...
'PlotFcns', @gaplotbestf);
The above should guarantee the survival of the two best members (so at least the one whose fitness is below 0.15).
If the above doesn't work, please describe your minimization problem in more detail. Also, include your call to the ga function so that we can get an idea of the number of variables you are optimizing on, the number of generations, if you have any constraints, etc.

Community Treasure Hunt

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

Start Hunting!