一、简介
1 量子免疫克隆

-
clear; C=[253 245 243 239 239 239 238 238 237 232 231 231 230 229 228 227 224 217 213 207 203 201 195 194 191 187 187 177 175 171 169 168 165 164 161 160 158 150 149 147 141 140 139 136 135 132 128 126 122 120 119 116 116 114 111 110 105 105 104 103 93 92 90 79 78 77 76 76 75 73 62 62 61 60 60 59 57 56 53 53 51 50 44 44 42 42 38 36 34 28 27 24 22 18 12 10 7 4 4 1]; W=[253 245 243 239 239 239 238 238 237 232 231 231 230 229 228 227 224 217 213 207 203 201 195 194 191 187 187 177 175 171 169 168 165 164 161 160 158 150 149 147 141 140 139 136 135 132 128 126 122 120 119 116 116 114 111 110 105 105 104 103 93 92 90 79 78 77 76 76 75 73 62 62 61 60 60 59 57 56 53 53 51 50 44 44 42 42 38 36 34 28 27 24 22 18 12 10 7 4 4 1]; V=6666; a=2.40; q=(sqrt(1/2)).*ones(20,100); [N,L] = size(q); ger =500; pm=0.0088; pc=0.88; fat=0.1; disp(sprintf('Number of generations: %d',ger)); disp(sprintf('Population size: %d',N/2)); % General parameters & Initial operations vmfit = []; it = 1; vx = []; T=[]; vw=[]; f='dot(v,C1,2)'; updatef=0; % Generations t0 = clock; c1=0; while it <= ger itemp=[1 3 5 7 9 11 13 15 17 19]; v=observe(q(itemp,:)); rate=C./W; [a,ind] = sort(rate); for j=1:N/2 i1=1; %repair knoverfilled=0; if dot(v(j,:),W)>6666 knoverfilled=1; end while knoverfilled==1 v(j,ind(i1))=0; if dot(v(j,:),W)<=6666 knoverfilled=0; end i1=i1+1; end v(j,:)=v(j,:); end %and/or Crossver for i=1:N/2 cind(i)=i; end for i=1:N/2 point=unidrnd(N/2-i+1); temp=cind(i); cind(i)=cind(i+point-1); cind(i+point-1)=temp; end for i=1:2:N/2 p=rand(1); if(p<pc) c1=and(v(cind(i),:),v(cind(i+1),:)); c2=or(v(cind(i),:),v(cind(i+1),:)); v(cind(i),:)=c1; v(cind(i+1),:)=c2; end end for j=1:N/2 i1=1; %repair knoverfilled=0; if dot(v(j,:),W)>6666 knoverfilled=1; end while knoverfilled==1 v(j,ind(i1))=0; if dot(v(j,:),W)<=6666 knoverfilled=0; end i1=i1+1; end v(j,:)=v(j,:); end C1=ones(N/2,1)*C; fit=eval(f); [sol,indb] = max(fit); maxf=sol; max1=v(indb,:); minf=min(fit); if updatef>=sol maxf=updatef; max1=updatec; else maxf=sol; max1=v(indb,:); end %量子变异 for i=1:2:size(q,1) for j=1:size(q,2) if v((i+1)/2,j)==max1(1,j) if max1(1,j)==0 s=0; angle=0; else if q(i,j)*q(i+1,j)>0 s=1; angle=0.015; end if q(i,j)*q(i+1,j)<0 s=-1; angle=0.015; end if q(i,j)==0 s=0; angle=0.015; end if q(i+1,j)==0 s=1; angle=0.015; end end elseif v((i+1)/2,j)==0 if maxf>fit((i+1)/2) s=0; angle=0; else if q(i,j)*q(i+1,j)>0 s=-1; angle=0.015; end if q(i,j)*q(i+1,j)<0 s=1; angle=0.015; end if q(i,j)==0 s=1; angle=0.015; end if q(i+1,j)==0 s=0; angle=0.015; end end else if maxf>fit((i+1)/2) if q(i,j)*q(i+1,j)>0 s=-1; angle=0.015; end if q(i,j)*q(i+1,j)<0 s=1; angle=0.015; end if q(i,j)==0 s=1; angle=0.015; end if q(i+1,j)==0 s=0; angle=0.015; end else if q(i,j)*q(i+1,j)>0 s=1; angle=0.015; end if q(i,j)*q(i+1,j)<0 s=-1; angle=0.015; end if q(i,j)==0 s=0; angle=0.015; end if q(i+1,j)==0 s=1; angle=0.015; end end end o=s*angle*pi; u=[cos(o) -sin(o);sin(o) cos(o)]; temp1=[q(i,j);q(i+1,j)]; temp2=u*temp1; q(i,j)=temp2(1,1); q(i+1,j)=temp2(2,1); end- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
- 90.
- 91.
- 92.
- 93.
- 94.
- 95.
- 96.
- 97.
- 98.
- 99.
- 100.
- 101.
- 102.
- 103.
- 104.
- 105.
- 106.
- 107.
- 108.
- 109.
- 110.
- 111.
- 112.
- 113.
- 114.
- 115.
- 116.
- 117.
- 118.
- 119.
- 120.
- 121.
- 122.
- 123.
- 124.
- 125.
- 126.
- 127.
- 128.
- 129.
- 130.
- 131.
- 132.
- 133.
- 134.
- 135.
- 136.
- 137.
- 138.
- 139.
- 140.
- 141.
- 142.
- 143.
- 144.
- 145.
- 146.
- 147.
- 148.
- 149.
- 150.
- 151.
- 152.
- 153.
- 154.
- 155.
- 156.
- 157.
- 158.
- 159.
- 160.
- 161.
- 162.
- 163.
- 164.
- 165.
- 166.
- 167.
- 168.
- 169.
- 170.
- 171.
- 172.
- 173.
- 174.
- 175.
- 176.
三、运行结果

四、备注
856

被折叠的 条评论
为什么被折叠?



