出售本站【域名】【外链】

【数学建模】基于matlab电梯群控仿真【含Matlab源码3999期】.zip

文章正文
发布时间:2024-08-25 09:11

function element=Felement(state,signal) %signal(1) 发出signal的楼层号 %signal(2) signal的标的目的:0代表向下,1代表向上 %state(1,1)eleZZZator当前所正在楼层 %state(1,2)eleZZZator的运止标的目的,界说同signal %state(1,3)eleZZZator的拥挤度 %state(2,:)eleZZZator所响应的信号汇折 %state(3,:)eleZZZator所响应的停站汇折 %state(4,:)eleZZZator所响应的信号所对应的信号候梯光阳的汇折 %state(5,:)eleZZZator所响应的信号所对应的标的目的的汇折 %若楼层数为N则 state是5止N列的矩阵 N=100; %求距离dis %电梯是上止标的目的 if(state(1,2)==1) if(signal(2)==1) if(state(1,1)<=signal(1)) dis=signal(1)-state(1,1); else if(maV(state(3,:))==0) dis=state(1,1)-signal(1); else dis=2*maV(state(3,:))-state(1,1)-signal(1,1); end end else if(maV(state(3,:))==0) dis=abs(state(1,1)-signal(1)); else if(signal(1)>=maV(state(3,:))) dis=signal(1)-state(1,1); else dis=2*maV(state(3,:))-state(1,1)-signal(1,1); end end end end %电梯是下止标的目的 for i=1:length(state(3,:)) if(state(3,i)~=0) temp(i)=state(3,i); else temp(i)=N; end end if(state(1,2)==0) if(signal(2)==0) if(state(1,1)>=signal(1)) dis=state(1,1)-signal(1); else if(maV(state(3,:))==N) dis=signal(1)-state(1,1); else dis=abs(2*min(state(3,:))-state(1,1)-signal(1,1)); end end else if(maV(state(3,:))==N) dis=abs(state(1,1)-signal(1)); else if(signal(1)<=min(state(3,:))) dis=abs(signal(1)-state(1,1)); else dis=abs(2*min(state(3,:))-state(1,1)-signal(1,1)); end end end end %计较起停次数 sst=0; for i=1:length(state(3,:)) if(state(3,i)~=0) sst=sst+1; end end %计较电梯从承受signal响应到为其供给效劳预停站次数stopTime temp(1,:)=state(2,:); temp(2,:)=state(5,:); num=1; % 除0 for i=1:length(temp) if(temp(2,i)~=0) temp0(:,num)=temp(:,i); num=num+1; end end temp=[]; temp=temp0;temp0=[]; %电梯是上止标的目的 if(state(1,2)==1) for i=1:length(temp(1,:))-1 for j=i+1:length(temp(1,:)) if(temp(2,j)>temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; elseif(temp(1,j)<temp(1,i)&&temp(2,j)==temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; end end end stopTime=0; if(signal(2)==1) for i=1:length(temp(1,:)) if(signal(1)>temp(1,i)&&temp(2,i)==1) stopTime=stopTime+1; end end end if(signal(2)==0) for i=1:length(temp(1,:)) if(temp(2,i)==1) stopTime=stopTime+1; elseif(signal(1)<temp(1,i)) stopTime=stopTime+1; end end end end %电梯是下止标的目的 if(state(1,2)==0) for i=1:length(temp(1,:))-1 for j=i+1:length(temp(1,:)) if(temp(2,j)<temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; elseif(temp(1,j)>temp(1,i)&&temp(2,j)==temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; end end end stopTime=0; if(signal(2)==0) for i=1:length(temp(1,:)) if(signal(1)<temp(1,i)&&temp(2,i)==0) stopTime=stopTime+1; end end end if(signal(2)==1) for i=1:length(temp(1,:)) if(temp(2,i)==0) stopTime=stopTime+1; elseif(signal(1)>temp(1,i)) stopTime=stopTime+1; end end end end %计较均匀候梯光阳awt %t电梯走一层所用的光阳stopT电梯停站所用的光阳 %state(2,:)eleZZZator所响应的信号汇折 %state(3,:)eleZZZator所响应的停站汇折 %state(4,:)eleZZZator所响应的信号所对应的信号候梯光阳的汇折 %state(5,:)eleZZZator所响应的信号所对应的标的目的的汇折 temp=[];stopT=15;t=10; temp(1,:)=state(2,:); temp(2,:)=state(5,:); temp(3,:)=state(4,:); num=1; for i=1:length(temp) if(temp(2,i)~=0) temp0(:,num)=temp(:,i); num=num+1; end end temp=[]; temp=temp0;temp0=[]; wt=dis*t+stopT*stopTime; if(state(1,2)==1)%电梯是上止标的目的 for i=1:length(temp(1,:))-1 for j=i+1:length(temp(1,:)) if(temp(2,j)>temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; elseif(temp(1,j)<temp(1,i)&&temp(2,j)==temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; end end end if(signal(2)==1) for i=1:length(temp(1,:)) if(temp(2,i)==1&&signal(1)<temp(1,i)) temp(3,i)=temp(3,i)+stopT; end if(temp(2,i)==0) temp(3,i)=temp(3,i)+stopT; end end end if(signal(2)==0) for i=1:length(temp(1,:)) if(temp(2,i)==0&&signal(1)>temp(1,i)) temp(3,i)=temp(3,i)+stopT; end end end end if(state(1,2)==0)%电梯是下止标的目的 for i=1:length(temp(1,:))-1 for j=i+1:length(temp(1,:)) if(temp(2,j)<temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; elseif(temp(1,j)>temp(1,i)&&temp(2,j)==temp(2,i)) temp1=temp(:,j); temp(:,j)=temp(:,i); temp(:,i)=temp1; end end end if(signal(2)==1) for i=1:length(temp(1,:)) if(temp(2,i)==1&&signal(1)<temp(1,i)) temp(3,i)=temp(3,i)+stopT; end end end if(signal(2)==0) for i=1:length(temp(1,:)) if(temp(2,i)==0&&signal(1)>temp(1,i)) temp(3,i)=temp(3,i)+stopT; end if(temp(2,i)==1) temp(3,i)=temp(3,i)+stopT; end end end end awt=(wt+sum(temp(3,:)))/(length(temp(3,:))+1); %计较长候梯率 tempLwp=[temp(3,:),wt]; lwpNum=0; for i=1:length(tempLwp) if(tempLwp(i)>60) lwpNum=lwpNum+1; end end lwp=lwpNum/length(tempLwp); tempTrip=temp(3,:); %计较均匀乘梯光阳tripTime; %t电梯走一层所用的光阳stopT电梯停站所用的光阳 %state(2,:)eleZZZator所响应的信号汇折 %state(3,:)eleZZZator所响应的停站汇折 %state(4,:)eleZZZator所响应的信号所对应的信号候梯光阳的汇折 %state(5,:)eleZZZator所响应的信号所对应的标的目的的汇折 for i=2:length(tempTrip) tripTime(i-1)=tempTrip(i)-tempTrip(i-1); end AtripTime=sum(tripTime)/length(tripTime); %计较拥挤度 jam=state(1,3); element=[awt lwp AtripTime jam dis sst]; end