# A Novel Optimal Control Strategy of Four Drive Motors for an Electric Vehicle
## 2 Simulation Platform and Optimal Energy Management
### Optimal Energy Management of the Four-Wheel-Side Motors
The program contains 5 \"For Loops\", which globally search for discretized demanded torque, motor speeds, etc. Within the program, through \"if-then-else\" conditions, various possible operation modes are determined, followed by calculations of various parameters, such as the efficiency and torque of the four-wheel-side motors. Then, using the concept of equivalent fuel consumption, equivalent fuel consumption under various conditions can be calculated. Minimum fuel consumption results are obtained and stored in a two-dimensional matrix called \"mf_total_boost\". Thus, by finding the minimum equivalent fuel consumption at fixed speeds and demanded torques and different torques of the four-wheel-side motors, the optimal power distribution ratio can be derived. Figure 6: The system configuration of the four-wheel-side motors for an electric vehicle. In the program calculation, the parameters for system model establishment, such as the efficiency of the four-wheel-side motors, the maximum torque limits of the four-wheel-side motors, and battery parameters, are included, and a control system's optimal distribution model parameter analysis process is constructed. This effectively simplifies the control model to meet the real-time computing needs of embedded systems. To obtain the optimal control model parameters, a global search is used to find the best parameter solution. For instance, in four-wheel torque mode, the optimal power distribution control can first discretize (discretization) necessary input parameters, such as the demanded torque and motor speed. A target function is then established to obtain the optimal power distribution ratio through the ECMS algorithm. Calculate the power consumption of the four-wheel-side motors and find the minimum value; the cost function is as shown in Formula (18):  
Figure 6.0  
where \(\dot{E}_{m,FL}\) is the input power of the left front wheel motor; \(\dot{E}_{m,FR}\) is the input power of the right front wheel motor; \(\dot{E}_{m,RL}\) is the input power of the left rear wheel motor; \(\dot{E}_{m,RR}\) is the input power of the right rear wheel motor; \(J\) is the optimal objective function; and \(\omega\) represents the relationship between the battery SOC and the penalty value. The output power calculation of the left front wheel motor is shown in Formula (19):  
Figure 6.1  
where \(N_{m}\) is the wheel speed (in rad/s) of the wheel-side motor; \(\eta_{m,FL}\) is the efficiency of the left front wheel motor. The output power calculation of the right front wheel motor is shown in Formula (20):  
Figure 6.2  
where \(\eta_{m,FR}\) is the efficiency of the right front wheel motor. The output power calculation of the left rear wheel motor is shown in Formula (21):  
Figure 6.3  
where \(\eta_{m,RL}\) is the efficiency of the left rear wheel motor. The output power calculation of the right rear wheel motor is shown in Formula (22):  
Figure 6.4  
where \(\eta_{m,RR}\) is the efficiency of the right rear wheel motor. By substituting Formula (18) into Formulas (19)-(22), the cost function is as shown in Formula (23):  
Figure 6.5  
When \(\omega\) the conditions of a search grid exceed physical limits for the four-wheel-side motors, a very large value will be given:  
Figure 6.6The system primarily needs to identify the motor's equivalent fuel consumption minimization strategy, the \(J\) function, and, based on this \(J\) function strategy, determine the optimal motor equivalent energy consumption. The optimal energy distribution loop is shown in Figure 6.7 Discretized variables include the demanded torque, motor speed, power ratio of the left front wheel motor (\(\alpha\)), power ratio of the right front wheel motor (\(\beta\)), and power ratio of the left rear wheel motor (\(\gamma\)). These are used to conduct a global search, calculating the total electrical energy consumption or equivalent fuel consumption of the four-wheel-side motors under different variables.