Traffic Simulator
Architecture Specification Document
Khalid AlHokail
LukeBay
James Grady
Michael Murphy
Version 1.0
20/3/2007

Table of Contents

1.Architecture Diagram

2.Component’s Description

2.1.Traffic Simulator

2.1.1.Data Display Plots

2.1.2.Data Storage

2.1.3.Assignment

2.1.4.Constraint Evaluator

2.1.5.User Interface

2.2.Map Model

2.2.1.Load_Graph

2.2.2.Load_Intersection_Rules

2.2.3.Load_Road_Properties

2.2.4.Segment_Divider

2.2.5.Draw_2D_Map

2.2.6.Start_End_Construction

2.2.7.Refresh_Map

2.3.Driving Model

2.3.1.Max_Population_Array

2.3.2.Current_Population_Array

2.3.3.Migration_Scheduler

2.3.4.Migration_Traffic_Generator

2.3.5.Random_Traffic_Generator

2.4.Traffic Light Control

2.4.1.Light_Cycle_Timer

2.4.2.Traffic_Light_Cycler

2.5.Decision Model

2.5.1.Route_Generator_General

2.5.2.Route_Generator_Blockage_Rerouter

2.5.3.Traffic_Incident_Generator

2.5.4.Traffic_Incident_Update_Map_Model

2.5.5.Traffic_Incident_Update_2D_Map

2.5.6.Traffic_Incident_Monitor_Collisions

2.5.7.Vehicle_Speed_Adapter

2.5.8.Map_Reader

3.Justification

3.1.Traffic Simulator

3.2.Map Model

3.3.Driving Model

3.4.Traffic Light Control

3.5.Decision Model

4.Component’s Responsibilities

4.1.Traffic Simulator

4.2.Map Model

4.3.Driving Model

4.4.Traffic Light Control

4.5.Decision Model

1.Architecture Diagram

2.Component’s Description

2.1.Traffic Simulator

2.1.1.Data Display Plots

2.1.1.1.Description

This component is responsible of displaying information to the user such as message boxes and current population and traffic distribution.

2.1.1.2.Components on which it depends
  • User Interface
2.1.1.3.Components that depend on it
  • Draw_2D_Map
2.1.1.4.SRS requirements that map to this component
  • 2.1.3 The time of day shall be displayed to the user.
  • 4.2.3 The status of the vehicle shall be displayed (start node, current node, next node, end node, edge position, speed).
  • 4.2.6 Traffic incidents shall be represented on the 2D map.

2.1.2.Data Storage

2.1.2.1.Description

The component is responsible of storing and loading the graph along with all the properties and any changes that occur on the graph. If any component needs to change something on the graph, such as adding a construction or creating an accident, it should go through this component.

2.1.2.2.Components on which it depends
  • None
2.1.2.3.Components that depend on it
  • Assignment
  • Load Map
  • Load_Intersection_Rules
  • Load_Road_Properties
  • Start_End_Construction
  • Max_Population_Array
2.1.2.4.SRS requirements that map to this component
  • 1.1.2.6 If the constraint evaluator determines the value is invalid, an exception will be generated by the assignment and no assignment will be performed.
  • 1.2.1.1 Legal turns are stored in each node.
  • 1.2.2.2 Each node will include all the allowed turns that can be made from that particular node.
  • 1.2.2.3 Allowed turns are stored as an enumeration (e.g. Left, Right, Straight means that this node only allows Left, Right or going straight, and doesn’t allow anything else).
  • 1.3.1.1 Lane capacity represents the number of lanes on an edge.
  • 1.4.1.1 Maximum allowed capacity is same as the lane capacity defined in 1.3.1.
  • 2.1.3.1 The format of the time shall be mm/dd/yyyy hh:mm:ss.
  • 2.2.1.1 A random number, > 10, of start and end nodes shall be generated, and each of these nodes shall be outside the boundary of the displayed map.
  • 2.2.1.2 Each of these nodes shall be associated with 2 double arrays.
  • 3.1.1 The rules of the location shall dictate the order in which the lights will cycle.
  • 3.2.1.1 The enumeration shall contain the colors Red, Yellow, and Green.
  • 3.2.2.3 When the cycle time has passed, the stored color of the light will change.
  • 3.2.2.6 The user must be able to change the cycle time of each light, individually.
  • 4.1.1.4 Each edge will have a value proportional to its length. Edges are instantiated as contiguous road segments, and each edge has its own speed limit.
  • 4.4.1.3 The waypoints shall be stored in an array such that element 0 is the start node, element n is the end node, and elements 1 to n-1 are the nodes which, when followed in order, connect the edges of the graph. These edges, which are a mathematical construct, correspond to the path the driver will follow. This path is represented by (a subset of the) connected road segments displayed on the screen.

2.1.3.Assignment

2.1.3.1.Description

If an assignment needs to be done by the user in the application, it should go through the Assignment component. This component will consult the Constraint Evaluator, first for the validity of the assignment.And based on Constraint Evaluator’s response, the Assignment will react either by assigning the value or rejecting the assignment.

2.1.3.2.Components on which it depends
  • Data Storage
  • Constraint Evaluator
2.1.3.3.Components that depend on it
  • None
2.1.3.4.SRS requirements that map to this component
  • 1.1.2.5 If the constraint evaluator determines that the value is valid, assignment is performed.

2.1.4.Constraint Evaluator

2.1.4.1.Description

This component is responsible of checking the validity of the data that was input by the user. If the input is valid then it returns True, otherwise returns False.

2.1.4.2.Components on which it depends
  • None
2.1.4.3.Components that depend on it
  • Assignment

2.1.4.4.SRS requirements that map to this component

  • 1.1.2.4 Assignment must consult the constraint evaluator.

2.1.5.User Interface

2.1.5.1.Description

This component is the part that is visible to the user where he can see the drawn map with all the information on it. It also enables the user to input some changes to the map, such as starting or ending a construction.

2.1.5.2.Components on which it depends

  • None

2.1.5.3.Components that depend on it

  • Start_End_Construction
  • Max_Population_Array
  • Migration_Scheduler

2.1.5.4.SRS requirements that map to this component

  • 1.1.2.1 A value of a property can be produced by a system entity or a user.

2.2.Map Model

2.2.1.Load_Graph

2.2.1.1.Description

This component will be used during the startup of the application where it will load the graph from a file into the memory. It will create all the nodes and edges and connect them.

2.2.1.2.Components on which it depends

  • Data Storage

2.2.1.3.Components that depend on it

  • Load_Intersection_Rules
  • Load_Road_Properties
  • Draw_2D_Map

2.2.1.4.SRS requirements that map to this component

  • 1.1 Graph

2.2.2.Load_Intersection_Rules

2.2.2.1.Description

After loading the graph, each node will be loaded with its rules. The rules are stored in a file and will be read by this component.

2.2.2.2.Components on which it depends

  • Load_Graph
  • Data Storage

2.2.2.3.Components that depend on it

  • None

2.2.2.4.SRS requirements that map to this component

  • 1.2 Rules for Intersections

2.2.3.Load_Road_Properties

2.2.3.1.Description

After loading the graph, each edge will be loaded with its properties such as number of lanes and road length. The properties are stored in a file and will be read by this component.

2.2.3.2.Components on which it depends

  • Load_Graph
  • Data Storage

2.2.3.3.Components that depend on it

  • Segment_Divider
  • Draw_2D_Map

2.2.3.4.SRS requirements that map to this component

  • 1.3 Number of Lanes.

2.2.4.Segment_Divider

2.2.4.1.Description

After loading the road properties, the Segment_Divider will take a road as an input and will divide it into car-length segments (where 1 segment represents 8 feet) depending on the road length.

2.2.4.2.Components on which it depends

  • Load_Road_Properties

2.2.4.3.Components that depend on it

  • None

2.2.4.4.SRS requirements that map to this component

  • 1.3.2.2 A system entity called segment divider is responsible for dividing the lane into segments.

2.2.5.Draw_2D_Map

2.2.5.1.Description

When the graph is loaded and each node and edge has all the properties set, this component will draw the graph for the user as a 2D map. The map will display each edge as a road and each node as an intersection visually representing its length, number of lanes, the status of each segment on the road, traffic lights, and cars.

2.2.5.2.Components on which it depends

  • Load_Graph
  • Load_Road_Properties
  • Data Display Plots

2.2.5.3.Components that depend on it

  • Refresh_Map

2.2.5.4.SRS requirements that map to this component

  • 1.1 Graph
  • 1.2.1.2 There shall be a directed edge for each direction a car may travel.
  • 1.3.2.1 Each segment will accommodate only one car at the same time.
  • 1.3.2.3 Each lane segment shall correspond to a real world segment that is 8 feet long by 5 feet wide.
  • 1.4.1.2 A drivable lane is a lane that has not been closed because of a collision.
  • 1.5 2D Map - Visualize Flow (over time)
  • 4.2.6 Traffic incidents shall be represented on the 2D map.

2.2.6.Start_End_Construction

2.2.6.1.Description

This component will take an edge as an input, the lane on that edge and a flag indicating whether to start or end a construction. If a construction needs to be started, the lane that was taken as an input is closed, and if a construction is finished, the lane that was taken as an input is opened.

2.2.6.2.Components on which it depends

  • Data Storage
  • User Interface

2.2.6.3.Components that depend on it

  • None

2.2.6.4.SRS requirements that map to this component

  • 1.4.2 The number of drivable lanes shall be updated in real time when a lane is closed or opened.

2.2.7.Refresh_Map

2.2.7.1.Description

Every specific amount of time, this component will call the Draw_2D_map to show the updates on the map.

2.2.7.2.Components on which it depends

  • Draw_2D_Map

2.2.7.3.Components that depend on it

  • None

2.2.7.4.SRS requirements that map to this component

  • None

2.3.Driving Model

2.3.1.Max_Population_Array

2.3.1.1.Description

This array determines the maximum number of residential and commercial drivers that can be assigned to a population node. These values shall be determined by the user.

2.3.1.2.Components on which it depends

  • User Interface
  • Data Storage

2.3.1.3.Components that depend on it

  • Current population array
  • Migration_Traffic_Generator
  • Random_Traffic_Generator

2.3.1.4.SRS Requirements that map to this component

  • 2.2.1 Static population distributions shall be provided.

2.3.2.Current_Population_Array

2.3.2.1.Description

This is an array that keeps track of the changing population of each population node. In addition to the residential and commercial values, there is a third value in the array.The third value keeps track of what percentage of the total population is currently present in the population node.

2.3.2.2.Components on which it depends

  • Static population array

2.3.2.3.Components that depend on it

  • Migration_Traffic_Generator
  • Random_Traffic_Generator

2.3.2.4.SRS Requirements that map to this component

  • 2.2.1.2.bArray2 = [rcur, wcur] where rcur is the current number of residents for the associated node, and wcur is the current number of workers for that node.

2.3.3.Migration_Scheduler

2.3.3.1.Description

This component is responsible for triggering a migration event and the appropriate migration type.The migration scheduler observes the clock and at times set by the user a to work or a to home migration will occur.

2.3.3.2.Components on which it depends

  • Time
  • User interface

2.3.3.3.Components that depend on it

  • Migration_Traffic_Generator

2.3.3.4.SRS Requirements that map to this component

  • 2.3.1.2For each day there will be a traffic migration from home nodes to work nodes in the morning, and, in reverse, from work nodes to home nodes in the evening.

2.3.4.Migration_Traffic_Generator

2.3.4.1.Description

The migration traffic generator is responsible for generating the traffic during rush hour periods.When a rush hour event is triggered this component randomly selects a population node and generates a vehicle with a destination node of a random population node.

2.3.4.2.Components on which it depends

  • Time
  • Set population array
  • Current population array

2.3.4.3.Components that depend on it

  • none

2.3.4.4.SRS Requirements that map to this component

  • 2.3.1.2.For each day there will be a traffic migration from home nodes to work nodes in the morning, and, in reverse, from work nodes to home nodes in the evening.

2.3.5.Random_Traffic_Generator

2.3.5.1.Description

The Random_Traffic_Generator is responsible for generating traffic between migration periods.At random intervals traffic is generated from one population node to another.

2.3.5.2.Components on which it depends

  • Current Population array

2.3.5.3.Components that depend on it

  • none

2.3.5.4.SRS Requirements that map to this component

  • 2.3.1.1Throughout the day, there will be random traffic migrations chosen from random start nodes to random end nodes.

2.4.Traffic Light Control

2.4.1.Light_Cycle_Timer

2.4.1.1.Description

The light cycle timer counts down from the current light color’s duration to zero.When the cycle timer reaches zero the light shall cycle to the next color.The cycle time shall be expressed in milliseconds and the timer shall count down in real time.

2.4.1.2.Components on which it depends

  • Time

2.4.1.3.Components that depend on it

  • Traffic Light Cycler

2.4.1.4.SRS requirements that map to this component

  • 3.2.2 Each traffic light shall have a separate timing.

2.4.2.Traffic_Light_Cycler

2.4.2.1.Description

The Traffic Light Cycler is a function that changes the light color enumeration after the light’s cycle time has reached zero.The enumeration will cycle to the next color dictated by the location of the traffic light.

2.4.2.2.Components on which it depends

  • Light Cycle Timer

2.4.2.3.Components that depend on it

  • Draw_2D_Map

2.4.2.4.SRS requirements that map to this component

  • 3.2.1 The lights shall be represented by enumerations and guide the drivers at intersections.

2.5.Decision Model

2.5.1.Route_Generator_General

2.5.1.1.Description

Given a graph with a start node and an end node, this component shall compute the shortest path connecting the nodes.

2.5.1.2.Components on which it depends

  • Map_Reader

2.5.1.3.Components that depend on it

  • Route_Generator_Blockage_Rerouter

2.5.1.4.SRS requirements that map to this component

  • 4.4.1.1Each driver shall follow a path in the directed graph, G, where a path is a sequence of vertices (nodes) <v0, v1, v2, . . . , vn> such that <vi, vi+1> for each i from 0 to n-1 is an edge in G.
  • 4.4.1.2The waypoints shall be generated using Dijkstra’s algorithm.
  • 4.4.1.3The waypoints shall be stored in an array such that element 0 is the start node, element n is the end node, and elements 1 to n -1 are the nodes which, when followed in order, connect the edges of the graph. These edges, which are a mathematical construct, correspond to the path the driver will follow. This path is represented by (a subset of the) connected road segments displayed on the screen.
  • 4.4.1.4At each node, the vehicle will read the allowable turns.

2.5.2.Route_Generator_Blockage_Rerouter

2.5.2.1.Description

When a vehicle finds that the next road segment in its path contains a stopped vehicle (which could result from a traffic incident or a red light), this component will search for a legal sub-route that connects with one of the nodes not yet visited in the vehicle’s original route.

2.5.2.2.Components on which it depends

  • Map_Reader
  • Route_Generator_General

2.5.2.3.Components that depend on it

  • Refresh_Map

2.5.2.4.SRS requirements that map to this component

  • 4.2.1.1When a vehicle is in motion and tries to move onto a blocked segment, it will stop and move to an adjacent open lane if one exists.
  • 4.4.1.5 In the case that the vehicle is unable to take a needed turn, it will travel to a node that is non-blocked and adjacent.
  • 4.4.1.6 Once the vehicle has selected the new node to travel to, it will generate a new route, using Dijkstra’s algorithm, with the node it is traveling to as a new start node and with the original end node.
  • 4.4.1.7 If a vehicle cannot make a needed turn and there are no other reachable nodes, the vehicle stops and waits for the turn to become available.

2.5.3.Traffic_Incident_Generator

2.5.3.1.Description

Using the values in SRS 4.2.1.4 for a vehicle located at a non-intersection and the values in SRS 4.2.4.2for a vehicle located at a non-intersection of the SRS, this component shall compute the probability that a vehicle shall cause a traffic incident.

2.5.3.2.Components on which it depends

  • Map_Reader

2.5.3.3.Components that depend on it

  • Traffic_Incident_Update_Map_Model
  • Traffic_Incident_Update_2D_Map

2.5.3.4.SRS requirements that map to this component

  • 4.2.4.1 The probability that a vehicle will cause an accident is a random number p,such that 0 ≤ p ≤ 0.001 for a roadway segment that is not an intersection.
  • 4.2.4.2 The probability that a vehicle will cause an accident is a random number p, such that 0 ≤ p ≤ 0.005 for an intersection. An accident at an intersection will only occur if the portion of the intersection that is perpendicular to the vehicle’s direction is spanned by stalled traffic.

2.5.4.Traffic_Incident_Update_Map_Model

2.5.4.1.Description

When a traffic incident occurs, this component updates the map model by setting the road segment on which the incident occurred to blocked status.

2.5.4.2.Components on which it depends

  • Traffic_Incident_Generator
  • Traffic_Incident_Monitor_Collisions

2.5.4.3.Components that depend on it

  • Refresh_Map

2.5.4.4.SRS requirements that map to this component

  • 4.2.5.1 Accidents located on a roadway will block the roadway segment that the accident occurred on. The blockage will not allow vehicles to travel on the blocked segment.
  • 4.2.5.2 Road segment closures shall be displayed as a black road segments.
  • 4.2.5.3 Accidents located on an intersection will restrict the allowable turns by blocking the roadway segment directly behind and the segment to the right of where the collision occurred in the intersection. So, if there is an accident in an intersection, then oncoming traffic cannot make a left turn at that intersection.
  • 4.2.5.4The blocked segments of an intersection shall be displayed as black segments.

2.5.5.Traffic_Incident_Update_2D_Map

2.5.5.1.Description

When a traffic incident occurs, this component directs the 2D map to show a flashing red Ø at incident’s road segment and to color road segments black that contain stopped vehicles.

2.5.5.2.Components on which it depends

  • Traffic_Incident_Generator
  • Traffic_Incident_Monitor_Collisions

2.5.5.3.Components that depend on it

  • Refresh_Map

2.5.5.4.SRS requirements that map to this component

  • 4.2.6.3 Each traffic incident shall be displayed as a flashing red Ø.

2.5.6.Traffic_Incident_Monitor_Collisions

2.5.6.1.Description

The component acts a listener to the platform’s Detect Object Collisions module and calls Traffic_Incident_Update_Map_Model and Traffic_Incident_Update_2D_Map when an event occurs.

2.5.6.2.Components on which it depends

  • Detect Object Collisions

2.5.6.3.Components that depend on it

  • Traffic_Incident_Update_Map_Model
  • Traffic_Incident_Update_2D_Map

2.5.6.4.SRS requirements that map to this component

  • 4.2.6.1 If two or more moving objects (cars) occupy the same space, then a collision occurs.
  • 4.2.6.2 If a car on segment i collides with a car on segment i + 1, both cars will occupy segment i + 1.

2.5.7.Vehicle_Speed_Adapter

2.5.7.1.Description

Using the equation in SRS 4.3.1.2, this component, when queried by a specific vehicle on a specific road segment, shall return the speed that vehicle should be travelling.

2.5.7.2.Components on which it depends

  • Data Storage

2.5.7.3.Components that depend on it

  • Refresh Map

2.5.7.4.SRS requirements that map to this component

  • 4.2.2.1Vehicles will not stop unless they are a part of a traffic incident or are blocked by traffic congestion.
  • 4.2.3.1 Vehicles shall never stop because of a lack of fuel.
  • 4.3.1.1 On segments that have traffic incidents or red lights; drivers will travel at 0% of the speed limit.
  • 4.3.1.2For a car at segment i, let

be 1 + the number of cars in the 20 contiguous segments that precede and succeed segment i. Then, the car at segment i will travel at p = of the speed limit. If segment i has fewer than 20 contiguous preceding or succeeding segments, then the value used by the summation for each non-existing segmentj is 0. The author generated the equation for p by entering estimations of empirical observations into an Excel spreadsheet, using Excel to produce an exponential trend line, and altering that trend line until R2, the coefficient of determination, = 1.

  • 4.3.1.3If a car travels from road segment i that has speed limit j to road segment i +1 that has speed limit k, where j ≠ k, then the car’s change in speed from one segment to the next shall be instantaneous.

2.5.8.Map_Reader

2.5.8.1.Description

The component returns a representation of the graph’s instantiation. This representation shall contain the graph’s nodes, edge lengths, edge connections, and data for each road segment.

2.5.8.2.Components on which it depends

  • Data Storage

2.5.8.3.Components that depend on it

  • Route_Generator_General
  • Route_Generator_Blockage_Rerouter
  • Traffic_Incident_Generator
  • Vehicle_Speed_Adapter

2.5.8.4.SRS requirements that map to this component

  • 4.1.1.1 The driver shall be able to read the properties of edges and nodes.
  • 4.1.1.2 The driver can only drive on roads, and roads are represented as edges.
  • 4.1.1.3 The driver can only travel from one node to another if these nodes are connected by an edge.
  • 4.1.1.4 Each edge will have a value proportional to its length. Edges are instantiated as contiguous road segments, and each edge has its own speed limit.

3.Justification

3.1.Traffic Simulator

The Data Display Plotscomponent is responsible for displaying the information along with the Draw_2D_Map component to the user, and since it is responsible for displaying only one thing, no further subdivision need to happen.