📄 complete.m
字号:
function [completed]=complete(arraymem,N);
%complete a individual
first=randint(1,1,[1 N]);
%arraymem=arraymem+1;
temparray=zeros(3,N); %the first line is used to set eval/sum, the second line is used to set new,the third is flag
temparray(2,1)=first;
temparray(3,first)=-1;
for p=2:N
sum=0;
temp=0;
for i=1:N
sum=sum+arraymem(first,i);
end
for i=1:N
temp=temp+arraymem(first,i)/sum;
temparray(1,i)=temp;
end %have set the temparray's first line
flag=1;
while flag
kk=rand(1,1);
if temparray(1,1)>=kk & temparray(3,1)==0
temparray(2,p)=1;
temparray(3,1)=-1;
flag=0;
end
for j=2:N
if temparray(1,j)>=kk & temparray(1,j-1)<kk & temparray(3,j)==0
temparray(2,p)=j;
temparray(3,j)=-1;
flag=0;
end
end
end
first=temparray(2,p);
end
completed=temparray(2,:);
%completed=mygaeval1(completed,N);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -