## 3 Case Study
### Modeling of Main Diesel Engine Rotational Speed Control by Fuzzy Logic Control Theory
\[PI=K.\sum\lvert e\rvert \tag{4}\]  
where:  
_PI_ is the fitness value;  
\(e\) is the speed error; and,  
\(K\) is a coefficient. Afterward, the fitness function has been determined then the fitness value and the number of generation will be considered if or not the applicable process stopped (maximum iteration number  
Figure 8: Surface of diesel engine speed control.3.2. Optimization of Main Diesel Engine Rotational Speed Control Process by Particle Swarm Optimization Algorithm. Figure 7: Diesel engine speed control rules. reached?). In addition, the calculation of the \(P_{best}\) of each particle and \(G_{best}\) of population (the best movement of all particles). In a result, the update of velocity, position, \(P_{best}\), and \(G_{best}\) of particles will approach a new best position (best chromosome in our proposition) (Figure 10). Figure 9: Particle Swarm Optimization to adjust membership functions. On the other hand, the performance of a fuzzy model can be measured by the mean-square-error (mse). In the case of two model estimates, for instance, the one with the smaller  
Figure 10: Algorithm of applying PSO to optimize fuzzy logic controller. mse with respect to the experimental model has a better match. The mse is defined by Equation (5) that is used as the fitness measure for the PSO algorithm implementation. \[mse=\frac{\sum\limits_{k=1}^{q}{(y_{k}-\hat{y}_{k})^{2}}}{\sum\limits_{k=1}^{q}{ y_{k}^{2}}} \tag{5}\]  
In where, \(y_{k}\) and \(\hat{y}_{k}\) represents the actual value and the estimated value at data point \(k\), respectively; and, \(q\) is the number of data points. In this study, the chromosomes of the particle swarm optimization (PSO) algorithms will consist of three elements (Figure 11). Firstly, the range of membership functions includes \(K_{e}\) and \(K_{de}\) coefficients. Secondly, the shape of membership functions includes following coefficients e\({}_{1}\)-e\({}_{7}\), de\({}_{1}\)-de\({}_{7}\), and n\({}_{1}\)-n\({}_{7}\). Thirdly, the fuzzy inference rules include r\({}_{1}\)-r\({}_{49}\). On the other hand, the diesel engine speed output is thereby such that the steady state error of response is zero. Moreover, the fuzzy inference rules from r\({}_{1}\)-r\({}_{49}\) are corresponded to number 1 (Negative Big--NB), 2 (Negative Medium--NM), 3 (Negative Small--NS), 4 (Zero--Z), 5 (Positive Small--PS), 6 (Positive Medium--PM), and 7 (Positive Big--PB). Table 2 represents the fuzzy inference rules with PSO algorithms. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**de** & **NB** & **NM** & **NS** & **ZO** & **PS** & **PM** & **PB** \\ \hline NB & r\({}_{1}\) & r\({}_{8}\) & r\({}_{15}\) & r\({}_{22}\) & r\({}_{29}\) & r\({}_{36}\) & r\({}_{43}\) \\ NM & r\({}_{2}\) & r\({}_{9}\) & r\({}_{16}\) & r\({}_{23}\) & r\({}_{30}\) & r\({}_{37}\) & r\({}_{44}\) \\ NS & r\({}_{3}\) & r\({}_{10}\) & r\({}_{17}\) & r\({}_{24}\) & r\({}_{31}\) & r\({}_{38}\) & r\({}_{45}\) \\ ZO & r\({}_{4}\) & r\({}_{11}\) & r\({}_{18}\) & r\({}_{25}\) & r\({}_{32}\) & r\({}_{39}\) & r\({}_{46}\) \\ PS & r\({}_{5}\) & r\({}_{12}\) & r\({}_{19}\) & r\({}_{26}\) & r\({}_{33}\) & r\({}_{40}\) & r\({}_{47}\) \\ PM & r\({}_{6}\) & r\({}_{13}\) & r\({}_{20}\) & r\({}_{27}\) & r\({}_{34}\) & r\({}_{41}\) & r\({}_{48}\) \\ PB & r\({}_{7}\) & r\({}_{14}\) & r\({}_{21}\) & r\({}_{28}\) & r\({}_{35}\) & r\({}_{42}\) & r\({}_{49}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Fuzzy inference rules with PSO algorithms. Figure 11: Block diagram of fuzzy logic control with particle swarm optimization. The main diesel engine speed controller has been established throughout the fuzzy logic control theory. This controller completely responses to the targets of main diesel engine speed control when considering the navigation environment conditions. Furthermore, fuzzy logic controller has been designed based on experience knowledge from the fact on ships that use the diesel engine speed controller (governor) for main diesel engines with specific types like MAN B&W and SULZER.