📄 mutation.m
字号:
function [outone]=mutation(inone,N);
%N=10;
outone=inone;
x=randint(1,2,[1 N]);
while x(1)==x(2) %created two random number:x(1),x(2),use them to gain the part in order to exchange
x(2)=randint(1,1,[1 N]);
end
if x(1)>x(2)
temp=x(2);
x(2)=x(1);
x(1)=temp;
end
k=randint(1,1,N);
for i=1:k %proceed k times
y=randint(1,2,[1 x(2)-x(1)+1]);
while y(1)==y(2) %created two random number:x(1),x(2),use them to gain the part in order to exchange
y(2)=randint(1,1,[1 x(2)-x(1)+1]);
end
y=y+x(1)-1;
% if y(1)~=0 & y(2)~=0
temp=inone(y(1));
inone(y(1))=inone(y(2));
inone(y(2))=temp;
% end
end
%compute eval
inone(1,1:N+3)=mygaeval1(inone(1,1:N+3),N);
if outone(N+1)<inone(N+1);
outone=inone;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -