利用模拟退火做的一个代码,求看看那边有问题,怎么解?
clearalla=;Tmax=150;N=100;n=30;set=[];x1=zeros(2,30);x2=zeros(2,30);=twoR(x1,x2,a);z1=x1;z2=x2;fz=fx;while Tmax>10^(-2) for L=1:N if fx<=fz z1=x1; z2=x2; fz=fx; end i=fix(n*rand+1); switch i case{1,2,3,4} j=fix(4*rand+1); case{5,6,7,8} j=fix(8*(0.5+0.5*rand)+1); case{9,10,11,12} j=fix(12*(2/3+(l/3)*rand)+1); case{13,14,15} j=fix(15*(4/5+(l/5)*rand)+1); case{16,17,18,19} j=fix(19*(15/19+(4/19)*rand)+1); case{20,21,22,23} j=fix(23*(19/23+(4/23)*rand)+1); case{24,25,26,27} j=fix(27*(23/27+(4/27)*rand)+1); otherwise j=fix(30*(9/10+(1/10)*rand)+1); end if i~=j b=a; yt=[]; yt(:,i)=b(:,i); b(:,i)=b(:,j); b(:,j)=yt(:,i); =twoR(x1,x2,b); if fb<=fx || exp(-(fb-fx)/Tmax)>rand a=b; fx=fb; end end set=; L; end Tmax=0.90*Tmax;endplot(set)z1;z2;fz;yt(:,i)=b(:,i);set=;这两个有问题怎么解决啊
页:
[1]