# Adaptive Model Output Following Control for a Networked Thermostat +
## 4 Adaptive Model Output Following Control
### Adaptation  
The adaptive controller is based on CGT theory. Assume that the reference model is denoted by \(G_{m}(s)\) and expressed as:  
\[G_{m}(s)=\frac{K_{m}}{T_{m}s+1}, \tag{36}\]  
and the state-space representation of \(G_{m}(s)\) is described as follows:  
\[\left\{ \begin{array}{l}\dot{x}_{m}(t)=A_{m}x_{m}(t)+B_{m}u_{m}(t)=-\frac{y_{ m}(t)}{T_{m}}+\frac{K_{m}}{T_{m}}u_{m}(t)\\ y_{m}(t)=\mathrm{C}_{m}x_{m}(t)+D_{m}u_{m}(t)=y_{m}(t)\end{array} \right., \tag{37}\]  
where \(x_{m}(t)\) can be represented by  
\[x_{m}(t)=y_{m}(t)=K_{m}u_{m}(t)-T_{m}y_{m}(t). \tag{38}\]  
Assuming the state space of \(G_{p}(s)\) is represented by  
\[\left\{ \begin{array}{l}\dot{x}_{p}(t)=Ax_{p}(t)+Bu_{p}(t)\\ y_{p}(t)=\mathrm{C}x_{p}(t)+Du_{p}(t)\end{array} \right., \tag{39}\]  
the tracking controller is given by [30]  
\[u^{*}(t)=S_{21}x_{m}(t)+S_{22}u_{m}(t)+S_{3}(t), \tag{40}\]where  
\[S_{11} =\Omega_{11}S_{11}A_{m}+\Omega_{12}C_{m}^{\mathrm{T}}, \tag{41}\] \[S_{12} =\Omega_{11}S_{11}B_{m},\] \[S_{21} =\Omega_{11}S_{11}A_{m}+\Omega_{22}C_{m}^{\mathrm{T}},\] \[S_{22} =\Omega_{11}S_{11}B_{m},\] \[\Omega_{11}\dot{v}(t) =v(t)-S_{12}\dot{u}_{m},\] \[S_{3} =\Omega_{21}v(t) \tag{42}\]  
\[ \begin{bmatrix}A&B\\ C^{\mathrm{T}}&D\end{bmatrix}\begin{bmatrix}\Omega_{11}&\Omega_{12}\\ \Omega_{21}&\Omega_{22}\end{bmatrix} =I. \tag{43}\]  
**Theorem 1**. : _When the NCS model and the first-order reference model are represented by Equations (21) and (36), respectively, the tracking performance can be ensured by the following forward controller:_  
\[u^{*}(t)=S_{1}x_{m}(t)+S_{2}\dot{y}_{m}(t)+S_{3}(t), \tag{44}\]  
_where \(S_{1}\) and \(S_{2}\) are computed by_  
\[S_{1} =K_{m}\frac{f_{n}}{e_{n}},\] \[S_{2} =(\frac{\Omega_{21}S_{11}}{T_{m}}-\frac{f_{n}}{e_{n}})T_{m}. \tag{45}\]  
_The first term, \(S_{1}x_{m}(t)\) in Equation (44), guarantees the steady steady-state error, and the other two ensure the tracking performance._  
Proof of Theorem 1.: Based on Equation (21), the state-space function of the NCS model \(G_{p}(\mathbf{s})\) can be given by  
\[\dot{x}_{p}(t) = \begin{bmatrix}0&1&0&\cdots&0\\ 0&0&1&\cdots&0\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ 0&0&0&0&1\\ -f_{n}&-f_{n-1}&-f_{n-2}&\cdots&-f_{1}\end{bmatrix} x_{p}(t)+ \begin{bmatrix} \gamma_{1}\\ \gamma_{2}\\ \vdots\\ \gamma_{n-1}\\ \gamma_{n}\end{bmatrix} u_{p}(t) \tag{46}\] \[y_{p}(t) =[1,0,\cdots,0,0]x_{p}(t)+\gamma_{0}u_{p}(t), \tag{47}\]  
where \([\gamma_{0},\gamma_{1},\gamma_{2},\cdots,\gamma_{n}]^{\mathrm{T}}\) is the solution of the following matrix equation  
\[ \begin{bmatrix}1&0&0&0\\ f_{1}&1&0&0\\ f_{2}&f_{1}&1&0\\ \vdots&\vdots&\vdots\\ f_{n}&f_{n-1}&f_{n-2}&1\end{bmatrix}\begin{bmatrix}\gamma_{0}\\ \gamma_{1}\\ \gamma_{2}\\ \vdots\\ \gamma_{n}\end{bmatrix} = \begin{bmatrix}e_{0}\\ e_{1}\\ e_{2}\\ \vdots\\ e_{n}\end{bmatrix} . \tag{48}\]  
Based on the equation above, the following equation can be obtained:  
\[\gamma_{n}+f_{1}\gamma_{n-1}+\cdots+f_{n}\gamma_{0}=e_{n}. \tag{49}\]  
Then \( \begin{bmatrix}A&B\\ C^{\mathrm{T}}&D\end{bmatrix} \) can be written as \[ \begin{bmatrix}A&B\\ C^{\text{T}}&D\end{bmatrix} = \begin{bmatrix}0&1&0&\cdots&0&\gamma_{1}\\ 0&0&1&\cdots&0&\gamma_{2}\\ \vdots&\vdots&\vdots&\ddots&\vdots&\vdots\\ 0&0&0&\cdots&1&\gamma_{n-1}\\ -f_{n}&-f_{n-1}&-f_{n-2}&\cdots&-f_{1}&\gamma_{n}\\ 1&0&0&\cdots&0&\gamma_{0}\end{bmatrix} . \tag{50}\]  
Its value can be computed by  
\[ \begin{array}{ll}\left|\begin{array}{ll}A&B\\ C^{\text{T}}&D\end{array}\right|&=(-1)^{n}(\gamma_{n}+f_{1}\gamma_{n-1}+ \cdots+f_{n}\gamma_{0})\\ &=(-1)^{n}e_{n}.\end{array}  \tag{51}\]  
The algebraic complement \(M_{(n+1)(n+1)}\) of the element at \(n+1\) row and \(n+1\) column in \(\left| \begin{array}{ll}A&B\\ C^{\text{T}}&D\end{array} \right|\) is shown as following  
\[M_{(n+1)(n+1)} =\left| \begin{array}{llll}0&1&0&0\\ 0&0&1&0\\ \vdots&\vdots&\vdots&\vdots\\ 0&0&0&1\\ -f_{n}&-f_{n-1}&-f_{n-2}&-f_{1}\end{array} \right|\] \[=(-1)^{n}f_{n}. \tag{52}\]  
The variable \(\Omega_{22}\) can be given by  
\[\Omega_{22}=\frac{M_{(n+1)(n+1)}}{\left|