# How would I find the solution of explicit MPC with piecewise u?

If I want to use this kind of system model

x(k+1)=$$A$$x(k)+$$\overbrace{[\Phi_1\ \Phi_2]}^{B}\begin{bmatrix} u(k)\\ u(k+1)\\ \end{bmatrix}$$

(Assume that the input is linearly interpolated between sample times) to solve the cost function

$$J(k) = \min_u \sum_{j=1}^{N_p-1} \|x(k+j|k)\|_{Q_i}^2 + \sum_{j=0}^{N_c-1} \|u(k+j)\|_{P_i}^2$$ by using explicit MPC.

\begin{aligned} \begin{bmatrix} x(k+1|k)\\ x(k+2|k) \\ \vdots \\ \vdots \\ \vdots \\ x(k+N_p-1|k)\\ x(k+N_P|k) \\ \end{bmatrix} &= \overbrace{\begin{bmatrix} A\\ A^2\\ A^3\\ \vdots \\ A^{N_p} \end{bmatrix}}^{M_x}x(k)+\overbrace{\begin{bmatrix} B &0 &\cdots & 0\\ AB & B & \cdots & 0\\ \vdots & \vdots & \ddots &\vdots \\ A^{N_{p}-1}B & A^{N_{p}-2}B & \cdots & A^{N_{p}-N_{c}}B\end{bmatrix}}^{M_u}\begin{bmatrix} u(k|k)\\ u(k+1|k) \\ u(k+1|k) \\ u(k+2|k) \\ \vdots \\ \vdots \\ u(k+N_c-1|k)\\ u(k+N_c-1|k)\\ u(k+N_c|k) \\ \end{bmatrix}\\ \end{aligned}

\begin{aligned} \label{Kostenfunktion} \mathbf{H}&=\mathbf{M}_{u}^{T}\mathbf{Q}\mathbf{M}_{u}+\mathbf{P}\\ \mathbf{f}^T&=-\mathbf{M}_{u}^{T}\mathbf{Q}(-\mathbf{M}_{x}x_{k})\\ \mathbf{u}&=-inv(\mathbf{H})*\mathbf{f}\\ \end{aligned}

should I still choose the first $$u=[1\ 0\ 0\ 0... 0]^T\mathbf{u}$$ as optimal input other $$u=[1\ 1\ 0\ 0... 0]^T\mathbf{u}$$ during the optimization?

• What do you mean by chosing the first $u$ as optimal input? Since you have an explicit optimal formula for $u$. Jan 22, 2020 at 4:11
• Thank you for your reply:) I mean, should I choose the $u=[1 1;0 0;0 0;...;0 0]u$ as the optimal control input for next iteration? Because my input is u=[u(k), u(k+1)]^T Jan 22, 2020 at 8:37

You could do a coordinate transformation such that it could be written into a more standard form. For your original system I use the following notation

$$x[k+1] = A\,x[k] + B_1\,u[k] + B_2\,u[k+1] \tag{1}$$

and the new coordinates are defined as

$$z[k] = x[k] - B_2\,u[k]. \tag{2}$$

Increasing the index in $$(2)$$ and substituting in $$(1)$$ gives

$$z[k+1] = A\,x[k] + B_1\,u[k]. \tag{3}$$

Solving $$(2)$$ for $$x[k]$$ and substituting that into $$(3)$$ gives the following standard form state space model

\begin{align} z[k+1] &= A\,(z[k] + B_2\,u[k]) + B_1\,u[k], \tag{4a} \\ &= A\,z[k] + (\underbrace{A\,B_2 + B_1}_{B})\,u[k]. \tag{4b} \end{align}

The cost function now has to be written in terms of $$z[k]$$ instead of $$x[k]$$

$$J(k) = \min_u \sum_{j=1}^{N_p-1} \|z[k+j|k] + B_2\,u[k+j]\|_{Q_i}^2 + \sum_{j=0}^{N_c-1} \|u[k+j]\|_{P_i}^2, \tag{5}$$

where the terms in the first summation can also be written as

\begin{align} \|z[k+j|k] + B_2\,u[k+j]\|_{Q_i}^2 &= (z[k+j|k] + B_2\,u[k+j])^\top Q_i\,(z[k+j|k] + B_2\,u[k+j]), \\ &= z[k+j|k]^\top Q\,z[k+j|k] + 2\,z[k+j|k]^\top N\,u[k+j] + u[k+j]^\top R\,u[k+j], \end{align}

with $$Q = Q_i$$, $$N = Q_i\,B_2$$ and $$R = B_2^\top Q_i\,B_2$$.

• Thank you so much, that's really help me a lot:) Jan 22, 2020 at 13:29