How to apply a random Crossover (Arithmeti​c/Scattere​d/Two-poin​t) in Genetic Algorithm using auto-generated file from Optimization Toolbox ?

5 visualizaciones (últimos 30 días)
I have prepared a code in MATLAB with optimization toolbox which seems to be giving fair results for different optimization functions but at present, accuracy is highly dependent on the type of crossover selected.
To take advantage of different crossover and to improve efficiency, i want to apply a random crossover after every iteration i.e. any of Arithmetic, Scattered or Two-point. How can I do that ?
  7 comentarios
Ankur Shah
Ankur Shah el 11 de Ag. de 2020
Editada: Ankur Shah el 11 de Ag. de 2020
Can u please explain where can it be applied ?.. At present I have prepared crossover code using optimization toolbox as follows
options = optimoptions(options,'CrossoverFcn', @crossoverscattered)
Walter Roberson
Walter Roberson el 11 de Ag. de 2020
options = optimoptions(options,'CrossoverFcn', @MyCustomCrossover)
function varargout = MyCustomCrossover(varargin)
crossfcns = {@crossoverarithmetic, @crossoverheuristic, @crossoveritnermediate, @crossoverscattered, @crossoversinglepoint, @crossovertwopoint};
chosen = crossfcns{randi(length(crossfcns))} ;
[varargout{:}] = chosen(varargin{:}) ;
end

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de En. de 2021
options = optimoptions(options,'CrossoverFcn', @MyCustomCrossover)
function varargout = MyCustomCrossover(varargin)
crossfcns = {@crossoverarithmetic, @crossoverheuristic, @crossoveritnermediate, @crossoverscattered, @crossoversinglepoint, @crossovertwopoint};
chosen = crossfcns{randi(length(crossfcns))} ;
[varargout{:}] = chosen(varargin{:}) ;
end

Más respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 11 de Ag. de 2020
See the screen shot given in the attachement. You should select from the drop-down options whichever crossover function suits for your task.
  3 comentarios
Ankur Shah
Ankur Shah el 25 de En. de 2021
Editada: Ankur Shah el 25 de En. de 2021
Hi, Yes the code worked perfectly. I was trying to to tag your answer as Accepted but couldn't do. Apologies for confusion... Could you have a look at this question https://in.mathworks.com/matlabcentral/answers/725727-how-to-find-function-and-variable-value-at-each-iteration-for-genetic-algorithm-with-parallel-comput?s_tid=prof_contriblnk

Iniciar sesión para comentar.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by