# Optimization of Fuzzy Logic Controller Used for a Differential Drive Wheeled Mobile Robot
## 2 Problem Description
### Optimization of the Fuzzy Logic Controller Based on the Genetic Algorithm
#### 4.1.2 Simulation Open-Course Code
\begin{table}
\begin{tabular}{c c c} \hline \hline \multirow{2}{*}{**Controllers**} & \multicolumn{2}{c}{**Energy Consumption**} & \multicolumn{2}{c}{**Travel Distance**} \\ \cline{2-3}  & **E (J)** & **E (\%)** & **s (m)** & **s (\%)** \\ \hline Circle-based controller & 17.76 & 209.68 & 43.82 & 129.42 \\ Mathew-based controller & 53.04 & 626.21 & **33.86** & **100.00** \\ Chaudhari-based controller & 17.85 & 210.74 & 45.09 & 133.17 \\ Thoa-based controller & 51.91 & 612.87 & 45.93 & 135.65 \\ Expert-based controller & 52.25 & 616.88 & 37.30 & 110.16 \\ Mohammad-FLC & 51.53 & 608.38 & 38.32 & 113.17 \\ Proposed GA\_FLC & **8.47** & **100.00** & 39.93 & 117.93 \\ \hline \hline \end{tabular}
\end{table} 
Table 13: Energy consumption and travel distance of the robot when the robot tracks the sharp turn path by the different controllers. Bold values are the best in the appropriate column. \begin{table}
\begin{tabular}{c c c} \hline \hline \multirow{2}{*}{**Generation**} & \multicolumn{2}{c}{**Energy Consumption (J)**} & \multicolumn{2}{c}{**Travel Distance (m)**} \\ \hline
30 & 15.93 & 48.53 \\
50 & 10.18 & 50.42 \\
100 & 8.50 & 46.27 \\
150 & 8.49 & **46.07** \\
200 & **8.47** & 46.10 \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Energy consumption and travel distance of the robot when the robot tracks the zigzag path by the different controllers. Bold values are the best in the appropriate column. \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Controllers**} & \multicolumn{2}{c}{**Energy Consumption**} & \multicolumn{2}{c}{**Travel Distance**} \\ \cline{2-5}  & **E (J)** & **E (\%)** & **s (m)** & **s (\%)** \\ \hline Circle-based controller & 17.80 & 210.15 & 45.80 & 106.66 \\ Mathew-based controller & 70.11 & 827.75 & **42.94** & **100.00** \\ Chaudhari-based controller & 17.90 & 211.33 & 46.19 & 107.57 \\ Thoa-based controller & 69.11 & 815.94 & 44.09 & 102.68 \\ Expert-based controller & 69.51 & 820.66 & 43.12 & 100.42 \\ Mohammad-FLC & 61.83 & 730.00 & 43.00 & 100.14 \\ Proposed GA\_FLC & **8.47** & **100.00** & 43.23 & 100.68 \\ \hline \hline \end{tabular}
\end{table} 
Table 12: Energy consumption and travel distance of the robot when the robot tracks the square path by the different controllers. Bold values are the best in the appropriate column. Figure 15: Analysis of the simulation results for the other paths. (**a**) The square path tracking of the robot; (**b**) The sharp turn path tracking of the robot; (**c**) The straightforward path tracking of the robot; (**d**) The diamond-shaped path tracking of the robot; (**e**) The number eight-shaped path tracking of the robot when it is controlled by the GA_FLC; (**f**) The circle path tracking of the robot when it is controlled by the GA_FLC. that leads to a slower optimization process, and the energy consumption also increases in comparison with the case of using the population size 50. For example, the processing time increases 21.1% and the energy consumption also increases 15.6% when using the population size is 55 in comparison with the case of using the population size is 50. Figure 16 and the simulation results clearly indicate that the value of the fitness function is rapidly reduced during the optimization process (from the 1 st generation to the 40 th generation). Then the value of this fitness function is slightly decreased from the 41 st generation to the 53 rd generation. From the 54 th generation onwards the value of the fitness function converges to E = 8.47 J and remains at this value. As this experiment is based on random behavior and it has been executed repeatedly, it can be concluded that the fitness function has converged and reached a stable suboptimal value. Table 10 shows the values of the energy consumption and the travel distance collected after the different generations (30 th, 50 th, 100 th, 150 th, 200 th), when the optimization of the FLC using the genetic algorithm to track the zigzag path with the size of the initial population is 50.