Source code: TrafficSim.tar.gz This code will require the following libraries: MASON, ECJ, JFreeChart, iText, COLT, and SSJ.
We have developed a lightweight urban traffic simulation in MASON to examine and find ways to improve traffic flow from a multiagent perspective. Of particular interest to us is how the system can adapt to "smooth out" sudden unexpected floods of traffic (after a sporting event ends, for example), in addition to handling regular "rush-hour" style floods.
The simulation uses a network field with intersections as nodes and roads as graph edges. Cars and traffic lights are scheduled using MASON's real-valued time schedule. Cars beginning travel along a road are scheduled to appear at the intersection at the end of the road at some time in the future, depending on road length and car speed. When a car reaches an intersection, it is placed in another queue to wait at the intersection's stoplight. While a light is green, a limited number of cars are allowed through the intersection.
Here's an screenshot of a 16-intesection instantiation of a scenario we call Grid-City.
Gray squares are intersections, and lines are two-way roads. Numbers indicate how many cars are traveling
on roads or waiting to perform various actions at intersections.