Using cellular automata to simulate the evacuation of large shopping malls

Using cellular automata to simulate the evacuation of large shopping malls

In the process of modern urbanization, large shopping malls have become important places for people to shop, entertain and relax. With the expansion of the scale of the shopping mall and the increase of the flow of people, how to ensure the safety and evacuation of people in the shopping mall has become an extremely important issue. This article will use cellular automata to simulate the evacuation process of large shopping malls, and provide the corresponding MATLAB source code.

Cellular automata is a computational model that divides the space into interconnected cells and controls the evolution of the cell state through local rules. In the specific evacuation simulation of people, we divide the space in the shopping mall into grid-like cells, and each cell represents a discrete space. The cellular automaton simulates in seconds, and simulates the movement of the crowd by continuously updating the state of the cells.

When realizing the evacuation simulation of people, it is necessary to define the movement rules and avoidance strategies of people. The movement rules of personnel are determined according to the conditions such as their position, speed and surrounding obstacles, while the avoidance strategy is set to avoid collisions between personnel. In this simulation, we adopted the most basic avoidance strategy - "direction priority method", that is, each person determines the direction of progress according to the set priority order, and tries to avoid collisions with surrounding people.

The following is the cellular automata code implemented in MATLAB language:

clear;
clc;
close all;
%定义相关参数
row = 50;%商场网格行数
col = 50;%商场网格列数
peopleNum = 200;%商场内人员数量
emergency = [25,25];%紧急出口位置
speed = 5;%每秒人员移动速率

%初始化人员、墙壁和紧急出口位置
People = zeros(row,col);
Wall = zeros(row,col);
[px,py]=meshgrid(1:col,1:row);
Emergency=abs(px-emergency(1)) + abs(py-emergency(2));
for i = 1:peopleNum%随机分布人员
    while 1
        x = randi([1,row],1);
     

Guess you like

Origin blog.csdn.net/Jack_user/article/details/131746398