📄 select6.m
字号:
function [out,coefs,pin,best,bestpin]=select6(chrom,d,x,y,s1,s2,s3,best,bestpin)
%
% out=select(in);
%
% selects a new population
%
%
%
% Mix up the population
%
chrom=shuffle(chrom);
%
% Decode the existing population
%
coefs=decodall(chrom,d);
%
% Evaluate its' performance
%
pin=perf6(coefs,x,y,s1,s2,s3);
%
% Find the best
%
[b ind1]=min(pin);
if b < bestpin
bestpin=b;
best=chrom(ind1,:);
end
%
% Now work through the population to
% select the best.
% "Who's the hardest?" selection
%
[D L]=size(chrom);
pin2=pin;
coefs2=coefs;
for i = 1:2:D
if pin(i)<pin(i+1)
chrom(i+1,:)=chrom(i,:);
coefs2(i+1,:)=coefs2(i,:);
pin2(1,i+1)=pin2(1,i);
else
chrom(i,:)=chrom(i+1,:);
coefs2(i,:)=coefs2(i+1,:);
pin2(1,i)=pin2(1,i+1);
end
end
pin=pin2;
coefs=coefs2;
%
% Now replace the worst with the previous best
%
[b ind1]=max(pin);
chrom(ind1,:)=best;
pin(1,ind1)=bestpin;
out=chrom;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -