# A Two-Level Rolling Optimization Model for Real-time Adaptive Signal Control
## 2 Traffic Signal Timing Optimization Algorithm
### Integer Linear Programming  
In Step 3 of the forward recursion, \(f_{j}(s_{j},x_{j})\), the optimal performance measure (objective function) at stage \(j\), given barrier group state \(s_{j}\) and control \(x_{j}\), needs to be calculated. The value of \(f_{j}\big{(}s_{j},x_{j}\big{)}\) depends on the green duration of the \(j\)th barrier group. In this study, the vehicle delays can be considered as the objective function. Then, the lower level integer linear programming is formulated in Equations (5)-(10). To solve the integer linear programming problem, the optimal phase duration is enumerated to find the minimum delay combination for the given \(x_{j}\). The arrival flow of each phase at each time step \((A_{r,p}(t))\) comes from a predicted arrival table, which is a two-dimensional matrix with time and phase respectively. The value in each cell is the number of vehicles that will arrive at the stop bar after time interval \(t\) requesting phase \(p\) in ring \(r\) and is the result of the traffic flow prediction model [26].  
Firstly, the cumulative delay can be calculated by using the IQA method [27]. Given \(x_{j}\) is the length of the barrier group, the lower level problem solves one of the following optimization problems. The objective function as shown in Equation (5).  
\[\min\sum_{r=1}^{2}\sum_{p=1}^{2}d\big{(}g_{r,p},R_{r,p}\big{)}, \tag{5}\]  
where,  
\[d\big{(}g_{r,p},R_{r,p}\big{)}=\sum_{t=s_{j-1}+1}^{s_{j-1}+x_{j}}l_{r,p}(t),r=1,2;p=1,2, \tag{6}\]  
where \(d\big{(}g_{r,p},R_{r,p}\big{)}\) is the total delay in the given \(g_{r,p}\) and \(R_{r,p};l_{r,p}(t)\) denotes the queue length of phase \(p\) in ring \(r\) at time interval \(t\).  
The queue length at time interval \(t\) depends on the queue length of time interval \(t-1\), the arrival and departure vehicles during time interval \(t\), which follows the basic flow conservation relationship as shown in Equation (7).  
\[l_{r,p}(t)=l_{r,p}(t-1)+A_{r,p}(t)-D_{r,p}(t),r=1,2;p=1,2, \tag{7}\]  
where \(A_{r,p}(t)\) and \(D_{r,p}(t)\) denote the number of arrival and departure vehicles of phase \(p\) in ring \(r\) at time interval \(t\), respectively.  
The analysis shows that the departure of vehicles at time interval \(t\) is related to the initial queue vehicles at time interval \(t\), traffic signal state, and the saturation flow rate. This relationship is shown in Equation (8).  
\[\begin{split} D_{r,1}(t)=\min(S_{r,1},l_{r,1}(t-1)+A_{r,1}(t)), \text{if }s_{j-1}+1\leq t\leq s_{j-1}+g_{r,1},r=1,2.\\ D_{r,2}(t)=\min(S_{r,2},l_{r,2}(t-1)+A_{r,2}(t)),\text{if }s_{j-1}+g_{r,1}+R_{r,1}<t\leq s_{j-1}+g_{r,1}+R_{r,1}+g_{r,2},r=1,2.\\ D_{r,p}(t)=0,\text{if }s_{j-1}+g_{r,1}+R_{r,1}+g_{r,2}<t\leq s_{j-1 }+x_{j},r=1,2;p=1,2.\end{split} \tag{8}\]where \(S_{r,p}\) denotes the saturation flow rate of phase \(p\) in ring \(r\), \(\mathrm{veh}/\mathrm{s}\).  
Then, considering the duration of two barrier groups in each ring, these should be equal to the current decision variable \(x_{j}\) Equation (9). In addition, the duration of each phase is bounded by a lower limit and an upper limit which is shown in Equation (10).  
\[g_{r,1}+R_{r,1}+g_{r,2}+R_{r,2}=x_{j},r=1,2. \tag{9}\]  
\[G_{r,p}^{\min}\leq g_{r,p}\leq G_{r,p}^{\max},r=1,2;p=1,2. \tag{10}\]