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

📄 reciprocal_exchange.m

📁 matlab的遗传算法的一个工具箱
💻 M
字号:
% low level function for TSP mutation% reciprocal exchange : two random cities in a tour are swapped% Representation is an integer specifying which encoding is used%	1 : adjacency representation%	2 : path representation%function NewChrom = reciprocal_exchange(OldChrom,Representation);NewChrom=OldChrom;if Representation==1 	NewChrom=adj2path(NewChrom);end% swap two random cities in the tourrndi=zeros(1,2);while rndi(1)==rndi(2)	rndi=randint(1,2,[1 size(NewChrom,2)]);endbuffer=NewChrom(rndi(1));NewChrom(rndi(1))=NewChrom(rndi(2));NewChrom(rndi(2))=buffer;if Representation==1	NewChrom=path2adj(NewChrom);end% End of function

⌨️ 快捷键说明

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