## 3 Methodology
### Optimal Control
#### 3.3.1 Full State Feedback (Linear Quadratic Regulator)  
The Full State Feedback controller assumes that every state in the system is available for use in the controller. The input defined as \(u\) in Equation (1) is calculated for Full State Feedback with:  
\[u\ =\ -Kx \tag{3}\]  
The \(K\) variable is the gain of the Full State Feedback controller. Input to the system (\(u\)) is calculated as the product of the negative feedback gain and the state vector (\(x\)). The controller architecture of this controller is defined in Figure 6[25].  
To equate the controller gain \(K\) in Equation (3) for LQR a series of procedures must be followed:  
1. Define the \(Q\) and \(R\) matrices;
2. Solve for \(S\) in the Algebraic Riccati Equation;
3. Compute the controller gains \(K\) from generated \(S\);
4. Evaluate produced controller gains to select the optimal controller.  
The \(Q\) and \(R\) matrices are square matrices the size of the state and input vectors used for weighting the cost function. Each diagonal element of the \(Q\) and \(R\) matrices corresponds to the element of the State or Input vector that they penalize. The cost function \(J\) shown in Equation (4) is used for measuring the cost of the controller. Although the variable \(J\) is not explicitly used in Equations (5)-(8), it shows the relationship between speed of response  
Figure 5: Multiloop PID with Static Output Feedback Control Block Diagram [24].  
Figure 6: Full State Feedback Controller.  
relating to the \(Q\) matrix and the actuator effort in the R matrix used to achieve the desired response from the controller.  
By setting elements in the \(Q\) matrix high, the non-zero states in the \(\overline{x}^{T}\) vector brought about by wind disturbance will introduce a high cost in Equation (4), prioritizing the offset state for faster return to equilibrium. By setting elements in the \(R\) matrix high, the cost of using an actuator is increased, meaning that the controller will prioritize return to equilibrium using small actuator effort. For fast return to equilibrium where actuator effort is not a concern, elements in the \(Q\) matrix are set high, while elements in the \(R\) matrix are set low; this produces a greater cost for non-zero state values. Contrastingly, if the speed of correction is not a priority but rather, conservation of actuator effort is mandatory, then values in the \(Q\) matrix are set low with values in the \(R\) matrix set high; this produces a greater cost for using actuators to respond to the state offset.  
\[J\ =\ \int_{0}^{\infty}\overline{x}^{T}.Q\overline{x}(t)+\overline{u}(t)^{T}R \overline{u}(t)\ dt \tag{4}\]  
Once the \(Q\) and \(R\) matrices are defined, the second step is to solve for S in the Algebraic Riccati Equation defined in Equation (5). This produces more than one solution, however, only one will stabilize the system optimally. The \(Q\) and \(R\) matrices used in Equation (4) defining the cost are used in Equation (5) as the next step towards solving controller gain \(K\).  
\[A^{T}S+SA-SBR^{-1}B^{T}+Q\ =\ 0 \tag{5}\]  
Once \(S\) is found, the feedback gain \(K\) can be computed using Equation (6) below.  
\[K\ =\ R^{-1}B^{T}S \tag{6}\]  
As there is more than one solution for Equation (5), there are many controllers created from Equation (6), each should be evaluated to identify which is optimal. To evaluate the produced controllers, the closed loop eigenvalues are generated using Equations (7) and (8). The controller that pushes all eigenvalues of the closed loop system into the negative domain is taken as optimal.  
\[CL\ =\ A-B.K \tag{7}\]  
\[Eigenvalues\ =\ \det(CL-\lambda\ I) \tag{8}\]  
The optimal controller gain \(K\) generated and evaluated by Equations (5)-(8) can then be used as part of Equation (3) as the feedback term generating the input \(u\) to bring about stability in the system.