You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Get Started :material-arrow-right-box:](get-started/installation.md){.md-button}
15
15
</p>
16
16
17
-
TinyMPC is an open-source solver tailored for convex model-predictive control that delivers high speed computation with a small memory footprint. Implemented in C++ with minimal dependencies, TinyMPC is particularly suited for embedded control and robotics applications on resource-constrained platforms. TinyMPC can handle state and input bounds and second-order cone constraints. A Python interface is available to aid in generating code for embedded systems.
17
+
TinyMPC is an open-source solver tailored for convex model-predictive control that delivers high speed computation with a small memory footprint. Implemented in C++ with minimal dependencies, TinyMPC is particularly suited for embedded control and robotics applications on resource-constrained platforms. TinyMPC can handle state and input bounds and second-order cone constraints. [Python](https://github.com/TinyMPC/tinympc-python), [MATLAB](https://github.com/TinyMPC/tinympc-matlab), and [Julia](https://github.com/TinyMPC/tinympc-julia) interfaces are available to aid in generating code for embedded systems.
18
18
19
19
!!! success ""
20
20
@@ -75,11 +75,11 @@ TinyMPC outperforms state-of-the-art solvers in terms of speed and memory footpr
TinyMPC is also capable of handling conic constraints. In (b), we benchmarked TinyMPC against two existing conic solvers with embedded support, [SCS](https://www.cvxgrp.org/scs/){:target="_blank"} and [ECOS](https://web.stanford.edu/~boyd/papers/ecos.html){:target="_blank"}, on the rocket soft-landing problem. TinyMPC achieves an average speed-up of 13x over SCS and 137x over ECOS.
82
+
TinyMPC is also capable of handling conic constraints. Conic-TinyMPC outperforms [SCS](https://www.cvxgrp.org/scs/){:target="_blank"} and [ECOS](https://web.stanford.edu/~boyd/papers/ecos.html){:target="_blank"} in execution time and memory, achieving an average speed-up of 13.8x over SCS and 142.7x over ECOS.
83
83
<!-- #gain, because of its lack of generality, TinyMPC is orders of magnitudes faster than SCS and ECOS. -->
84
84
</div>
85
85
</figure>
@@ -98,76 +98,79 @@ TinyMPC outperforms state-of-the-art solvers in terms of speed and memory footpr
@@ -15,10 +15,10 @@ The alternating direction method of multipliers algorithm was developed in the 1
15
15
We want to solve optimization problems in which our cost function $f$ and set of valid states $\mathcal{C}$ are both convex:
16
16
17
17
$$
18
-
\begin{alignat}{2}
19
-
\min_x & \quad f(x) \\
20
-
\text{subject to} & \quad x \in \mathcal{C}.
21
-
\end{alignat}
18
+
\begin{aligned}
19
+
\min_x \quad & f(x) \\
20
+
\text{subject to} \quad & x \in \mathcal{C}
21
+
\end{aligned}
22
22
$$
23
23
24
24
We define an indicator function for the set $\mathcal{C}$:
@@ -35,12 +35,29 @@ The indicator function says simply that there is infinite additional cost when $
35
35
36
36
We modify the generic optimization problem to include the indicator function by adding it to the cost. We introduce a new state variable $z$, called the slack variable, to describe the constrained version of the original state variable $x$, which we will now call the primal variable.
37
37
38
-
$$
38
+
Our approach leverages the ADMM framework to distinctly separate the dynamics constraints from other convex constraints such as torque limits and obstacle avoidance. This separation is crucial as it allows us to:
39
+
1. Handle dynamics through efficient LQR techniques in the primal update
40
+
2. Manage other convex constraints through simple projection methods in the slack update
41
+
42
+
Since both the state constraints ($\mathcal{X}$) and input constraints ($\mathcal{U}$) are convex, this decomposition works by projecting the primal variables ($x, u$) onto these constraint sets through the slack updates. This projection ensures constraint satisfaction while leveraging the separability of the constraint structure, significantly reducing computational complexity compared to solving the fully constrained problem directly.
At minimum cost, the primal variable $x$ must be equal to the slack variable $z$, but during each solve they will not necessarily be equal. This is because the slack variable $z$ manifests in the algorithm as the version of the primal variable $x$ that has been projected onto the feasible set $\mathcal{C}$, and thus whenever the primal variable $x$ violates any constraint, the slack variable at that iteration will be projected back onto $\mathcal{C}$ and thus differ from $x$. To push the primal variable $x$ back to the feasible set $\mathcal{C}$, we introduce a third variable, $\lambda$, called the dual variable. This method is referred to as the [augmented Lagrangian](https://en.wikipedia.org/wiki/Augmented_Lagrangian_method){:target="_blank"} (originally named the method of multipliers), and introduces a scalar penalty parameter $\rho$ alongside the dual variable $\lambda$ (also known as a Lagrange multiplier). The penalty parameter $\rho$ is the augmentation to what would otherwise just be the Lagrangian of our constrained optimization problem above. $\lambda$ and $\rho$ work together to force $x$ closer to $z$ by increasing the cost of the augmented Lagrangian the more $x$ and $z$ differ.
46
63
@@ -51,18 +68,132 @@ $$
51
68
Our optimization problem has now been divided into two variables: the primal $x$ and slack $z$, and we can optimize over each one individually while holding all of the other variables constant. To get the ADMM algorithm, all we have to do is alternate between solving for the $x$ and then for the $z$ that minimizes our augmented Lagrangian. After each set of solves, we then update our dual variable $\lambda$ based on how much $x$ differs from $z$.
where $x^+$, $z^+$, and $\lambda^+$ refer to the primal, slack, and dual variables to be used in the next iteration.
62
79
63
80
Now all we have to do is solve a few unconstrained optimization problems!
64
81
65
-
## TODO: primal and slack update and discrete algebraic riccati equation
82
+
---
83
+
84
+
## Primal and slack update
85
+
86
+
The primal update in TinyMPC takes advantage of the special structure of Model Predictive Control (MPC) problems. The optimization problem can be written as:
where $\mathcal{X}$ and $\mathcal{U}$ are convex sets representing the feasible state and input regions, respectively. These convex constraints ensure that the solution remains within feasible boundaries for both the state and the control inputs at every time step.
103
+
104
+
When we apply ADMM to this problem, the primal update becomes an equality-constrained quadratic program with modified cost matrices:
where $\mathcal{X}$ and $\mathcal{U}$ are the feasible sets for states and inputs respectively, and $y_k, g_k$ are scaled dual variables.
141
+
142
+
A key optimization in TinyMPC is the pre-computation of certain matrices that remain constant throughout the iterations. Given a sufficiently long horizon, the Riccati recursion converges to the infinite-horizon solution, allowing us to cache:
143
+
144
+
$$
145
+
\begin{aligned}
146
+
C_1 &= (R + B^\intercal P_{\text{inf}} B)^{-1} \\
147
+
C_2 &= (A - B K_{\text{inf}})^\intercal
148
+
\end{aligned}
149
+
$$
150
+
151
+
This significantly reduces the online computational burden while maintaining the algorithm's effectiveness.
152
+
153
+
---
154
+
155
+
## Discrete Algebraic Riccati Equation (DARE)
156
+
157
+
For long time horizons, the Riccati recursion converges to a steady-state solution given by the discrete algebraic Riccati equation:
158
+
159
+
$$
160
+
P_{\text{inf}} = Q + A^\intercal P_{\text{inf}} A - A^\intercal P_{\text{inf}} B(R + B^\intercal P_{\text{inf}} B)^{-1} B^\intercal P_{\text{inf}} A
161
+
$$
162
+
163
+
This steady-state solution $P_{\text{inf}}$ yields a constant feedback gain:
164
+
165
+
$$
166
+
K_{\text{inf}} = (R + B^\intercal P_{\text{inf}} B)^{-1} B^\intercal P_{\text{inf}} A
167
+
$$
168
+
169
+
TinyMPC leverages this property by pre-computing these steady-state matrices offline, significantly reducing the online computational burden. The only online updates needed are for the time-varying linear terms in the cost function.
170
+
171
+
---
172
+
173
+
## Dual Updates and Convergence
174
+
175
+
The dual update step in ADMM pushes the solution toward constraint satisfaction:
176
+
177
+
$$
178
+
\begin{aligned}
179
+
y_k^+ &= y_k + x_k^+ - z_k^+ \\
180
+
g_k^+ &= g_k + u_k^+ - w_k^+
181
+
\end{aligned}
182
+
$$
183
+
184
+
where $y_k$ and $g_k$ are the scaled dual variables ($y_k = \lambda_k/\rho$ and $g_k = \mu_k/\rho$).
185
+
186
+
The algorithm terminates when both primal and dual residuals are sufficiently small:
0 commit comments