%附录一
function ABL(N,M,T,p1,p2,Ta,Tb,NN,MM,n)
TaS=zeros(N,M,T);TbS=zeros(N,M,T);%TaS,TbS respectively for patients cured of illness, immunization period
i=1:1:100;j=1:1:100;t=0:1:100;i=0;j=0;
QQ1=round(1000*rand(1,p1*1000));
QQ2=round(1000*rand(1,p2*1000)); %Ask whether the node chosen for a random number
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S=ones(N,M,T);S(NN,MM,1)=SS(2);S(15,5,1)=SS(2);
S(10,30,1)=SS(2);S(40,40,1)=SS(2); %S为状态矩阵
for t=2:1:T
for i=2:N-1
for j=2:M-1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Determine the distribution of state S at time t
if S(i,j,t-1)==SS(1)
S(i,j,t)=SS(1);TaS(i,j,t)=0;
elseif S(i,j,t-1)==SS(2)
if TaS(i,j,t-1)>=Ta
TaS(i,j,t)=0;
S(i,j,t)=SS(3);
else
TaS(i,j,t)=TaS(i,j,t-1)+1;S(i,j,t)=SS(2);
end
else
if TbS(i,j,t-1)>=Tb22
TbS(i,j,t)=0;S(i,j,t)=SS(1);
else
TbS(i,j,t)=TbS(i,j,t-1)+1 ; S(i,j,t)=SS(3);
end
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S t get the distribution of time
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Scanning all the nodes
for i=2:N-1
for j=2:M-1
if S(i,j,t)==SS(1) %%%%%%%%%%%Determines whether SS (1) for the distribution
S(i,j,t)=SS(1);
elseif S(i,j,t)==0 %To determine whether the new sick, but is no longer involved infection
S(i,j,t)=0;
elseif S(i,j,t)==SS(4)
S(i-1,j,t)=SS(3);
elseif S(i,j,t)==SS(2) %%%%Determines whether SS (2) distribution
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Circumstances surrounding the eight sick judge position
if S(i-1,j,t)~=SS(1)
S(i-1,j,t)=S(i-1,j,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i-1,j,t)=SS(2);
end23
end
end
if S(i,j-1,t)~=SS(1)
S(i,j-1,t)=S(i,j-1,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i,j-1,t)=SS(2);
end
end
end
if S(i+1,j,t)~=SS(1)
S(i+1,j,t)=S(i+1,j,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i+1,j,t)=0;
end
end
end24
if S(i,j+1,t)~=SS(1)
S(i,j+1,t)=S(i,j+1,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i,j+1,t)=0;
end
end
end
if S(i-1,j-1,t)~=SS(1)
S(i-1,j-1,t)=S(i-1,j-1,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i-1,j-1,t)=SS(2);
end
end
end
if S(i+1,j-1,t)~=SS(1)
S(i+1,j-1,t)=S(i+1,j-1,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i+1,j-1,t)=0;
end
end
end
if S(i+1,j+1,t)~=SS(1)
S(i+1,j+1,t)=S(i+1,j+1,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i+1,j+1,t)=0;
end
end
end
if S(i-1,j+1,t)~=SS(1)
S(i-1,j+1,t)=S(i-1,j+1,t);
else ii1=round(1000*rand(1));
one=ones(1,p1*1000);
ii2=ii1*one;
QQ=QQ1-ii2;
for kk=1:p1*1000
if abs(QQ(1,kk))<=0.05
S(i-1,j+1,t)=SS(2);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Eight locations around the end of the judgment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Determine the relationship between the sick and infect other nodes
yy=random('Poisson',n,[N,M]);
for ii=2:N-1
for jj=2:M-1
if yy(ii,jj)==n
if(ii==i-1&jj==j-1)|(ii==i-1&jj==j)|(ii==i-1&jj==j+1)|(ii==i&jj==j-1)|(ii==i&jj==j)|(ii==i&jj==j+1)|(ii==i+1&jj==j-1)|(ii==i+1&jj==j)|(ii==i+1&jj==j+1)|S(ii,jj,t)~=SS(1)
S(ii,jj,t)=S(ii,jj,t);
else ii1=round(1000*rand(1));
one=ones(1,p2*1000);
ii2=ii1*one;
QQ=QQ2-ii2;
for kk=1:p2*1000
if abs(QQ(1,kk))<=0.05
S(ii,jj+1,t)=0;
end
end27
end
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Determine the relationship between the sick infect other nodes and end
end %%%%%%%%% End SS state judge
end
end
else
S(i,j,t)=SS(3); %%%%%%%%%Determines whether SS (4) state
end
end
end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%End scan all nodes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Di
评论0