一、元胞自动机简介

1 元胞自动机发展历程
最初的元胞自动机是由冯 · 诺依曼在 1950 年代为模拟生物 细胞的自我复制而提出的. 但是并未受到学术界重视.
1970 年, 剑桥大学的约翰 · 何顿 · 康威设计了一个电脑游戏 “生命游戏” 后, 元胞自动机才吸引了科学家们的注意.

1983 年 S.Wolfram 发表了一系列论文. 对初等元胞机 256 种 规则所产生的模型进行了深入研究, 并用熵来描述其演化行 为, 将细胞自动机分为平稳型, 周期型, 混沌型和复杂型.

2 对元胞自动机的初步认识
元胞自动机(CA)是一种用来仿真局部规则和局部联系的方法。典型的元胞自动机是定义在网格上的,每一个点上的网格代表一个元胞与一种有限的状态。变化规则适用于每一个元胞并且同时进行。典型的变化规则,决定于元胞的状态,以及其( 4 或 8 )邻居的状态。

3 元胞的变化规则&元胞状态
典型的变化规则,决定于元胞的状态,以及其( 4 或 8 )邻居的状态。

4 元胞自动机的应用
元胞自动机已被应用于物理模拟,生物模拟等领域。

5 元胞自动机的matlab编程
结合以上,我们可以理解元胞自动机仿真需要理解三点。一是元胞,在matlab中可以理解为矩阵中的一点或多点组成的方形块,一般我们用矩阵中的一点代表一个元胞。二是变化规则,元胞的变化规则决定元胞下一刻的状态。三是元胞的状态,元胞的状态是自定义的,通常是对立的状态,比如生物的存活状态或死亡状态,红灯或绿灯,该点有障碍物或者没有障碍物等等。

6 一维元胞自动机——交通规则
定义:
6.1 元胞分布于一维线性网格上.
6.2 元胞仅具有车和空两种状态.

7 二维元胞自动机——生命游戏
定义:
7.1 元胞分布于二维方型网格上.
7.2 元胞仅具有生和死两种状态.

元胞状态由周围八邻居决定.
规则:

骷髅:死亡;笑脸:生存
周围有三个笑脸,则中间变为笑脸
少于两个笑脸或者多于三个,中间则变死亡。

8 什么是元胞自动机
离散的系统: 元胞是定义在有限的时间和空间上的, 并且元 胞的状态是有限.
动力学系统: 元胞自动机的举止行为具有动力学特征.
简单与复杂: 元胞自动机用简单规则控制相互作用的元胞 模拟复杂世界.


9 构成要素

(1)元胞 (Cell)

元胞是元胞自动机基本单元:
状态: 每一个元胞都有记忆贮存状态的功能.
离散: 简单情况下, 元胞只有两种可能状态; 较复杂情况下, 元胞具有多种状态.
更新: 元胞的状态都安照动力规则不断更新.
(2)网格 (Lattice)
不同维网格

常用二维网格

(3)邻居 (Neighborhood)

(4)边界 (Boundary)

反射型:以自己作为边界的状态
吸收型:不管边界(车开到边界就消失)

(5)规则(状态转移函数)
定义:根据元胞当前状态及其邻居状况确定下一时刻该元胞状态的动力学函数, 简单讲, 就是一个状态转移函数.
分类 :
总和型: 某元胞下时刻的状态取决于且仅取决于它所有邻居 的当前状态以及自身的当前状态.
合法型: 总和型规则属于合法型规则. 但如果把元胞自动机 的规则限制为总和型, 会使元胞自动机具有局限性.
(6)森林火灾

绿色:树木;红色:火;黑色:空地。
三种状态循环转化:
树:周围有火或者被闪电击中就变成火。
空地:以概率p变为树木
理性分析:红为火;灰为空地;绿是树

元胞三种状态的密度和为1

火转化为空地的密度等于空地转换为树的密度(新长出来的树等于烧没的树)

f是闪电的概率:远远小于树生成的概率;T s m a x T_{smax}T smax
​是一大群树被火烧的时间尺度
程序实现
周期性边界条件
购进啊

其中的数字为编号
构建邻居矩阵

上面矩阵中的数字编号,对应原矩阵相同位置编号的上邻居编号,一 一对应
同样道理:

(7)交通概念
车距和密度

流量方程

守恒方程

时空轨迹(横轴是空间纵轴为时间)

红线横线与蓝色交点表示每个时间车的位置。
如果是竖线则表示车子在该位置对应的时间

宏观连续模型:

最常用的规则:

红色条表示速度是满的。

1 加速规则:不能超过v m a x ( 2 格 / s ) v_{max}(2格/s)v
max(2格/s)
2 防止碰撞:不能超过车距

理论分析:

结果分析: 密度与流量

第一个图:横坐标是归一化后的密度,纵坐标是车流量。第二个图:理论值与CA的结果

结果分析: 时空轨迹

中间的深色区域是交通堵塞的区域。

二、案例及部分源代码

1 案例
基于元胞自动机的人员疏散模型研究,可以根据未疏散人员位置信息、为环境信息、为未疏散人数、未疏散人员个体特性、为场所区域宽、为区域长、元胞边长、出口信息;同时可以改变人数、出口大小,出口位置分布,火灾扩散速度等参数,人员移动速度,4邻域或8邻域模式。并有GUI界面和动图展示,美观形象。
2 部分源代码

function varargout = renyuanshusan(varargin)
% RENYUANSHUSAN M-file for renyuanshusan.fig
%      RENYUANSHUSAN, by itself, creates a new RENYUANSHUSAN or raises the existing
%      singleton*.
%
%      H = RENYUANSHUSAN returns the handle to a new RENYUANSHUSAN or the handle to
%      the existing singleton*.
%
%      RENYUANSHUSAN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in RENYUANSHUSAN.M with the given input arguments.
%
%      RENYUANSHUSAN('Property','Value',...) creates a new RENYUANSHUSAN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before renyuanshusan_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to renyuanshusan_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help renyuanshusan% Last Modified by GUIDE v2.5 08-Mar-2014 16:52:27% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @renyuanshusan_OpeningFcn, ...'gui_OutputFcn',  @renyuanshusan_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before renyuanshusan is made visible.
function renyuanshusan_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to renyuanshusan (see VARARGIN)% Choose default command line output for renyuanshusan
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes renyuanshusan wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = renyuanshusan_OutputFcn(~, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Get default command line output from handles structure
varargout{1} = handles.output;function edit1_Callback(~, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
end% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
x=get(hObject,'value');
set(handles.text16,'string',num2str(x));% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor',[.9 .9 .9]);
end

三、运行结果

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
[3]【数学建模】元胞自动机.博主:二进制 人工智能

【元胞自动机】基于matlab元胞自动机地铁火灾疏散模型【含Matlab源码 246期】相关推荐

  1. 【Matlab生物电信号】生物电信号仿真【含GUI源码 684期】

    一.代码运行视频(哔哩哔哩) [Matlab生物电信号]生物电信号仿真[含GUI源码 684期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]董兵,超于毅,李 ...

  2. 【Matlab语音分析】语音信号分析【含GUI源码 1718期】

    一.代码运行视频(哔哩哔哩) [Matlab语音分析]语音信号分析[含GUI源码 1718期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]韩纪庆,张磊,郑铁 ...

  3. 【Matlab身份证识别】身份证号码识别【含GUI源码 014期】

    一.代码运行视频(哔哩哔哩) [Matlab身份证识别]身份证号码识别[含GUI源码 014期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 蔡利梅.MAT ...

  4. 【Matlab车牌识别】停车计费系统【含GUI源码 735期】

    一.代码运行视频(哔哩哔哩) [Matlab车牌识别]停车计费系统[含GUI源码 735期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 蔡利梅.MATLA ...

  5. 【Matlab水果识别】自助水果超市【含GUI源码 594期】

    一.代码运行视频(哔哩哔哩) [Matlab水果识别]自助水果超市[含GUI源码 594期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]倪云峰,叶健,樊娇娇 ...

  6. 【Matlab验证码识别】遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别【含GUI源码 1694期】

    一.代码运行视频(哔哩哔哩) [Matlab验证码识别]遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别[含GUI源码 1694期] 二.matlab版本及参考文献 1 matlab ...

  7. 【Matlab人脸识别】BP神经网络人脸识别(含识别率)【含GUI源码 891期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]BP神经网络人脸识别(含识别率)[含GUI源码 891期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] ...

  8. 【Matlab人脸识别】形态学教室人数统计(带面板)【含GUI源码 1703期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]形态学教室人数统计(带面板)[含GUI源码 1703期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟 ...

  9. 【Matlab人脸识别】人脸实时检测与跟踪【含GUI源码 673期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]人脸实时检测与跟踪[含GUI源码 673期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟逸凡,柳益君 ...

  10. 【Matlab图像融合】小波变换遥感图像融合【含GUI源码 744期】

    一.代码运行视频(哔哩哔哩) [Matlab图像融合]小波变换遥感图像融合[含GUI源码 744期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 包子阳,余 ...

最新文章

  1. 坚持不懈续集 (二) 初学者挑战学习Python编程30天
  2. python截取html图片大小,Python打开html文件,截取屏幕截图,裁剪并保存为图像
  3. python自学 知乎-学习Python的迷茫,如何高效有趣地学习Python?
  4. struct 与class 的区别?
  5. 华思视频 CCNA 听而思
  6. 任何项目都适用的CMakeLists配置
  7. 夸大 iPhone 防水功能?苹果遭起诉,曾已被罚 1200 万美元
  8. ElementUI:没有dist文件夹,vue项目打包后字体图标失效,变成小方框解决方案
  9. js ...运算符_JS专题之深浅拷贝
  10. python哈希类型_python 入门之 – hash(十七)
  11. 《Involution:Inverting the Inherence of Convolution for Visual Recognition》论文笔记
  12. 中环混改尚存变数 高调的TCL要上演“资本魔输”?
  13. php定时自动发送邮件(从数据库取数据)(超详细版本)
  14. OpenFOAM当中监测力和阻力系数
  15. 基于matlab的调用电脑摄像头,截取视频图像识别颜色
  16. 如何查看计算机主机端口型号,电脑端口号怎么查看(怎么查自己电脑的端口号)...
  17. 因特网上的英语学习资源
  18. 文件上传一句话木马getshell
  19. 七、Kali Linux 2 渗透攻击
  20. 计算机毕业设计java+ssm理论课_考勤,作业,签到管理系统(源码+系统+mysql数据库+Lw文档)

热门文章

  1. 猿创征文|弃文从工,从小白到蚂蚁工程师,我的 Java 成长之路
  2. 我有几张阿里云幸运券分享给你,用券购买或者升级阿里云相应产品会有特惠惊喜哦!把想要买的产品的幸运券都领走吧!快下手,马上就要抢光了。
  3. 记录一下落地网关soul(shenyu)过程中的一些实践
  4. 以太坊存储项目Swarm (代币bzz)1.0 主网正式上线
  5. 模拟电子_热敏电阻PTC和NTC的区别与作用
  6. 通用型免疫(共)沉淀(IP/Co-IP)工具箱(磁珠)实验
  7. 【论文笔记】BMVC2009 Integral Channel Features
  8. NLP专题:LSA浅层语义分析
  9. 深度学习-浅层神经网络
  10. SSM Service ServiceImpl 优缺点