# A Randomized Algorithm for Optimal PID Controllers
## 5 Experimental Section  
To synthesize LQR or \(H_{\infty}\) optimal PID controller, we execute the Ray-Shooting algorithm ([6]) in order to get a starting SOF \(\hat{K}^{(0)}\) such that the augmented system (1) is \(\Omega\)-stable and \(I-\hat{K}^{(0)}_{3}C_{2}B_{2}\) is invertible. Next, we apply Algorithm 1 in order to get \(\hat{K}^{(best)}\) from which the PID controller is derived,using (2). For the \(H_{2}\) optimal PID controller, we execute the Ray-Shooting algorithm, in order to get a starting SOF \(\hat{K}^{(0)}\), as above. Next, we execute the algorithm from [7], in order to get a SOF \(\hat{K}^{(1)}\) with the structure (6). This step is the most demanding step as can be seen from the following example. Finally, we execute Algorithm 1 in order to get \(\hat{K}^{(best)}\) from which the PID controller is derived, using (2). **Example 1**. : _For the AC1 system (taken from COMP\(l_{e}\)ib--see [27; 28; 29]) with the following state-space model:_  
\[A=\left[ \begin{array}{cccc}0&0&1.132&0&-1\\ 0&-0.0538&-0.1712&0&0.0705\\ 0&0&0&1&0\\ 0&0.0485&0&-0.8556&-1.013\\ 0&-0.2909&0&1.0532&-0.6859\\ \end{array} \right],\]  
\[B_{1}=\left[ \begin{array}{cccc}0.03593&0&0.01672\\ 0&0.00989&0\\ 0&-0.07548&0\\ 0&0&0.05635\\ 0.00145&0&0.06743\\ \end{array} \right],B_{2}=\left[ \begin{array}{cccc}0&0&0\\ -0.12&1&0\\ 0&0&0\\ 4.419&0&-1.665\\ 1.575&0&-0.0732\\ \end{array} \right]\]  
\[C_{1}=\left[ \begin{array}{cccc}0&0.707106781186547&0&0&0\\ 0&0&0.707106781186547&0&0\\ \end{array} \right],\]  
_and_  
\[D_{1,1}=0_{2\times 3}\]  
\[D_{1,2}=\left[ \begin{array}{cccc}0.707106781186547&0&0\\ 0&0.707106781186547&0\\ \end{array} \right]\]  
\[C_{2}=\left[ \begin{array}{cccc}1&0&0&0&0\\ 0&1&0&0&0\\ 0&0&1&0&0\\ \end{array} \right]\]  
\[D_{2,1}=0_{3\times 3}\]  
_with_  
\[\sigma\left(A\right)=\left\{ \begin{array}{c}0\\ -0.780052457480417\pm 1.029636749384622i\\ -0.017597542519583\pm 0.182585375210158i\\ \end{array} \right\},\]  
_let the objective be to find a PID LQR-optimal controller, where the closed-loop eigenvalues should be in the rectangular region defined by:_  
\[\Omega=\left\{z\in\mathbb{C}\left|-1\leq\Re\left(z\right)\leq-0.1,\left|\Im \left(z\right)\right|\leq 1\right\}.\]  
_With the following parameters for the algorithm: \(m=100,n=100,s=100,h=r_{\infty}=100,\epsilon=10^{-16}\), \(Q=I_{8}\), \(R=I_{2}\) we had the following feasible SOF_  
\[\hat{K}^{(0)}=\left[ \begin{array}{cc}\hat{K}_{1}^{(0)}&\hat{K}_{2}^{(0)}& \hat{K}_{3}^{(0)}\\ \end{array} \right],\]  
_where_  
\[\hat{K}_{1}^{(0)}=\left[ \begin{array}{cc}0&0\\ 0&0\\ 0&0\\ \end{array} \right],\]  
_and_  
\[\hat{K}_{2}^{(0)}=\left[ \begin{array}{cc}0&0\\ 0&0\\ 0&0\\ \end{array} \right],\]  
\[\hat{K}_{1}^{(0)}=\left[ \begin{array}{rr}-1.139087350327457&-0.076805805847702&-1. 175733971595813\\ 0.175620269295905&1.249662743416654&-0.394592760970558\\ -2.524143751375688&-0.262506326222373&-3.380417685135832\end{array} \right]\]  
\[\hat{K}_{2}^{(0)}=\left[ \begin{array}{rr}-0.265188982290714&0.082432589634872 &-0.236137372902669\\ 0.106177753653144&0.443637620004996&-0.074457362520092\\ -0.527328403725350&0.200910957443737&-0.850599462623321\end{array} \right]\]  
\[\hat{K}_{3}^{(0)}=\left[ \begin{array}{rr}-1.120493844818183&0.1905819990143 16&-0.522738193473694\\ -0.036425300944087&-0.028600461083115&-0.183279009240151\\ -3.229623103192055&0.550761163041108&-2.205172558841497\end{array} \right],\]  
_found by the Ray-Shooting algorithm in \(CPU-time=0.0001[sec]\) and with LQR functional value \(f_{\text{LQR}}\left(\hat{K}^{(0)}\right)=16.746246825328360\). Executing Algorithm 1, we had_  
\[\hat{K}^{(best)}=\left[ \begin{array}{rr}\hat{K}_{1}^{(best)}&\hat{K}_{2}^{( best)}&\hat{K}_{3}^{(best)}\end{array} \right],\]  
_where_  
\[\hat{K}_{1}^{(best)}=\left[ \begin{array}{rr}-1.085160433924800&-0. 152380406023858&-1.111840435453025\\ 0.173224251962231&1.253268146513151&-0.449756208653024\\ -2.518304745419560&-0.284285880826183&-3.437786815141788\end{array} \right]\]  
\[\hat{K}_{2}^{(best)}=\left[