Mpc horizon tuning

From xuansenpa1/skillrevise · View interactive version

Mpc horizon tuning is an AI agent skill from the GitHub repository xuansenpa1/skillrevise. Selecting MPC prediction horizon and cost matrices for web handling.

How to use this skill

Skill file

MPC Tuning for Tension Control

Prediction Horizon Selection

Horizon N affects performance and computation:

For R2R systems with dt=0.01s: N = 5-15 typical

Cost Matrix Design

State cost Q: Emphasize tension tracking

Q_tension = 100 / T_ref²  # High weight on tensions
Q_velocity = 0.1 / v_ref²  # Lower weight on velocities
Q = diag([Q_tension × 6, Q_velocity × 6])

Control cost R: Penalize actuator effort

R = 0.01-0.1 × eye(n_u)  # Smaller = more aggressive

Trade-offs

| Higher Q | Effect |

|----------|--------|

| Faster tracking | More control effort |

| Lower steady-state error | More aggressive transients |

| Higher R | Effect |

|----------|--------|

| Smoother control | Slower response |

| Less actuator wear | Higher tracking error |

Terminal Cost

Use LQR solution for terminal cost to guarantee stability:

P = solve_continuous_are(A, B, Q, R)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.