⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xalt_edges.m

📁 matlab的遗传算法的一个工具箱
💻 M
字号:
% alternating edges crossover for TSP% as described in the book by Zbigniew Michalewicz on page 212% this crossover assumes that the ajacency representation is used to represent% TSP tours%% KULeuven, december 2002 % email: Tim.Volodine@cs.kuleuven.ac.be%%% Syntax:  NewChrom = xals_edges(OldChrom, XOVR)%% Input parameters:%    OldChrom  - Matrix containing the chromosomes of the old%                population. Each line corresponds to one individual%                (in any form, not necessarily real values).%    XOVR      - Probability of recombination occurring between pairs%                of individuals.%% Output parameter:%    NewChrom  - Matrix containing the chromosomes of the population%                after mating, ready to be mutated and/or evaluated,%                in the same format as OldChrom.%function NewChrom = xalt_edges(OldChrom, XOVR);if nargin < 2, XOVR = NaN; end   [rows,cols]=size(OldChrom);      maxrows=rows;   if rem(rows,2)~=0	   maxrows=maxrows-1;   end      for row=1:2:maxrows	     	% crossover of the two chromosomes   	% results in 2 offsprings	if rand<XOVR			% recombine with a given probability		NewChrom(row,:) =cross_alternate_edges([OldChrom(row,:);OldChrom(row+1,:)]);		NewChrom(row+1,:)=cross_alternate_edges([OldChrom(row+1,:);OldChrom(row,:)]); 	else		NewChrom(row,:)=OldChrom(row,:);		NewChrom(row+1,:)=OldChrom(row+1,:);	end   end   if rem(rows,2)~=0	   NewChrom(rows,:)=OldChrom(rows,:);   end   % End of function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -