《2014美赛A题元胞数据模型仿真matlab源程序.docx》由会员分享,可在线阅读,更多相关《2014美赛A题元胞数据模型仿真matlab源程序.docx(6页珍藏版)》请在优知文库上搜索。
1、D14*4UpdtaCoHSpcoYithVhiclo!nfo.b:匚4赖刘bziiCi*tWi2rmJIUr.9imUCpUIali3qwa自“ilfvVtolttfhiCr7YhiQVkTitrirUSpM*itbVUUUf;y.“S70XgnTHC*nTrM“Pja.TJi0Ueh.UfrlllSyclitMvrttm主函数function=main_tca()%基础变量声明%基本仿真信息(或以配置文件方式直接获得)%VolumeSimTimeTimeStep1.aneNumCeIINumVMAX=GetBasicInfoO;%生成元胞空间%CellSpace_currentCellSp
2、ace_nextstep=GenerateCellSpace(1.aneNum,CeIINum);%生成车辆空间%VehicIeSpace=GeneratevehicleSpace(VoIume);%开始仿真%CellSpace-nextstepzTraffiCSimUIating(SimTime,TimeStep,CellSpace_current,VehicleSpace,VMAX);%展示结果ResuItsPIottingO;%endfunctionCellSpace_nextstepVehicIeSpace=TrafficSimulating(SimTimeJimeStepzCellS
3、pace-currentzCellSpace-nextstep,VehicIeSpacezVMAX)%TRAFFICSIMU1.ATINGSummaryofthisfunctiongoeshere%仿真程序主体CeIISpaceJnit=CellSpace_nextstep;%读取信号配时数据SignaICycIeMat=load(,SignalCyclelnfo.ini);sCycle=SignalCydeMaM1);%周期长度SGreenTime=SignaICydeMaU2);%绿灯时长SRedTime=SignalCydeMat(3);%红灯时长%是否加载换道模型1.aneChangi
4、ngModeIINIMat=IoacIC1.aneChangingModeInfo.ini);Use1.aneChangingModeIFIag=1.aneChangingModeIINIMat(I);%时间步长和时长必须满足整除关系foriStep=IrTimeStepiSimTime%判断信号配时tCurrentMod=mod(iStep,sCycle);iftCurrentMod=O);end;%meanSpeed=ZeroS(StePNUm,1);%平均速度meanQueue=ZerOS(StePNUm,1);%平均排队长度VoIDensity=ZeroS(StePNUm,1);%密度forj=IistepNumexistedCarlDs=find(SpeedDMat(j)=O);volDensity(jzl)=sum(GetVehicle1.ength(existedCarlDs)/(1.aneNum*CeIINum);meanQueue(jxl)=sum(GetVehicle1.ength(find(SpeedDMat(j)=O);end;%end