## 3 T-S Fuzzy Modelling
### Fuzzy Identification of a Second-Order System  
It is well known that any real-time system identification technique is commonly affected by uncertainties and identification errors. In fact, if multiple runs of an identification process applied to exactly the same model were performed, we would end up obtaining similar but slightly different results [30]. For this reason, we decided to use fuzzy logic to determine a model that was sufficiently close to the physical system and that would allow us to perform the desired voltage regulation despite the inherent errors and uncertainties. Since the central axis of the modelling with fuzzy logic lies in the knowledge base of the system to be modelled, we rely on the observation of the operation of the power generation system of this research work, and the experimental measurements of the input-output, to propose four fuzzy rules. Thus, the grouping of the power generator operation dynamics was divided into four clusters, using the learning data \(Z=[VG(k-1);VG(k);u(k)]\). These clusters correspond to the time series of the voltage measurements of the electrical generator and the excitation of the system, which are respectively in variables of state \(x_{1}\) and \(x_{2}\) and the input signal \(u(k)\). The centroids of the prototype membership functions were determined using the c-means algorithm. Table 1 presents the 4 coordinates of the centroids, which were obtained in Matlab(r) using the _fcn()_ function inside the search loop for the best parameter \(m\) with Algorithm 1. These values correspond to the time series of the measurements of the voltage of the electric generator and the PWM excitation, which are, respectively, in the identification of the states \(x_{1}\), \(x_{2}\), and \(u(k)\) control signal, as shown in Figure 1. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Centroids** & \(\mathbf{x_{1}}\) & \(\mathbf{x_{2}}\) & \(\mathbf{u}\) \\ \hline
1 & 45.5960 & 45.5858 & 0.7158 \\
2 & 38.8837 & 38.8710 & 0.6258 \\
3 & 21.2521 & 21.2416 & 0.3369 \\
4 & 25.3004 & 23.9919 & 0.4860 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Centres of the prototype membership functions. ```
\(VG,u\leftarrow\) Load open_loop_experimental_data.mat \(Z\leftarrow\left[VG(k-1),VG(k),u(k)\right]\) \(c\gets 4\) \(\triangleright\) Number of rules or clusters \(N\leftarrow\) Total number of data function fuzzy c-means(\(Z,c\))  Calculate the centroids c end function return c for i \(\gets 1\) to c do \(\triangleright\) Obtaining of consequents \(A_{i},B_{i}\leftarrow\) Equation (5) \(\triangleright\) Least squares endfor return\(A_{i},B_{i}\) function PSO Algorithm \(\triangleright\) Open Loop System for\(m\gets 1.1\) to 3 do \(\triangleright\) Fuzzy Parameter \(m\)  Optimize \(m\) using Equation (10) \(\triangleright\) Objective function endfor endfunction return\(m\)
```  
**Algorithm 1** Fuzzy system identification and \(m\) parameter optimization. Four clusters and their corresponding fuzzy rules, which map fuzzy linear subspaces, were proposed. Each clustering operation is defined by locally mapping the system of equations into state-space variables; Equation (6). The global model is the defuzzification of the rules, which infers the non-linear response. The non-linearities of the ICE driver are represented within the ensemble of the four T-S fuzzy rules; Equation (7). Figure 2 shows the dynamics of operation, due to the excitation input and the response in the state variables, as well as the clustering centres. The proposed state-space structure, Equation (8), for each of the four rules locally does not represent all the effects acting on the system, but globally the rule base integrates the non-linearity of the identified system. Figure 2: Measurements of the excitation input and state variable responses, characterised with groups by clustering centres identified as *. \[ \begin{bmatrix}x_{1}^{i}(k+1)\\ x_{2}^{i}(k+1)\end{bmatrix} =\underbrace{ \begin{bmatrix}0&1\\ a_{2}^{i}&a_{1}^{i}\end{bmatrix} }_{A_{i}} \begin{bmatrix}x_{1}(k)\\ x_{2}(k)\end{bmatrix} +\underbrace{