# A Randomized Algorithm for Optimal PID Controllers
## 1 Introduction
For two sets \(X,Y\) we denote by \(CH\left(X,Y\right)\) the convex-hull of \(X\) and \(Y\), i.e., the minimal closed convex set that contains \(X\cup Y\). **2. The Problem of Stabilization via PID Controllers**  
Let a system be given by:  
\[\left\{ \begin{array}{l}\dot{x}\left(t\right)=Ax\left(t\right)+B_{1}w\left(t \right)+B_{2}u\left(t\right)\\ z\left(t\right)=C_{1}x\left(t\right)+D_{1,1}w\left(t\right)+D_{1,2}u\left(t\right) \\ y\left(t\right)=C_{2}x\left(t\right)+D_{2,1}w\left(t\right),\end{array} \right.\]  
where \(A\in\mathbb{R}^{n_{x}\times n_{x}},B_{1}\in\mathbb{R}^{n_{x}\times n_{w}},B_{ 2}\in\mathbb{R}^{n_{x}\times n_{x}},C_{1}\in\mathbb{R}^{n_{x}\times n_{x}},D _{1,1}\in\mathbb{R}^{n_{x}\times n_{w}},D_{1,2}\in\mathbb{R}^{n_{x}\times n_{ u}},C_{2}\in\mathbb{R}^{n_{y}\times n_{x}},D_{2,1}\in\mathbb{R}^{n_{y}\times n_{w}}\), where \(x\) is the state, \(z\) is the regulated output, \(y\) is the measurement, \(u\) is the control input and \(w\) is the noise. Assume that \(D_{2,1}=0\) and let  
\[u\left(t\right)=r\left(t\right)-K_{P}y\left(t\right)-K_{I}\int_{0}^{t}y\left( \tau\right)d\tau-K_{D}\dot{y}\left(t\right),\]  
where \(r\left(t\right)\) is the new reference input. Let \(\hat{x}\left(t\right)=\left[ \begin{array}{c}x\left(t\right)\\ \int_{0}^{t}y\left(\tau\right)d\tau\end{array} \right]\) be the augmented state, then:  
\[u\left(t\right) =r\left(t\right)-K_{P}y\left(t\right)-K_{I}\int_{0}^{t}y\left( \tau\right)d\tau-K_{D}\dot{y}\left(t\right)\] \[=r-K_{P}\left[ \begin{array}{cc}C_{2}&0\end{array} \right]\hat{x }\left(t\right)-K_{I}\left[ \begin{array}{cc}0&I\end{array} \right]\hat{x} \left(t\right)+\] \[\quad-K_{D}C_{2}\hat{x}\left(t\right)\] \[=r-K_{P}\left[ \begin{array}{cc}C_{2}&0\end{array} \right]\hat{x }\left(t\right)-K_{I}\left[ \begin{array}{cc}0&I\end{array} \right]\hat{x} \left(t\right)+\] \[\quad-K_{D}C_{2}\left(Ax\left(t\right)+B_{1}w\left(t\right)+B_{2 }u\left(t\right)\right),\]  
implying that:  
\[u\left(t\right) =M^{-1}r\left(t\right)-M^{-1}K_{P}\left[ \begin{array}{cc}C_{2} &0\end{array} \right]\hat{x}\left(t\right)+\] \[\quad-M^{-1}K_{I}\left[ \begin{array}{cc}0&I\end{array} \right] \hat{x}\left(t\right)+\] \[\quad-M^{-1}K_{D}\left[ \begin{array}{cc}C_{2}A&0\end{array}  \right]\hat{x}\left(t\right)-M^{-1}K_{D}C_{2  
where:  
\[\left\{ \begin{array}{l}\hat{w}\left(t\right)=w\left(t\right)\\ \hat{u}\left(t\right)=\hat{r}\left(t\right)-\hat{K}\hat{y}\left(t\right)\\ \hat{r}\left(t\right)=M^{-1}r\left(t\right)\\ \hat{y}\left(t\right)=\left[\begin{array}{c}\mathcal{C}_{2}x\left(t\right) \\ \int_{0}^{t}y\left(\tau\right)d\tau\\ \mathcal{C}_{2}Ax\left(t\right)\end{array}\right]\\ \hat{K}=M^{-1}\left[\begin{array}{cc}K_{P}&K_{I}&K_{D}\end{array}\right]. \end{array} \right.\]  
Let  
\[\left\{ \begin{array}{l}\hat{A}=\left[\begin{array}{cc}A&0\\ C_{2}&0\end{array}\right],\;\hat{B}_{2}=\left[\begin{array}{c}B_{2}\\ 0\end{array}\right]\\ \hat{B}_{1}=\left[\begin{array}{c}B_{1}-B_{2}M^{-1}K_{D}C_{2}B_{1}\\ 0\end{array}\right]\\ \hat{C}_{1}=\left[\begin{array}{cc}C_{1}&0\end{array}\right],\;\hat{C}_{2}= \left[\begin{array}{cc}C_{2}&0\\ 0&I\\ C_{2}A&0\end{array}\right]\\ \hat{D}_{1,1}=D_{1,1}-D_{1,2}M^{-1}K_{D}C_{2}B_{1},\;\hat{D}_{1,2}=D_{1,2}.\end{array} \right.\]  
Let \(\hat{z}\left(t\right)=z\left(t\right)\) then, the augmented system is given by:  
\[\left\{ \begin{array}{l}\hat{x}\left(t\right)=\left(\hat{A}-\hat{B}_{2}\hat{ K}\hat{C}_{2}\right)\hat{x}\left(t\right)+\hat{B}_{1}\hat{w}\left(t\right)+\hat{B}_{2} \hat{r}\left(t\right)\\ \hat{z}\left(t\right)=\left(\hat{C}_{1}-\hat{D}_{1,2}\hat{K}\hat{C}_{2}\right) \hat{x}\left(t\right)+\hat{D}_{1,1}\hat{w}\left(t\right)+\hat{D}_{1,2}\hat{r }\left(t\right)\\ \hat{y}\left(t\right)=\hat{C}_{2}\hat{x}\left(t\right).\end{array} \right. \tag{1}\]  
Once that a stabilizing SOF matrix \(\hat{K}=\left[ \begin{array}{cc}\hat{K}_{1}&\hat{K}_{2}&\hat{K}_{3}\end{array} \right]\) for the augmented system (1) has been found, we have \(K_{D}=M\hat{K}_{3}\).