注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Mister.Hu(巷里人家)

Go abroad!

 
 
 

日志

 
 
关于我

A campus photograph palyer,an enthusiastic reader,a solitary writer,a future traffic engineer.

网易考拉推荐

The first part(Four days totally to accomplish it ,maybe more than four days to finish the other.)  

2015-12-19 23:59:46|  分类: Senior |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

clear;

clc;

dbstop if error;

SM=zeros(30,10);PM=[];SVM=[];SDM=[];PP=[];%the initialization of [] matrix.

TRP={};ITRP={};FRP={};IFRP={};NRP={};% the initialization of {} matrix.

SFI0=Static_field_density;%call the function Static_field_density.m to get the Static field density(SFI0)

SFI=SFI0(2:31,2:11);

Time=exprnd(360/100,100,1);%Time can create the 1000*1 matrix indicate the time interval for each pedestrian which submit to negative exponential distribution

CSTime=cumsum(Time);

for m=1:360

SPN(m,1)=length(find(CSTime>=m-1&CSTime<m));%SPN means the number of pedestrians for every second.

end

%i means the seconds,total is 360.There is the beginning of the timing cycling.

for i=1:360

%confirm the position of initial pedes.

AllNoPed=find(SM==0);

EnNoPed=AllNoPed(AllNoPed>210);%210=30*(10-3),if 30 and 10 is changed,210 should also be changed.EnNoPed means the entrys which don't have pedestrians.

IPos=randsrc(SPN(i,1),1,EnNoPed');%IPos means the initial pedes' position.

PM=[PM;IPos];%PM means the position matrix,the people previous in time would be in front at PM.

SM(IPos)=1;

PP=(1:(size(PP,1)+SPN(i,1)))';%PP is the Pedestrians Pool.

%confirm the speed of initial pedes.

ISV=randsrc(SPN(i,1),1,[1 2 3]);

SVM=[SVM;ISV];

ISD=3*ones(SPN(i,1),1);%ISD=randsrc(SPN(i,1),1,[1 2 3]);

SDM=[SDM;ISD];

%the valuation of The Dynamic Field Intensity(DFI)

for a=1:30

for b=1:10

DFI(a,b)=(max(a-1,b-1)*size(find(SM(1:a,1:b)==1),1)*size(find(SM(1:a,1:b)==1),2))/(a*b);

end

end

CFI=DFI+SFI;%the valuation of The Comprehensive Field Intensity(CFI)

%the NaSch model to update Speed

for c=1:size(SVM,1)

if SVM(c)<3

SVM(c)=SVM(c)+1;

end

end

Rdde=randperm(size(PP,1),round(0.1*size(SVM,1)))';%0.1 means the p in NaSch model,Rdde means the Random decrease subscript of pedes.

for d=1:size(Rdde,1)

SVM(Rdde(d))=SVM(Rdde(d))-1;

end

%j means the existing pedes in the field now.the following is to find out the TRP.Each existing peds would get a row in TRP

for j=1:size(PP,1)

if SVM(j,1)==0

TRP(j,1)={[PM(j,1)]};

end

if SVM(j,1)==3&SDM(j,1)==1

ITRP(j,1)={[PM(j,1) PM(j,1)-1 PM(j,1)-2 PM(j,1)-3 PM(j,1)-30 PM(j,1)-29 PM(j,1)-28 PM(j,1)-60]};

end

if SVM(j,1)==2&SDM(j,1)==1

ITRP(j,1)={[PM(j,1) PM(j,1)-1 PM(j,1)-2 PM(j,1)-30 PM(j,1)-29]};

end

if SVM(j,1)==1&SDM(j,1)==1

ITRP(j,1)={[PM(j,1) PM(j,1)-1]};

end

if SVM(j,1)==3&SDM(j,1)==2

ITRP(j,1)={[PM(j,1) PM(j,1)-1 PM(j,1)-2 PM(j,1)-30 PM(j,1)-29 PM(j,1)-28 PM(j,1)-60 PM(j,1)-59 PM(j,1)-58]};

end

if SVM(j,1)==2&SDM(j,1)==2

ITRP(j,1)={[PM(j,1) PM(j,1)-1 PM(j,1)-29 PM(j,1)-28]};

end

if SVM(j,1)==1&SDM(j,1)==2

ITRP(j,1)={[PM(j,1)]};

end

if SVM(j,1)==3&SDM(j,1)==3

ITRP(j,1)={[PM(j,1) PM(j,1)-30 PM(j,1)-60 PM(j,1)-90 PM(j,1)-1 PM(j,1)-31 PM(j,1)-61 PM(j,1)-2]};

end

if SVM(j,1)==2&SDM(j,1)==3

ITRP(j,1)={[PM(j,1) PM(j,1)-30 PM(j,1)-60 PM(j,1)-1 PM(j,1)-31]};

end

if SVM(j,1)==1&SDM(j,1)==3

ITRP(j,1)={[PM(j,1) PM(j,1)-30]};

end

end

%we should choose from ITRP to get the final matrix TRP

for f=1:length(ITRP)

TRP(f,1)={ITRP{f}(find(ITRP{f}>0&ITRP{f}<=300))};

end

%use the SM to get FRP and NRP

for f=1:length(TRP)

FRP(f,1)={TRP{f}(find(SM(TRP{f})==0))};

MNRP(f,1)={TRP{f}(find(SM(TRP{f})==1))};

[FI0,RA0]=sort(CFI(FRP{f}));%sort FRP by CFI (ascend),RA0 is the origin rank.

FRP(f,1)={FRP{f}(RA0)};

if ~isempty(FRP{f})

NRP(f,1)={MNRP{f}(find(CFI(MNRP{f})<min(CFI(FRP{f}))))};%the CFI of NRP should less than min(CFI(FRP))

else

NRP(f,1)={[]};

end

[FI1,RA1]=sort(CFI(NRP{f}));%sort NRP by CFI (ascend),RA1 is the origin rank.

NRP(f,1)={NRP{f}(RA1)};

end

%calculate the probability of choosing NRP or FRP

SFRP=0;LFRP=0;SNRP=0;LNRP=0;PFRP=0;PNRP=0;

for f=1:length(FRP)

SFRP=SFRP+sum(CFI(FRP{f}));

LFRP=LFRP+length(FRP{f});

end

AFRP=SFRP/LFRP;

for f=1:length(NRP)

SNRP=SNRP+sum(CFI(NRP{f}));

LNRP=LNRP+length(NRP{f});

end

ANRP=SNRP/LNRP;

if LFRP~=0&LNRP~=0

SURP=1/((2*(1/AFRP))+(1/ANRP));

PFRP=SURP*2*(1/AFRP);

PNRP=SURP*(1/ANRP);

elseif LFRP~=0&LNRP==0

PFRP=1;PNRP=0;

elseif LFRP==0&LNRP~=0

PFRP=0;PNRP=1;

end

%determine the final set

SFRP=randperm(size(PP,1),round(PFRP*size(PP,1)))';%SFRP means the subscript of the people who belongs to the FRP final.

SNRP=setdiff(PP,SFRP);

%now we can update the existing pedestrians'status.

for j=1:length(PP)

if ismember(PM(j,1),[1 30 60 90])

SDM(j,1)= SDM(j,1);

PM(j,1)= PM(j,1);

elseif ismember(j,SFRP)&~isempty(FRP{j})

SDM(j,1)=randsrc(1,1,[1 2 3]);%this is just the assumption,for the test of the part one.it must be modified later.

SM(PM(j,1))=0;%as the people will depart in this condition,so the SM in this place should be 0.

PM(j,1)=FRP{j}(1,1);

else %that means the pede now has no place to go or choose the NRP.

SDM(j,1)= SDM(j,1);

PM(j,1)= PM(j,1);

end

end

SM(PM)=1;

SM([1,30,60,90])=0;%the entry should always keep empty.

STSM(:,:,i)=SM;%the STSM is used to storing the SM.

end

  评论这张
 
阅读(53)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016