{'fraction_non_alphanumeric': 0.037277737340126856, 'fraction_numerical': 0.01263387750857856, 'mean_word_length': 4.709409320273078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Numerical Simulation of Macroscopic Traffic Equations

Macroscopic traffic simulations are based on coupled non-linear partial differential equations, the solutions of which are either shock-like or inhomogeneous with steep gradients, at least in the interesting density regime. We discuss several suitable explicit integration schemes, including their advantages and disadvantages, their numerical robustness and errors. We compare the effects of diffusion with that of nonlocal terms. In addition, we investigate different possibilities of treating realistic open boundary conditions. The theoretical considerations are illuminated by many examples of simulation results.

the continuity equation for the vehicle density ρ(x, t) per lane at position x and time t: where V (x, t) is the average vehicle velocity. According to Eq. (1), the temporal change ∂ρ/∂t of the vehicle density is given by the spatial change −∂Q/∂x of the traffic flow Q(x, t) = ρ(x, t)V (x, t) and the rate ν ± (x, t) ≥ 0 of vehicles entering (+) or leaving (−) the highway at on-or off-ramps.
According to Eq. (2), the change ∂V /∂t of the average vehicle velocity is given by three terms. The transport term originates from the propagation of the velocity profile with the velocity V of the vehicles. The pressure term reflects either an anticipation of spatial changes in the traffic situation or dispersion effects due to a finite variance of the vehicle velocities.
The relaxation term describes the adaptation to a dynamic equilibrium velocity V e with a relaxation time τ .
All forms of congested traffic seem to have almost universal properties which are largely independent of the initial conditions and the spatially averaged density. For example, the characteristic outflow Q out from traffic jams is about 1800 ± 200 vehicles per kilometer and lane, and a typical dissolution velocity C of about −15 ± 5 kilometers per hour. 13 This universality arises from the highly correlated state of motion produced by traffic congestions. 14 In particular, the outflow Q out is related to the time interval between successive departures from the traffic jam. Therefore, the outflow is almost independent of the kind and density of congested traffic. As a consequence of the constant outflow, the dissolution velocity of traffic jams is nearly constant as well. These observations and the transition from free to "synchronized" congested traffic 15 are correctly described by the nonlocal, gas-kinetic-based traffic model, [16][17][18][19] which we now introduce.

The Nonlocal, Gas-Kinetic-Based Traffic Model
Our approach is to derive macroscopic traffic models from gas-kinetic traffic equations, 12,16 which are obtained from "microscopic" models of driver-vehicle behavior. 16 Gas-kinetic traffic models have been proposed earlier, but the correct treatment of the most interesting regime of moderate and high densities was still an open problem.
We have managed to evaluate the vehicular interaction term of the gas-kinetic traffic model almost exactly. 16 The analytical result can be represented by the nonlocal, dynamical equilibrium velocity V e : According to Eq. (3), V e is given by the desired (maximum) velocity V 0 , reduced by a term which reflects necessary deceleration maneuvers. Here, ρ max is the maximum vehicle density, and T is the average time headway at large densities. For example, German authorities require that the distance in meters to the front vehicle be not less than half the velocity in km per hour, which gives a time headway of T = 1.8 s. For the intra-lane variance θ, we assume the constitutive relation θ = A(ρ)V 2 where A(ρ) is given by Eq. (5). The prime indicates that the variable is calculated at the advanced "interaction point" with 1 ≤ γ < 2 rather than at the actual position x. This factor accounts for the fact that drivers anticipate the behavior of vehicles in front of them. The monotonically increasing "Boltzmann factor" describes 16 the dependence of the braking interaction on the dimensionless velocity difference θ + θ ′ between the actual location x and x ′ . In homogeneous traffic, we have B(0) = 1. If the preceding cars are much slower (δ V ≫ 0), the interaction strength given by B is particularly large, and it follows that B(δ V ) = 2δ 2 V . For δ V ≪ 0, we have B(δ V ) ≈ 0. That is, because the distance to the next vehicle is increasing, the vehicle will not brake, even if its distance is smaller than the safe distance.
Finally, the dynamics of the intra-lane variance can be approximated by the constitutive where the coefficients A 0 = 0.008, ∆A = 0.02, ρ c = 0.27ρ max , and ∆ρ = 0.05ρ max have been obtained from single-vehicle data on a section of the Dutch motorway A9. 16 Simulations of sections of other motorways, for example, the German motorway A8, give a somewhat lower value of ∆A = 0.01, which we will use in the following. Equation (5) shows that the standard deviation √ θ of vehicle velocities is proportional to the average velocity V , with a density-dependent proportionality factor which is small for the density range found in free traffic. The velocity variance also enters the gas-kinetic traffic pressure If not explicitly stated otherwise, the simulation results presented here were calculated with the model parameters V 0 = 110 km/h, τ = 32 s, T = 1.8 s, ρ max = 160 vehicles/km, and The main difference between the gas-kinetic-based traffic model and other macroscopic traffic models is the nonlocal character of the braking term. The nonlocal term in Eq. (3) has smoothing properties similar to those of a viscosity term, but its effect is forwardly directed and, therefore, more realistic. In contrast, models with an explicit viscosity term 20 lead to unphysical humps in the vehicle density (see Figure 1) and even negative velocities 21 (see Figure 2). Our model also has favorable properties with respect to numerical stability and integration speed, and hence allows a robust real time simulation of freeway stretches up to several thousand kilometers on a personal computer.

Some Explicit Finite Difference Methods
A desirable property of the above traffic equations is that they can be formulated in terms of a conservation equation with a sink/source term s: This form makes it possible to use a variety of numerical standard methods developed for the simulation of hydrodynamic problems. 10,11,22 The conservative form of the traffic equations reads ∂ρ ∂t and where Q(x, t) = ρ(x, t)V (x, t) is the traffic flow and V ± denotes the average velocity of vehicles which enter (+) or leave (−) the freeway at ramps. For the case V ± = V , we obtain the additional terms ±ν ± (V ± − V )/ρ in (2). We have For the explicit numerical solution methods we will discuss, x and t are discretized with uniform values of ∆x and ∆t, respectively. Hence, we calculate u at the discrete points (j ∆x, n ∆t) with j, n ∈ {0, 1, 2, . . .}. For brevity, we use the notation u n j = u(j ∆x, n ∆t). We will discuss the following numerical integration methods: 10,22

Lax-Friedrichs method
2. Upwind method 3. MacCormack method 4. Lax-Wendroff method Consistency Order. If the spatial variation of u is sufficiently smooth, the Lax-Friedrichs and upwind methods are first-order, that is, the upper bound of the local error is proportional to α if ∆x and ∆t are simultaneously decreased by a factor of α. In general, the upwind method is not stable and the differential operator needs to be decomposed into parts which are treated by upwind and downwind differencing, respectively (the Godunov method 22,5-7 ).
Fortunately, for traffic equations of the form (2), the upwind method is stable (and equivalent to the Godunov method).
The two-step MacCormack and Lax-Wendroff methods are second-order, that is, the upper bound of the local error is proportional to α 2 . However, for shock-like solutions, the order is lower for all of the above integration methods. 22 Note that the predictor step of the MacCormack method is an ordinary upwind step, and the corrector step consists of the average between the predictor and a "downwind" step with f calculated with the values of the predictor. Interchanging the order of the upwind and downwind differencings of the two steps has nearly no effect for the equations investigated here.
Accuracy. Although the discretization errors associated with nonlinear equations are difficult to determine, good estimates are usually obtained by doing a local linearization, at least for smooth solutions. 22 Because realistic traffic models can produce sharp gradients, but no real shock fronts, the linearization is applicable to the numerical treatment of macroscopic traffic equations. This analysis shows that the upwind method is more accurate than the Lax-Friedrichs method.
Although the main discretization error of the Lax-Friedrich and upwind methods yields a numerical diffusion, which causes a smoothening of shock fronts (see Numerical Stability. An integration method is numerically unstable if errors grow exponentially, which usually leads to wildly oscillating density profiles with very short wave lengths and eventually to overflow error. Even in the quasi-linear case, the above explicit discretization methods can lead to three types of instabilities which implies three conditions for numerical stability: 1. Convective instability. Instabilities of the finite difference method for the flux term lead to the Courant-Friedrichs-Lewy condition 10,22 which for our model becomes where V 0 is the maximum average velocity. For example, for V 0 = 40 m/s (144 km/h) and a spatial discretization of ∆x = 20 m, we obtain ∆t ≤ 0.5 s.
2. Diffusion instability. Models which contain an explicit viscosity term D∂ 2 V /∂x 2 , change the otherwise hyperbolic character of the partial differential equations to a parabolic one. For numerical stability, the additional diffusional Courant-Friedrichs-Lewy condition D (∆x) 2 /(2 ∆t) ≤ 1 must be fulfilled. 10,22 This condition does not apply to simulations of the nonlocal, gas-kinetic-based traffic model.  Figure 4 shows that a finer discretization gives almost identical results.
The development of traffic instabilities starting with almost homogeneous initial traffic is a very strict test of numerical accuracy (see Figure 4). In most situations, for example, when simulating fronts or already developed congested traffic, the accumulated discretization error is much smaller.
In addition to the quasi-linear instabilities discussed above, genuine nonlinear instabilities may arise for certain numerical methods and simulation conditions. An example is the oscillations at the downstream front of the large amplitude jam of Figure 3d. It turns out that second-order methods are more sensitive to these instabilities. Note that, although the quasi-linear behavior is the same for the MacCormack and Lax-Wendroff methods, the nonlinear behavior can be different. 10 For the above traffic equations, the MacCormack method is more stable than the Lax-Wendroff method, and hence we will use the MacCormack method whenever a second-order method is desired.
When simulating the nonlocal model with one of the first-order methods, we did not observe nonlinear instabilities. Furthermore, higher order methods are not necessarily more accurate, 11 especially for large gradients. Thus, one should always implement different numerical methods and compare their simulation results. Aside from their double integration speed, it is sometimes preferable to use first-order methods (causing somewhat smoothed wave fronts) instead of second-order methods (producing oscillations and sometimes nonlinear numerical instabilities). One reason is that oscillations act like perturbations, which may give rise to additional traffic jams that do not correspond with reality.

Initial and Boundary Conditions
To calculate traffic flows, it is necessary to specify the initial and boundary conditions.
The initial conditions are completely determined by specifying u( where L is the length of the simulated section and δ is the maximum nonlocality, which Again, a constant value of u is assumed for x > L.

4.
In-and outflows ±Q rmp at on-ramps (+) and off-ramps (−), can be considered as follows. [17][18][19] If n is the number of freeway lanes (without ramps) and L rmp is the length of the ramp, we simply set Generally speaking, periodic boundary conditions are best suited for theoretical investi- However, for a simulated time interval T sim = 2 h, the required additional length is order V 0 T sim ≈ 200 km, which considerably reduces the efficiency of the numerical integration.
There are problems associated with using Dirichlet boundary conditions. Imposing  We illustrate the effects of different boundary conditions by a simulation of the German motorway A8 near Munich with real traffic data using the upwind method. Figure 5a shows a space-time plot of the density with Dirichlet boundary conditions on both sides. The winglike regions of higher density represent "synchronized" congested traffic 15    Finally, Fig. 5d shows a simulation with the hybrid boundary conditions (see Eq. (23)) and the upstream boundary shifted downstream by 3.5 km. In this case, the traffic jam reaches the upstream boundary, which is handled by the hybrid boundary conditions, while all other boundary conditions would lead to a numerical instability for any integration method.

Summary
We have seen that traffic flows are characterized by the occurrence of congested regions, jams, and stop-and-go waves which are associated with large gradients of the vehicle density and average velocity. This rich behavior has stimulated an intense research activity. We have discussed the problems of macroscopic traffic simulations which are related to the numerical integration of systems of coupled nonlinear partial differential equations. Despite the differences with hydrodynamic equations, many integration methods developed for conservation equations turn out to be applicable. Compared to implicit methods, 10 explicit methods are less robust, but much more flexible with regard to time-dependent boundary conditions and (variational) optimization problems, and are usually computationally faster. Among the explicit first-order methods, the upwind method is more accurate than the Lax-Friedrichs method. The MacCormack and the two-step Lax-Wendroff methods are second-order, but they are less efficient by a factor of two and produce unrealistic oscillations close to steep gradients. The numerical precision may be improved by "high resolution methods," 22 where a first-order method is used for large gradients and a second-order method is used for small gradients. This approach may combine the accuracy of the second-order methods with the smoothness of the first-order methods.
The most important factor that determines the computation time is the choice of the traffic model. In particular, the simulation of the nonlocal, gas-kinetic-based traffic model is significantly more efficient than the numerical solution of models with viscosity or diffusion terms. This efficiency is mainly related to the fact that the diffusional Courant-Friedrichs-Lewy condition, which does not apply for nonlocal terms, is usually far more restrictive than the other instability conditions, especially for fine discretizations. Because diffusion terms also produce unrealistic effects close to steep gradients, it may be reasonable to generally replace models with diffusion or viscosity terms by nonlocal models. Anyway, diffusion and viscosity terms are often a lowest-order approximation of nonlocal terms. They are mainly used for historical reasons, because they can be better treated analytically.
Finally, we have discussed suitable specifications of the boundary conditions. In most previous simulation studies, periodic boundary conditions were used to circumvent the in- 2. Stability of homogeneous traffic with respect to a localized perturbation. Simulate freeway traffic for a circular road of 10 km circumference with the nonlocal, gas-kinetic-based traffic model and the parameters used in this column. Assume homogeneous equilibrium traffic of density ρ, and add to the density a localized perturbation of amplitude ∆ρ so that the initial conditions are given by 23 Here, (a) Choose a small perturbation amplitude of ∆ρ = 1 vehicle/km and run the simulation for 30 minutes. Check that the perturbation does not grow for ρ < ρ c2 and ρ > ρ c3 with ρ c2 = 29 vehicles/km and ρ c3 = 47 vehicles/km, but gives rise to large-amplitude stop-andgo waves for ρ c2 ≤ ρ ≤ ρ c3 .
(b) Use larger perturbations of amplitudes up to ∆ρ = 60 vehicles/km and show the traffic flow is metastable. To do so, show that the model produces a single traffic jam for ρ ∈ (ρ c1 , ρ c2 ) with ρ c1 = 27 vehicles/km and a dipole-like localized structure for ρ ∈ (ρ c3 , ρ c4 ) with ρ c4 = 50 vehicles/km, if ∆ρ exceeds a (density-dependent) critical amplitude; homogeneous traffic flow is found for subcritical perturbation amplitudes. 23,16 (c) In sufficiently large systems, there exists a subset of densities ρ ∈ (ρ cv , ρ c3 ) in the linearly unstable regime where traffic is convectively stable. 19 This stability means that the localized perturbation will disappear for t → ∞ at any given location x while, nevertheless, the global maximum of the perturbation grows (because the system is linearly unstable). In our case, ρ cv is given by the value of ρ at which the downstream boundary of the perturbed zone does not move. Illustrate the case of convective stability by making a three-dimensional plot of ρ(x, t) of a simulation running for 15 minutes with ρ = 45 vehicles/km and ∆ρ = 1 vehicles/km. Show that ρ cv = 42.5 vehicles/km.
3. Characteristic parameters. 16 Assume a circular road, model parameters, and initial conditions as in Problem 2. Q rmp at t = 25 min. After running the simulation for a total of 60 minutes, you should see "synchronized" congested traffic, that is, an increasing region of high density and low velocity, but relatively high flow, whose upstream front is propagating upstream, while the downstream front is pinned at the ramp.
(b) Verify that "synchronized" congested traffic is in equilibrium and determine the numerical value of its outflowQ out . Show that the propagation velocity v g of the upstream front can be expressed by the relation where Q rmp and Q main = Q e (ρ) are the inflows at the ramp and to the main road. The densities ρ cong (Q) and ρ free (Q) denote, in accordance with Q e = ρV e (ρ), congested traffic (ρ ≥ 31 vehicles/km) and free traffic (ρ < 31 vehicles/km), respectively.
5. Different traffic states close to an on-ramp. 19 Varying the initial traffic density, the length of the on-ramp, and the ramp flow leads to several interesting states of congested  In the viscosity traffic model , the finite velocity diffusion leads to an increase of velocity also in the congested part (see (d)) and to a subsequent further increase of density (see (c)). The ensuing positive density gradient would lead to negative velocities for an initial jam density higher than 106 vehicles/km, which is much lower than the maximum density ρ max = 160 vehicles/km.