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

조회 수: 5 (최근 30일)
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
Ankur Shah
Ankur Shah 2020년 8월 11일
편집: Ankur Shah 2020년 8월 11일
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 2020년 8월 11일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 1월 25일
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

추가 답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020년 8월 11일
See the screen shot given in the attachement. You should select from the drop-down options whichever crossover function suits for your task.
  댓글 수: 3
Ankur Shah
Ankur Shah 2021년 1월 25일
편집: Ankur Shah 2021년 1월 25일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by