资源简介
应用社会力模型,模拟一个人群疏散或人行道(斑马线)对流的过程。熟悉行人模型及其仿真过程。
社会力模型(Social-Force Model)是 D. Helbing 与 P. Molnár 于1995年提出的,并在之后不断完善的理论模型。
在2000年, Dirk Helbing 的一篇NATURE文章发表了,题目是 “Simulating dynamical features of escape panic”, 文中提出了社会力模型,一种描述人与人之间避碰的心理力。

代码片段和文件信息
import numpy as np
import numpy.random as nr
from component import BFS as bfs
from component import person
class ForceMap:
def __init__(self graph width height x y num):
self.A = 2000
self.B = 0.02
self.r = 0.3
self.k = 480000
self.K = 960000
# self.A = 2000
# self.B = 0.08
# self.r = 0.2
# self.k = 120000
# self.K = 240000
self.crowd = []
self.width = height
self.height = width
self.distMap = bfs.BFS(graph width height y x).dist
self.randomPos(height width num)
def randomPos(self width height num): # 随机生成行人位置,行人不会在墙内,多个行人也不会出现在同一块中
i = 0
tmp = []
while i < num:
px = nr.randint(1 width - 1)
py = nr.randint(1 height - 1)
if self.distMap[px py] != -1:
if (px py) not in tmp:
tmp.append((px py))
self.crowd.append(person.Person(px + 0.5 py + 0.5 self.r))
i += 1
def obstacleMap(self): # 导出障碍地图格式字符串
st = ‘[‘
for i in range(self.height):
for j in range(self.width):
if self.distMap[i j] == -1:
st += ‘[{}{}]‘.format(i j)
st += ‘]‘
return st
def personMap(self): # 导出行人位置图字符串
plist = []
for p in self.crowd:
plist.append([round(p.pos[0] 5) round(p.pos[1] 5) p.r])
return plist
def clear(self): # 清空上一轮计算的力
for p in self.crowd:
p.clearForce()
def setDir(self): # 确定每个行人的寻路方向
for p in self.crowd:
x = int(p.pos[0])
y = int(p.pos[1])
nd = self.distMap[x y]
if nd - self.distMap[x - 1 y] == 1:
p.setDir(np.array([-1 0]))
if nd - self.distMap[x + 1 y] == 1:
p.setDir(np.array([1 0]))
if nd - self.distMap[x y - 1] == 1:
p.setDir(np.array([0 -1]))
if nd - self.distMap[x y + 1] == 1:
p.setDir(np.array([0 1]))
def g(self dis):
if dis <= 0:
return 0
else:
return dis
def wallR(self i x y):
for xi in range(x + 1 self.width):
if self.distMap[xi y] == -1:
return xi - self.crowd[i].pos[0]
return self.width
def wallL(self i x y):
for xi in range(x - 1 -1 -1):
if self.distMap[xi y] == -1:
return self.crowd[i].pos[0] - xi - 1
return self.width
def wallU(self i x y):
for yi in range(y + 1 self.height):
if self.distMap[x yi] == -1:
return yi - self.crowd[i].pos[1]
return self.height
def wallD(self i x y):
for yi in range(y - 1 -1 -1):
if self.distMap[x yi] == -1:
return self.crowd[i].pos[1] - yi - 1
return self.heig
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-12-26 09:14 Social_Force\.git\
目录 0 2018-12-11 15:58 Social_Force\.git\branches\
文件 11 2018-12-25 01:01 Social_Force\.git\COMMIT_EDITMSG
文件 269 2018-12-11 15:58 Social_Force\.git\config
文件 73 2018-12-11 15:58 Social_Force\.git\desc
文件 23 2018-12-11 15:58 Social_Force\.git\HEAD
目录 0 2018-12-11 15:58 Social_Force\.git\hooks\
文件 478 2018-12-11 15:58 Social_Force\.git\hooks\applypatch-msg.sample
文件 896 2018-12-11 15:58 Social_Force\.git\hooks\commit-msg.sample
文件 3327 2018-12-11 15:58 Social_Force\.git\hooks\fsmonitor-watchman.sample
文件 189 2018-12-11 15:58 Social_Force\.git\hooks\post-update.sample
文件 424 2018-12-11 15:58 Social_Force\.git\hooks\pre-applypatch.sample
文件 1642 2018-12-11 15:58 Social_Force\.git\hooks\pre-commit.sample
文件 1492 2018-12-11 15:58 Social_Force\.git\hooks\prepare-commit-msg.sample
文件 1348 2018-12-11 15:58 Social_Force\.git\hooks\pre-push.sample
文件 4898 2018-12-11 15:58 Social_Force\.git\hooks\pre-reba
文件 544 2018-12-11 15:58 Social_Force\.git\hooks\pre-receive.sample
文件 3610 2018-12-11 15:58 Social_Force\.git\hooks\update.sample
文件 3436 2018-12-25 17:25 Social_Force\.git\index
目录 0 2018-12-11 15:58 Social_Force\.git\info\
文件 240 2018-12-11 15:58 Social_Force\.git\info\exclude
目录 0 2018-12-11 15:58 Social_Force\.git\logs\
文件 931 2018-12-25 01:01 Social_Force\.git\logs\HEAD
目录 0 2018-12-11 15:58 Social_Force\.git\logs\refs\
目录 0 2018-12-11 15:58 Social_Force\.git\logs\refs\heads\
文件 931 2018-12-25 01:01 Social_Force\.git\logs\refs\heads\master
目录 0 2018-12-11 15:58 Social_Force\.git\logs\refs\remotes\
目录 0 2018-12-11 18:59 Social_Force\.git\logs\refs\remotes\origin\
文件 185 2018-12-11 15:58 Social_Force\.git\logs\refs\remotes\origin\HEAD
文件 715 2018-12-25 01:02 Social_Force\.git\logs\refs\remotes\origin\master
目录 0 2018-12-25 17:25 Social_Force\.git\ob
............此处省略397个文件信息
相关资源
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
- 量化交易(附python常见函数的使用方
评论
共有 条评论