**4. LPV-MPC Controller**

To develop a MPC scheme for LPV models, the future states need to be formulated so a trajectory can be formed along the prediction horizon. The *i*-steps-ahead prediction can be structured as the following:

$$\mathbf{x}(k+i|k) = \left(\prod\_{j=0}^{i-1} \mathbf{A}\left(\rho\_1(k+j)\right) \mathbf{x}(k) + \left(\sum\_{s=1}^{i-1} \left(\prod\_{l=s}^{i-1} \mathbf{A}\left(\rho\_1(k+l)\right)\right)\right) \mathbf{B}u(k+s-1)\right) + \mathbf{B}u(k+i-1) \tag{11}$$

Prediction of the future states needs to be performed for the future *Np* time steps, thus using (11) the following matrix equation can be deduced.

$$\mathbf{X} = \Phi \ast \mathbf{x}(k) + \mathbf{Y} \ast \mathbf{U} \tag{12}$$

Where:

$$\mathbf{X} = \begin{bmatrix} x(k+1|k) \\ x(k+2|k) \\ \vdots \\ x(k+N\_p|k) \end{bmatrix} \tag{13}$$
 
$$\boldsymbol{\Phi} = \begin{bmatrix} \mathbf{A}(\rho\_1(k)) \\ \prod\_{j=0}^{1} \left( \mathbf{A}\left(\rho\_1(k+j)\right) \right) \\ \vdots \\ \prod\_{j=0}^{N\_p-1} \left( \mathbf{A}\left(\rho\_1(k+j)\right) \right) \end{bmatrix} \tag{14}$$

$$\mathbf{V} = \begin{bmatrix} \mathbf{B} & \mathbf{0}\_{n\_x \times n\_u} & \dots & \mathbf{0}\_{n\_x \times n\_u} \\ \mathbf{A} \left( \rho\_1 (k+1) \right) \mathbf{B} & \mathbf{B} & \dots & \mathbf{0}\_{n\_x \times n\_u} \\ \mathbf{A} \left( \rho\_1 (k+2) \right) \mathbf{A} \left( \rho\_1 (k+1) \right) \mathbf{B} & \mathbf{A} \left( \rho\_1 (k+2) \right) \mathbf{B} & \dots & \mathbf{0}\_{n\_x \times n\_u} \\ \vdots & \vdots & \ddots & \vdots \\ \left( \prod\_{i=1}^{N\_V} \mathbf{A} \left( \rho\_1 (k+i) \right) \right) \mathbf{B} & \left( \prod\_{i=1}^{N\_V-1} \mathbf{A} \left( \rho\_1 (k+i+1) \right) \right) \mathbf{B} & \dots & \mathbf{B} \end{bmatrix} \tag{15}$$

$$\mathbf{U} = \begin{bmatrix} u(k) \\ u(k+1) \\ \vdots \\ u(k+N\_p-1) \end{bmatrix} \tag{16}$$

with **<sup>X</sup>** <sup>∈</sup> <sup>R</sup>*Np*·*nx* , **<sup>Φ</sup>** <sup>∈</sup> <sup>R</sup>*Np*·*nx*×*nx* , **<sup>Ψ</sup>** <sup>∈</sup> <sup>R</sup>*Np*·*nx*×*Np*·*nu* and **<sup>U</sup>** <sup>∈</sup> <sup>R</sup>*Np*·*nu* where *nx* is the number of states and *nu* the number of inputs. With the state prediction equation, we can construct a cost function to minimize the deviation from the equilibrium states and the energy used by the inputs, so that the cost function is defined as:

$$J = \mathbf{X}^{\mathrm{T}} \mathbf{Q}\_{\mathrm{c}} \mathbf{X} + \mathbf{U}^{\mathrm{T}} \mathbf{R}\_{\mathrm{c}} \mathbf{U} \tag{17}$$

where **Qc** and **Rc** are weight matrix of appropriate dimensions. To find the optimal control trajectory **U**, (17) needs to be minimized subject to the constraints in the inputs (18) and the states (19).

$$
u\_{\min} \le \mathcal{U} \le u\_{\max} \tag{18}$$

$$\mathbf{x}\_{\min} \le \mathbf{X} \le \mathbf{x}\_{\max} \tag{19}$$

with both *umin* & *umax* <sup>∈</sup> <sup>R</sup>*Np*×*nu* and both *xmin* & *xmax* <sup>∈</sup> <sup>R</sup>*Np*×*Np* . However, to properly solve the MPC problem, the future values of *ρ*1, which are unknown, must be estimated. To obtain the values we must estimate them using an RLS approach to obtain an approximate value of the scheduling parameter based on its previous behavior and the system response.

#### **5. Scheduling Parameter Prediction Using RLS**

To obtain an estimation of the future scheduling parameter, an RLS approach is used as presented by Sename, Morato & Normey-Rico in [26]. The scheduling parameter is assumed to be measurable at instant *k* and all previous values can be stored; however, the future parameters will be estimated based on the previous measurements of the scheduling parameters as well as the previous inputs and outputs to consider the behavior of the system.

The behavior of the scheduling parameter of a LPV system can be approximated by a linear ARX model, which is a function of the previous scheduling parameter values, the previous inputs and the previous outputs. This ARX model can be represented as:

$$
\rho\_1(k + N\_p) = a\_0 \rho\_1(k) + \dots + a\_{N\_p} \rho\_1(k - N\_p) + b\_0 \mu(k - 1) + \dots
$$

$$
\dots + b\_{N\_p} \mu(k - N\_p - 1) + c\_0 \mu(k) + \dots + c\_{N\_p} \mu(k - Np) \tag{20}
$$

Afterwards, (20) can be expressed in a compact form and be dependent only on known values to be suitable for MPC design. To find a solution to the RLS, parameters *a*<sup>0</sup> to *cNp* need to be calculated. These parameters will be grouped into the following vector:

$$\boldsymbol{\Theta}(k) = \begin{bmatrix} a\_{0} \dots c\_{N\_{p}} \end{bmatrix}^{T} \tag{21}$$

resulting in:

$$
\rho\_1(k) = \gamma(k)^T \Theta(k) \tag{22}
$$

with:

$$\gamma(k)^{\mathsf{T}} = \left[ \rho\_1(k - N\_{\mathsf{P}}), \dots, \rho\_1(k - 2N\_{\mathsf{P}}), u(k - N\_{\mathsf{P}} - 1), u(k - 2N\_{\mathsf{P}} - 1), y(k - N\_{\mathsf{P}}), \dots, y(k - 2N\_{\mathsf{P}}) \right] \tag{23}$$

with (22) and (23) a direct solution can be built and used to find *ρ*<sup>1</sup> in an online RLS algorithm as presented in [30]:

$$\Theta(k) = \Theta(k-1) + \sigma(k)\left(\rho\_1(k) - \gamma(k-1)^T \Theta(k-1)\right) \tag{24}$$

$$\mathbf{Q}(k) = \left(I - \sigma(k)\gamma(k)^T\right) \frac{\mathbf{Q}(k-1)}{\mu} \tag{25}$$

with *μ* ∈ [0, 1] being a forgetting factor that gives exponentially less weight to older error samples of the RLS algorithm and *σ*(*k*) being a vector defined as:

$$
\sigma(k) = \frac{1}{\mu c(k)} \hat{\mathbf{Q}}(k-1)\gamma(k) \tag{26}
$$

and *c*(*k*) is a scalar defined by:

$$\mathcal{L}(k) = 1 + \gamma(k)^T \frac{\mathbf{\hat{Q}}(k-1)}{\mu} \gamma(k) \tag{27}$$

Therefore, the RLS algorithm for estimating the future scheduling parameters is shown as Algorithm 1:

After solving the RLS algorithm for the *Np* future scheduling parameters, they will be considered to be known and exact to build a vector **Pˆ**(*k*) = - *ρ*1(*k*), ..., *ρ*1(*k* + *Np*) *T* which contains all of them; therefore, (12) is no longer an equation with unknown variables and can be solved through LMI optimization.
