Distributed macroscopic traffic simulation with Open Traffic Models

This paper presents OTM-MPI, an extension of the Open Traffic Models platform (OTM) for running macroscopic traffic simulations in high-performance computing environments. Macroscopic simulations are appropriate for studying regional traffic scenarios when aggregate trends are of interest, rather than individual vehicle traces. They are also appropriate for studying the routing behavior of classes of vehicles, such as app-informed vehicles. The network partitioning was performed with METIS. Inter-process communication was done with MPI (message-passing interface). Results are provided for two networks: one realistic network which was obtained from Open Street Maps for Chattanooga, TN, and another larger synthetic grid network. The software recorded a speed-up ratio of 198 using 256 cores for Chattanooga, and 475 with 1,024 cores for the synthetic network.


I. INTRODUCTION
R ECENT years have seen significant technological changes in transportation with the advent of sharedmobility services such as Uber and Lyft, electric vehicles, and vehicle automation. There is a need for government agencies and industry to understand the impact of wide-spread adoption of these new technologies on the transportation system. This in turn requires regional scale modeling tools, which consume large computing and memory resources. Parallel computation and modern supercomputers provide the power and memory to handle such large-scale traffic simulations. They also enable running thousands of parallel simulations that can answer future what-if scenarios.
There are two types of approaches to parallel computation: shared memory and distributed memory. On a sharedmemory computer, parallel simulation takes advantage of the computer's many processors to execute tasks in parallel. In this case, the simulation speed-up is limited by the number of processors on one computer. On a multiprocessor distributed-memory computer system, parallel simulation can use processors on multiple computers while communicating over a message passing system. This paper describes such an approach for a fluid-based traffic simulation model. We begin by reviewing previous efforts, most of which have focused on vehicle-based (microscopic and mesoscopic) models.

A. Related Works
Since Greenshield presented the first traffic model in 1934 [18], three main model categories have emerged: microscopic models, macroscopic models, and mesoscopic models. While microscopic models represent the behavior and interaction of individual vehicles, macroscopic models describe traffic as a continuum. Mesoscopic models are an intermediate class in which macroscopic parameters such as link capacity are applied to individual vehicles. Traffic simulation software tools usually implement a single microscopic, macroscopic or mesoscopic model. Open Traffic Models is one of a few hybrid simulation tools, which allow the combination of two or more models.
Most of the traffic simulators with parallel computation capabilities are microscopic simulators. An example of this is Paramics [1], which was implemented on a the T3D parallel computer with Message Passing Interface (MPI) for interprocessor communication. FastTrans [2] and TRANSIMS [19] are also microscopic simulators and use parallel computation on distributed-memory computer systems by dividing the road network into multiple subnetworks. FastTrans uses MPI to share boundary information among processes, while TRANSIMS can support both MPI and Parallel Virtual Machine (PVM) communication. AIMSUN [4], SEMSim [5], and IBM's Mega MEgaffic simulator [6] implement parallel computation with a multi-threading approach, which enables them to update multiple agents simultaneously. The popular microscopic simulator SUMO exploits multi-threading parallel computation for vehicle routing, but the rest of simulation is single-core [7]. The BEAM simulator [11] extends MATSIM [20], which is a microscopic agent-based traffic simulator. BEAM incorporates parallel computation via the Akka [21] library, which implements the Actor Model paradigm [22].
In the realm of mesoscopic traffic simulation, Nökel and Schmidt present a parallel implementation for Dynemo, that uses a master-slave parallelization. Mobiliti [9], a mesoscopic simulator, models links as agents and vehicles as events. It uses GASNet [23] to enable parallel computation on high performance computing resources. POLARIS [10]
On the other hand, parallel computation has not been applied extensively to macroscopic traffic simulation. [15] presents a parallel continuum traffic model on an nCubes2 hypercube distributed-memory parallel computer, where a freeway is partitioned into equal segments and assigned to different processors. Similarly, [16] describes a parallel laxmomentum traffic model that divided the freeway into equal segments assigned to different processors of a Cray T3E distributed-memory computer. Although [15] and [16] use parallel computation for macroscopic traffic simulation on distributed-memory computers, they are focused on freeways only. In addition, the reported studies involve only about 20 miles of freeway, and were executed on older computer systems.
The work presented here is based on the Open Traffic Models simulator. OTM is a full-featured traffic simulator that has in the past been used in single-process environments. OTM [24] is a hybrid simulator, in the sense that it incorporates multiple (macroscopic, mesoscopic, and microscopic) models which can be combined arbitrarily on a single network. It also supports various road geometries (turn pockets, managed lanes on freeways, etc.), multiple vehicle types, and a variety of traffic control systems (traffic signals, variable speed limits, on-board information systems, etc.). Here we focus on the parallelization of the macroscopic model only. This is both because there are many high quality distributed implementations of vehicle-based models, and because it avoid some of the complexities of asynchronous updates that occur in vehicle-based model. OTM-MPI represents, to the best of our knowledge, the first open-source, distributed-memory, macroscopic simulation model developed for modern high performance parallel machines and large networks [17].

II. METHODOLOGY
In this section we begin by describing the methodology for dividing the network. We then describe the inter-process communication. Finally we give a brief description of the macroscopic traffic model.

A. Network partitioning
The process of distributing the simulation among n cores is illustrated in Figure 1. The first step is to split the base network into n subnetworks. To obtain these, the set of nodes is divided into non-overlapping sets. Let N i , i ∈ [1 . . . n], denote the ith subset of nodes. The ith subnetwork contains all of the nodes in N i , as well as all of the links with either start or end node in N i . Links with start node in one subset and end node in another constitute the overlap between two subnetworks. An overlap link with start node in N i and end node in N j is called a relative source with respect to subnetwork j and a relative sink with respect to subnetwork i. The road connections that enter (exit) a relative source (sink) link are called relative source (sink) road connections (with respect to a given subnetwork). The implementation utilizes an off-line module that invokes METIS [25] to create the node subsets, and then constructs separate input files for each of the subnetworks. These files contain all of the information (and only that information) that is required to run the given subnetwork as a stand-alone simulation.

B. Process communication
The connections between the n subnetworks are encoded in a so-called metagraph. This is a graph in which each vertex represents the non-overlapping portions of a subnetwork, and the edges are the relative sources and sinks. Each subnetwork is executed by a separate process. The appropriate MPI communicator for this configuration is the graph communicator, which encodes the relations of the metagraph. An all-to-all transmission with a graph communicator exchanges messages amongst neighboring vertices in the metagraph.
The message passed between two neighboring subnetworks consists of an array of numbers representing the vehicles that travel along all of the relative source and sink road connections that join the two subnetworks. During the initialization phase, the processes construct and exchange decoder maps with each of their neighbors. These map each position in the array to a lane group and state index. This same map is used throughout the entire simulation. The approach is conservative in the sense that the size of the message is fixed, and may contain many zeros at any given time. As is shown in Section III, the communication time is a small fraction of the total run time, and hence the potential advantage of using dynamic message sizes is small.
The number of vehicles that travel at each time step over relative road connections (i.e. the flow between subnetworks) is computed by the node model in step 2. The MPI communication step is then inserted between steps 2 and 3. This completes the input and output flow computation for relative sources and sinks. After this, step 3) is executed to compute the downstream link for probabilistically routed vehicles, and then the internal state of all of the lane groups is updated. These steps are identical to their counterparts in the sequential model. Hence the result is not affected by the distribution of the calculation over multiple processes.

C. Traffic modeling
The full mathematical description of OTM can be found in [24]. The description provided here omits certain details, but is sufficient to understand the inter-process communication that enables distributed simulation. The model is in the class of cell transmission models first introduced by Daganzo in [26]. Since then there have been many extensions and improvements to the CTM, incorporating multiple lanes, non-triangular fundamental diagrams, etc. The CTM model that is implemented in OTM is adapted to an underlying representation of the road network that can be applied to the different models in the hybrid simulation environment. As with most traffic simulators, there is a high-level graph (links and nodes) which encodes the connectivity of the road network. Each link (i.e. a segment of road between two junctions) has an internal geometry consisting of multiple lanes, turn pockets, and possibly a managed lane with access gates (in the case of a freeway link). There can also be sensors and control devices within the link.
The relations between lanes that enter and exit a junction are defined by road connections. A road connection indicates which lanes in an upstream link can turn into which other lanes in a downstream link. For example, a road connection may indicate that vehicles must be in the outer two lanes of the freeway in order to reach the off-ramp. The road connections that leave a link are used by the program to aggregate lanes into lane groups. All lanes in a lane group access the same set of downstream road connections, and are therefore presumed to travel at similar speeds. In our previous example, the two outer lanes of the freeway constitute a lane group, and the remaining inner lanes are another.
Vehicles in OTM (whether microscopic, mesoscopic, or macroscopic) are classified according to their type. The vehicle type encodes two sets of parameters. First, it determines the vehicle's routing behavior which may be deterministic or probabilistic. Deterministically routed vehicles follow a predetermined sequence of links from their origin to their destination. Probabilistically routed vehicles direct themselves at every junction according to time-varying turning probabilities. The software supports arbitrary numbers of deterministic and probabilistic vehicle types. The second parameter of the vehicle type is a vehicle class. The vehicle class encodes any set of parameters that the modeler wishes to prescribe. For example, it can be used to distinguish passenger vehicles from trucks (vehicle size), high-occupancy vehicles from single-occupancy vehicles (lane-usage rules), routing app equipped versus not (access to network information), etc.
In OTM's macroscopic model, each lane group is divided into a sequence of cells. The state of each cell is the number of vehicles for each vehicle type and each downstream link. The downstream link of a vehicle is the next link in its route. This is determined in step 3) below for probabilistically routed vehicle types. Vehicles change lanes (ie move laterally between cells in adjacent lane groups) in order to reach a lane group that connects (via road connections) to its downstream link.
The state update for each cell is executed in multiple steps, listed below. The respective formulas can be found in [24]. 2) Inter-link flow calculation. The flows between links travel along road connections. The node model resolves these flows from upstream demands and downstream supplies. The details of the node model can be found in [24]. Here it will suffice to state that the output of the node model is a set of vehicle flux packets that are delivered along road connections to downstream links. The node model ensures that the downstream links have sufficient available space to accommodate the packets.
3) Probabilistic routing. When a node has several outgoing links, probabilistically routed vehicles select which one to take according to given turning probabilities. These probabilities are sampled when the vehicle enters the approaching link. This is in contrast with many macroscopic models where turning probabilities are sampled at the node, i.e. when the vehicle exits the approaching link. This is done in order to improve the representation of lane changing that occurs upstream of the split.

4) State update.
Once all packets have been received and tagged with their next downstream link, then the state of the cells can be updated using the conservation of vehicles. This calculation follows the standard cell transmission model formulas for internal cells.

III. EXPERIMENTS
We ran OTM-MPI on Cori, a Cray XC40 supercomputer at NERSC [27]. Each of Cray's processing nodes has two sockets, each with a 16-core Intel© Xeon™ Processor E5-2698 v3 ("Haswell") at 2.3 GHz and 128 GB of RAM memory. This is a very modern parallel computer, taking advantage of recent advances in parallel computing technology. We report here two experiments; one with a model of Chattanooga, TN, and another with a large synthetic network.

A. Experiments with the Chattanooga network
OTM includes a module for extracting networks from Open Street Maps [28], [29]. This module was used to construct a model of Chattanooga, Tennessee (see Figure 2). The goal of this experiment is to demonstrate the improvements in computation time that can be achieved for a realistic traffic network topology. Traffic performance metrics were not collected for this reason, nor was any effort made to reproduce the demand or routing characteristics of Chattanooga. The network has 32,260 nodes, 38,440 links, and contains 248 source links. Each of these was supplied with a large congestion-inducing demand of 2,000 vph per lane. We conducted 9 runs. In each, the number of parallel processes used was doubled, starting from a single process and up to 256 processes. Each trial was initialized with an empty network and was advanced 10,000 time steps. Figure 3 shows the results.
In all of the subplots of the figure, the x-axis is the number of processes involved in the simulation (n), represented in base-2 logarithmic scal. The first plot shows that, as expected, the average size of the subnetworks generated by METIS is inversely proportional to the number of processes. The second subplot shows the setup time of the program. This includes the network load time and the time taken to create the MPI communicator and distribute the message decoders. Notice that this load time reaches a minimum and increases slightly for 256 processes. This is because, although the subnetworks are smaller, the complexity of the metagraph and decoders increases and becomes significant for n = 256.
The third plot shows the average size of the messages being passed through the MPI communicator. For n = 2, each process sends an average of 56 floats to each of its neighbors in the metagraph. As n increases, the size of the messages gets smaller, while the number of messages and the total amount of information increases. The fourth subplot shows that the total time spent in communication generally decreases with larger n. The graph communicator can more quickly transmit many small messages than a few large messages. This trend is true on average, however the plot also shows that the maximum and minimum communication times are not monotonic.
Finally the fifth subplot shows the total run time, including load, communication, and computation time, on a log-log scale. The nearly linear trend indicates an inverse proportional relation between run time and the number of processes. For this network, the execution on a single process took 6,026 seconds (1 hour and 40 minutes), and was reduced to 30.6 seconds when run with 256 cores. This corresponds to speed up ratio of 198.

B. Experiment with a synthetic network
We conducted experiments on a large, grid-like, synthetic network, with a tiled topology as shown in Figure 4. The goal of this experiment was to test the program on a second larger network, this one with 81,250 nodes and 268,000 links, which is about seven times the size of the Chattanooga network (in terms of links).
Source flows were placed on 15,620 source links, again in sufficient amount to create congestion. The simulation was run with n ranging from 1 to 1024 processes (11 runs), and  run for 1,000 simulated seconds each. Figure 5 shows load time, communication time, and computation (run) time in each case. The lower plot focuses on the simulations that are not distinguishable in the upper plot (n ≥ 6). The trend is similar as in the first example, with inverse proportionality between the run time and the number of processes.  Figure 6 demonstrate the scaling of OTM-MPI compared to the ideal scaling simulation rate. For each simulation experiment, the simulation rate 1/(simulation time), which corresponds to the number of simulations that can be completed within 1 seconds (simulations/s). The ideal rate is calculated as (numberof processes) * (serialsimulationrate), and assumes that simulation rate increases proportionally with the number of processes. In practice, parallel simulation does not attain the ideal scaling rate as the (communicationtime)/(simulationtime) ratio grows with the number of processes. In fact, we observed that for the experiment with 1024 processes, each process spend half of its computation time in communicating with other processes. However, we still observed that for the simulation time, the parallel OTM had a speed up of 475 times with 1024 processes compared to the serial OTM. This corresponded to a time reduction from 8,245 seconds to 17 seconds.

IV. CONCLUSION
The main contribution of this work is an open-source implementation of macroscopic traffic simulation for high- performance computing (HPC). As was detailed in the introduction, there are currently a host of platforms for running vehicle-based simulations in HPC. OTM-MPI offers an alternative for scenarios in which macroscopic modeling may be preferred over vehicle-based simulation. This may be the case if the following two conditions are given. First, that the available data is better suited for estimating macroscopic quantities (capacities) than microscopic ones (car-following rules). For example, if the data consists in loop detector measurements, and detailed vehicle accelerations are absent. Second, that the metrics of interest can be obtained from the macroscopic model. For instance, if we are interested in travel times and delays, and not in vehicle accelerations. Studies of routing behaviors in particular, either 'natural' or induced by routing apps, can equally be carried out in macroscopic models. OTM-MPI can be obtained from [17].