MPC#

This method requires a model or model estimation of the system along with a Kalman Gain matrix. The process noise and measurement noise covariance matrices need to be provided or estimated.

For more details on the MPC method, refer to the Wikipedia page.

We have two variants implemented to obtain the model:

  1. Oracle

  2. N4SID

Oracle#

The Oracle MPC is intended to be used as a benchmark. In this variant, the true state model (or linearized dynamics) is injected. The optimal Kalman gain is calculated. No other DDPC method can outperform this variant.

N4SID#

The Numerical Subspace State Space System Identification (N4SID or NFourSID) is a system identification algorithm, detailed in this paper. The tunable parameter n_block_rows \(\geq 1\) must be an integer.

The state dimension \(n_{state}\) is calculated as:

\[n_{state} = p * n_\text{block_rows},\]

where \(p\) is the number of outputs.

Note

Choosing a large n_block_rows increases computational complexity, while a small n_block_rows may hinder the accurate determination of the system order in the eigenvalue diagram.

Optimization Formulation#

\[\begin{split}\min_{u_f,y_f} &\quad \|y_f - y_r\|_Q^2 + \|u_f - u_r\|_R^2 \\ \text{s.t.} &\quad y_f = \Gamma x + H_u u_f \\ &\quad u_f \in \mathcal{U}, \quad y_f \in \mathcal{Y}\end{split}\]

Here:

  • \(\Gamma\) is the extended observability matrix,

  • \(H_u\) maps future inputs to future outputs,

  • \(x\) is the estimated state of the system which needs to be updated.

\(\Gamma\) is constructed as follow:

\[\begin{split}\Gamma = \begin{bmatrix} C \\ CA \\ CA^2 \\ \vdots \\ CA^{(\tau_f-1)} \end{bmatrix}\end{split}\]

\(H_u\) is constructed as follow:

\[\begin{split}H_u = \begin{bmatrix} D & 0 & 0 & \cdots & 0 \\ CB & D & 0 & \cdots & 0 \\ CAB & CB & D & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ CA^{(\tau_f-2)}B & CA^{(\tau_f-3)}B & CA^{(\tau_f-4)}B& \cdots & D \end{bmatrix}\end{split}\]

Solving#

The solution is set up in two steps:

  1. Update the state using the Kalman Filter.

\[\begin{split}x &= A x + B u \\ x &= x + K(y-Cx-Du)\end{split}\]
  1. Solve the optimization problem

Closed-Form Solution Derivation#

Set \(y_f\) into the cost equation leads to:

\[\|H_u u_f + \Gamma x - y_r\|_Q^2 + \|u_f - u_r\|_R^2\]

Now taking the derivative in respect to \(u_f\) and set it to zero.

\[(H_u^T Q H_u + R )u_f^\star = (-H_u^TQ \Gamma)x + (H_u^TQ)y_r + R u_r\]

Defining the help matrices:

\[\begin{split}F_1 &= (H_u^T Q H_u + R)^{-1} \\ F_2 &= -H_u^TQ \Gamma \\ F_3 &= H_u^TQ\end{split}\]

Leads to the following closed-form gain matrices:

\[\begin{split}K_{x} &= F_1 F_2 \\ K_{y_r} &= F_1 F_3 \\ K_{u_r} &= F_1 R\end{split}\]

With the optimal \(u_f^\star\) calculated as:

\[u_f^* = K_{x} x + K_{y_r} y_r + K_{u_r} u_r\]