interface( warnlevel=0, rtablesize=20 ):
with( laylinalg ):
# Text Reference: Section 1.6
# Lab 2: Traffic Flow and Networks
#
# The purpose of this lab is to show how systems of linear equations may be used to model traffic flow, using network theory.
#
# Consider the problem of calculating the pattern of traffic flow for a community. The network in this case consists of a system of streets and nodes, or intersections, where the roads meet. Each street will have a certain rate of flow, measured in vehicles per some time interval. Given certain flow rates into the road system, the rates of flow on each street will be computed. There is one big assumption: at each intersection, the flow is ``conserved''; that is, a car that reaches an intersection must continue through the network. For example, if the flow rates into a given intersection are x[1]; and 30, and the flow rates out of the same intersection are x[2]; and 50, then x[1]+30 = x[2]+50;, or x[1]-x[2] = 20;. Thus each intersection produces a linear equation in the unknown rates. Solving the system of linear equations resulting from each intersection will give the flow rates over each branch.
# Problems to be solved and submitted:
# Problem 1.
# Consider the following network of roads found in Seattle, which are shown in Figure 1. The flow rates are given in vehicles per day, and are derived from an official study by the Seattle Transportation Traffic Management Division. All of the roads in the diagram are one-way in the direction indicated except for Third Avenue, which runs both northbound and southbound. Variables are assigned to the traffic flows as given in the diagram. For example, since Fifth Street is a one-way street, x[1]; represents the volume of traffic flowing along Fifth Street from Pike Street to Union Street. On Third Street the variables x[15];, x[16];, and x[17]; represent the net traffic flow southbound along Third Street, which is the volume of traffic southbound minus the volume northbound.
#
# Figure 1: Seattle street network
# (a)
# Considering the flows given, construct a system of linear equations which would model this situation.
# (b)
# Check your work in part (a) by comparing your augmented matrix to the matrix A which is defined by the following Maple command:
# A := Matrix(
# [ [ 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7669],
# [ 1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16680],
# [ 0, 1, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7593],
# [ 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9358],
# [ 0, 0, 0, 1, 0, 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, 0, 1,-1, 0, 8080],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,-1, 1, 5379],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,-1, 4993] ] ):
A;
# (c)
# Find the general flow pattern for this network of roads.
# (d)
# Do more cars travel northbound or southbound
# i. between Pike Street and Union Street?
# ii. between Union Street and University Street?
# iii. between University Street and Seneca Street?
# Hint:
# The net flow southbound between Pike Street and Union Street could be represented by x[1]-x[8]+x[15];.
# (e)
# Do more cars travel eastbound or westbound
# i. between Third Avenue and Fourth Avenue?
# ii. between Fourth Avenue and Fifth Avenue?
# Hint:
# Express the net flow as in part (d), then use your solution to the system in part (c) to calculate the quantities you need.
# Problem 2.
# The following network of roads existed in Washington DC prior to 1995. The flow rates are given in thousands of vehicles per day, and are derived from an official 1993 Disrict of Columbia survey.
#
# Figure 2: Washington D.C. road network (pre-1995)
# (a)
# Considering the flows given, find the traffic flow along each of the roads in the network.
# (b)
# In 1995, the Federal Government closed the block of Pennsylvania Avenue in front of the White House to vehicular traffic. How did this closure affect the rates of flow on the other roads in the network?
# Problem 3.
# Another problem is to calculate the flow of water through a community's network of water mains. This network of underground pipes has intersections where the pipes meet, as well as where individual houses and businesses connect into the system. Each section of water main will have a certain rate of flow, which is usually measured in hundreds of cubic feet (CCF) per some time interval. Given certain flow rates into the network, the rates of flow on each section of main can be computed as before. Once again conservation of flow is assumed, so each intersection of pipes produces a linear equation in the unknown rates. Consider the following block in Charlotte, North Carolina. The houses on this block use between 0.75 and 3.3125 CCF per day. The flow rates given on the map below were provided by the Charlotte-Mecklenberg Utilities Department and the Charlotte-Mecklenberg Fire Department.
#
# Figure 3: Charlotte-Mecklenberg Utilities Department water flow network
# (a)
# Considering the flows given, find the flow in each section of pipe in the network.
# (b)
# Suppose that a water main breaks at the spot marked with the red X. How does this event affect the rates of flow in the other pipes in the network?