## 3 The Freeway Merging Framework
### Trajectory Optimization  
CAVs enter the trajectory optimization zone after completing the lane-changing operation. After that, vehicles are no longer allowed to change lanes, so we could convert the problem of merging the main road and the ramp into the merging problem of the Outer Lane of the mainline and the ramp, as shown in Figure 7.  
In actual scenarios, vehicles on freeways and ramps enter continuously and in real-time. It is challenging to optimize all vehicles' trajectories from the global perspective, so we decided to optimize the entering vehicles round by round in the trajectory optimization zone. In detail, the traffic controller starts to optimize all vehicles in the trajectory optimization zone when the first entering vehicle (which may be in the Outer Lane or the Ramp Lane) is about to leave in the trajectory optimization zone. After the optimization, the traffic controller starts to process the next round of incoming vehicles when the first vehicle of the next round of vehicles is about to leave the trajectory optimization area. We decided that  
Figure 4: Schematic diagram of the target gap for lane changing in the lane-changing zone.  
Figure 5: Vehicle conditions in the Outer Lane within the target gap for lane changing: (**a**) only one vehicle exists; (**b**) there are multiple vehicles.  
we needed to remove the vehicles that are in the other lane during optimization without leaving the trajectory optimization zone in the last round of optimization.  
Specifically, the traffic controller firstly collects all vehicles' information in the trajectory optimization zone, including position, speed, and acceleration, when the traffic controller optimizes the trajectory of vehicles entering the Outer Lane and Ramp Lane. The traffic controller then uses the following control model for optimization to obtain each vehicle's trajectory in the future \(T^{TO}\) seconds. The traffic controller controls each vehicle's speed and acceleration according to the optimized results so that vehicles can pass the merge point without collision along the optimized trajectory.  
Figure 6: Flow chart of vehicle lane changing in the lane-changing zone.  
Figure 7: Simplified diagram of the trajectory optimization zone.  
Here, we borrowed the optimal control strategy in [26], where the trajectory optimization model is linear time discrete and each time step's speed is used as a decision variable. The objective function of trajectory optimization is to maximize all vehicles' speed while minimizing the acceleration rate in the trajectory optimization zone, as shown in Equation (4).  
\[\min(-\omega_{1}\sum_{l=1}^{2}\sum_{n=1}^{N_{l}}\sum_{t=1}^{T^{TO}}v_{l,n,t}+ \omega_{2}\sum_{l=1}^{2}\sum_{n=1}^{N_{l}}\sum_{t=1}^{T^{TO}}|u_{l,n,t}-u_{l,n,t -1}|) \tag{4}\]  
subject to  
\[0\leq v_{l,n,t}\leq v_{\max};\forall l,n,t \tag{5}\]  
\[u_{\min}\leq u_{l,n,t}\leq u_{\max};\forall l,n,t \tag{6}\]  
\[s_{l,n,t}-s_{l,n,t-1}=v_{l,n,t-1}\cdot\Delta t;\forall l,n,t=2,3,\ldots,T^{TO} \tag{7}\]  
\[v_{l,n,t}-v_{l,n,t-1}=u_{l,n,t-1}\cdot\Delta t;\forall l,n,t=2,3,\ldots,T^{TO} \tag{8}\]  
\[\left|s_{l,n,t}-s_{l,n-1,t}\right|\geq TG_{\min}^{TO}\times v_{l,n-1,t}; \forall l,n=2,3,\ldots,N_{l} \tag{9}\]  
\[\left|s_{1,i,T^{TO}}-s_{2,j,T^{TO}}\right|\geq\left\{\begin{array}{c}TG_{ \min}^{TO}\times v_{1,j,T^{TO}},ifs_{2,j,T^{TO}}>s_{1,j,T^{TO}}\\ TG_{\min}^{TO}\times v_{2,j,T^{TO}},else\end{array};\forall i=1,2,\ldots,N_{ 1};j=1,2,\ldots,N_{2}\right. \tag{10}\]  
Constraints (5) and (6) are the limits of speed and acceleration, respectively. Constraints (7) and (8) are vehicle dynamics equations. Constraint (9) means that the distance between two adjacent vehicles in the same lane must meet the minimum safety gap requirement. Constraint (10) is imposed onto the last optimization time step to ensure that the outside lane and ramp vehicles maintain a safe distance after the optimization is completed.  
Table 1 details the parameters and symbol descriptions involved in the trajectory optimization model.