## 5 Solution of the Bi-Level Optimization Problem  
The bi-level optimization problem is solved in an iterative manner. Each calculation iteration estimates as solutions the cycle duration \(y_{j}\); \(j\) = 1,..., 8 (upper-level optimization problem), and green light duration \(u_{k}\), \(k\) = 1,..., 16 (lower-level optimization problem). These values are applied for estimation of each queue length \(x_{i}\), \(i\) = 1,..., 30, which represents the value \(x_{i0}\) for the next iteration or control cycle. In that manner, by controlling the traffic light settings (solving the bi-level optimization problem), we indirectly observe the state of the network's queue lengths. The estimated solutions \(y_{j}\) and \(u_{k}\) are used for updating both bi-level problems for the next iteration/control cycle. In this updating, the authors apply a new approach in order to improve the model to the reality. The innovation here is the check of the durations of the estimated values of the cycles and green light durations and using the shorter duration comparing two crossroads for the next control cycle. Thus, for each control cycle, we apply the model predictive control [49; 50] by shorter cycle duration. This approach is applied to all couples of nodes (junctions) of the network. Here, we describe this idea only for the first and second crossroads, but this is done for all crossroad couples of the network. The network traffic control has the peculiarity of synchronization of the traffic lights in order to provide a green wave of moving vehicles. In our network, the distances are short, and according to the included limits of changes of the variables in the problems' constraints, an additional offset for the green wave is not necessary. The distances between the neighbor junctions are short enough to consider that the estimated cycles and green light durations are synchronized as control influences. The time during which a vehicle drives from one junction to the next is approximately the duration of a traffic light cycle. This means that we can neglect the distance between the traffic lights and observe the relation between the durations of the cycles and green lights. That is why we consider three variants of the estimated optimization results: \(y_{1}\) = \(y_{2}\), \(y_{1}\) > \(y_{2}\), and \(y_{1}\) < \(y_{2}\). Case I: \(y_{1}\) = \(y_{2}\). In this case, the values of the queue lengths are calculated according to the store-and-forward model. The first queue length \(x_{1}\) is determined by Equation (7). The queue lengths of the first and second junctions are evaluated according to the following equations:  
\[x_{1} =x_{1_{0}}+a_{3}s_{1}y_{1}-(1+2a_{2})s_{1}u_{1}\] \[x_{2} =x_{2_{0}}+a_{3}s_{2}y_{1}-(1+2a_{2})s_{2}u_{2}\] \[x_{3} =x_{3_{0}}+s_{3}u_{3}+2a_{2}s_{4}u_{4}-(1+2a_{2})s_{1}u_{1}\] \[x_{4} =x_{4_{0}}+a_{3}s_{2}y_{1}-(1+2a_{2})s_{2}u_{2}\] \[x_{5} =x_{5_{0}}+s_{1}u_{1}+2a_{2}s_{2}u_{2}-(1+2a_{2})s_{3}u_{3}\] \[x_{6} =x_{6_{0}}+s_{12}u_{12}+2a_{2}s_{1}u_{11}-(1+2a_{2})s_{4}u_{4}\]\[x_{7}=x_{7_{0}}+s_{5}u_{5}+2a_{2}s_{6}u_{6}-(1+2a_{2})s_{3}u_{3}\]  
\[x_{8}=x_{8_{0}}+a_{3}s_{4}y_{2}-(1+2a_{2})s_{4}u_{4}\]  
Case II: \(y_{1}>y_{2}\). In order to avoid queue lengths in front of the junctions, when the estimated cycle durations are not equal, we have to perform the shorter cycle as a traffic light setting. In other words, the determination of the queue lengths and respectively the traffic flows depend in this case on the shorter cycle \(y_{2}\). Here, we have to consider one more relation: between \(y_{2}\) and \(u_{1}\). When \(u_{1}<y_{2}\), the duration of \(u_{2}\) will be limited to the difference \(u_{2}=y_{2}-u_{1}-0.1y_{1}\), Figure 4a. The expression \(0.1y_{1}\) represents the decrease of the cycle because of amber light (0.1 part of the cycle). When \(u_{1}>y_{2}\), the duration of \(u_{1}\) will last until \(y_{2}\) and \(u_{2}\) will not start lighting at all, \(u_{2}=0\); see Figure 4b.