--- id: wiki-2026-0508-model-predictive-control-mpc title: Model Predictive Control (MPC) category: 10_Wiki/Topics status: verified canonical_id: self aliases: [MPC, Receding-Horizon-Control, RHC] duplicate_of: none source_trust_level: A confidence_score: 0.95 verification_status: applied tags: [control, optimization, robotics, autonomous-vehicles, receding-horizon] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: python framework: cvxpy-acados --- # Model Predictive Control (MPC) ## 매 한 줄 > **"매 step마다 future를 optimize, 첫 action만 실행, 매 반복"**. Receding horizon control은 매 dynamics model + cost + constraints를 매 online QP/NLP로 풀어낸다. 2026 자율주행·드론·humanoid robot의 매 dominant control paradigm으로 reinforcement learning과도 hybrid 구성된다. ## 매 핵심 ### 매 정식화 ``` 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로 재최적화. ### 매 종류 - **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로. ### 매 응용 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. ## 💻 패턴 ### 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 ``` ### 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... ``` ### Receding horizon loop ```python for t in range(T): x_meas = sensor.read() u_star = mpc_solve(x_meas) actuator.apply(u_star) ``` ### Reference tracking cost ```python cost += cp.quad_form(x[:, k] - x_ref, Q) ``` ### Soft constraint via slack ```python slack = cp.Variable(N, nonneg=True) cons += [g(x[:, k], u[:, k]) <= slack[k]] cost += 1e3 * cp.sum(slack) ``` ### Warm-start (next iter uses prev solution) ```python solver.set_initial_guess(shift(u_prev)) ``` ## 매 결정 기준 | 상황 | 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]] - 응용: [[Autonomous-Vehicle-Path-Planning]] - 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 |