CSE 6323: Spring 2010 Voluntary Assignment #1 PROBLEM DESCRIPTION In this assignment, you will develop a simple model of a railroad signaling system. Most signaling systems use colored lights (similar to auto traffic lights) placed at regular intervals along a railroad track. The goal of the signaling system is to ensure that two trains are not in the same place at the same time (if this simple constraint is satisfied, there can be no collision between two trains). The signaling system we will consider is a simplified version of the railway signalling system based on the following "Principles of Signalling" taken from a web-page maintained by Mark D. Bej (http://broadway.pennsyrr.com/Rail/Signal/). Everything you need to know about signalling to complete this assignment is given in this assignment description. However, if you are curious about real signalling systems, you can check out (http://www.trainweb.org/railwaytechnical/sigind.html). ----------- BEGINING of "Principles of Signalling" excerpt ------------ Railroad signals are similar in purpose to highway traffic signals for cars. Keep in mind, though, in reading this, that it was highway signals that developed from railroad signals, not the other way around. Everyone needs some warning before getting a signal to stop. For your car, that warning is the yellow light that appears for a few seconds before the red light appears. The yellow light is timed according to the prevailing speed on the road it governs and, of course, according to the required stopping distances for cars and trucks. It does not take much time or distance (relative to trains) for cars and trucks to stop. (Cars and trucks can also turn out of the way of danger.) Therefore, the yellow warning light can be provided at the same physical location (the same signal apparatus) as the red light. Trains, however, are heavy. They may require 1/2 to 1+1/2 mile to stop. Thus, they need a warning well before the point where they have to stop. The arrangement must inherently be different from what is present on roads. Here are the basics of how it works. Each section of track, from signal to signal, is one 'block'. So far as we are concerned here, the signal defines the block regardless of how the underlying hardware may work. Except in infrequent instances beyond the scope of this introduction, only one train is permitted in each block. Entry into the block is permitted or denied by the signal. That signal is said to 'govern' the block. Blocks in the past, in the days of short trains, were often about a mile (about 1.5 km) long. With longer and heavier trains, they've been lengthened over the years, so that a more typical value on large U.S. mainlines at present is about 2-3 miles. However, there are many factors involved in determining block lengths. A red signal can mean one of several things: - The next block is occupied. - If the signal is a controlled signal (under direct human control, not automatic), the person controlling it may simply want to hold the train at that location for some time, to allow some other train to pass; - Some other danger situation exists. This may include a switch (points) in the next block not properly lined. Or, another route may have been set which does not allow the train to proceed (e.g., at a 90 degrees crossing). A yellow signal indicates that the next block is clear, but that the block following that is occupied or unsafe. Thus, the following signal is red, and the train has the length of one block to stop. A green signal, finally, means that the next two blocks (at least) are clear, and that the next signal is therefore either yellow, or also green. ----------- END of "Principles of Signalling" excerpt ------------ Based on this description above, we will model the signalling on a simple railway consisting of a single linear track with trains moving east to west. >Train 1> >Train 2> East s(1) ======= s(2) ======= s(3) === ....... === s(k) ======= s(k+1) West b(1) b(2) b(k) ---- direction of train travel ---> The railway signalling system consists of signals s(1)..s(k+1) and blocks b(1)..b(k) where a signal s(i) governs block b(i) as described above. Each signal has a single color setting -- it is either set to red, yellow, or green. As described above, a signal setting is determined by occupancy state of the block that it governs and the state of signals that follow it in the direction of train travel. You should begin the construction of your model by enforcing the physical constraints of the railway layout above. Specifically, here are some constraints that your model must satisfy: Physical Layout Constraints: i) Each block has exactly one signal on its east side and exactly one signal on its west side. Since traffic is moving from east to west, the signal on the east side of the block "governs" the block. ii) Of course, a signal cannot be both the east and west signal of a block (i.e., the east and west signals of a block are distinct). iii) Every signal except the east-most signal is on the west side of a block; Every signal except the west-most signal is on the east side of a block. Note that the west-most signal does not govern a block. iv) A block can be occupied by at most one train. v) A train occupies exactly one block. Signal Setting Constraints: vi) The meanings of the signal colors, described above, governing each track block should be enforced. Problem Steps: ------------------------ 1) Draw a UML class diagram for the signaling system described above. The diagram shall encode all of the constraints, including both the physical layout and signaling constraints. OCL expressions can be used whenever necessary. It is recommended to use Rational Rose to draw the class diagram. But it is also fine to use any other tool. 2) Using your class diagram identify one uniqueness constraint, one multiplicity related constraint and one cyclic constraint that is not already included in your model. Describe the constraint in English first and then formally specify it using OCL. 3) Using OCL define a query operation "followingTrains" that returns the set of trains that are following a given train. The result of this operation must be precisely defined. 4) Define a "move" operation for trains. Train movement is governed by the following policies: vii) A train can only move to an unnoccupied block. viii) Trains can only move forward. ix) Signals should be updated appropriately to reflect the new position of the train. x) More than one train can move simultaneously, but no train may overtake another, i.e., trains stay in the same relative position. These should be encoded as pre and post-conditions for your operation. (Hint: The "followingTrains" opertion in 3) may be used to specify the "no overtake" policy.) Note that in order to validate your UML/OCL model, it is recommended that for each constraint you encode, you may want to find a model instance that satisfy the constraint and another model instance that falsify the constraint.