# Traffic simulation

Traffic simulation or the simulation of transportation systems is the mathematical modeling of transportation systems (e.g., freeway junctions, arterial routes, roundabouts, downtown grid systems, etc.) through the application of computer software to better help plan, design, and operate transportation systems. Simulation of transportation systems started in the 1950s, and is an important area of discipline in traffic engineering and transportation planning today. Various national and local transportation agencies, academic institutions and consulting firms use simulation to aid in their management of transportation networks.
Simulation in transportation is important because it can study models too complicated for analytical or numerical treatment, can be used for experimental studies, can study detailed relations that might be lost in analytical or numerical treatment and can produce attractive visual demonstrations of present and future scenarios.
To understand simulation, it is important to understand the concept of system state, which is a set of variables that contains enough information to describe the evolution of the system over time. System state can be either discrete or continuous. Traffic simulation models are classified according to discrete and continuous time, state, and space.

## Theory
### Traffic models

Simulation methods in transportation can employ a selection of theories, including probability and statistics, differential equations and numerical methods.
* Monte Carlo method
One of the earliest discrete event simulation models is the Monte Carlo simulation, where a series of random numbers are used to synthesise traffic conditions.
* Cellular automata model
This was followed by the cellular automata model that generates randomness from deterministic rules.
* Discrete event and continuous-time simulation
More recent methods use either discrete event simulation or continuous-time simulation. Discrete event simulation models are both stochastic (with random components) and dynamic (time is a variable). Single server queues for instance can be modeled very well using discrete event simulation, as servers are usually at a single location and so are discrete (e.g. traffic lights). Continuous time simulation, on the other hand, can solve the shortcoming of discrete event simulation where the model is required to have input, state and output trajectories within a time interval. The method requires the use of differential equations, specifically numerical integration methods. These equations can range from simple methods, such as Euler's method, to higher order Taylor's series methods, such as Heun's method and Runge-Kutta.
* Car-following models
A class of microscopic continuous-time models, known as car-following models, are also based on differential equations. Significant models include the Pipes, intelligent driver model and Gipps' model. They model the behavior of each vehicle ("microscopic") to see its implications on the whole traffic system ("macroscopic"). Employing a numerical method with a car-following model (such as Gipps' with Heun's) can generate important information for traffic conditions, such as system delays and identification of bottlenecks.

### Systems planning

The methods noted above are generally used to model the behavior of an existing system, and are often focused around specific areas of interest under a range of conditions (such as a change in layout, lane closures, and different levels of traffic flow). Transport planning and forecasting can be used to develop a wider understanding of traffic demands over a broad geographic area, and predicting future traffic levels at different links (sections) in the network, incorporating different growth scenarios, with feedback loops to incorporate the effect of congestion on the distribution of trips.

## Applications in transportation engineering

Traffic simulation models are useful from a microscopic, macroscopic and sometimes mesoscopic perspective. Simulation can be applied to both transportation planning and to transportation design and operations. In transportation planning the simulation models evaluate the impacts of regional urban development patterns on the performance of the transportation infrastructure. Regional planning organizations use these models to evaluate what-if scenarios in the region, such as air quality to help develop land use policies that lead to more sustainable travel. On the other hand, modeling of transportation system operations and design focus on a smaller scale, such as a highway corridor and pinch-points. Lane types, signal timing and other traffic related questions are investigated to improve local system effectiveness and efficiency. While certain simulation models are specialized to model either operations or system planning, certain models have the capability to model both to some degree.
Whether it is for planning or for systems operations, simulations can be used for a variety of transportation modes.

### Roadway and ground transportation

Ground transportation for both passenger and goods movement is perhaps the area where simulation is most widely used. Simulation can be carried out at a corridor level, or at a more complex roadway grid network level to analyze planning, design and operations such as delay, pollution, and congestion. Ground transportation models can include all modes of roadway travel, including vehicles, trucks, buses, bicycles and pedestrians. In traditional road traffic models, aggregate representation of traffic is typically used where all vehicles of a particular group obey the same rules of behavior; in micro-simulation, driver behavior and network performance are included so that complete traffic problems (e.g. Intelligent transportation system, shockwaves) can be examined.

### Rail transportation

Rail is an important mode of travel for both freight and passengers. Modeling railways for freight movement is important to determine the operational efficiency and rationalize planning decisions. Freight simulation can include aspects such as dedicated truck lanes, commodity flow, corridor and system capacity, traffic assignment/network flow, and freight plans that involve travel demand forecasting.

### Maritime and air transportation

Maritime and air transportation presents two areas that are important for the economy. Maritime simulation primarily includes container terminal modeling, that deals with the logistics of container handling to improve system efficiency. Air transportation simulation primarily involves modeling of the airport terminal operations (baggage handling, security checkpoint), and runway operations.

### Other

In addition to simulating individual modes, it is often more important to simulate a multi-modal network, since in reality modes are integrated and represent more complexities that each individual mode can overlook. Inter-modal network simulation can also better understand the impact of a certain network from a comprehensive perspective to more accurately represent its impact in order to realize important policy implications. An example of an inter-modal simulator is Commuter developed by Azalient which introduces both dynamic route and mode choice by agents during simulation - this type of modeling is referred to as nanosimulation as it considers demand and travel at a finer level of detail than traditional microsimulation.
Simulation in transportation can also be integrated with urban environment simulation, where a large urban area is simulated which includes roadway networks, to better understand land use and other planning implications of the traffic network on the urban environment.

## Software programs

Simulation software is getting better in a variety of different ways. With new advancements in mathematics, engineering and computing, simulation software programs are increasingly becoming faster, more powerful, more detail oriented and more realistic.
Transportation models generally can be classified into microscopic, mesoscopic, macroscopic, and metascopic models. Microscopic models study individual elements of transportation systems, such as individual vehicle dynamics and individual traveler behavior. Mesoscopic models analyze transportation elements in small groups, within which elements are considered homogeneous. A typical example is vehicle platoon dynamics and household-level travel behavior. Macroscopic models deal with aggregated characteristics of transportation elements, such as aggregated traffic flow dynamics and zonal-level travel demand analysis.

## Microsimulation

Microsimulation models track individual vehicle movements on a second or subsecond basis. Microsimulation relies on random numbers to generate vehicles, select routing decisions, and determine behavior. Because of this variation, it is necessary to run the model several times with different random number seeds to obtain the desired accuracy. There will be a 'warm-up' period before the system reaches a steady state, and this period should be excluded from the results.
Microsimulation models usually produce two types of results: animated displays, and numerical output in text files. It is important to understand how the software has accumulated and summarized the numerical results to prevent incorrect interpretation. Animation can allow the analyst to quickly assess the performance, however it is limited to qualitative comparisons. The main indication of a problem that can be seen in an animation is the forming of persistent queues.
'Measures of Effectiveness' (MOEs) may be calculated or defined in a manner which is unique to each simulation program. MOEs are the system performance statistics that categorize the degree to which a particular alternative meets the project objectives. The following MOEs are most common when analyzing simulation models:
* 'VMT' (vehicle miles traveled) is computed as a combination of the number of vehicles in the system and the distance they travel.
* 'VHT' (vehicle hours of travel) is computed as the product of the link volume and the link travel time, summed over all links.
* 'Mean system speed' is equal to VMT/VHT.
* 'Total system delay' is one of the most effective ways to evaluate different congestion relieving alternatives and it is usually the MOE that the travelling public notices. Delay can be calculated several ways. Some consider it to be only that delay which is above free flow conditions. Others include the baseline delay which occurs as a result of traffic control devices. Some even include acceleration and deceleration delay, while others include only stopped delay.
Other commonly reported metrics from traffic simulation tools include: .
* Link road section speeds, flow, density, travel time, delay, stop time
* Intersection turning volumes, delay,
* Journey times
* Loop detector records for speed, occupancy, headway, gap
* Vehicle trajectories and speed vs. distance plots

### Comparing simulation results with the US Highway Capacity Manual

The output of a microsimulation model is different from that of the US Federal Highway Capacity Manual (HCM). For example, most HCM procedures assume that the operation of one intersection will not be affected by the conditions of an adjacent roadway (with the exception of HCS 2000 Freeways). 'Rubbernecking' and long queues from one location interfering with another location would contradict this assumption.
The HCM 2010 provides revised guidance on what types of output from traffic simulation software are most suitable for analysis in, and comparison to, the HCM for example vehicle trajectories and raw loop detector output.

### Comparison with HCM delay and level of service

In the HCM delay is used to estimate the level of service (LOS) for intersections. However, there are distinct differences between the way microsimulation programs and the HCM define delay. The HCM bases its delay on adjusted flow using mean control delay for the highest 15 minute period within the hour. The distinction between total delay and control delay is important. Control delay is when a signal control causes a group to slow down or stop. It's important to look at the software's documentation to understand how it calculates delay. In order to use microsimulation outputs to find LOS, the delay must be accumulated over 15 minute intervals and averaged over several runs with different random seeds. Because the HCM uses adjusted flow, another way to compare delay is divide the simulation input's 15 minute peak volume by the peak hour factor (PHF) to increase the simulation's volume.

### Comparison with HCM Queues

HCM 2000 defines a queue as a line of vehicles, bicycles, or persons waiting to be served by the system in which the flow rate from the front of the queue determines the average speed within the queue. Slowly moving vehicles or people joining the rear of the queue are usually considered part of the queue. These definitions are somewhat relative and can be ambiguous. In most microsimulation programs the queue length cannot exceed the storage capacity for that turn-bay or lane. Overflows into the adjacent link or off the network are usually not accounted for, even though this may affect the results. (If this is the case, a work-around can be to temporarily ignore those effects and extend the network or storage area for the link to include the maximum queue length.)