5、ran<0) ran=rand; end ran; ifran<=fitness(1) newpopulation(ranseti,:)=population(1,:);
6、 else forfet=2:popsize if(ran>fitness(fet-1))&&(ran<=fitness(fet))共享知识技术资料 newpopulation(ranseti,:)=population(fet,:); end end endendclearran;newpopulation;%交叉forint=1:2:popsize-1 popmoth=newpopulation(int,:); popf
8、oint2=round(rand*hromlength); end ifcpoint1>cpoint2 tem=cpoint1; cpoint1=cpoint2; cpoint2=tem;共享知识技术资料 end cpoint1; cpoint2; forterm=cpoint1+1:cpoint2 forss=1:hromlength
9、 ifpopcross(int,ss)==popfath(term) tem1=popcross(int,ss); popcross(int,ss)=popcross(int,term); popcross(int,term)=tem1; end end cleartem1; end forterm=cpoint1+1: