Main Content

Model Traffic Intersections as a Queuing Network

This example shows how to create a SimEvents® model to represent a vehicle traffic network and to investigate mean waiting time of vehicles when the network is in steady-state.

Suppose a vehicle traffic network consists of two vehicle entry and two vehicle exit points, represented by brown and green nodes in the next figure. Each blue node in the network represents a route intersection with a traffic light, and the arrows represent the route connections at each intersection. The values next to the arrows represent the percentage of vehicles taking the route in that intersection.

The rate of vehicle entries into the network are represented by the Poisson processes with rates0.5for Entry1and0.15for Entry2. Service rates represent the time vehicles spend at each intersection, which are drawn from exponential distribution with mean1. The arrow values are the probabilities of choosing a route for vehicles in the intersection.

Model Traffic Network

To represent a vehicle traffic network, this model uses Entity Generator, Entity Server, Entity Queue, Entity Input Switch, Entity Output Switch, and Entity Terminator blocks.

model ='QueueServerTransportationNetwork'; open_system(model);

Model Vehicle Arrivals

The two Entity Generator blocks represent the network entry points. Their entity intergeneration time is set to create a Poisson arrival process.

This is the code in theIntergeneration time actionfield of the Entry1block.

% Random number generationcoder.extrinsic('rand'); ValEntry1 = 1; ValEntry1 = rand();% Pattern: Exponential distributionmu = 0.5; dt = -1/mu * log(1 - ValEntry1);

In the code,muis the Poisson arrival rate. Thecoder.extrinsic('rand')is used because there is no unique seed assigned for the randomization. For more information about random number generation in event actions, seeEvent Action Languages and Random Number Generation. To learn more about extrinsic functions, seeWorking with mxArrays.

Model Vehicle Route Selection

Entities have aRouteattribute that takes value1or2. The value of the attribute determines the output port from which the entities depart an Entity Output Switch block.

This code in theEntry actionof the Entity Server1represents the random route selections of vehicles at the intersection represented by Node1.

Coin1 = 1; coder.extrinsic('rand'); Coin1 = rand;ifCoin1 <= 0.2 entity.Route = 1;elseentity.Route = 2;end

This is an example of randomRouteattribute assignments when entities enter the Entity Server 1 block. The value ofRouteis assigned based on the value of the random variablerandthat takes values between0and1.Routebecomes1ifrandis less than or equal to0.2, or2ifrandis greater than0.2.

Model Route Intersections

Each blue node represents a route intersection and includes an infinite capacity queue, and a server with service time drawn from an exponential distribution with mean1.

Entity Server1contains this code.

% Pattern: Exponential distributioncoder.extrinsic('rand'); Val1 = 1; Val1 = rand(); mu = 1; dt = -mu * log(1 - Val1);

Calculate Mean Waiting Time for Vehicles in the Network

The network is constructed as an open Jackson network that satisfies these conditions.

  • All arriving vehicles can exit the network.

  • Vehicle arrivals are represented by Poisson process.

  • Vehicles depart an intersection as first-in first-out. The wait time in an intersection is exponentially distributed with mean1.

  • A vehicle departing the intersection either takes an available route or leaves the network.

  • The utilization of each traffic intersection queue is less than1.

In the steady state, every queue in an open Jackson network behaves independently as an M/M/1 queue. The behavior of the network is the product of individual queues in equilibrium distributions. For more information about M/M/1 queues, seeM/M/1 Queuing System.

The vehicle arrival rate for each node$i$is calculated using this formula.

$\lambda_i = r_i + \sum_{j=1}^N \theta_{ji} \lambda_j,$

In the formula:

  • $r_i$is the rate of external arrivals for node$i$.

  • $j=1,\ldots,N$is the total number of incoming arrows to node$i$.

  • $\theta_{ji}$is the probability of choosing the node$i$from node$j$.

  • $\lambda_j$节点的总车辆到达率吗$j$.

For all of the nodes in the network, the equation takes this matrix form.

$\lambda = R(I-\theta)^{-1}$

Here,$\theta$is the routing matrix, and each element represents the probability of transition from node$j$to node$i$.

For the network investigated here, this is the routing matrix.

$\theta = \left[\begin{array}{cccc} 0 & 0.2 & 0.8 & 0\\ 0 & 0 & 0.7 & 0.3\\ 0 & 0 & 0 & 0.4\\ 0 & 0 & 0 & 0 \end{array}\right]$

$R$is the vector of external arrivals to each node.

$R = \left[\begin{array}{cccc} 0.5 & 0 & 0 & 0.15 \end{array}\right]$

Using these values, the mean arrival rate is calculated for each node.

$\lambda = \left[ \begin{array}{cccc} 0.5 & 0.1 & 0.47 & 0.368 \end{array}\right]$

Each node behaves as an independent M/M/1 queue, and the mean waiting time for each node$i$由这个公式计算。看到M/M/1 Queuing System.

$\rho_i=\frac{\lambda_i}{1-\lambda_i}$

Mean waiting time for each node is calculated by incorporating each element of$\lambda$.

$\rho = \left[\begin{array}{cccc} 1 & 0.11 & 0.88 & 0.58 \end{array}\right]$

View Simulation Results

Simulate the model and observe that the mean waiting time in each queue in the network matches the calculated theoretical results.

  • The waiting time for the queue in node1converges to1.

  • The waiting time for the queue in node2converges to0.11.

  • The waiting time for the queue in node3converges to0.88.

  • The waiting time for the queue in node4converges to0.58.

References

[1] Jackson, James R.Operations researchVol. 5, No. 4 (Aug., 1957), pp 518-521.