How to change Crossover Function in GA midway through solving?

5 次查看(过去 30 天)
Hi all,
I have a GA setup to search for a minimum of a problem. I think my problem is well defined, except it has many local optima. I read in the documentation that changing the Crossover and Mutation Functions midway through iterations can be very useful in aiding of finding global optima. I understand it needs to be modified by the 'OutputFcn' settings, but all the documentation I see include cases where multiple things are being changed. Say if I just want to change the Crossover from 0.2 at the beginning to 0.8 after a certain number of iterations, what would the script for OutputFcn look like?
All the best.

回答(1 个)

Alan Weiss
Alan Weiss 2018-8-6
I think that this will work, but I have not tested it, so use at your own risk.
Suppose that you want to change the crossover probability at generation 27.
function [state,options,optchanged] = gaoutfun(options,state,flag)
optchanged = false;
if state.Generation == 27
options.CrossoverFraction = 0.8;
optchanged = true;
end
Pass @gaoutfun as the OutputFcn option (I assume that you use optimoptions to set your options).
Alan Weiss
MATLAB mathematical toolbox documentation

类别

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

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by