Two point Crossover in Genetic Algorithm

조회 수: 9 (최근 30일)
candvera
candvera 2016년 1월 13일
답변: Pavithra Ashok Kumar 2016년 1월 19일
I have a simple piece of code that carries out the crossover with just one point. How would I go about making the following a two-point crossover operation?
if (rand < CrossoverProbability)
C1 = TempChromosome_1;
C2 = TempChromosome_2;
% now copy over the data from the other parent that is "crossed over" with the first
% parent
crossoverPoint = randi([1,30]);
TempChromosome_1(:,crossoverPoint:end) = C2(:,crossoverPoint:end);
TempChromosome_2(:,crossoverPoint:end) = C1(:,crossoverPoint:end);
end
The data itself (i.e. TempChromosome_1) is a 30-digit sequence with numbers 1-9

답변 (1개)

Pavithra Ashok Kumar
Pavithra Ashok Kumar 2016년 1월 19일
Hi, If you are looking for a built-in function to implement a 2-point crossover, set the "CrossOverFcn" parameter to be @crossovertwopoint. Refer the page for more details: http://www.mathworks.com/help/gads/genetic-algorithm-options.html

카테고리

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