Two point Crossover in Genetic Algorithm
조회 수: 9 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!