# Optimal Sliding Mode Control for an Active Suspension System Based on a Genetic Algorithm
## 4 The OSMC Controller Design
### Optimal Tuning of the Switching Function Based on GA  
As a GA is an efficient optimization method in solving complex problems of high-multimodal, multi-dimensionality, nonlinear, discrete, and discontinuous characters, it has been widely used in engineering fields in the past few years [23]. Thus, a GA is applied in this paper to optimize five parameters \((c_{1},c_{2},c_{3},\varepsilon_{e},k_{e})\) of the SMC controller. Based on the maximum of the fitness function, a GA can find the optimal control gain automatically, such that the control system performance is closer to the expected value [33].  
Penalty function methods have been widely used in GAs for constrained optimization problems in the last few years. This method transforms the constrained optimization problem into an unconstrained one by penalizing the objective function corresponding to the infeasible solution [34]. According to the given constraints in Sections 4.1 and 4.2, the penalty function is given in Equation (22):  
\[\begin{split}& F(x)=\min\bigl{\{}J+M\bigl{\{}\min[{g_{1}}^{2}(x), 0]+\min[{g_{2}}^{2}(x),0]\bigr{\}}\bigr{\}},\text{M}=10000\\ & g_{1}(x)=m_{u}c_{2}-m_{s}c_{1},g_{2}(x)=m_{u}-m_{s}c_{3}\end{split} \tag{22}\]  
Figure 5: Simulation model of SMC in MATLAB/Simulink.  
The objective function \(J\) proposed in Equation (6) could reflect the performance of the optimized results. The smaller the value of \(J\), the better the control performance of the OSMC controller. Hence, the fitness function is defined based on \(J\), which is shown below:  
\[f(x)=\frac{1}{F(x)} \tag{23}\]  
When the fitness function reaches the maximum, the OSMC controller has the best control results, and then the five parameters \((c_{1},c_{2},c_{3},\varepsilon_{e},k_{e})\) of the OSMC controller are optimal. The procedures of a GA in the present study are illustrated in Figure 6.  
Step1. The initial population is created based on the binary coding rules.  
Step2. Calculate the corresponding fitness values using Equation (23). Individuals are selected according their fitness value. Those individuals with maximum fitness are copied to the next generation.  
Step3. Once the iteration criterium is satisfied, the GA optimization is concluded; otherwise, the next step is conducted.  
Step4. A new generation of individuals (i.e., selection) is obtained through the application of genetic operators (i.e., crossover, mutation).  
Step5. The GA algorithm concludes once the maximum number of generations is reached. Otherwise, repeat step 4.  
The parameters related to the GA-based optimization algorithm are shown in Table 2.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Population size & 100 \\ Crossover probability & 0.5 \\ Mutation probability & 0.02 \\ Maximum number of generations & 30 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Parameters related to the GA-based optimization algorithm.  
Figure 6: Working mechanism flowchart of the GA.  
For the purpose of reducing the optimization time, the ranges of OSMC parameters are selected based on Equations (16)-(18) and Table 3 as follows.  
\[c_{1}\in[-5,10],c_{2}\in[0,10],c_{3}\in[-5,10],\epsilon_{e}\in[0,0.1],k_{e}\in[0,50] \tag{24}\]  
The relationship between genetic algebra and the fitness function values in the process of GA optimization based on MATLAB/Simulink (version 2014a) is shown in Figure 7, and the optimized results are shown in in Section 5.