---
id: wiki-2026-0508-systemic-simulation-principles
title: Systemic Simulation Principles
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Simulation-Principles, System-Simulation]
duplicate_of: none
source_trust_level: A
confidence_score: 0.88
verification_status: applied
tags: [simulation, systems, modeling, abm, monte-carlo]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: python
  framework: simpy-mesa-numpy
---

# Systemic Simulation Principles

## 매 한 줄
> **"매 system 의 동작 = 매 component 의 interaction 의 누적"**. Simulation 의 closed-form X analytic intractable system 의 numerical exploration — 매 weather, traffic, market, biology, game 의 backbone. 1940s Manhattan Monte Carlo 에서 시작, 2026 에 ABM, digital twin, RL 환경 의 광범.

## 매 핵심

### 매 paradigm
- **Discrete-event (DES)**: 매 event 의 sequence — queue, network, factory. SimPy.
- **Agent-based (ABM)**: 매 autonomous agent + rule + interaction — flock, market, epidemic. Mesa, NetLogo.
- **System dynamics (SD)**: 매 stock-flow + feedback loop — macroeconomy, ecology. Vensim, Stella.
- **Continuous (ODE/PDE)**: 매 differential equation 의 numeric solve — physics, chemistry.
- **Monte Carlo**: 매 random sampling — integration, uncertainty propagation, MCMC.

### 매 principle
- **Reproducibility**: seed fix → 매 same output. 매 always.
- **Validation vs verification**: VV — verify (code = model) vs validate (model = reality).
- **Sensitivity analysis**: 매 input 의 perturbation → output 의 변화 의 측정. Sobol, Morris.
- **Calibration**: 매 real data 에 model param 의 fit — Bayesian / ABC.
- **Curse of dimensionality**: 매 input dim ↑ → 매 sample 의 exponential.

### 매 응용
1. Operations research — supply chain, queueing.
2. Climate / epidemiology — IPCC, COVID models.
3. Game / RL — environment for agent training.
4. Finance — Monte Carlo VaR, derivatives.
5. Engineering — CAE, digital twin, FEM.

## 💻 패턴

### 1. SimPy — discrete-event queue
```python
import simpy, random
def customer(env, server):
    yield env.timeout(random.expovariate(1.0))  # arrival
    with server.request() as req:
        yield req
        yield env.timeout(random.expovariate(0.5))  # service

env = simpy.Environment()
server = simpy.Resource(env, capacity=2)
for i in range(100): env.process(customer(env, server))
env.run(until=200)
```

### 2. Mesa — agent-based (Schelling segregation)
```python
from mesa import Agent, Model
from mesa.space import MultiGrid
class Resident(Agent):
    def step(self):
        similar = sum(1 for n in self.model.grid.iter_neighbors(self.pos, True) if n.type == self.type)
        if similar < 3:
            self.model.grid.move_to_empty(self)

class Schelling(Model):
    def __init__(self, n=100, width=20, height=20):
        super().__init__()
        self.grid = MultiGrid(width, height, torus=True)
        # ... place agents
```

### 3. Monte Carlo integration
```python
import numpy as np
def mc_integral(f, n=100000, lo=0, hi=1):
    x = np.random.uniform(lo, hi, n)
    return (hi - lo) * f(x).mean()
# 매 SE = σ/√n — 매 4x sample → 매 2x precision
```

### 4. ODE — population dynamics (Lotka-Volterra)
```python
from scipy.integrate import solve_ivp
def lv(t, y, a=1.0, b=0.1, c=1.5, d=0.075):
    x, y = y
    return [a*x - b*x*y, -c*y + d*x*y]
sol = solve_ivp(lv, [0, 50], [10, 5], dense_output=True, rtol=1e-8)
```

### 5. Sensitivity (Sobol via SALib)
```python
from SALib.sample import sobol
from SALib.analyze import sobol as sobol_analyze
problem = {"num_vars": 3, "names": ["a", "b", "c"], "bounds": [[0, 1]]*3}
X = sobol.sample(problem, 1024)
Y = np.array([model(x) for x in X])
Si = sobol_analyze.analyze(problem, Y)
print(Si["ST"])  # total-order index
```

### 6. Calibration (ABC — Approximate Bayesian Computation)
```python
def abc(prior, simulator, observed, eps=0.1, n=1000):
    accepted = []
    while len(accepted) < n:
        theta = prior()
        sim = simulator(theta)
        if distance(sim, observed) < eps:
            accepted.append(theta)
    return accepted
```

### 7. Reproducibility — seed everything
```python
import numpy as np, random, torch
SEED = 42
random.seed(SEED); np.random.seed(SEED); torch.manual_seed(SEED)
```

### 8. Variance reduction — antithetic sampling
```python
u = np.random.uniform(size=n//2)
samples = np.concatenate([u, 1 - u])  # 매 negative correlation → SE 의 ↓
```

### 9. Parallel — joblib / Ray
```python
from joblib import Parallel, delayed
results = Parallel(n_jobs=-1)(delayed(simulate)(i) for i in range(1000))
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| Queue, network, factory | DES (SimPy) |
| Heterogeneous agents + rule | ABM (Mesa) |
| Stock-flow, macro feedback | System Dynamics |
| Physical / continuous | ODE/PDE (scipy / FEniCS) |
| Integration, uncertainty | Monte Carlo |
| Param fit | ABC / MCMC / Bayesian opt |
| Sensitivity | Sobol (interactions) / Morris (cheap) |
| RL training env | Gymnasium / PettingZoo |

**기본값**: 매 question 의 type 의 paradigm 의 결정 → seed fix → calibrate → sensitivity → validate.

## 🔗 Graph
- 부모: [[Probability Theory]] · [[Statistics]]
- 변형: [[Monte-Carlo-Integration]] · [[Chaos-Theory in Systems]]
- 응용: [[Operations-Research]] · [[Autonomous-Vehicle-Path-Planning]] · [[Climate Change Mitigation Frameworks]]
- Adjacent: [[Feedback-Loops in Systems]] · [[Emergence]]

## 🤖 LLM 활용
**언제**: model design discussion, paradigm selection, code scaffolding (SimPy, Mesa), sensitivity interpretation.
**언제 X**: 매 large-scale numeric solve — 매 dedicated solver 의 사용.

## ❌ 안티패턴
- **No seed**: 매 reproducibility X — debugging 의 nightmare.
- **Validation skip**: 매 model 의 reality 의 일치 의 unverified — "fit data ≠ predict future".
- **Overfitting calibration**: 매 historical replication 의 hyper-fit → 매 OOD prediction 의 fail.
- **Single run conclusion**: 매 stochastic 의 1 run = 매 anecdote — 매 N runs + CI.
- **Wrong paradigm**: 매 ABM problem 의 ODE 로, 매 ODE problem 의 ABM 로.
- **Ignore curse of dim**: 매 10+ params 의 grid search → 매 infeasible. 매 Sobol / surrogate 의 사용.

## 🧪 검증 / 중복
- Verified (Law *Simulation Modeling and Analysis*, NRC simulation guide, SimPy/Mesa docs).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — DES/ABM/SD/MC paradigms + reproducibility/SA. |
