CS452 - Real-Time Programming - Winter 2013

Lecture 26 - Reserving Track

Public Service Annoucements

  1. When you will give the second demo

Track Reservations

A possible solution to collision avoidance

You have to be able to look ahead.

To do so treat the track as a divisible resource like pixels on a display. Train driver requests some of the resource in order to move.

A Staged Approach

1. A very simple way to do it not very well

  1. Train driver gets a job to do using the train, and figures out whither he needs to move.
  2. Train driver asks for a route to that place.
  3. Train driver is blocked until no other train is moving.
  4. Train driver requests track all the way to the end of the route from the track manager.
  5. Train driver drives the train to the end of the route.
  6. Train driver tells route finder

Only one problem here but it's a big one: only one train moves at a time. But, you have basic route-finding and sensor attribution working and there are no collisions.

Just be sure that your implementation is extensible to the following extensions.

2. Getting two trains moving at once

We have to elaborate the third step above to take into account other moving trains.

  1. as above
  2. as above
  3. Route finder excludes track blocked by stationery trains and track that is reserved
  4. as above
  5. as above
  6. Train driver returns requested track to the track manager.

You now have two trains moving at once most of the time, but the solution does not scale well with number of trains.

3. Removing one bottleneck

A moving train holds its entire route until it is finished moving. It could free parts of the route it will not traverse again. To do so elaborate steps 5 and 6.

  1. as above
  2. as above
  3. as above
  4. as above
  5. Train driver drives to the end of the route switching switches.
  6. Train driver continues to hold the piece of track on which the train sits.

Trains that are blocked waiting for a route now wait for less time, the solution scales a little better but more improvements can be made.

4. Removing another bottleneck

The solution above can be made less conservative by starting a train moving before it can get a complete path by giving the train driver incomplete routes, by changing steps 3, 4 & 5.

  1. as above
  2. as above
  3. If possible route finder provides a route that goes all the way. If not, route finder chooses an intermediate destination closer to the final destination that doesn't cross any route.
  4. Train driver requests track to the intermediate destination.
  5. Train driver drives to the intermediate destination.
  6. as above

Return to: