Files
2nd/10_Wiki/Topic_Programming/Architecture/Swarm_Intelligence.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

180 lines
6.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: wiki-2026-0508-swarm-intelligence
title: Swarm Intelligence
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Swarm AI, Collective Intelligence, Multi-Agent Optimization]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [optimization, multi-agent, bio-inspired, ai]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: python
framework: numpy-deap
---
# Swarm Intelligence
## 매 한 줄
> **"매 simple agents 의 collective 의 emergent intelligence"**. 매 ant colony, bird flock, bee swarm 의 inspired — 매 local rules + interaction 의 global optimization. 2026 의 application 의 LLM agent swarms (CrewAI, AutoGen) + classic optim.
## 매 핵심
### 매 핵심 algorithms
- **PSO (Particle Swarm Optimization)**: 매 particle 의 personal best + global best 의 update.
- **ACO (Ant Colony Optimization)**: 매 pheromone trail 의 path optim — TSP.
- **ABC (Artificial Bee Colony)**: 매 employed/onlooker/scout 의 분업.
- **Firefly / Cuckoo**: 매 attractiveness / Lévy flight 의 search.
### 매 properties
- **Decentralization**: 매 central control 의 X.
- **Self-organization**: 매 local interaction → global pattern.
- **Robustness**: 매 single agent 의 fail 의 swarm 의 survive.
- **Stigmergy**: 매 environment 의 state 의 indirect communication (pheromone).
### 매 응용
1. Routing (vehicle, network).
2. Scheduling (job shop, cloud workload).
3. Hyperparameter tuning (PSO 의 grid search 의 대체).
4. LLM multi-agent (CrewAI roles, debate, voting).
5. Drone swarms (formation, coverage).
## 💻 패턴
### PSO — minimize objective
```python
import numpy as np
def pso(f, dim, n=30, iters=200, w=0.7, c1=1.5, c2=1.5, lo=-5, hi=5):
x = np.random.uniform(lo, hi, (n, dim))
v = np.zeros_like(x)
pbest = x.copy()
pbest_val = np.array([f(p) for p in x])
g = pbest[pbest_val.argmin()]
for _ in range(iters):
r1, r2 = np.random.rand(n, dim), np.random.rand(n, dim)
v = w*v + c1*r1*(pbest - x) + c2*r2*(g - x)
x = np.clip(x + v, lo, hi)
vals = np.array([f(p) for p in x])
mask = vals < pbest_val
pbest[mask], pbest_val[mask] = x[mask], vals[mask]
g = pbest[pbest_val.argmin()]
return g, pbest_val.min()
best, val = pso(lambda x: np.sum(x**2), dim=10)
```
### ACO — TSP
```python
import numpy as np
def aco_tsp(dist, n_ants=20, iters=100, alpha=1, beta=3, rho=0.1, Q=1):
n = len(dist)
tau = np.ones((n, n))
eta = 1 / (dist + 1e-10)
best_path, best_len = None, float('inf')
for _ in range(iters):
paths = []
for _ in range(n_ants):
path = [np.random.randint(n)]
unvisited = set(range(n)) - {path[0]}
while unvisited:
i = path[-1]
p = np.array([(tau[i,j]**alpha) * (eta[i,j]**beta) for j in unvisited])
p /= p.sum()
j = list(unvisited)[np.random.choice(len(unvisited), p=p)]
path.append(j)
unvisited.remove(j)
paths.append(path)
# update
tau *= (1 - rho)
for path in paths:
length = sum(dist[path[i], path[i+1]] for i in range(n-1))
if length < best_len:
best_len, best_path = length, path
for i in range(n-1):
tau[path[i], path[i+1]] += Q / length
return best_path, best_len
```
### LLM agent swarm — CrewAI
```python
from crewai import Agent, Task, Crew
researcher = Agent(role="Researcher", goal="find facts",
llm="claude-opus-4-7")
critic = Agent(role="Critic", goal="poke holes",
llm="claude-opus-4-7")
synth = Agent(role="Synthesizer", goal="merge views",
llm="claude-opus-4-7")
crew = Crew(
agents=[researcher, critic, synth],
tasks=[
Task(description="research X", agent=researcher),
Task(description="critique research", agent=critic),
Task(description="synthesize", agent=synth),
],
process="sequential",
)
result = crew.kickoff()
```
### Boids — flocking simulation
```python
import numpy as np
def boids_step(pos, vel, sep_r=1, ali_r=3, coh_r=5, max_v=2):
n = len(pos)
new_vel = vel.copy()
for i in range(n):
d = np.linalg.norm(pos - pos[i], axis=1)
sep = -np.sum((pos[d < sep_r] - pos[i]), axis=0)
ali = np.mean(vel[(d < ali_r) & (d > 0)], axis=0) - vel[i] if ((d < ali_r) & (d > 0)).any() else 0
coh = np.mean(pos[(d < coh_r) & (d > 0)], axis=0) - pos[i] if ((d < coh_r) & (d > 0)).any() else 0
new_vel[i] += 0.5*sep + 0.3*ali + 0.2*coh
speed = np.linalg.norm(new_vel[i])
if speed > max_v:
new_vel[i] = new_vel[i] / speed * max_v
return pos + new_vel, new_vel
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Continuous optimization | PSO |
| Combinatorial (TSP, scheduling) | ACO |
| Multi-objective | NSGA-II / MOPSO |
| LLM-based reasoning | Agent swarm (CrewAI) |
| Convex problem | 매 swarm 의 X — gradient descent |
**기본값**: 매 PSO 의 continuous, 매 ACO 의 graph problems.
## 🔗 Graph
- 변형: [[Genetic Algorithms]] · [[Simulated Annealing]] · [[CMA-ES]]
- Adjacent: [[Emergence]] · [[Self-Organization]]
## 🤖 LLM 활용
**언제**: black-box optimization, multi-agent reasoning, 매 gradient 의 unavailable.
**언제 X**: convex / differentiable (use gradient methods), small discrete (use exact).
## ❌ 안티패턴
- **No diversification**: 매 premature convergence — 매 inertia / mutation 의 tune.
- **Wrong neighborhood topology**: 매 fully-connected 의 always 의 X — ring/star 의 try.
- **Naive multi-LLM swarm**: 매 cost 의 N× — 매 token budget 의 monitor.
## 🧪 검증 / 중복
- Verified (Kennedy & Eberhart 1995 PSO; Dorigo ACO; CrewAI 2026 docs).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — PSO, ACO, boids, LLM agent swarms |