# A Randomized Algorithm for Optimal PID Controllers
## 3 Statement of the Problem  
The \(H_{\infty}\) and \(H_{2}\) norm minimization relates to the transfer function \(T_{\hat{w},\hat{z}}\left(s\right)\) from the noise \(\hat{w}\) to the output \(\hat{z}\) (when the reference signal \(\hat{r}\) is zero and the system is derived only by the noise). The transfer function is given by:  
\[T_{\hat{w},\hat{z}}\left(s\right)=\hat{D}_{1,1}+\left(\hat{C}_{1}-\hat{D}_{1,2 }\hat{R}\hat{C}_{2}\right)\left(sI-\hat{A}+\hat{B}_{2}\hat{R}\hat{C}_{2}\right) ^{-1}\hat{B}_{1}. \tag{3}\]  
In order that the \(H_{2}\)-norm of \(T_{\hat{w},\hat{z}}\left(s\right)\) would be finite, we need that \(\hat{D}_{1,1}=0\). We therefore have the following lemma (given without a proof):  
**Lemma 1**: _We have:_  
\[\hat{D}_{1,1}=D_{1,1}-D_{1,2}M^{-1}K_{D}C_{2}B_{1}=D_{1,1}-D_{1,2}\hat{K}_{3}C _{2}B_{1}=0, \tag{4}\]  
_if and only if:_  
\[\left(\left(C_{2}B_{1}\right)^{T}\otimes\ D_{1,2}\right)\cdot\left(\left(C_{2} B_{1}\right)^{T}\otimes\ D_{1,2}\right)^{+}\mathit{vec}\left(D_{1,1}\right)= \mathit{vec}\left(D_{1,1}\right). \tag{5}\]  
_In this case, the set of all matrices \(\hat{K}_{3}\) satisfying (4) is given by:_  
\[\hat{K}_{3}=\mathit{mat}\left(\left(\left(C_{2}B_{1}\right)^{T}\otimes\ D_{1,2 }\right)^{+}\mathit{vec}\left(D_{1,1}\right)+L_{\left(C_{2}B_{1}\right)^{T} \otimes\ D_{1,2}}\mathit{vec}\left(Z\right)\right), \tag{6}\]  
_where \(Z\) is arbitrary matrix with the same size as \(\hat{K}_{3}\)._  
For the LQR minimization, we assume that \(\hat{w}\left(t\right)=0\) and \(\hat{r}\left(t\right)=0\), i.e., the system is derived by the initial state \(\hat{x}_{0}:=\hat{x}\left(0\right)\) (initial step input). Assume that a SOF \(\hat{K}\) was found, such that \(\hat{A}_{c\ell}\left(\hat{K}\right):=\hat{A}-\hat{B}_{2}\hat{R}\hat{C}_{2}\) is stable. Let the LQR functional be defined by:  
\[J\left(\hat{x}_{0}\right):=\int_{0}^{\infty}\left(\hat{x}\left(t\right)^{T}Q \hat{x}\left(t\right)+\hat{z}\left(t\right)^{T}R\hat{z}\left(t\right)\right)dt, \tag{7}\]  
where \(Q>0\) and \(R\geq 0\). Let \(\hat{C}\left(\hat{K}\right):=\hat{C}_{1}-\hat{D}_{1,2}\hat{R}\hat{C}_{2}\). Then, \(\hat{z}\left(t\right)=\hat{C}\left(\hat{K}\right)\hat{x}\left(t\right)\) and substitution of the last into (7) yields  
\[J\left(\hat{x}_{0},\hat{K}\right)=\int_{0}^{\infty}\hat{x}\left(t\right)^{T} \left(Q+\hat{C}\left(\hat{K}\right)^{T}R\hat{C}\left(\hat{K}\right)\right) \hat{x}\left(t\right)dt=\hat{x}_{0}^{T}P\left(\hat{K}\right)\hat{x}_{0}, \tag{8}\]  
where \(P\left(\hat{K}\right)>0\) is the unique solution to the Lyapunov equation  
\[\hat{A}_{c\ell}\left(\hat{K}\right)^{T}P+P\hat{A}_{c\ell}\left(\hat{K}\right)= -\left(Q+\hat{C}\left(\hat{K}\right)^{T}R\hat{C}\left(\hat{K}\right)\right) \tag{9}\]  
given explicitly by  
\[P\left(\hat{K}\right)=-\mathit{mat}\left(\left(I\otimes\hat{A}_{c\ell}\left( \hat{K}\right)^{T}+\hat{A}_{c\ell}\left(\hat{K}\right)^{T}\otimes I\right)^{-1} \cdot\mathit{vec}\left(Q+\hat{C}\left(\hat{K}\right)^{T}R\hat{C}\left(\hat{K} \right)\right)\right). \tag{10}\]Thus, we look for SOF \(\hat{K}\) that minimizes the functional \(J\left(x_{0},\hat{K}\right)=\hat{x}_{0}^{T}P\left(\hat{K}\right)\hat{x}_{0}\). When \(\hat{x}_{0}\) is unknown, we seek a SOF \(\hat{K}\) for which  
\[\sigma_{max}\left(\hat{K}\right):=\max\left(\sigma\left(P\left(\hat{K}\right) \right)\right) \tag{11}\]  
is minimal. In this case, we get a robust LQR via SOF, in the sense that it minimizes \(J\left(\hat{x}_{0},\hat{K}\right)\) for the worst possible (unknown) \(\hat{x}_{0}\). Please note that  
\[\hat{x}_{0}^{T}P\left(\hat{K}\right)\hat{x}_{0} =\left\|P\left(\hat{K}\right)^{\frac{1}{2}}\hat{x}_{0}\right\|^{2}\leq\] \[\hat{D}_{1,1}=D_{1,1}-D_{1,2}M^{-1}K_{D}C_{2}B_{1}=D_{1,1}-D_{1,2}\hat{K}_{3}C _{2}B_{1}=0, \tag{4}\]0 \[\hat{D}_{1,1}=D_{1,1}-D_{1,2}M^{-1}K_{D}C_{2}B_{1}=D_{1,1}-D_{1,2}\hat{K}_{3}C _{2}B_{1}=0, \tag{4}\]1  
and that there exists \(\hat{x}_{0}\
eq 0\) for which equality holds.