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!