traffic control using graph theory

2 downloads 0 Views 382KB Size Report
Discrete Event Systems; traffic control; graph theory; Dynamic Programming, ... In this paper the design of a controller for a traffic crossing is presented by means ...
TRAFFIC CONTROL USING GRAPH THEORY Th. Riedel, U. Brunner Automatic Control Laboratory, Swiss Federal Institute of Technology ETH-Zentrum, 8092 Zürich, Switzerland E-mail [1994]: {riedel, brunner}@aut.ethz.ch E-mail [2018]: [email protected], [email protected] Keywords:

Discrete Event Systems; traffic control; graph theory; Dynamic Programming, algorithms.

ABSTRACT In this paper the design of a controller for a traffic crossing is presented by means of an example. The controller to be developed has to minimise the waiting time of the public transportation while maintaining the individual traffic flowing as good as possible. First, the model of our chosen traffic crossing is derived. Then, using a combination of 'Dynamic Programming' and 'Branch and Bound' the control algorithm is presented. A visualisation of the algorithm is given by means of graphs, complexity issues are investigated, and computational refinements proposed. The actual implementation of the control algorithm for the example shown is under way and carried out in co-operation with the Transportation Authority of the city of Zurich. The work presented here is part of a bigger project. The overall goal is to provide the traffic engineer with a tool for designing 'intelligent' controllers for traffic lights.

INTRODUCTION During rush hours many intersections get saturated (temporarily unstable). Saturated intersections can be optimally controlled using an off-line calculated steady state of traffic light switching sequences. But in the case of low traffic, it takes more than flow analysis to control the intersection. A frequently used control mechanism works like the barrel of a musical box, but the pins are switching the traffic lights of the intersection. In a first approach traffic dependency has been implemented by a fixed schedule of barrel-changes. But, because of its poor adaptability to fast changing situations this control has not worked satisfactory. Therefore, in a second approach a dynamic barrel has been introduced whose pins can be shifted within a given range. In addition, the dynamic barrel can be slowed down or speeded up what makes up a quite flexible control-mechanism. However, the problem what indications should be used to shift the pins and to change the speed of the barrel is left up to the actual design. In this paper an alternative approach is proposed. Traffic Control Using Graph Theory

1

As for usual control systems a controlled traffic system consists of the plant (here representing the intersection), the observer which reconstructs/estimates its state, and the controller which makes the decisions. This control structure is sketched in Fig. 1. All road users (we call them customers below) are considered as disturbances entering and driving the system. As the control goal is the flushed system (no customers in the system), we omit the reference-input in Fig. 1. Arrivals and departures of customers are called input events, and accordingly switching commands of the traffic lights are called output events. By the way, it is noted that only in absence of measuring noise and detector failures the sensor readings report accurately the input events.

Fig. 1.

Block-diagram of the controlled system, consisting of plant, observer, and controller.

In order to formulate a control problem, an objective has to be defined. Two common objectives are the total waiting time and the throughput: -

In the former case the accumulated waiting times of all customers flowing through the system is minimised. We choose this objective for the trams (or buses) to achieve that they operate on schedule.

-

In the other case the throughput of the system (and so the capacity) is maximised. We choose this objective to maintain the individual traffic flowing.

In general, the two objectives lead to different control rules (Riedel, 1991; Riedel and Brunner, 1992). Actually, one is concerned with both issues in real traffic systems, as the public-transportation is mostly not separated from the individual traffic. Although using different lanes they interfere at crossings. In the city of Zurich, the public transportation is given an almost absolute priority over the individual traffic. Therefore, the total waiting time of the public-transportation is minimised on the top level of the hierarchical decision making, while on a second level, given the constraints, the throughput is maximised. The paper is organised as follows: In the next two sections the example and the modelling technique are introduced. Then the control algorithm is presented and discussed. Finally it is applied to the example.

Traffic Control Using Graph Theory

2

EXAMPLE

Fig. 2.

Phases at Heimplatz in Zürich.

We will demonstrate the algorithm by means of an example. Figure 2 shows "Heimplatz", a famous square and quasi a benchmark crossing in Zürich. Trams, pedestrians, and individual traffic use the two crossings A and B with the following phases: A1 - A5 and B1 - B6 (cars), A6 - A10 and B7 - B13 (pedestrians), A11 - A12 and B14 - B20, B23 (trams). To keep the paper readable we will only discuss the tram phases which have to be optimised in the top hierarchical layer. The resulting problem is depicted in Fig. 3: two closely coupled crossings. 5 different tram routings (also called lines) pass the crossing: number 3, 5, 8 and 9, and number E, a rarely used route of trams not operating on schedule. There are stops for all lines, except for E, namely before phases B20 and after B17 for line 3, and before A12 and after A11 for all other lines. Detectors are placed in such a way that trams and their corresponding routings are detected and reported in good time (about 1 minute before arriving at the crossing).

Fig. 3. Traffic Control Using Graph Theory

Tram phases at Heimplatz. 3

MODELLING First, let us consider phases B14 and B20 where two traffic flows cross and exclude mutually. For each traffic light we distinguish the usual three phases, resp. states: Red (Stop!), Green (Go!), and Intermediate (amber phase). Unlike the phases R and G, the duration of the phase I is fixed. We introduce the notion of time (Riedel, 1991) and we distinguish between states and sets of states (a sequence of consecutive states). Thus the following four elements of a timed state diagram are defined: -

A Bar represents a state at a discrete point of time t = t1.

-

A Circle represents a set of states at consecutive points of time t1 < t < t2, where t2 is free.

-

An Arc represents an instantaneous transition from one state or set of states to another at a given time t = t1.

-

A Double arc represents a time consuming transition from one state or set of states to another with t1 < t < t1 + t, for a given t.

By introducing the state I’ and the time consuming transition I’’ the timed state diagram is obtained, see Fig. 4. (R has degenerated to a bar, as an all-red-state makes no sense.) In a second step, the timed state diagram is further simplified by neglecting the uncontrollable states.

Fig. 4.

Timed state diagrams.

We now consider the approach roads at time t = 0. The situation is represented by the diagram shown in Fig. 5. (For both directions, the position of the traffic light is placed at the left side of the diagram.)

Fig. 5.

Diagram of customers and their locations at time t = 0.

On the horizontal axis denoted by s (s represents the distance of a customer from the traffic light), the arrivalpattern of customers at t = 0 is shown. For simplicity we assume here that the customers can instantaneously stop and re-accelerate. Suppose that the traffic light of access road B14 has been red for a time tr and the arrivTraffic Control Using Graph Theory

4

ing customers have stopped. The corresponding waiting time diagram is shown in Fig. 6. As time is going on, customers are being scrolled left with constant speed according to a default speed. When a customer cannot be scrolled farther along the horizontal axis because of red light or a stopped customer in front of him, he gets "scrolled" along the vertical axis. Thus the accumulated waiting time of a customer is displayed on his vertical axis. You can think of the customer's waiting time as an additional road-mile he has to cover.

Fig. 6.

Delayed traffic of approach B14 at t = tr.

The height of the bars on each customer is equal to the customer’s waiting time. The intersection spans a two-dimensional grid (see the upper part of Fig. 7). Below the grid the two diagrams are re-drawn, and the dashed lines represent the projection of the customers onto the axes of the state space. Due to the projection the information about the arrival time of a customer is lost. In Fig. 7, when we give green to phase B14, we move through the graph along the positive A-axis correspondingly to the number of passing customers (the bold line represents a possible switching plan). Thus, the vertices of the graph represent the state space of the intersection and the edges the transition respectively. Moving from one vertex to the next produces some costs (depending on the choice of the objective) given by the weight of the edges. The goal is to reach the vertex which is most far from the origin, i.e. the rearmost corner vertex. By then all customers will have passed the intersection.

Fig. 7.

Traffic Control Using Graph Theory

State space representation.

5

ALGORITHM It can be shown (Riedel, 1991; Riedel and Brunner, 1992) that generally for an optimal decision the controller must know all future events (arrivals of customers); i.e. an optimal controller is non-causal. However, it is sufficient in practice to guess the future events by an estimator. The estimator receives messages from detectors (which are mounted in good distance from the intersection) when customers are about to pass the intersection. Detectors should be reliable, redundant detectors are recommended. The more detectors and the farther they are, the better the estimate of the future is. Estimation issues are investigated in details in (Wirth, 1992). For finding the optimum Dynamic Programming is used. Its complexity is exponential, though often this worst case does not happen. If the algorithm does not stop before reaching the end of the estimated data (i.e. the optimal signal switching sequence is not found), the problem becomes a Finite Time Horizon optimisation and thus its result is sub-optimal. Basic ideas and Dynamic Programming Each state is called a node K in the tree of Dynamic Programming. At the very beginning the state is all lights red and all queues empty; it is called the root node. The following 5 conditions must hold (Riedel, 1991): 1.

There has to be defined a Generating Rule g(K). The function g determines all nodes which can follow directly after K: g(K) = {g1(K), …, gn(K)}. Time is not relevant for this rule. The Generating Rule follows directly from the state diagram of the intersection. Remember the grid-like graph mentioned; it defines all states. When looking at coupled intersections, there will be additional constraints for the transitions because blocking the intersection by customers is forbidden.

2.

There must exist a Generating Strategy G telling at what point of time g(K) should be applied, i.e. when the next nodes have to be generated. It is never smart to break up a queue of customers. Thus we formulate the Generating Strategy as follows: Stay as long green as the queue is not yet empty, never break up a queue. Then allow other green states to follow.

3.

There must be a Cost Function c(K) describing the costs for node K. The Cost Function must be additive (Bertsekas, 1987), the costs of a following node must result from an addition of costs of the last node with some increment: c(gi(K)) = c(K) + ∆K.→g (K)c. i

The costs (being the global waiting time) of the final node must be minimised. 4.

There must exist a Comparison Condition V which determines whether two nodes KA and KB are comparable or not: (KA, KB)  V or not?

5.

And finally there must be a Comparison Rule “≤” for comparable states KA and KB, as usual: is c(KA) ≤ c(KB)?

Traffic Control Using Graph Theory

6

The system is represented by an n-dimensional, non-intersecting graph (Läuchli, 1991), n being the number of approaches. Both Comparability and Comparison Rule can be stated with the following proposition: Proposition: Two paths through the n-dimensional grid can be compared when they come across the same node and if they leave the node in the same direction. (This condition obviously does not apply for the last node not.) For the throughput as objective, the path with the least duration up to a compared node is better; otherwise the path is worse. For the waiting time as objective, the path having less waiting time accumulated and needing less time to reach the node is better; otherwise no conclusion can be drawn. Idea for the proof: If one path is better than the other path, it must be clear that the better path never can be outperformed by the path identified as worse; then Dynamic Programming can be used. This can be shown for both objectives: throughput and waiting time (Riedel, 1991; Riedel and Brunner, 1992). The Generating Strategy (2.) makes the problem easier to handle in its complexity by limiting the number of states to be calculated explicitly. The Cost Function (3.) makes the solutions comparable. The Comparability Rule (4.) finds equal states, reached on different paths but being in fact the same states. Practical aspects Due to the Generating Strategy paths might have few bends (mostly for individual traffic). When two paths stop at the same node in the grid (to follow a bend) they can be compared, sure. But it is possible to compare them between the stopping points, too: -

Two paths are crossing each other (see Fig. 12). At the crossing point path A can do an experiment: Would it be better than path B when following B after the crossing point? If yes, path A is better than path B, otherwise no conclusion is possible. But bending path A contradicts the Generating Strategy. Therefore it is not optimal. Consequently both, path B and the (experimental) bent path A cannot be a part of the optimal path. Of course the same experiment is possible for path B trying to follow path A.

-

When paths are in a state space with more than 3 dimensions they can be skew. But they can be compared, too, at the points with the least distance to each other.

Fig. 8.

Crossing paths and skew paths.

The algorithm is implemented as Depth First Search (DFS) following a path, once begun, until its end; the final state will be reached very soon by some paths, but they might be cancelled later on. An advantage of the DFS implementation is that we can obtain very quickly a bound for the objective (following a reasonable path) and Traffic Control Using Graph Theory

7

then apply Branch and Bound in addition to Dynamic Programming. A bound is useful for nodes “in the periphery” of the n-dimensional cube, because these nodes have only a few other paths to be compared with as paths in the center of the cube. Coupled intersections Coupling intersections extends the Generating Strategy. The Generating Strategy for one intersection is as follows: -

light A stays green until queue A is empty,

-

B is green until B empty.

Fig. 9.

Extension to 2 intersections.

Now, two intersections are coupled. If the queue in front of light C increases too much, intersection (A,B) is blocked; therefore light A is forced by light C to switch to red. Or light A itself can force light C to switch to green to let pass the arriving traffic and not to block intersection (A,B). Or finally light C wants to switch to green and asks A to send customers. The modified Generating Strategy looks as follows: -

light A is green until queue A is empty or blocked by queue C,

-

B is green until B empty or A polled by C,

-

C is green until C empty,

-

D is green until D empty or C forced by A.

Traffic Control Using Graph Theory

8

APPLICATION The example shown in Fig. 3 consists of two coupled intersections. Intersection A can switch both phases at arbitrary points of time without loss of time: intersection A is a slave of intersection B. The objective is to minimise the overall writing time of both intersections together. There are 4 tram stops. The intersection must not be 'punished' by waiting time due to these stops. This leads to the first step of the algorithm: Information pre-processing The estimator feeds the algorithm with position data of trams. The data is put into diagrams like shown in Fig. 5, one for each phase. Note that several phases can use the same approach road (tracks), ad for B145 and B15. When several trams arrive together (at A11 e.g.), all followers must be delayed artificially because of the scheduled delay at the tram stop. When a tram passes A11, it is re-scheduled for either B14 or B15 with the default delay at the stop. This is depicted in Fig. 10.

Fig. 10.

Information pre-processing.

If the estimated information differs from reality a re-computation is needed. (A tram might need more time to reach the intersection, or might stay longer in a stop as usual.) A handy situation We assume 4 trams in the system. Three at t = 10 for the phases B15, B17 and B19, and one at t = 15 for B20. By incidence vectors the problem can be reduced to a 4-dimensional state space. All following calculations will be done in this subspace.

Traffic Control Using Graph Theory

9

We introduce the vector f containing the actual fronts of all queues: f = [10, 10, 10, 15]. The matrix Z defines the intermediate times between the phases. The element zij is to be understood as 'time for clearing i due to incoming j. If zij is 0, phases i and j can run simultaneously; if zij = 0, then also zji = 0. If more than 2 phases shall run simultaneously, the following conditions must hold (p = set of phases to be run):

i, j i, j  p | i  j: zij  0 The following combinations are possible: (B15), (B17), (B19), (B20), (B15,B17), (B15,B19), (B17,B20), Enumerating the nodes We introduce the vector r, containing the points of time when a phases switched to red the last time. It must not be reduced to the mentioned subspace. There is a point of time T which indicates the earliest moment for the system to let the next customer pass. To compute T, we first compute the vector t:



t j  max zi, j  ri i



It contains the earliest moment for each phase to be switched to green. If by that time no customer's front is in the queue, ti takes on the value of fi:

t  ti: t i: maxti , f i 

Finally T is computed as the minimum component of the ti. At T several phases might be enabled. Suppose T = 10, then B15, B17 and B19 are enabled. To enumerate all nodes correctly, the tree of Dynamic Programming must be timed. All edges of the tree equal a transition in the state space grid. No duplicates are allowed, i.e. a transition must be taken in the earlier moment. Suppose (B15, B17) has been chosen at t =10, then at t = 16 B19 will be enabled and at t = 18 B20. If we choose at t = 16 to wait until t = 18 before making the next phase change, at t = 18 only B20 is enabled, because B19 could have taken on earlier. And thus B19 after B20 will be cancelled as well.

Fig. 11. Traffic Control Using Graph Theory

Allowed and forbidden phases. 10

To formalise this we introduce the set of maximal combinations M for each node. M is the set with the least elements, that contains all enabled combinations. For the root node is M = {(B15, B17), (B15, B19)}. If the set of chosen phases pk in node k does not contain phases that could have been chosen in node k-1 already, only in this case pk is allowed to be checked; otherwise the phase combination is useless or at least not optimal. Or formally, a phase combination can only be selected, if the following equation hold for all j:



for j: pk 1  Mk 1 j

 M



k 1 j \ pk1  pk 



If due to the condition, no phase can be selected, the node is dead. Bounds Now we are sure not to compute the same node twice; the Generating Strategy has been implemented. To obtain the best solution, -

comparable nodes must be compared and thrown out when they are bad,

-

Branch and Bound must be applied by (e.g. recursively) implementing a DFS.

Figure 12 shows how fast the algorithm can find the solution of the given handy example:

Fig. 12.

Solution of the handy example.

At the top there is the root node. First the algorithm enable the phases (15,19); we omit the B before the numbers. At t = 16 a new phase can begin, a waiting time of 7 has been collected up to now. Here, phases 17 and 20 are enabled; choosing both together leads to a final node with total waiting time 7. Choosing only one of the phases, or even none, leads to a dead node. Following the next selection from the rood node, (15,17), leads to another node with waiting time 7. 20 cannot be enabled yet because of the intermediate time of 8. Therefore only 19 or none can be enabled, both leading to nodes which can be crossed out because of the bound of 7 we already have found. Choosing a single phase when starting at the root node (or even none) leads every time to a node with a waiting time above the bound of 7. Why selecting 15 and then 19 is not possible? Because of the maximal combination restriction which says that (15,19) together have to be chosen.

Traffic Control Using Graph Theory

11

Thus the optimal solution is the left-hand path. The solution has been obtained by evaluating 13 nodes instead of 176 nodes for a brute force search through the tree.

CONCLUSIONS Using an example the design of a control algorithm for traffic lights has been presented. As the state of the intersection must be known for an optimal decision, we assumed that there is a device (an observer) which reconstructs the intersection state by receiving sensor-readings of the input events. Given such a device and by using Dynamic Programming for optimisation it is straight forward to develop a control algorithm that minimises the overall waiting time (as shown) or maximises the throughput. Moreover, it has been shown that Branch-andBound techniques can be used to reduce the computational complexity. The state space of the problem does not exhibit (explicitly) time, but ordered customers. The presented algorithm does not reduce this state space, but -

the number of transitions is reduced, and

-

the number of states to be searched for is also reduced.

Problems only raised in the paper are subjects of further research: -

design of an observer,

-

simulation of an intersection to test the controller and the observer,

-

robustness of controllers and observers with respect to unreliable sensor outputs.

REFERENCES Bertsekas, D.P. (1987). Dynamic Programming. Prentice Hall, Englewood Cliffs, NJ. Läuchli, P. (1991). Algorithmische Graphentheorie. Birkhäuser, Basel. Riedel, Th. (1991). Reglerentwurf für Verkehrskreuzungen, theoretische Aspekte (Some Theoretical Aspects for Designing Traffic Light Controllers). Automatic Control Lab Report No. 91-19, ETH Zürich (also presented with title “A Generic DEDS Control” at: Workshop on Discrete Event Systems, Amherst, MA, June 1991. Riedel, Th and U. Brunner (1992). A control algorithm for traffic lights. The 1st IEEE conference on control applications, Dayton, OH, Sept. 1992. Wirth, M. (1992). State estimator for DES with defective event detectors. Personal communications which will be presented at: WODES, Joint Workshop on Discrete Event Systems, Prague, August 1992.

Traffic Control Using Graph Theory

12