[cellular automata] two lane traffic flow model based on MATLAB cellular automata, including right driving [including Matlab source code phase 231]

Jiang Xiaohu 2021-08-07 09:44:27 阅读数:554

本文一共[544]字,预计阅读时长:1分钟~
cellular automata lane traffic flow

One 、 brief introduction

A preliminary understanding of cellular automata
A preliminary understanding of cellular automata
Cellular automata (CA) It is a method used to simulate local rules and local connections . Typical element
Cellular automata is defined on a grid , The grid at each point represents a cell and a finite shape
state . The change rule applies to each cell and is performed simultaneously .
The change rules of cells & Cellular state
Typical change rules , It depends on the state of the cell , And its ( 4 or 8 ) The state of the neighbors .
Application of cellular automata
Cellular automata has been applied to physical simulation , Biological simulation and other fields .
Of cellular automata matlab Programming
Combined with the above , We can understand that cellular automata simulation needs to understand three points . One is the cell , stay matlab Can be understood as a square block composed of one or more points in the matrix , Generally, we use a point in the matrix to represent a cell . Second, change rules , The change rule of the cell determines the state of the cell at the next moment . The third is the state of cells , The state of the cell is custom , It's usually a state of opposition , For example, the living state or death state of organisms , Red or green , There are obstacles or no obstacles at this point, etc .
ad locum , Let's discuss the application of cell in traffic flow model . as everyone knows , The simplest cellular traffic flow model is wolfram Proposed Elementary CA Of the 184 Number rule , Its evolution rules are as follows :

figure 1:wolfram Of 184 Number rule

This rule allows the cell to simulate the feeling of traffic flow , Why is it a feeling , Because everyone seems to see a box or a car , Moving forward , But it doesn't simulate many phenomena in traffic flow . And then there's this NaSch The rules were put forward , This rule can be said to be the ancestor of all cellular traffic flow models , Many of the latter rules have evolved from this rule . The two lane model that we are discussing today is also based on NaSch Improved from the model , Briefly discuss NaSch Model , Then it further leads to the right driving model to be explained in this paper .

NaSch The rules :

(1) Speed up ,

(2) Slow down ,

(3) With probability p Random slowing down speed ,

(4) March on ,

You can see ,NaSch There are only four simple rules , But it simulates the most basic thing of traffic flow , It can be seen from its space-time map :
 Insert picture description here
figure 2:Density=0.15,Vmax=5

figure 2 Is the length of the cell 1000, The time step is 500 The time-space map obtained when . There are also corresponding basic diagrams including flow density diagram and velocity density diagram .

Next, we took another step away from our right-hand driving model , before this , Let's introduce based on NaSch Two lane model STNS, With a two lane model , The right-hand model is no longer difficult .

STNS The rules :
 Insert picture description here
It can be downloaded from STNS See in the rules of , In order to achieve two lane CA Traffic flow model , We are essentially right NaSch The change to the model is just the addition of a lane change rule , And the lane changing rules seem so easy to understand and realistic . This is it. CA The charm of , By slightly changing the rules , We can achieve some of the results we want , Later, we will use the right-hand driving model to explain this . Of course, the rules are CA The nightmare of , We usually don't know when to use CA What are the rules of .

Now I'll introduce another rule , Under this rule CA Can be realized 2014MCM The rules for driving on the right in the race , At the same time, it can be expected that , Modify some more rules , It can still be fully implemented 2014MCM match A Any question in the question , But this is not discussed here .

Keep-Right Rule:
 Insert picture description here
 Insert picture description here
thus , The right-hand driving rule is realized by cellular automata . The following is to use Matlab Simulation diagram of the implementation :

Two 、 Source code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A Two-Lane Cellular Automaton Traffic Flow Model with the Keep-Right Rule
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
close all;
B=3; % The number of the lanes
plazalength=100; % The length of the simulation highways
h=NaN; % The handle of the image
[plaza,v]=create_plaza(B,plazalength);
h=show_plaza(plaza,h,0.1);
iterations=1000; % Number of iterations
probc=0.1; % Density of the cars
probv=[0.1 1]; % Density of two kinds of cars
probslow=0.3; % The probability of random slow
Dsafe=1; % The safe gap distance for the car to change the lane
VTypes=[1,2]; % Maximum speed of two different cars
[plaza,v,vmax]=new_cars(plaza,v,probc,probv,VTypes);% Generate cars on the lane
size(find(plaza==1))
PLAZA=rot90(plaza,2);
h=show_plaza(PLAZA,h,0.1);
for t=1:iterations;
size(find(plaza==1))
PLAZA=rot90(plaza,2);
h=show_plaza(PLAZA,h,0.1);
[v,gap,LUP,LDOWN]=para_count(plaza,v,vmax);
[plaza,v,vmax]=switch_lane(plaza,v,vmax,gap,LUP,LDOWN);
[plaza,v,vmax]=random_slow(plaza,v,vmax,probslow);
[plaza,v,vmax]=move_forward(plaza,v,vmax);
end

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.

3、 ... and 、 Running results

 Insert picture description here

Four 、 remarks

edition :2014a

版权声明:本文为[Jiang Xiaohu]所创,转载请带上原文链接,感谢。 https://car.inotgo.com/2021/08/20210807094123004r.html