---
id: wiki-2026-0508-ecology-and-ecosystem-modeling
title: Ecology and Ecosystem Modeling
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [ecosystem modeling, agent-based ecology, Lotka-Volterra, food web, population dynamics]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
verification_status: applied
tags: [ecology, ecosystem, abm, lotka-volterra, simulation, biodiversity, food-web]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: Python / NetLogo / Mesa
  framework: NumPy / scipy / Mesa
---

# Ecology and Ecosystem Modeling

## 매 한 줄
> **"매 species 매 environment 의 interaction 의 mathematical / computational simulate"**. 매 Lotka-Volterra (predator-prey), 매 food web, 매 ABM (agent-based). 매 modern: 매 deep learning + 매 climate model coupling.

## 매 핵심

### 매 model type
- **Differential equation**: 매 Lotka-Volterra, SIR-like.
- **Matrix model** (Leslie): 매 age-structured.
- **Individual-based** (IBM/ABM): 매 agent.
- **Network-based**: 매 food web.
- **Spatial**: 매 PDE / cellular automata.

### 매 famous
- **Lotka-Volterra**: 매 predator-prey oscillation.
- **NetLogo Wolves-Sheep**: 매 ABM textbook.
- **Madingley Model**: 매 global-scale ecosystem.
- **EwE (Ecopath with Ecosim)**: 매 marine fisheries.

### 매 응용
1. **Conservation**: 매 endangered species.
2. **Fisheries**: 매 stock assessment.
3. **Invasive species**: 매 spread.
4. **Climate adaptation**: 매 range shift.
5. **Disease ecology**: 매 zoonotic.
6. **Restoration**: 매 rewilding scenario.

### 매 modern AI
- **Species distribution**: 매 ML predict.
- **Image classification**: 매 camera trap.
- **Bioacoustic**: 매 bird ID.
- **Foundation model**: 매 GeoCLIP, BioCLIP.

## 💻 패턴

### Lotka-Volterra
```python
import numpy as np
from scipy.integrate import odeint

def lv(state, t, alpha, beta, delta, gamma):
    prey, pred = state
    dprey = alpha * prey - beta * prey * pred
    dpred = delta * prey * pred - gamma * pred
    return [dprey, dpred]

t = np.linspace(0, 50, 1000)
sol = odeint(lv, [10, 5], t, args=(0.5, 0.1, 0.05, 0.5))
```

### Logistic growth (carrying capacity)
```python
def logistic(N, t, r, K):
    return r * N * (1 - N / K)

t = np.linspace(0, 30, 300)
N = odeint(logistic, 5, t, args=(0.5, 100))
```

### Leslie matrix (age-structured)
```python
def leslie_step(pop, fecundity, survival):
    L = np.zeros((len(pop), len(pop)))
    L[0, :] = fecundity
    for i in range(len(pop) - 1):
        L[i + 1, i] = survival[i]
    return L @ pop

# 매 example
pop = np.array([100, 80, 50, 20])
fec = np.array([0, 0.5, 1.5, 0.8])
surv = np.array([0.6, 0.7, 0.5])
for _ in range(20): pop = leslie_step(pop, fec, surv)
```

### Agent-based (Mesa)
```python
from mesa import Agent, Model
from mesa.space import MultiGrid
from mesa.time import RandomActivation

class Sheep(Agent):
    def step(self):
        self.energy -= 1
        if grass_at(self.pos): self.energy += 5
        # 매 move
        x, y = self.random.choice(self.model.grid.get_neighborhood(self.pos, True))
        self.model.grid.move_agent(self, (x, y))
        # 매 reproduce
        if self.energy > 20:
            self.energy /= 2
            self.model.add_sheep(self.pos, self.energy)
        # 매 die
        if self.energy <= 0: self.model.kill(self)

class Wolf(Agent):
    def step(self):
        # 매 hunt sheep
        sheep_nearby = self.model.grid.get_cell_list_contents([self.pos])
        sheep_nearby = [a for a in sheep_nearby if isinstance(a, Sheep)]
        if sheep_nearby:
            self.energy += 20
            self.model.kill(sheep_nearby[0])

class Ecosystem(Model):
    def __init__(self, n_sheep, n_wolves, w, h):
        self.grid = MultiGrid(w, h, torus=True)
        self.schedule = RandomActivation(self)
        for _ in range(n_sheep): self.add_sheep((random_pos), 10)
        for _ in range(n_wolves): self.add_wolf((random_pos), 20)
    def step(self): self.schedule.step()
```

### Food web (network)
```python
import networkx as nx

G = nx.DiGraph()
# 매 edge: prey → predator
G.add_edges_from([
    ('grass', 'rabbit'), ('grass', 'mouse'),
    ('rabbit', 'fox'), ('mouse', 'fox'),
    ('mouse', 'owl'), ('rabbit', 'eagle'),
])

# 매 trophic level
def trophic_level(G, species):
    if G.in_degree(species) == 0: return 1
    preys = list(G.predecessors(species))
    return 1 + np.mean([trophic_level(G, p) for p in preys])
```

### Species distribution model (MaxEnt-style)
```python
from sklearn.ensemble import RandomForestClassifier

def fit_sdm(presences, absences, env_features):
    X = np.vstack([presences, absences])
    y = np.array([1] * len(presences) + [0] * len(absences))
    clf = RandomForestClassifier(n_estimators=200).fit(X, y)
    return clf

def project(clf, future_env_grid):
    return clf.predict_proba(future_env_grid)[:, 1]  # 매 suitability
```

### Spatial spread (cellular automaton)
```python
def spread_step(grid, infected_value=1, p_spread=0.3):
    new_grid = grid.copy()
    H, W = grid.shape
    for i in range(1, H - 1):
        for j in range(1, W - 1):
            if grid[i, j] == 0:
                neighbors = grid[i-1:i+2, j-1:j+2].sum() - grid[i, j]
                if neighbors > 0 and np.random.rand() < 1 - (1 - p_spread) ** neighbors:
                    new_grid[i, j] = infected_value
    return new_grid
```

### Camera trap classifier (BioCLIP)
```python
from transformers import CLIPModel, CLIPProcessor
model = CLIPModel.from_pretrained('imageomics/bioclip')

def classify_animal(image, candidate_species):
    inputs = processor(text=candidate_species, images=image, return_tensors='pt')
    out = model(**inputs)
    return candidate_species[out.logits_per_image.argmax().item()]
```

### Bird sound (BirdNET-style)
```python
def detect_birds(audio, sr=48000, window_s=3):
    # 매 chunked inference
    chunks = chunk(audio, window_s * sr)
    return [birdnet_model.predict(c) for c in chunks]
```

### Sensitivity analysis
```python
from SALib.sample import saltelli
from SALib.analyze import sobol

problem = {
    'num_vars': 4,
    'names': ['alpha', 'beta', 'delta', 'gamma'],
    'bounds': [[0.1, 1], [0.05, 0.2], [0.01, 0.1], [0.1, 1]],
}
param_values = saltelli.sample(problem, 1024)
Y = np.array([simulate(p)[-1, 0] for p in param_values])  # 매 final prey
Si = sobol.analyze(problem, Y)
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| 2-3 species | Lotka-Volterra ODE |
| Age structure | Leslie matrix |
| Behavioral | ABM (Mesa / NetLogo) |
| Network | Food web graph |
| Range / spatial | SDM + CA |
| Fisheries | Ecopath / EwE |
| Camera trap data | BioCLIP / DL |

**기본값**: 매 question-driven — 매 quick population → ODE; 매 behavioral → ABM; 매 modern data → ML SDM.

## 🔗 Graph
- 부모: [[Ecology]] · [[Systems-Biology]]
- 변형: [[Lotka-Volterra]] · [[Agent-Based-Model]] · [[Food-Web]]
- 응용: [[Conservation-Biology]] · [[Fisheries]] · [[Climate-Change]]
- Adjacent: [[Cellular-Automata]] · [[Species-Distribution-Model]] · [[BioCLIP]]

## 🤖 LLM 활용
**언제**: 매 conservation. 매 invasive species. 매 climate adaptation.
**언제 X**: 매 hard physics (use mechanistic instead).

## ❌ 안티패턴
- **Ignore stochasticity**: 매 small population.
- **Single-scale**: 매 cross-scale interaction 의 miss.
- **Calibrate to single dataset**: 매 over-fit.
- **No sensitivity analysis**: 매 parameter uncertainty.

## 🧪 검증 / 중복
- Verified (May, Levin Mathematical Ecology).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-04-20 | Auto-reinforced |
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — ODE / ABM / food web / SDM / sensitivity code |
