# Optimizing Parameters for an Electrical Car Employing Vehicle Dynamics Simulation Program
## 4 Description of the Optimization Methods
### Approximation of the Optimal Technical Data Using a \"Graphical Method\"  
In technical practice, it often happens that we search for the optimum with only one or two design variables, and the objective function has a \"smooth\" behavior, free of discontinuities or sudden changes. In this case, instead of computationally demanding optimization methods, we have the option of using a simpler \"graphical method\". In this procedure, we generate a uniform \"grid\" on the space of design variables and calculate the values of the objective function at the grid points. Due to the nature of the task, the values of the objective function can be represented on one- or two-variable diagrams and the optimum can be read with a good engineering approximation. Of course, this procedure cannot be used in the case of a higher-dimensional design variable space or a highly complex objective function.  
If we intend to optimize only one of the variables (for example, the gear ratio in the chain drive) then the objective function is a univariate function. Let the optimization problem be to find the optimal value of the gear ratio (\(i_{12}\)) at which a speed of 40 km/h can be reached by the race car in the shortest possible time (\(t\)). In this problem the design variable is the gear ratio, and the objective function is function \(t(i_{12})\). Applying our simulation program, we calculate the velocity-time function of the vehicle at different gear ratios and read the time required to reach a speed of 40 km/h. After that, the above time is plotted as a function of the gear ratio (Figure 6), and then the approximate value of the optimal gear ratio, corresponding to the minimum time, is read from the graph.  
Since we have to run the program for many different gear ratios, we automated the process with the application of a self-developed MATLAB code (Figure 7).  
Figure 6: The time that is necessary for reaching the 40 km/h speed as a function of the gear ratio.  
In the MATLAB code above, we first specify the gear ratio range and the step size which are [2.5; 6] and 0.05, respectively. After that, we run the simulation program with every gear ratio value one by one. For this, we use a for loop in the program code. After that, the program records the times required to reach 40 km/h for each run and then plots them as a function of the corresponding gear ratios.  
If we intend to optimize two of the variables, then the objective function is a bivariate function. In this case, the procedure presented previously for a univariate function can still be used. Let the optimization problem be to find the optimal values of the gear ratio and center-of-mass position (\(l_{b}\)) at which a speed of 40 km/h is reached by the car in the shortest possible time. Variable \(l_{b}\) is the distance of the centre of mass of the vehicle from the rear shaft, and its value can be varied in the [0.4; 1] m range. Applying our simulation program, we calculate the velocity-time function of the vehicle at the different center-of-mass position and gear ratio pairs and read the time required to reach a speed of 40 km/h. After that, the above time is plotted as a function of the center-of-mass position and gear ratio pairs (Figure 8). Finally, the approximate center-of-mass position and gear ratio, corresponding