I. Case Introduction (With course Report)
Urban scale designXiongan New Area covers a total area of about 2,000 square kilometers, covering xiongxian county, Rongcheng County and Anxin County of Hebei Province and some surrounding areas, and is located in the hinterland of Beijing, Tianjin and Baoding. This area was searched and extracted by ArcGIS map software, as shown in the regional map below.For better simulation of Xiongan New Area, the map of Xiongan New Area is first captured in the map, and then the edge contour is extracted and the undevelopable areas such as Baiyangdian are removed to obtain the pre-processed image. Finally, MATlAB is used for image grayscale and binarization processing, as shown in the figure below. Provide evolution map for subsequent cellular automata.The general steps of urban planning model are as follows: firstly, the main elements of urban planning model are determined: cellular, cellular space, cellular state, cellular neighborhood and transformation rules are analyzed to simulate urban spatial structure; Determine the parameters of the model: reproduction parameters, diffusion parameters, propagation parameters and parameters subject to planning constraints determine the definition of cellular transformation rules required by the model for urban development simulation. (1) Pixel of xiongan New Area map extracted in this paper is, and cellular space is defined as; The cellular state corresponds to four states in this region: unurbanized (i.e., undeveloped areas that can be developed), urbanized, expanded central city, and undeveloped (such as Baiyangdian and other areas). The state of the land is coded.
2. Introduction of cellular automata
Cellular automata was originally proposed by Von Neumann in the 1950s to simulate the self-replication of biological cells. Cellular automata came to the attention of scientists in 1970 when John Holden Conway of Cambridge University designed a computer game called “The Game of Life”.
S. Wolram published a series of papers in 1983. In this paper, the models generated by 256 rules of elementary cellular machine are studied and their evolution is described by entropy. Cellular automata are classified into stationary, periodic, chaotic and complex types.
Cellular automata (CA) is a method used to simulate local rules and local connections. Cellular automata are typically defined on a grid, where each point represents a cell and a finite state. The change rule applies to each cell and simultaneously. The rules of change typically depend on the state of the cell and the state of its (4 or 8) neighbors.
Change rules for 3 cells & change rules for cell states typically depend on the state of a cell and the states of its (4 or 8) neighbors.
Application of cellular automata Cellular automata has been applied to physical simulation, biological simulation and other fields.
5 Cellular automata MATLAB programming combined with the above, we can understand cellular automata simulation needs to understand three points. One is cellular, which can be understood as a square block composed of one or more points in the matrix in MATLAB. Generally, we use a point in the matrix to represent a cellular. The second is the change rule. The change rule of cellular determines the state of cellular at the next moment. The third is the state of the cell. The state of the cell is self-defined and usually opposite, such as the living state or death state of the creature, the red light or the green light, the point with or without obstacles, and so on.
One dimensional cellular automata — traffic rulesDefinition: 6.1 Cells are distributed on a one-dimensional linear grid. 6.2 Cells have only two states: car and empty. Two-dimensional cellular automata — The Game of lifeDefinition: 7.1 Cells are distributed on a two-dimensional square grid. 7.2 Cells have only two states of life and death.The cellular state is determined by its eight neighbors. Rules:Skull: death; Smiley face: if there are three smiley faces around you, the middle will become smiley face less than two or more smiley faces, and the middle will become death.
What is cellular automata discrete system: cellular is defined in finite time and space, and the state of cellular is finite. Dynamical system: The behavior of cellular automata is characterized by dynamics. Simplicity and complexity: Cellular automata simulate complex worlds by controlling interacting cells with simple rules.
9 Constituent Elements (1) Cell Cell is the basic unit of cellular automata: state: Every cell has the function of memory storage state. Discrete: In the simple case, there are only two possible states of cellular; In more complex cases, cells have multiple states. Update: cellular states are constantly updated according to dynamic rules.(2) LatticeDifferent dimensional gridCommon two-dimensional grid (3) Neighborhood (4) Boundary Reflective: the state with itself as the boundary absorbing: regardless of the boundary (the car disappears when it reaches the boundary)
(5) Rules (State transition function)Definition: The dynamic function of the cellular state at the next moment is determined according to the current state of the cell and its neighbors. Simply speaking, it is a state transfer function. Classification: Summation type: the state of a cell depends on and only depends on the current state of all its neighbors and its own current state. Legal: The sum rule belongs to the legal rule. However, if the rules of cellular automata are limited to summation type, cellular automata will be limited.6. Forest fires Green: trees; Red: fire; Black: empty space. Tree: Becomes fire when there is fire around or when struck by lightning. Open space: with probability P into trees rational analysis: red for fire; Ash is empty space; Green is the treeThe sum of the three states of cell density is 1The density of fire to open space is equal to the density of open space to trees (new trees are equal to burned trees)F is the probability of lightning: much less than the probability of tree generation; T smax T_{smax}T smax is the time scale for a whole bunch of trees to burnProgram implementationPeriodic boundary condition purchasesThe numbers are numbered to construct the neighbor matrixThe numbers in the above matrix correspond to the upper neighbor numbers of the same position numbers of the original matrix, and 1 and 1 correspond to the same principle: (7) Transportation conceptDistance and densityFlow equationConservation equationSpacetime trajectory (horizontal axis is space and vertical axis is time)The intersection of the red line and the blue line indicates the position of the car at each time. If it’s a vertical line, it’s the time the car was in that position
Macro continuous model:The most commonly used rules:The red bar means the velocity is full.
1 Acceleration rule: do not exceed v max (2 grids /s) v_{Max} (2 grids /s) v Max (2 grids /s) 2 Collision prevention: do not exceed the vehicle distance
Theoretical analysis:Result analysis: density and flowThe first graph: the abscissa is the normalized density, and the ordinate is the traffic flow. Second figure: theoretical value versus CA result
Result analysis: space-time trajectoryThe dark area in the middle is a traffic jam.
Three, some source code
clear; close all I=imread('city.png'); level=graythresh(I); % image gray processing bw= IM2bw (I,level); % image binarization I=bw; cells=double(I); Button plotButton =uicontrol('style'.'pushbutton'.'string'.'Run'.'fontsize'.12.'position'[100.400.50.20],...
'callback'.'run=1; ');
erasebutton=uicontrol('style'.'pushbutton'.'string'.'Stop'.'fontsize'.12.'position'[300.400.50.20],...
'callback'.'freeze=1; ');
number=uicontrol('style'.'text'.'string'.'1'.'fontsize'.12.'position'[20.400.50.20]); % initialize cells(33.44) =2;
cells(88.31) =2;
cells(33.80) =2; The % parameter defines Kuosan =0.2; fanzhi=0.2; chuanbo=0.2; chengshihua=0.0004; sch=[]; skz=[]; t=1;
[x,y]=size(cells);
run=0;
freeze=0;
stop=0;
while (stop==0)
if(run==1)
for i=1:x
for j=1:y
if(cells(i,j)~=1)
if(cells(i,j)==0) % natural growthif(rand<chengshihua)
cells(i,j)=2;
end
if(aroundcenter(i,j,cells))
if(rand<chuanbo)
cells(i,j)=2;
end
end
end
if(cells(i,j)==2 && rand<kuosan)% boundary growthif(exist1(i,j,cells))
m=1+3*rand;
switch m
case 1
ii=i- 1; jj=j;case 2
otherwise 4
ii=i+1; jj=j;end
if(cancity(ii,jj,cells))
cells(ii,jj)=2;
end
end
end
if(cells(i,j)==2 && exist1(i,j,cells))% New extension center typeif(rand<fanzhi)
if(cancity(i,j,cells))
cells(i,j)=3;
end
end
end
end
end
end
ch=0; kzch=0;
for i=1:x
for j=1:y
if(cells(i,j)==2) ch=ch+1;end
if(cells(i,j)==3) kzch=kzch+1;end
end
end
sch(t)=ch; skz(t)=kzch; t=t+1;
[A,B]=size(cells);
Area(1:A,1:B,1)=zeros(A,B);
Area(1:A,1:B,2)=zeros(A,B);
Area(1:A,1:B,3)=zeros(A,B);
for i=1:A
for j=1:B
if cells(i,j)==1
end
end
end
pause(0.0005); Area=uint8(Area); Area=imagesc(Area); Step % meter stepnumber =1+str2num(get(number,'string'));
set(number,'string',num2str(stepnumber));
end
if freeze==1
run=0;
freeze=0;
end
drawnow
end
function result=cancity(i,j,cells)
s=0
if(cells(i- 1,j- 1) = =1) s=s+1;end
if(cells(i- 1,j)==1) s=s+1;end
if(cells(i- 1,j+1) = =1) s=s+1;end
if(cells(i,j- 1) = =1) s=s+1;end
if(cells(i,j+1) = =1) s=s+1;end
if(cells(i+1,j- 1) = =1) s=s+1;end
if(cells(i+1,j)==1) s=s+1;end
if(cells(i+1,j+1) = =1) s=s+1;end
if(s>=4)
result=0;
else
result=1;
end
end
function result= exist1(i,j,cells)
a=0;
if(cells(i- 1,j)==2) a=a+1; end
if(cells(i+1,j)==2) a=a+1;end
if(a>=2)
result=1;
else
result=0;
end
end
Copy the code
4. Operation results
City scale simulation The initial stage
Figure 7. Initial evolution stage of cellular automataThe intermediate stage
FIG. 8 Intermediate evolution stage of cellular automataThe forward phase
FIG. 9 Cellular automata evolution in the long term
Matlab version and references
1 matlab version 2014A
2 Reference [1] CAI Limei. MATLAB Image Processing — Theory, Algorithm and Case Analysis [M]. Tsinghua University Press, 2020. [2] Yang Dan, ZHAO Haibin, LONG Zhe. Examples of MATLAB Image Processing In detail [M]. Tsinghua University Press, 2013. [3] Zhou Pin. MATLAB Image Processing and Graphical User Interface Design [M]. Tsinghua University Press, 2013. [4] LIU Chenglong. Proficient in MATLAB Image processing [M]. Tsinghua University Press, 2015. [5] MENG Yifan, LIU Yijun. [6] Zhang Na, Liu Kun, Han Meilin, Chen Chen. A PCA-SVM based Face Recognition Method [J]. Science and Technology Vision, 2021,(07) A face recognition algorithm based on PCA and LDA fusion [J]. Electronic measurement technology, 2020,43(13) [7] Chen yan. [8] dai lirong, Chen wanmi, guo sheng. Analysis of face recognition method based on BP neural network [J]. Information and computer (theory edition), 2020,32(23). Research on face recognition based on skin color model and SURF algorithm [J]. Industrial control computer, 2014,27(02)