# Traffic Demand Estimations Considering Route Trajectory Reconstruction in Congested Networks
## 4 Solving Algorithm  
When solving the Gaussian mixture model, expectation maximization algorithm (EM) [21]. is used to calculate \(c_{k}^{\omega},\sigma_{k}^{\omega 2}\), and \(\pi_{k}^{\omega}\) in order. The mean \(c_{k}^{\omega}\) and variance \(\sigma_{k}^{\omega 2}\) of route travel time are the extreme points of the Gaussian mixture model; that is, the partial derivatives of Equation (2) at \(\epsilon_{k}^{\omega}\) and \(\sigma_{k}^{\omega 2}\) are zero:  
\[\frac{\partial L}{\partial c_{k}^{\omega}}=0,\forall k\in K^{\omega},\omega\in W \tag{15}\]  
\[\frac{\partial L}{\partial c_{k}^{\omega 2}}=0,\forall k\in K^{\omega},\omega\in W \tag{16}\]  
According to the KKT optimality conditions of Formulas (2)-(4), mixing weight is calculated as follows:  
\[\pi_{k}^{\omega}=\frac{\sum_{i\in I^{\omega}}\gamma_{k,i}^{\omega}}{|I^{\omega} |},\forall k\in K^{\omega},\omega\in W \tag{17}\]  
where \(|I^{\omega}|\) is the potential of set \(I^{\omega}\). As prior traffic demand is subject to multivariate normal distribution and all variables are linearly related (Equations (7), (11), and (12)), the Bayesian posterior distribution of unobserved variables (traffic demand) is also subject to multivariate normal distribution after observing some variables (road travel data) where the mean vector \(\mathbf{\mu}_{\mathbf{D}|\mathbf{Z}=\mathbf{C}}\) and covariance matrix \(\mathbf{\Sigma}_{\mathbf{D}|\mathbf{Z}=\mathbf{C}}\), respectively, are [22]:  
\[\mathbf{\mu}_{\mathbf{D}|\mathbf{Z}=\mathbf{C}}=\mathbf{\mu}_{\mathbf{D}}+ \mathbf{\Sigma}_{\mathbf{D}\mathbf{Z}}\mathbf{\Sigma}_{\mathbf{Z}}^{-1} \mathbf{\left(\mathbf{C}-\mathbf{\mu}_{\mathbf{Z}}\right)} \tag{18}\]  
\[\mathbf{\Sigma}_{\mathbf{D}|\mathbf{Z}=\mathbf{C}}=\mathbf{\Sigma}_{\mathbf{DD }}-\mathbf{\Sigma}_{\mathbf{D}\mathbf{Z}}\mathbf{\Sigma}_{\mathbf{Z}}^{-1} \mathbf{\Sigma}_{\mathbf{Z}\mathbf{D}} \tag{19}\]  
where \(\mathbf{Z}\) represents all observed variables' vectors. Therefore, the established upper-level model can be solved by updating Formulas (18) and (19). At each moment, the Bayesian traffic demand estimation model in congested environments was solved using the iterative algorithm framework, and the lower-level SUE model was solved using the method of successive averages (MSA). The designed algorithms for proposed model are as Algorithm 1. ``` Step \(\mathbf{C}\)  Initialize: Set the number of iteration steps \(n=0\), convergence accuracy \(\varepsilon\), initial demand weight matrix \(\mathbf{k}^{(0)}\), mean \(\mu_{U}\) and variance \(\sigma_{U}^{2}\) of traffic demand level, random error parameter \(\sigma_{q}^{2}\), discrete parameters \(\theta\) of travel perception error; observed data, and observed route travel time \(\hat{x_{i}}\). According to Equation (1), the observed variables are transformed to a uniform format to obtain the link travel time \(t_{a}\). The EM algorithm is used to solve \(c_{k}^{\omega},c_{k}^{\omega 2}\), and \(\pi_{k}^{\omega}\) to determine the observed route trajectory. (a) Initialize the mean \(c_{k}^{\omega}\), variance \(\sigma_{k}^{\omega 2}\), and mixing coefficient \(\pi_{k}^{\omega}\) of route travel time; (b) Calculate the probability \(\gamma_{k,i}^{\omega}\) using Equation (6); (c) Use Equations (15) and (16) to update the mean \(c_{k}^{\omega}\) and variance \(\sigma_{k}^{\omega 2}\) according to the current \(\gamma_{k,j}^{\omega}\), update the mixing coefficient \(\pi_{k}^{\omega}\) according to Equation (17); (d) If the parameter \(\gamma_{k,j}^{\omega}\) converges (that is, the difference between the parameters of two iterations reaches convergence accuracy), the algorithm ends. Otherwise, go to step (b); (e) Determine the observed route trajectory; that is, calculate \(x_{i}\) using Equation (5).