## 4 Mathematical Models in Intersections  
Our study elaborates on a network control process consisting of several junctions that control all the traffic lights. The aim of achieving an optimal balance at intersections has been proposed in this algorithm based on selecting a kind of traffic light and the duration of the green phase. This intersection consists of many independent agents that exchange information with each other, and the stability of each agent is proved separately. This article investigates eight isolated intersections; the four phases are shown in Figure 2. We used a dynamic model from a single intersection at the first step. After that, with attention to the dynamic model intersection, we prove stability, then we get a new equation. To expand an intersection to 8 intersections, we proposed a multiagent method to connect intersections. Here, Figure 2 shows the presented multiagent model, which has been used for eight intersections in traffic control and reducing the queue length using a model predictive control. Finally, we want to reduce the queue length created at the intersections by the proposed model. In this section, mathematical equations and several connecting intersections have been mentioned. The stability of an intersection has been mentioned in [53]. For more explanation, there are two phases at an intersection, Leg 1, Leg 3, and Leg 2, Leg 4. Here, a vehicle's queue length is one of the main parameters in the equation of traffic flow at each intersection in the Equation (1). \[Q_{i}(n+1)=Q_{i}(n)+q_{i}(n)-d_{i}(n)s_{i}(n) \tag{1}\]  
In this case, \(i=1,2,3,\ldots,n\) is the leg index that enters the intersection. In addition, \(n=0,1,2,...,N-1\) is the discrete-time interval index. \(Q_{i}(n)\) represents the length of the queue of vehicles, \(q_{i}(n)\) represents the number of leaving cars, \(d_{i}(n)\) represents the number of entering vehicles and \(s_{i}\in[0,1]\) represents the traffic light status in the legs of the simulation. As long as T has been considered as a discretized time interval, and can  
Figure 2: The overall structure of the proposed method. be assumed uniform in every time interval, a uniform arrival of vehicles is presumed for every time interval, resulting in the calculation of the overall waiting time as Equation (2). \[W_{i}(n+1)=W_{i}+TQi(n)+q_{i}(n)-d_{i}(n)s_{i}(n)1/2q_{i}(n)l \tag{2}\]  
For further details, state-space equations for a single intersection are as below:  
\[\left\{ \begin{array}{c}X(n+1)=AX(n)+B(n)S+C(n)\\ Y(n)=CX(n)\end{array} \right. \tag{3}\]  
We used Equation (2) for proving the stability of eight intersections. At this Equation, \(X_{i}(n),W_{i}(n)\) are control variables. Additionally, Equation (3) shows other matrices of coefficients and vectors, for example A,B,C,D, as follows:  
\[C= \begin{bmatrix}I_{M}&0\\ 0&I_{M}\end{bmatrix}  \tag{4}\]  
\[A= \begin{bmatrix}I_{M}&0\\ T_{M}&I_{M}\end{bmatrix}  \tag{5}\]  
\[B(n)=- \begin{bmatrix}d_{1}(n)&0&\cdot&\cdot&\cdot&0\\ 0&d_{2}(n)&\cdot&\cdot&\cdot&0\\ \cdot&\cdot&\cdot&\cdot&\cdot&\cdot\\ \cdot&\cdot&\cdot&\cdot&\cdot&\cdot\\ \cdot&\cdot&\cdot&\cdot&\cdot&\cdot\\ 0&\cdot&\cdot&\cdot&\cdot&d_{M}(n)\\ 1/2 Td_{1}(n)&0&\cdot&\cdot&\cdot&0\\ 0&1/2 Td_{2}(n)&0&0&0&0\\ \cdot&\cdot&\cdot&\cdot&\cdot&\cdot\\ \cdot&\cdot&\cdot&\cdot&\cdot&\cdot\\ \cdot&\cdot&\cdot&\cdot&\cdot&\cdot\\ 0&0&\cdot&\cdot&\cdot&1/2 Td_{M}(n)\end{bmatrix}  \tag{6}\]  
These are:  
\[X(n)=[Q_{1}(n)Q_{2}(n)...Q_{M}(n)W_{1}(n)W_{2}(n)...1/2 Tq_{M}(n)]^{T} \tag{8}\]  
These variables refer to state variables and queue lengths and delays of \(Q_{i}(n)\). Mathematical Model of Multi-Agent Intersections  
Figure 3 shows multi-agent intersections linked to each other. When the intersections are connected to each other, all the parameters of \(Q_{i}(n),W_{i}(n)\) all the matrices of the coefficients are similar to the intersection. Their only difference is in the state-space equations based on the Kronecker product as Equation (9).