select5.m

来自「gaotv5,一个著名的遗传算法工具箱.安装在任意目录」· M 代码 · 共 49 行

M
49
字号
function [out,coefs,pin]=select(in,d,x,y,h1,h2)
%
% out=select(in);
%
% selects a new population
%
%
global stop;
%
% Mix up the population
%
chrom=shuffle(in);

%
% Decode the existing population
%
coefs=decodall(chrom,d);

%
% Evaluate its' performance
%
pin=perf5(coefs,x,y,h1,1);


%
% Now work through the population to
% select the best.
% "Who's the hardest?" selection
%

[D L]=size(chrom);


for i = 1:2:D
	if stop == 1 
		break;
	end
	if pin(i)<pin(i+1)
		chrom(i+1,:)=chrom(i,:);
	else
		chrom(i,:)=chrom(i+1,:);
	end
end
coefs=decodall(chrom,d);
pin=perf5(coefs,x,y,h2,2);

out=chrom;

⌨️ 快捷键说明

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