Time-Optimal Low-Level Control and Gearshift Strategies for the Formula 1 Hybrid Electric Powertrain

: Today, Formula 1 race cars are equipped with complex hybrid electric powertrains that display signiﬁcant cross-couplings between the internal combustion engine and the electrical energy recovery system. Given that a large number of these phenomena are strongly engine-speed dependent, not only the energy management but also the gearshift strategy signiﬁcantly inﬂuence the achievable lap time for a given fuel and battery budget. Therefore, in this paper we propose a detailed low-level mathematical model of the Formula 1 powertrain suited for numerical optimization, and solve the time-optimal control problem in a computationally efﬁcient way. First, we describe the powertrain dynamics by means of ﬁrst principle modeling approaches and neural network techniques, with a strong focus on the low-level actuation of the internal combustion engine and its coupling with the energy recovery system. Next, we relax the integer decision variable related to the gearbox by applying outer convexiﬁcation and solve the resulting optimization problem. Our results show that the energy consumption budgets not only inﬂuence the fuel mass ﬂow and electric boosting operation, but also the gearshift strategy and the low-level engine operation, e.g., the intake manifold pressure evolution, the air-to-fuel ratio or the turbine waste-gate position.


Introduction
Formula 1 (F1) is the top category for single-seater circuit racing and features the fastest racing cars in the world. In the past, these were powered by V8, V10 or even V12 engines. Since 2014, however, the Fédération Internationale de l'Automobile (FIA) [1,2] has prescribed the parallel hybrid powertrain topology shown in Figure 1. In this so-called power unit, the main source of propulsive power is still the internal combustion engine, but in the form of a downsized and turbocharged V6 with a displacement volume of 1.6 L. However, the engine is supplemented by an electric recovery system composed of two electric motor generator units, denoted by motor generator units (MGUs), and an electric energy storage in the form of a battery. The MGU-K (K for kinetic) is coupled to the engine's crankshaft and is used to increase the propulsive power of the car or to recuperate energy during braking. To increase the powertrain's efficiency, the FIA allows the installation of a second electric motor on the turbocharger shaft, referred to as MGU-H (H for heat). As a consequence, the turbine is oversized and in general produces more a racetrack. Structural components that additionally influence the achievable lap time were included in the optimization framework: the suspensions [51] and the tyres [52]. The computation of the optimal driving trajectory was further extended with the inclusion of power flows [53], of the F1 specific power flows and regulations [54], or of the power flows and therewith associated thermal management of a Formula E race car [55]. Finally, the authors of [56] show that the time-optimal energy management marginally influences the race car's velocity evolution in the corners, whilst it significantly impacts its speed on the straights. The most important assumption made in the previous works on F1 in our group, is to decouple the energy management from the driving path: we assume the driver to be responsible for following the time-optimal path on the racetrack, whilst we put the focus on the optimal usage of the available energy [57][58][59][60][61][62]. The time-optimal control strategies for race and qualifying scenarios were solved numerically in [57,60], while real-time feedforward and feedback control architectures were derived analytically and tested in [58,59]. A two-level model predictive control architecture was also proposed as an online controller in [62] and afterwards extended with adaptation algorithms in [61]. Finally, in [63] we combined convex optimization, dynamic programming and Pontryagin's minimum principle in an iterative scheme to solve the energy management and gearshift control of a modern F1 powertrain. However, the majority of the models used for minimum time optimization are high-level models that mainly rely on quasi-static formulations, ensuring low computational times in the order of seconds to minutes. Thus, they can serve a rapid parametrization of the energy management but neglect important effects such as transient motor generator unit (MGU)-H operation during the gearshifts. Moreover, they do not consider the dynamics of the engine, e.g., the intake manifold and the turbocharger, they do not model the engine cylinder deactivation and do not include the air-to-fuel ratio and the spark advance influence on the achievable engine power.
To the best of the authors' knowledge, there exists no framework so far that jointly computes the time-optimal control and gearshift strategy for a detailed low-level model of a F1 hybrid electric powertrain. The impact of both the gearshift strategy and the targets for fuel and battery usage on the engine power generation and on the low-level dynamics, e.g., on the air-to-fuel ratio or on the intake manifold pressure evolution, has not been studied yet for time-optimal control purposes. Therefore, in this paper we propose a detailed lowlevel mathematical formulation of the F1 powertrain suited for numerical optimization. Beside the specific focus on the engine speed dependency of each powertrain's component, we propose a continuous nonlinear model to describe the engine cylinder deactivation and reformulate non-smooth inequality constraints such that they can be accommodated by off-the-shelf nonlinear solvers. We relax the resulting mixed integer nonlinear model using outer convexification techniques, thereby reducing computational times for solving the time-optimal control problem by two orders of magnitude. The presented framework can be used as a tool to benchmark the low-level actuation of the internal combustion engine components in the context of the time-optimal energy management. Specifically, the suboptimality of the control strategy adopted during a race week-end can be assessed, reference trajectories for online control can be generated and control heuristics can be inferred. Moreover, the framework allows to perform parametric studies aimed at the design of new powertrain components. For the purpose of this work, only a part of the FIA sporting and technical regulations [1,2] are considered and modeled. As an example, specific limits on the energy transfer between the battery and the electric motor connected to the crankshaft are not implemented. This is due to confidentiality reasons and also facilitates the results analysis given the complexity of the system. The paper is structured as follows: in Section 2 we present a mixed integer nonlinear model of the F1 hybrid electric powertrain and the car's longitudinal dynamics, especially focusing on the engine speed dependency, the dynamic behavior of the intake manifold and the turbocharger, as well as the engine cylinder deactivation. Thereafter, we formulate the time-optimal control problem and apply outer convexification. In Section 4 we present parameter studies where we compute and discuss the time-optimal control strategies for different energy budgets and operational limits, both over portions of lap and entire lap. Finally, conclusions are drawn in Section 5.

Modeling of the Formula 1 Powertrain
In this section we identify and validate a detailed low-level model of the F1 hybrid electric powertrain. A schematic of the system is shown in Figure 1 and its mathematical mean-value model formulation suited for numerical optimization is mostly based on or inspired by [31,47,57]. In addition to the energy storages onboard, i.e., the battery and the fuel tank, the power unit consists of an internal combustion engine equipped with an electrified turbocharger and two motor generator units: the MGU-K is mounted on the engine shaft and is used for electric boosting or regenerative braking, whilst the MGU-H is an electric motor that converts part of the heat contained in the hot exhaust gases into electrical energy or reduces the turbo lag. The engine system is composed of an intake manifold equipped with an intercooler and a throttle valve, a 1.6 L gasoline direct injection engine with cylinder deactivation capabilities, an exhaust manifold and a turbocharger. The turbocharger consists of a radial compressor, a radial turbine equipped with a waste-gate valve and the MGU-H mounted on the turbocharger shaft. Finally, the remaining part of the powertrain consists of a gearbox and a differential that connect the engine and the MGU-K to the wheels.
A schematic representation of how the state and the input variables of the considered system relate to each other, is displayed in the causality diagram shown in Figure 2. The system's state variables are the car's velocity v and its position s on the racetrack, the intake manifold pressure p im , the turbocharger rotational kinetic energy E tc , the battery energy E b and fuel energy E f consumed. In contrast to the intake manifold dynamic behavior, the exhaust manifold is modeled as a static subsystem. This modeling assumption will be motivated in Section 2.4. The system's input variables are the power of the friction brakes P brk , the MGU-K power P k , the MGU-H power P h , the engaged gear g, the throttle valve position u th , the spark-advance position u sa , the cylinder fuel mass flowṁ f,cyl , the cylinder deactivation variable Ψ e and the waste-gate valve position u wg . The powertrain model is partly taken or inspired by the works conducted at our institute or published by ourselves. Specifically, the energy recovery system model in Section 2.5 and the longitudinal dynamics in Section 2.6 are taken from [57]. The linear waste-gate model in Section 2.3 and the static approximation of the exhaust manifold in Section 2.4 are taken from our previous work [47], where the engine speed over the entire mission was given and we made use of integer variables and linear equations to model a high-performance power unit. For confidentiality reasons, the model parameters cannot be disclosed and the data shown on the plots are normalized and denoted by (·) 0 . For instance, the normalized value of the turbine mass flowṁ t is denoted byṁ t,0 . To quantify the modeling mismatch, we use the normalized mean absolute error defined as where N is the number of data points considered, x model is the modeled value and x meas is the measured one. The data displayed in the Figures 3, 5-10 are telemetry data acquired during a race week-end on a current F1 hybrid electric race car by our industrial partner. For confidentiality reasons, we are not allowed to disclose the exact experimental setup used to obtain them, i.e., sensor specification and placement. The majority of the data are acquired directly by means of sensors, e.g., intake manifold pressure, or are computed online by means of maps that were recorded on dedicated test-benches, e.g., compressor and turbine mass flow maps. Finally, all the validation plots shown in the following sections cover roughly a third of the racetrack and include three straights and two corners.

Intake Manifold
The intake manifold is modeled as an isothermal receiver [31], since the intercooler operation leads to temperature fluctuations over one lap of less than 1%, as Figure 3 shows. As a consequence, we assume a constant temperature ϑ im inside the intake manifold. We then model the dynamics of the intake manifold pressure p im as where V im is the intake manifold volume, R air is the specific gas constant of air,ṁ c is the compressor mass flow andṁ β is the engine air mass flow. The engine air mass flow is modeled asṁ where ω e is the engine speed, V d is the engine displacement volume, λ vol is the volumetric efficiency and u th ∈ [0, 1] is the throttle position. Since the throttle is placed after the plenum, the intake manifold pressure dependency [31] of the volumetric efficiency is neglected. The map λ vol (ω e ) that relates the volumetric efficiency to the engine speed is identified using the neural network technique presented in Appendix C. For confidentiality reasons, it cannot be displayed.

Engine Power and Cylinder Deactivation
The internal combustion engine power P e is the sum of three contributions: the engine power stemming from the fuel combustion P e,c , the engine power losses due to the pistons' friction P e,fr and the engine pumping power P e,p arising from the gas exchange in the intake and exhaust manifold. Therefore we model the engine power as P e (t) = P e,c (t) + P e,fr (t) + P e,p (t).
Since the engine features cylinder deactivation, the engine combustion power P e,c is the sum of all the cylinder-individual combustion power values: where P e,c,i denotes the engine combustion power delivered by cylinder i ∈ {1, . . . , N cyl }.
It is defined as where H l is the fuel lower heating value andṁ f,i is the amount of fuel injected in cylinder i. The combustion efficiency η ω e is engine speed dependent, whereas η AF,i and η SA,i are cylinder individual correction factors that capture the influence of the air-to-fuel ratio and spark-advance position, respectively. Since all cylinders share the same engine speed and, if active, we assume the same amount of fuel injectedṁ f,cyl , air-to-fuel ratio and spark-advance, (6) can be rewritten as where the cylinder deactivation variable Ψ e ∈ [0, N cyl ] defines the number of active cylinders. This variable is assumed to be continuous to reduce the calculation complexity (more on that in Section 3.2). The total fuel mass flow injectedṁ f is thereforė while the change in fuel energy E f consumption is modeled as The maximum amount of fuel injected per cylinder is limited by the FIA regulations [1,2]: where the speed-dependent maximum allowed fuel injection in where ω FIA e = 10, 500 rpm is the engine speed threshold imposed by the FIA regulations. To implement this non-smooth constraint in the optimization framework, we rewrite and relax (11) and introduce the lifting variableṁ max f in the following manner:m Finally, using (12) we can rewrite (10) as The reformulation (12) is schematically drawn in Figure 4 and can be interpreted as follows: if the engine speed is below 10, 500 rpm the maximum amount of fuel that can be injected is constrained by the engine-speed dependent ramp f FIA,ω e ; if the engine speed is above 10, 500 rpm, the maximum amount of fuel is limited by the constant constraint f FIA,const . The spark-advance efficiency depends on the spark advance position u SA and the engine speed ω e . The relationship is usually defined by a map η SA = f SA (u SA , ω e ). We assume that for any engine speed we can realize a spark-advance efficiency η SA ∈ [η min SA , η max SA ] and in post-processing compute the spark-advance position u SA which realizes the desired efficiency. The engine speed efficiency is modeled as where k 1,e , k 2,e and k 3,e are coefficients subject to identification. Next, we introduce the definition of the air-to-fuel ratio in the cylinder [31] λ AF,cyl (t) =ṁ where σ 0 is the stoichiometric constant. The main drawback of (15) is its singularity if no fuel is injected, i.e., forṁ f,cyl = 0. For this reason, we introduce the fuel-to-air ratio φ AF,cyl , which is defined as The fuel-to-air ratio φ AF,cyl is always defined and bounded, since the engine air mass flow cannot be zero during operation. Furthermore, the fuel-to-air ratio mixture has an impact on the combustion efficiency, which is defined by the map η AF,cyl = f AF (φ AF,cyl ). Similar to the engine speed efficiency maps, the fuel-to-air ratio efficiency maps usually present a peak efficiency at the optimal fuel-to-air ratio value and gradually decrease in an asymmetric way if the fuel-to-air ratio is larger or smaller than that [31]. To properly capture the asymmetric form of the map, the fuel-to-air ratio efficiency is fitted using the neural network techniques presented in Appendix C. If a cylinder is activated, i.e., Ψ e = 0, the fuel-to-air ratio must lie in the allowed range [31], leading to the case distinction It is worth noticing that φ AF,cyl can be any value if Ψ e = 0. Ideally, when the engine is completely shut off, i.e., Ψ e = 0, the fuel-to-air ratio should be zero because no fuel should be injected, i.e.,ṁ Since it is computationally expensive to implement (18), we neglect it for the following reason: If Ψ e = 0, the fuel injected in the cylinders is constrained by both the FIA regulations (11) and the fuel-to-air ratio constraints (17); If Ψ e = 0, the fuel injected in the cylinders is only constrained by the FIA regulations, but it will not have an impact on any algebraic or dynamic equation of the model, e.g., on the combustion engine power in (7) or the fuel energy dynamics in (9), sinceṁ f,cyl is always multiplied with Ψ e . Finally, we make use of so-called vanishing constraints [64] to rewrite (17) as The engine friction power P e,fr is modeled as a quadratic function of the engine speed as P e,fr (t) = k 1,fr · ω 2 e (t) + k 2,fr · ω e (t) + k 3,fr , where k 1,fr , k 2,fr and k 3,fr are coefficients subject to identification. Finally, the engine pumping power P e,p is modeled as where p em is the exhaust manifold pressure and k p is a coefficient subject to identification. Figure 5 shows the fitting of the engine combustion, friction and pumping power. Whilst all three power contributions match precisely the measurements data on the straights, the friction and pumping powers partially differ during the corners, i.e., where the engine is not operated at full load. Regarding the friction power, this might be attributable to the simple model which lacks additional (input or state) dependencies, whilst the difference in the pumping power might be due to physical phenomena that zero-dimensional models are not able to capture properly.

Turbocharger and Waste-Gate
The turbocharger's state variable is its rotational kinetic energy E tc defined as where Θ tc is the moment of inertia of the entire turbocharger and ω tc is the rotational speed of the shaft. The rotational kinetic energy evolves as a function of the turbine power P t , compressor power P c and MGU-H power P h acting on the shaft: In Ref. [47], it was shown that the compressor and turbine mass flows and powers can be accurately described as a function of the turbocharger rotational energy E tc , the intake manifold pressure p IM , the exhaust manifold pressure p em and exhaust manifold temperature ϑ EM . Therefore, these quantities can be represented with the following multi-dimensional maps M: This is a direct consequence of the assumption that the pressure and temperature at the compressor entrance, as well as the pressure after the turbine, are assumed to be constant and equal to the ambient conditions [47]. Both compressor and turbine are subject to operational limits. While the mechanical, blocking and choke limits of the compressor can be accounted for by introducing constant constraints on the turbocharger rotational speed and compressor mass flow, the compressor surge limit varies depending on the turbocharger rotational speed: In order to avoid compressor operation in the surge region, we introduce the constraint All the turbocharger maps are fitted using the neural network modeling technique presented in Appendix C. Since the turbine and the waste-gate mass flows are well approximated as orifices [31] and share the same exhaust manifold pressure and temperature, the waste-gate mass flowṁ wg is modeled as [47] m where u wg ∈ [0, 1] is the normalized waste-gate position andṁ wg,max is defined aṡ with k 1,wg and k 2,wg being parameters subject to identification. Figures 6 and 7 show that the fitting precision of the turbocharger quantities and the waste-gate maximum mass flow is satisfactory, with very good agreement between the model and the measurements.

Exhaust Manifold
The exhaust manifold of the considered engine displays a small gas residence time and its volume is much smaller compared to the one of the intake manifold. As a consequence, we approximate the exhaust manifold to be quasi-static and adiabatic [31]. In Ref. [47], this simplification was shown to satisfactorily approximate the dynamic nature of a small plenum. Therefore, the exhaust manifold temperature ϑ em is modeled as an algebraic function where ϑ e,out,i is the temperature of the gases exiting cylinder i. Since we assume all the active cylinders to share the same combustion conditions, and the inactive cylinders to share the same non-combustion conditions, (32) can be rewritten as where the variables ϑ ON comb and ϑ OFF comb represent the engine-out temperature if the cylinder is active and inactive, respectively. The engine-out temperature of the active cylinders ϑ ON comb is modeled by superposing an enthalpic balance and a temperature increase induced by the spark-advance retardation [65][66][67] where ϑ fuel is the temperature of the injected fuel, c p is the heat capacity at constant pressure of the exhaust gases and η EM,enth is a fitting coefficient that represents how much combustion enthalpy goes into the exhaust manifold in form of heat. The term accounting for the temperature increase due to the ignition delay is where η EM,SA is a fitting coefficient that represents how much the exhaust manifold temperature is increased by the extra heat arising from the spark-advance retardation. Finally, the engine-out temperature of an inactive cylinder is modeled as in [47] by where k OFF 1,em and k OFF 2,em < 0 are coefficients subject to identification. The model (37) captures that the engine-out temperature is colder for a higher engine air-mass flow. Figure 8 shows the comparison of the exhaust manifold temperature model to measurement data. The proposed model properly captures the behavior on the straights where the temperature is high, especially during the upshifts (recognizable as little peaks), whereas it overestimates the temperature in the last part of the corner. This might be attributable to the quasi-static modeling choice, which entails the absence of the receiver's inertia. Following the quasi-static modeling approach, the pressure in the exhaust manifold is implicitly defined through the algebraic mass balancė In Section 2.3, it was shown that the waste-gate mass flow can be approximated as a function of the turbine mass flowṁ t and the waste-gate position u wg , i.e., and that the turbine mass flowṁ t is a function of the turbocharger rotational kinetic energy E tc , exhaust manifold pressure p em and exhaust manifold temperature ϑ EM , i.e., If we combine (38) with (39), we obtaiṅ Finally, combining (41) with (40) the exhaust manifold pressure is found to be The exhaust manifold pressure map is identified using the neural network technique presented in Appendix C and its fitting is shown in Figure 9. Despite its quasi-static modeling, the exhaust manifold pressure partially displays a dynamic behavior: this is due to its dependency on the engine air mass flow, which is a function of two dynamic variables, i.e., the intake manifold pressure and the car's velocity.

Energy Recovery System
In this section, we model the energy recovery system using a high-level modeling approach [57]. The power conversion losses of the motor generator units (MGUs) from mechanical-to-electrical conversion and vice-versa are approximated using the quadratic functions where P k,dc and P h,dc are the electrical powers of the MGUs, P k and P h the mechanical power of the MGUs, and α k and α h coefficients subject to identification. The MGUs electrical actuator limits are considered, namely P min h,dc P h,dc (t) P max h,dc , P min k,dc P k,dc (t) P max k,dc .
The battery electrical losses can also be approximated using a quadratic model where P i is the internal battery power, P b = P h,dc + P k,dc + P aux is the terminal battery power, α b a coefficient subject to identification and P aux a constant auxiliary power. Figure 10 shows the satisfactory fitting precision of the MGU-H, MGU-K and battery power conversions. Finally, we assume a constant battery voltage [68,69] and model the battery energy dynamics as an open integrator [47,57], i.e.,

Longitudinal Dynamics and Gearbox
In this section we present the longitudinal dynamics and the gearbox of the race car. The position s of the car on the circuit evolves according to its velocity v, hence d dt The lateral dynamics of the car are condensed [57] into a track-dependent maximum velocity profile v max which constrains the velocity at each position of the racetrack v s(t) v max s(t) .
The achievable velocity when the driver is not fully pressing the accelerator pedal, i.e., in the corners, is inferred from the telemetry data or using sophisticated simulations of the car's lateral dynamics, while the maximum velocity constraint on the straight is set constant and equal to a value that is not achievable, e.g., 400 km/h. As an example, in Figure 11 we depict a measurement of the car's velocity on the layout of the Bahrain International Circuit. The longitudinal dynamics are modeled as [57] with where m car is the car mass, k a , k curve , k drs and k r are the aerodynamic, curvature, drag reduction (DRS) and rolling coefficient subject to identification, γ s(t) is a positiondependent curvature parameter that accounts for the aerodynamic change during cornering of open wheeled cars, ξ drs s(t) is a position-dependent boolean (where ξ drs = 1 in DRS zones, otherwise 0), G is the gravitational acceleration and P tr is the traction power. The traction power is defined as where P brk ∈ 0, P max brk is the power dissipated in the friction brakes and P p is the propulsive power modeled as [57] P p (t) = k 1,sl · P 2 u (t) + k 2,sl · P u (t), where k 1,sl and k 2,sl are the slip coefficients subject to identification and P u is the total power unit power, i.e., P u = P e + P k . More details on the longitudinal model and its validation can be found in [57]. Finally, the power unit is equipped with an eight-speed gearbox, i.e., N g = 8. The overall transmission of the gear g from the engine shaft to the car's wheel is denoted by Γ ∈ {Γ 1 , . . . , Γ N g }. Therefore the engine speed whit the gear g ∈ {1, . . . , N g } engaged is related to the velocity by (54) Figure 11. Track layout of the Bahrain International Circuit with a color-coded representation of the F1 car velocity measured during a race week-end. This specific racetrack layout is used in Section 4 for the results and case studies. The points A and B mark the beginning and end of the track segment investigated in Section 4.

Optimal Control Problem
In this section, we state the optimal control problem. The state variables are the position s, the car's velocity v, the intake manifold pressure p im , the turbocharger's rotational kinetic energy E tc , the battery energy E b and the fuel energy E f . The input variables are the throttle position u th , the waste-gate position u wg , the cylinder fuel mass flowṁ f,cyl , the cylinder deactivation variable Ψ e , the spark-advance efficiency η SA , the MGU-K power P k , the MGU-H power P h , the braking power P brk and the engaged gear g.

Objective and Space Domain
The objective of the optimal control problem is to minimize the lap time subject to the system dynamics and constraints presented in Section 2, as well as the energy consumption targets imposed on the fuel ∆E f,target and on the battery ∆E b,target as terminal constraints: As presented in Section 2.6, the track-dependent parameters, e.g., the maximum velocity profile v max s(t) or the track curvature γ s(t) , are given as a function of the position s(t) on the track. Therefore, we reformulate the optimal control problem in space domain with the following change of variable based on (47) where ds and dt are the differential variables in space and in time domain, respectively. While the algebraic equations and constraints do not change, the differential equations change as follows: where F x(.), u(.), Γ(.) is the right-hand side of the differential equation in time domain andF x(.), u(.), Γ(.) is its counterpart in space domain. Finally, the objective function changes to where T is the time necessary to cover the considered track length S.
Furthermore, we impose the variables δ 1 , δ 2 , . . . , δ N g to fulfill the special ordered set type 1 property (SOS-1), i.e., Next, we relax the problem by making the integer variable continuousδ g , i.e., The outer convexified differential equations of the system read as while the inequality constraints of the form 0 h s, x(s), u(s), Γ(s) , read as The detailed formulation of the outer convexified optimal control problem is presented in Appendix A. Finally, to construct an integer δ g sequence of the gear command from the relaxed optimal oneδ g , a rounding strategy is applied. Due to the conditions imposed by the equality constraint in (61), the rounding strategy should not violate the SOS-1 property. Therefore, we use the rounding methodology proposed in [74] that reads as where α g,i is an auxiliary variable of gear g at point i introduced to make (67) more readable, ∆s m = s m+1 − s m is the distance between two space points and i is the space point at which the rounding is sought. This recursive methodology simultaneously takes into account all N g gears up to i − 1 and favors the choice of the smallest gear g with the largest α g,i .
Regarding the engine cylinder deactivation, the variable Ψ e is treated as continuous, although it is integer by nature. This is done to reduce the calculation time and complexity, i.e., to avoid introducing N g × N cyl relaxed integers at each time step instead of N g only. In addition to that, the solution to this problem can be used as a benchmark to compare the results obtained with an integer number of active cylinders and assess the resulting suboptimality. Finally, for the sake of completeness, we compare in Appendix B the relaxed and rounded nonlinear solution to the original mixed-integer nonlinear program solution. The results highlight that the trajectories of the two solutions are close to identical and that the lap time difference is negligible, thereby justifying the outer convexification approach.

Numerical Solution Method
We discretize the optimization problem using the multiple shooting method and the standard explicit Euler integration method, which approximates the continuous derivative of the variable x(s) as where ∆s is the space domain discretization length, k = {0, 1, 2, . . . , N − 1} is the discrete space variable, N = round(S/∆s) is the number of discrete steps and S is the considered track length. The optimization problem is implemented in MATLAB [75] using the symbolic framework CasADi [76] and solved with IPOPT [77]. Furthermore, the mixed-integer nonlinear program (MINLP) solution presented in Appendix B is computed using BONMIN with the branch-and-bound algorithm [78]. In [47], it was shown and validated that sampling frequencies larger than 15 Hz were able to properly capture the intake manifold and turbocharger dynamics. Since the optimization problem is described in space domain, we pre-compute a variable space domain discretization length ∆s[k] for a specific (time domain) sampling frequency f s using a nominal car's velocity trajectory v nom measured during a race week-end on a particular circuit: While it is most likely that the optimized velocity profile will not be the same as the nominal one in each point of the track, the sampling frequency does not deviate more than 0.9-1.2 Hz on average for entire lap optimizations. The computational time to solve both the relaxed and the rounded nonlinear program solutions on a desktop computer varies from minutes to hours and depends on the chosen boundary conditions and the space horizon length. As an example, if only a small portion of the lap is considered, e.g., a straight with two corners, the computational time is between 5 and 20 min. If the entire lap is considered, the computational time varies between 2 and 4 h. Finally, the MINLP displays computational times up to 100 times slower compared to the presented methodology.

Results
In this section, we show the results of the time-optimal control problem presented in Section 3 for racing scenarios on the Bahrain International Circuit, a lap of which takes roughly 90 s. The racetrack under consideration influences the vehicle dynamics through its specific maximum velocity profile, path curvature and DRS zones. Our non-causal optimization framework is not based on a driving cycle, since the velocity profile and the propulsive power are subject to optimization. First, we analyze over a portion of the lap the optimal gearshift and power unit control from a low-level point of view. Second, we extend the analysis to entire lap results.

Detailed Analysis on a Portion of the Lap
In this subsection we present several case studies where we apply the proposed optimization framework to practically relevant strategy and design decisions. To facilitate a detailed analysis, we consider only a portion of the lap. We start by comparing the optimal control of the power unit for two different battery recharge targets, which is a strategy parameter that can be changed by the driver during a race. Thereafter, we add a constraint on the compressor outlet temperature to showcase how the presented framework can support the design choice of the intercooler dimension. Figure 12 shows the most significant optimal state and input trajectories for two different battery recharge targets and the same fuel consumption target. The considered portion of lap is the section between the points A and B in Figure 11. It can be noticed that the gearshift strategy is different: not only is the 8th gear solely engaged for the battery discharge case (∆E b,target = −0.3 MJ), but also several upshifts occur earlier compared to the battery recharge case (∆E b,target = 0.5 MJ). This trend can be attributed to the abundance of electrical energy at disposal: the gears are selected to maximize the overall engine power and therefore the propulsive power. For the battery recharge case, however, the trade-off between the engine power and the MGU-H recuperation is more pronounced. The fact of not shifting into the 8th gear keeps the engine speed high and therefore the pressure in the intake manifold lower (compared to the battery discharge case). As a consequence, the compressor power is lower and more power can be recuperated by the MGU-H. The power unit control around the upshifts occurs each time in a similar manner: the MGU-H recuperates less to accelerate the turbocharger shaft, whilst the throttle valve is operated to achieve the optimal fuel-to-air ratio value. The battery recharge target also influences the waste-gate operation. In conventional gasoline turbocharged engines, the waste-gate is operated to diminish the turbine power and thereby controls the intake manifold pressure [79]. By contrast, for the considered high-performance power unit the waste-gate is used to increase the engine power by diminishing the exhaust manifold pressure. The turbine power extraction is reduced and therefore the MGU-H power recuperation goes roughly to zero (when no upshift is taking place). The intake manifold pressure is not affected, the engine pumping power increases and so does the overall engine power. In addition to that, the MGU-K operation is also influenced by the battery availability. Not only the MGU-K cut occurs later on the straight if more battery energy can be deployed, but also the slope is different: the analytical explanation for this can be found in [58]. Finally, the optimal behavior in the corner is analyzed. The optimal cylinder deactivation is mainly the same, except at the corner exit. In this region, for the battery discharge case, slightly more fuel is injected. At the same time the spark-advance is slightly retarded and produces a lower spark-advance efficiency. This causes a small increase in the exhaust manifold temperature and pressure, allowing the MGU-H to recuperate more. The procedure of converting a small portion of fuel energy into electrical energy through the increase of the exhaust manifold temperature is possible in the cases where the battery recharge targets allow it. For the battery recharge case, this operation only occurs for a very short amount of time, since every drop of fuel counts and the gearshift strategy is not aimed at maximizing the engine efficiency, but rather finding the optimal trade-off between the internal combustion engine and the energy recovery system. Next, we investigate the suboptimality entailed by a smaller intercooler choice in Figure 13. In such a case, to keep the same intake manifold temperature, the compressor outlet temperature needs to be lowered. As an example we include a constraint to decrease the maximum outlet temperature of the compressor by 3 % compared to the unconstrained case, i.e., ϑ lim c 0.97 · max ϑ unlim c . The compressor outlet temperature was modeled using the assumptions presented in Section 2.3 and fitted with the methodology of Appendix C, i.e., ϑ c (s) = M ϑ c E tc (s), p im (s) . To better visualize the transient phenomena during the gearshifts, thin vertical lines have been inserted at the upshift locations. The battery recharge target and fuel consumption target are the same for both scenarios. It can be noticed at first glance that the intake manifold and turbocharger speed trajectories are different and almost everywhere lower compared to the unconstrained case. This is mainly due to their dependency on the compressor outlet temperature. In addition, the engine air and fuel mass flows, as well as the gearshift strategy, differ markedly to case studies previously analyzed. Since the intake manifold pressure is (indirectly) limited, the gearshifts occur at higher engine speeds to avoid large engine air mass flow deficits after the upshift. Despite the throttle valve being completely opened after the upshifts, the fuel mass flow is limited by the available engine air mass flow and the allowed fuel-to-air ratio range. Consequently, the injected fuel displays a transient behavior induced by the intake manifold inertia. The influence of the gradual increase of both the fuel injection and the air mass flow are visible in the exhaust manifold quantities: The pressure is lower because of a lower total mass flow through the turbine, whilst the temperature is higher due to the larger fuel-to-air ratio. Finally, the lap time loss is roughly 12 ms and arises from the engine power deficits occurring after the upshifts.

Trends in Entire Lap Solutions
In this subsection we look at entire lap solutions with a focus on the gearshift strategy, power unit actuation and lap time trends. First, we discuss the engine speed thresholds at which the upshifts occur. Second, we extend the investigations of Section 4.1 for entire lap results. Third, we analyze the power unit optimal control on the straights for a set of battery recharge targets.
The engine speed thresholds at which the upshifts occur for each gear are shown in Figure 14 for three different battery recharge targets. In the left plot the raw data are depicted, in the right plot the averaged values are displayed. Regarding the raw data, the points are spread and no clear pattern on the engine speed threshold can be inferred. Instead, for the averaged data, two regions can be distinguished. In the first region, the upshift thresholds from 2nd to 3rd and from 3rd to 4th gear are the same, irrespective of the battery budget. This could be attributed to the fact that these two specific upshifts always occur in the corners, where the power unit is (for the considered energy budgets) controlled in a similar way, as also discussed in Section 4.1. In the second region on the other hand, the upshift thresholds are related to the energy budget. This trend could be explained by the fact that upshifting at higher engine speeds favors the electrical recuperation via MGU-H at the expenses of lower engine efficiency, as seen and discussed in the case study of Figure 12. In Section 4.1 it was analyzed in detail how the compressor outlet temperature influences the achievable lap time. For this reason, the lap time losses over an entire lap for the limited compressor outlet temperature for five different battery recharge targets, are shown in Figure 15. The trend shows that irrespective of the battery recharge target, limiting the compressor outlet temperature can yield a significant lap time loss. This result clearly quantifies how lap time sensitive the choice of the compressor material or the intercooler design can be. The average internal combustion engine and energy recovery system powers for different battery recharge targets but the same fuel target are shown in Figure 16. While the internal combustion engine and the energy recovery system powers in the corners influence the energy at disposal to the power unit when exiting the corners, they do not have a direct impact on the achievable lap time. For this reason, each power entry is averaged over all straights. The trends displayed in Figure   Finally, the lap time loss between ∆E b,target = −2.0 MJ and ∆E b,target = 2.0 MJ for several fuel consumption targets is shown in Figure 17. It can be noticed how the lap time loss increases nonlinearly if less fuel is used over the lap. This is a further proof of the complexity and inherent cross-couplings between the internal combustion engine and the energy recovery system of the considered hybrid electric powertrain.

Conclusions
In this paper we presented an optimization framework to compute the time-optimal low-level control and gearshift strategies for the Formula 1 hybrid electric powertrain. We put the focus on the engine speed dependency of the internal combustion engine components and proposed a continuous nonlinear model to describe the engine cylinder deactivation. Furthermore, we applied convex relaxations to model the non-smooth maximum fuel mass flow regulation and captured the highly nonlinear turbocharger maps with neural network techniques. Finally, we solved the time-optimal control problem efficiently by applying outer convexification to the integer decision variable introduced by the gear selection. To showcase the optimization framework, we performed several case studies for different energy budgets. The results underlined the significant existing coupling between the internal combustion engine and the energy recovery system: The gearshift strategy, the MGU-K and MGU-H operation, the air-to-fuel ratio operational range, the waste-gate and throttle valve actuation, as well as the intake manifold pressure evolution were found to be strongly dependent on the energy budgets. Finally, we demonstrated the effectiveness of our framework as a design tool. For example, if the compressor outlet temperature has to be reduced by 3 % due to a change in the intercooler design, the lap time can increase by up to 130 ms for the considered conditions. The results presented in this work underline that the framework can be used as a tool to benchmark real-time control strategies, to generate reference trajectories and to develop control heuristics.

Acknowledgments:
We would like to thank Ferrari S.p.A. for supporting this project. Moreover, we would like to express our gratitude to Ilse New for her helpful and valuable comments during the proofreading phase. Last, but not least, we would like to acknowledge Ristorante Montana for the support and the inspiration.

Conflicts of Interest:
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Appendix A. Optimal Control Problem (Outer Convexified Formulation)
In this section, we state the optimal control problem. The state x and input u variables are The resulting time-optimal low-level optimization problem is subject to the dynamics the system equality constraints the system inequality constraints related to the integer variables and the initial and terminal constraints v(0) = v 0 , v(S) = v S , p im (0) = p im,0 , p im (S) = p im,S , E tc (0) = E tc,0 , E tc (S) = E tc,S , where v 0 , v S , p im,0 , p im,S , E tc,0 and E tc,S are the initial and terminal conditions for the velocity of the car, the intake manifold pressure and the turbocharger kinetic energy, respectively. For periodic paths (e.g., entire lap optimizations where the start and finish line coincide), the last six constraints of Equation (A7) can be rewritten as periodicity conditions, i.e., v(0) = v(S), p im (0) = p im (S), E tc (0) = E tc (S), and can be freely optimized.

Appendix B. Mixed-Integer Nonlinear Program Solution
In this section, we present a comparison between the continuous solution, the rounded solution and the mixed-integer nonlinear program (MINLP) solution. The results are shown in Figure A1. As can be seen, the continuous solution partially differs from the rounded one. The gear trajectories are close to each other except in the braking phase of the second corner. Despite this fact, the difference between the solutions is marginal and the overall lap time difference is less than 1 ms. Except for one point where the gearshift occurs one space step earlier, the rounded and the MINLP solutions are similar. This results in a lap time difference of less than 0.5 ms. Given that the optimization of the continuous and rounded NLPs together displays computational times more than 100 times faster than the MINLP optimization, we deem the small difference acceptable.

Appendix C. Neural Networks
This Appendix is based on [47] and briefly summarizes the methodology used to fit the maps presented in Section 2. We apply feedforward neural networks. More precisely, we focus only on regression, i.e., both the input u ∈ U ⊆ R M in and output y ∈ U ⊆ R M out vectors consist of real numbers, where M in , M out ∈ N >0 .  Figure A2. Feedforward neural network schematic taken from [47]. The structure consists of L = 2 hidden layers, M in = 3 inputs and M out = 1 output. Each neuron is connected to the next ones through arrows.
As shown in Figure A2, neural networks are structured in layers, each consisting of multiple nodes. In particular, our architecture is composed of the input layer, where each node stores the s-th entry of the input vector u, with s ∈ {1, . . . , M in }, L ∈ N >0 hidden layers, where each node is fed with all output information of the previous layer, and the output layer, that collects the information of the L-th hidden layer and generates a prediction. More precisely, each node i ∈ {1, . . . , N k } of layer k ∈ {2, . . . , L + 2} performs following operation: where N k ∈ N >0 denotes the number of nodes of layer k, x k i ∈ R is the node's internal variable, and z k i ∈ R denotes its output. The activation function f k : R → R of layer k can be chosen arbitrarily. In this work we choose the hyperbolic tangent function for the hidden layers to increase the fitting quality of the nonlinear maps, and a linear function for the output layer. Finally, the parameters w k ij ∈ R, j ∈ {1, . . . , N k−1 } and b k i ∈ R are learned during the training phase. It consists of determining the set of parameters The optimization methodology used does not guarantee global optimality of the solution. Therefore it is important to check the quality of the fitting a posteriori.