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 Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by