文件名称:路况不可知原胞自动机交通流模型-计算机系统:核心概念及软硬件实现(英文第五版 )
文件大小:835KB
文件格式:PDF
更新时间:2024-07-02 16:46:01
数学建模 matlab 小区开放
1.1路况不可知原胞自动机交通流模型 clear all; X=20;Y=20; global map xto yto; xto = [-1 0 1 0]; %方向 1,2,3,4 分别指上,右,下,左 yto = [0 1 0 -1]; global c1; global k; global Timeall; Timeall=0; %总时间统计 global Tmoveok Tmoveok = 0; %到达目的地车数 k=1; count=30; c1 = cell(1,count+1); map=ones(X,Y); %地图大小 for i=1:X %定义主干路 map(i,X)=0; map(1,i)=0; end for j=1:X/2 %定义支路 map(j,X/2+6)=0; map(X/2,j+X/2+6)=0; end map(X+1,:) = 1; map(:,Y+1) = 1; %包围主干路 map(20,20)=3; %终点坐标 carCome=abs(round(exprnd(2,1,count+1)))+1; %每隔多久产生一辆车 tc = carCome(1); for timer = 1:100 if tc == timer creatCar; if k<=count