[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,62 +2,138 @@
id: wiki-2026-0508-model-predictive-control-mpc
title: Model Predictive Control (MPC)
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AI-MPC]
aliases: [MPC, Receding-Horizon-Control, RHC]
duplicate_of: none
source_trust_level: A
confidence_score: 0.98
tags: [Engineering, ControlTheory, MPC, Predictive]
confidence_score: 0.95
verification_status: applied
tags: [control, optimization, robotics, autonomous-vehicles, receding-horizon]
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: cvxpy-acados
---
# [[Model-Predictive-Control (MPC)|Model-Predictive-Control (MPC)]] (모델 예측 제어)
# Model Predictive Control (MPC)
## 📌 한 줄 통찰 (The Karpathy Summary)
> "몇 수 앞을 내다보고 현재의 핸들을 꺾는 지능형 조타수." 시스템의 수학적 모델을 사용해 미래의 거동을 예측하고, 수천 번의 가공 시뮬레이션을 통해 현재 시점에서 최선의 제어 입력을 결정하는 고도의 제어 알고리즘이다.
## 한 줄
> **"매 step마다 future를 optimize, 첫 action만 실행, 매 반복"**. Receding horizon control은 매 dynamics model + cost + constraints를 매 online QP/NLP로 풀어낸다. 2026 자율주행·드론·humanoid robot의 매 dominant control paradigm으로 reinforcement learning과도 hybrid 구성된다.
## 📖 구조화된 지식 (Synthesized Content)
- **Mechanism**:
1. 현재 상태를 측정함.
2. 일정 기간(Prediction Horizon) 동안 시스템이 어떻게 움직일지 미래를 예측함.
3. 제약 조건(예: 속도 100km 제한)을 만족하면서 가장 목표에 근접하는 입력 시퀀스를 계산.
4. 계산된 여러 수 중 **첫 번째 명령만 실행**하고 다시 1번으로 돌아감 (Receding Horizon).
- **Strength**: 여러 개의 입력과 출력이 얽힌 복잡한 시스템(MIMO)을 다루는 데 탁월하며, 제약 조건을 하드코딩으로 반영할 수 있다.
- **Domain**: 정유 공정, 우주선 도킹, 고성능 자율주행 차량.
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- MPC는 매 순간 최적화 문제를 풀어야 하므로 계산 성능이 엄청나게 소모된다. 최근에는 강화학습(RL)이 MPC의 역할을 대신하거나, 반대로 RL이 갈 방향을 MPC가 제약 조건으로 가이드해주는 하이브리드 제어(Learning-based MPC)가 로보틱스의 새로운 표준이 되고 있다.
### 매 정식화
```
min_{u_0..u_{N-1}} Σ (x_k, u_k) + V_f(x_N)
s.t. x_{k+1} = f(x_k, u_k)
g(x_k, u_k) ≤ 0
x_0 = x_current
```
매 첫 u_0만 적용, 다음 step에서 매 새 measurement로 재최적화.
## 🔗 지식 연결 (Graph)
- Related: [[Control-Theory|Control-Theory]] , [[Decision Theory|Decision Theory]]
- AI Hybrid: Deep-[[Reinforcement-Learning|Reinforcement-Learning]]-for-Control
### 매 종류
- **Linear MPC**: f linear, quadratic → QP.
- **Nonlinear MPC (NMPC)**: NLP (IPOPT, acados).
- **Robust MPC**: tube/min-max — uncertainty 처리.
- **Stochastic MPC**: chance constraints.
- **Learning-based MPC**: f를 NN/GP로.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### 매 응용
1. Autonomous driving — trajectory tracking, lane change.
2. Quadrotor / drone control.
3. Humanoid locomotion (Boston Dynamics, Tesla Optimus 추정).
4. Process industry — refinery, chemical plant.
5. HVAC, smart grid.
**언제 이 지식을 쓰는가:**
- *(TODO)*
## 💻 패턴
**언제 쓰면 안 되는가:**
- *(TODO)*
### Linear MPC with CVXPY
```python
import cvxpy as cp, numpy as np
def lin_mpc(A, B, x0, N=10, Q=None, R=None):
nx, nu = B.shape
Q = Q if Q is not None else np.eye(nx)
R = R if R is not None else 0.1*np.eye(nu)
x = cp.Variable((nx, N+1))
u = cp.Variable((nu, N))
cost, cons = 0, [x[:, 0] == x0]
for k in range(N):
cost += cp.quad_form(x[:, k], Q) + cp.quad_form(u[:, k], R)
cons += [x[:, k+1] == A @ x[:, k] + B @ u[:, k]]
cons += [cp.norm(u[:, k], 'inf') <= 1.0]
cp.Problem(cp.Minimize(cost), cons).solve()
return u[:, 0].value
```
## 🧪 검증 상태 (Validation)
### NMPC with CasADi/acados (sketch)
```python
import casadi as ca
x = ca.SX.sym('x', nx); u = ca.SX.sym('u', nu)
f = ca.Function('f', [x, u], [dynamics(x, u)])
# build NLP with multiple shooting...
```
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
### Receding horizon loop
```python
for t in range(T):
x_meas = sensor.read()
u_star = mpc_solve(x_meas)
actuator.apply(u_star)
```
## 🧬 중복 검사 (Duplicate Check)
### Reference tracking cost
```python
cost += cp.quad_form(x[:, k] - x_ref, Q)
```
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
### Soft constraint via slack
```python
slack = cp.Variable(N, nonneg=True)
cons += [g(x[:, k], u[:, k]) <= slack[k]]
cost += 1e3 * cp.sum(slack)
```
## 🕓 변경 이력 (Changelog)
### Warm-start (next iter uses prev solution)
```python
solver.set_initial_guess(shift(u_prev))
```
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 매 결정 기준
| 상황 | MPC variant |
|---|---|
| Linear plant, quadratic cost | QP-based linear MPC |
| Nonlinear dynamics | NMPC (acados, CasADi) |
| Bounded uncertainty | Tube MPC |
| Probabilistic constraint | Stochastic MPC |
| Hard real-time (kHz) | Explicit MPC (precomputed) |
**기본값**: Linear MPC + warm-start (cycle time < 10 ms).
## 🔗 Graph
- 부모: [[Optimal-Control-Theory]] · [[Optimization]]
- 변형: [[Nonlinear-MPC]] · [[Robust-MPC]] · [[Stochastic-MPC]]
- 응용: [[Autonomous-Vehicle-Path-Planning]] · [[Quadrotor-Control]] · [[Humanoid-Robot]]
- Adjacent: [[Reinforcement-Learning]] · [[Kalman-Filter-and-State-Tracking]] · [[Feedback-Control-Systems]]
## 🤖 LLM 활용
**언제**: Constrained dynamic systems, real-time replanning, model + cost are known.
**언제 X**: Model 알 수 없거나 long-horizon strategic decision (use RL).
## ❌ 안티패턴
- **Horizon 너무 짧음**: 매 myopic control.
- **Constraint feasibility 무시**: infeasible 시 fallback 없음.
- **Cold-start 매 iteration**: 매 latency 폭발 — warm-start 필수.
- **Plant-model mismatch 무시**: 매 robust/adaptive 가 필요.
## 🧪 검증 / 중복
- Verified (Rawlings, Mayne, Diehl "Model Predictive Control").
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — MPC formulation + CVXPY/acados patterns |