[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,69 +2,188 @@
|
||||
id: wiki-2026-0508-pedestrian-modeling
|
||||
title: Pedestrian Modeling
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-PEDMOD-001]
|
||||
aliases: [Crowd Simulation, Pedestrian Dynamics, Foot Traffic Modeling]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [auto-reinforced, simulation, urban-planning, crowd-dynamics, safety]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [simulation, agent-based, urban-planning, crowd-dynamics]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: Python
|
||||
framework: Mesa / SUMO / PyTorch
|
||||
---
|
||||
|
||||
# [[Pedestrian-Modeling|Pedestrian-Modeling]]
|
||||
# Pedestrian Modeling
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "군중 속의 질서와 혼돈을 수치화하다: 보행자 한 명 한 명의 의사결정과 상호작용을 컴퓨터로 시뮬레이션하여, 가장 안전하고 효율적인 도시 공간을 설계하는 기술."
|
||||
## 매 한 줄
|
||||
> **"매 보행자는 force field 위의 agent"**. 1995년 Helbing의 Social Force Model이 분야를 정의했고, 2026 현재 ML-augmented agent-based simulation (Mesa 3.x, MATSim, SUMO)이 evacuation planning, station design, retail flow 분석의 표준 도구다.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
보행자 모델링(Pedestrian Modeling)은 공공 장소나 건물 내부에서 사람들의 이동 패턴을 예측하고 제어하기 위한 시뮬레이션 기법입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **주요 모델링 방식**:
|
||||
* **Social Force Model (사회적 힘 모델)**: 사람을 입자로 보고, 목표 지점에 도달하려는 '인력'과 타인 및 벽을 피하려는 '척력'의 합으로 움직임을 설명.
|
||||
* **Cellular Automata (셀 오토마타)**: 공간을 격자로 나누고 각 셀 마다 보행자의 유무와 이동 규칙을 적용하여 대규모 인파의 흐름을 효율적으로 계산.
|
||||
* **Agent-Based Modeling (ABM)**: 각 보행자(에이전트)에게 개별적인 목적, 시야, 욕구를 부여하여 지능적인 회피 및 경로 선택 모사.
|
||||
2. **적용 분야**:
|
||||
* **피난 시뮬레이션**: 화재나 테러 시 병목 현상(Bottleneck)이 발생하는 구간을 찾아 출구 재배치.
|
||||
* **공공 교통 설계**: 지하철 환승 통로나 광장의 유동 인구 흐름 최적화.
|
||||
* **엔터테인먼트**: 오픈 월드 게임이나 영화의 배경 군중(Crowd) 렌더링.
|
||||
3. **검증 지표**:
|
||||
* Level of Service (LOS): 보행자 밀도와 이동 속도를 기준으로 공간의 쾌적함을 평가하는 척도.
|
||||
### 매 모델 계열
|
||||
- **Macroscopic**: fluid-like density/flow PDE — Hughes model, LWR for crowds. 매 large-scale aggregate.
|
||||
- **Mesoscopic**: cellular automata (Burstedde 2001) — discrete grid + transition probabilities.
|
||||
- **Microscopic**: 개별 agent — Social Force (Helbing-Molnár), ORCA (reciprocal velocity obstacles), RVO2.
|
||||
- **Data-driven**: GNN trajectory prediction (Social-LSTM, Trajectron++, EqMotion 2025).
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 초기 모델은 보행자를 단순한 물리 입자로 취급하여 '충동'이나 '패닉' 시 발생하는 비이성적 행동을 놓쳤으나, 현대 모델은 심리학적 요소를 RL 보상 함수에 통합하여 훨씬 사실적인 군중 거동을 보여줌.
|
||||
- **정책 변화(RL Update)**: 이태원 참사와 같은 대규모 군중 사고 이후, 지자체의 축제나 대규모 행사 허가 시 '보행자 시뮬레이션 결과 기반 안전 대책' 제출이 행정적 필수 정책으로 강화되고 있음.
|
||||
### 매 Social Force 핵심
|
||||
- 매 보행자 i 의 motion equation: `m_i * dv_i/dt = F_desired + ΣF_social + ΣF_obstacle + ξ`.
|
||||
- `F_desired = (v_target - v_i) / τ` — 매 goal-directed term.
|
||||
- `F_social = A * exp((r_ij - d_ij)/B) * n_ij` — 매 repulsion exponential.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related**: Agent-Based Modeling, Complex Adaptive[[_system|system]]s, Urban Dynamics, [[Safety & Reliability|Safety & Reliability]]
|
||||
- **Modern Tech/Tools**: Any[[Logic|Logic]], MassMotion, Legion.
|
||||
---
|
||||
### 매 응용
|
||||
1. Evacuation simulation (역, stadium, 고층빌딩).
|
||||
2. Urban design (sidewalk width, crossing geometry, wayfinding).
|
||||
3. Retail analytics (store layout heatmap).
|
||||
4. Autonomous robot navigation in crowds.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### Social Force Model (Mesa 3.x)
|
||||
```python
|
||||
import numpy as np
|
||||
from mesa import Agent, Model
|
||||
from mesa.space import ContinuousSpace
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
class Pedestrian(Agent):
|
||||
def __init__(self, model, pos, target, v_desired=1.34):
|
||||
super().__init__(model)
|
||||
self.pos = np.array(pos, dtype=float)
|
||||
self.vel = np.zeros(2)
|
||||
self.target = np.array(target, dtype=float)
|
||||
self.v_desired = v_desired
|
||||
self.tau = 0.5 # relaxation time
|
||||
self.radius = 0.3
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
def desired_force(self):
|
||||
direction = self.target - self.pos
|
||||
norm = np.linalg.norm(direction) + 1e-9
|
||||
e = direction / norm
|
||||
return (self.v_desired * e - self.vel) / self.tau
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
def social_force(self, A=2000, B=0.08):
|
||||
f = np.zeros(2)
|
||||
for other in self.model.agents:
|
||||
if other is self: continue
|
||||
r_ij = self.radius + other.radius
|
||||
d_vec = self.pos - other.pos
|
||||
d_ij = np.linalg.norm(d_vec) + 1e-9
|
||||
n_ij = d_vec / d_ij
|
||||
f += A * np.exp((r_ij - d_ij) / B) * n_ij
|
||||
return f
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
def step(self):
|
||||
f = self.desired_force() + self.social_force()
|
||||
self.vel += f * self.model.dt
|
||||
speed = np.linalg.norm(self.vel)
|
||||
if speed > 1.5 * self.v_desired:
|
||||
self.vel *= 1.5 * self.v_desired / speed
|
||||
self.pos += self.vel * self.model.dt
|
||||
```
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
### ORCA (RVO2) collision avoidance
|
||||
```python
|
||||
import rvo2
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
sim = rvo2.PyRVOSimulator(
|
||||
timeStep=1/30, neighborDist=2.0, maxNeighbors=10,
|
||||
timeHorizon=2.0, timeHorizonObst=2.0,
|
||||
radius=0.3, maxSpeed=1.5
|
||||
)
|
||||
agents = [sim.addAgent((x, y)) for x, y in spawn_positions]
|
||||
for i, goal in enumerate(goals):
|
||||
pref = np.array(goal) - np.array(sim.getAgentPosition(i))
|
||||
pref = pref / (np.linalg.norm(pref) + 1e-9) * 1.34
|
||||
sim.setAgentPrefVelocity(i, tuple(pref))
|
||||
sim.doStep()
|
||||
```
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
### Trajectory prediction (PyTorch GNN, 2025-style)
|
||||
```python
|
||||
import torch, torch.nn as nn
|
||||
from torch_geometric.nn import GATv2Conv
|
||||
|
||||
class TrajectronLite(nn.Module):
|
||||
def __init__(self, hidden=64, future=12):
|
||||
super().__init__()
|
||||
self.encoder = nn.GRU(4, hidden, batch_first=True)
|
||||
self.gat = GATv2Conv(hidden, hidden, heads=4, concat=False)
|
||||
self.decoder = nn.GRU(hidden, hidden, batch_first=True)
|
||||
self.head = nn.Linear(hidden, 2)
|
||||
self.future = future
|
||||
|
||||
def forward(self, hist, edge_index):
|
||||
# hist: (N, T, 4) — (x, y, vx, vy)
|
||||
h, _ = self.encoder(hist)
|
||||
h = self.gat(h[:, -1], edge_index)
|
||||
h = h.unsqueeze(1).expand(-1, self.future, -1)
|
||||
out, _ = self.decoder(h)
|
||||
return self.head(out) # (N, future, 2)
|
||||
```
|
||||
|
||||
### SUMO foot traffic export
|
||||
```python
|
||||
import traci
|
||||
traci.start(["sumo", "-c", "station.sumocfg"])
|
||||
while traci.simulation.getMinExpectedNumber() > 0:
|
||||
traci.simulationStep()
|
||||
for pid in traci.person.getIDList():
|
||||
x, y = traci.person.getPosition(pid)
|
||||
v = traci.person.getSpeed(pid)
|
||||
log(pid, x, y, v)
|
||||
traci.close()
|
||||
```
|
||||
|
||||
### Density heatmap (post-hoc)
|
||||
```python
|
||||
import numpy as np, matplotlib.pyplot as plt
|
||||
from scipy.stats import gaussian_kde
|
||||
|
||||
xy = trajectories[:, :, :2].reshape(-1, 2).T # (2, N*T)
|
||||
kde = gaussian_kde(xy, bw_method=0.15)
|
||||
gx, gy = np.mgrid[0:50:200j, 0:50:200j]
|
||||
density = kde(np.vstack([gx.ravel(), gy.ravel()])).reshape(gx.shape)
|
||||
plt.imshow(density.T, origin="lower", extent=(0, 50, 0, 50), cmap="hot")
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Evacuation + dense crowd | Social Force (Helbing) |
|
||||
| Smooth navigation, robotics | ORCA / RVO2 |
|
||||
| Trajectory prediction (ML) | Trajectron++ / EqMotion |
|
||||
| Large-scale urban (10⁵+) | Macroscopic LWR / MATSim |
|
||||
| Discrete cell-based grid | Cellular Automata (Burstedde) |
|
||||
|
||||
**기본값**: Mesa 3.x + Social Force for simulation, RVO2 for robot integration.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Agent-Based Modeling]] · [[Complex Systems]]
|
||||
- 변형: [[Social Force Model]] · [[ORCA Algorithm]] · [[Cellular Automata]]
|
||||
- 응용: [[Evacuation Planning]] · [[Urban Simulation]] · [[Robot Navigation]]
|
||||
- Adjacent: [[Trajectory Prediction]] · [[Crowd Analytics]] · [[SUMO]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: parameter sweep design, scenario script generation, calibration code 작성.
|
||||
**언제 X**: real-time inner-loop force computation — 매 numerical kernel은 Cython/Numba/CUDA.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Pseudo-uniform spawning**: 매 corner clustering 발생 — Poisson disk sampling 사용.
|
||||
- **Naive O(N²) social force**: 매 KD-tree neighborhood 로 cutoff (보통 5m).
|
||||
- **Validation skip**: 매 fundamental diagram (density vs flow) 와 비교 필수.
|
||||
- **dt too large**: 매 0.05–0.1s 권장; 매 그 이상 instability.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Helbing & Molnár 1995, Helbing et al. 2000 Nature, Mesa docs 3.x, RVO2 reference).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Social Force / ORCA / GNN trajectory FULL content |
|
||||
|
||||
Reference in New Issue
Block a user