% maxpop 给定群体规模
% pop 群体
% newpop 种群
%t0 初始温度
function [codmin,finmin]=fc0(cc,v0,t0) N=length(cc(1,:));
%定群体规模
if N>50
maxpop=2*N-20;
end
if N<=40
maxpop=2*N;
end
%产生初始群体
pop=zeros(maxpop,N);
pop(:,1)=v0;
finmin=inf;
codmin=0;
for i=1:maxpop
Ra=randperm(N);
Ra(find(Ra==v0))=Ra(1);
Ra(1)=v0;
pop(i,:)=Ra;
end
t=t0;
while t>0
%用模拟退火产生新的群体
pop=fc1(maxpop,pop,N,cc,v0,t);
%转轮赌选择种群
f=zeros(1,maxpop);
for i=1:maxpop
for j=1:N-1
x=pop(i,j);
y=pop(i,j+1);
fo1=cc(pop(i,j),pop(i,j+1));
f(i)=f(i)+fo1;
end
f(i)=f(i)+cc(pop(i,1),pop(i,N));
end
fmin=min(f);
for i=1:maxpop
if fmin==inf&f(i)==inf
dd=inf;
end