CS452 - Real-Time Programming - Spring 2010

Lecture 27 - Reservations

Public Service Announcements

  1. Due date for Tracking 1
  2. Fraser's back.


Somebody has been doing something right for the last century. The answer is reservations.

Two Level Train Control

The two levels are completely independent of one another.

Upper Level


Engineer receives instructions.


  1. Train asks despatcher for a route
  2. Despatcher provides a route that he/she thinks to be conflict free
  3. Train follows the route, reporting back to the despatcher as landmarks (sensors) are passed.

Lower Level

The lower level is encoded in the coloured lights you see along the track

Here's how it works

  1. Train asks reservation system for several blocks of track
  2. Reservation system grants the blocks if they are available

An Interesting Tit-bit That Doesn't Concern You

Real trains are long and sometimes occupy several blocks at once. How does the engineer know that the end of a train is clear of a switch?

Something Essential that You Must Do

Design your reservation system before coding it.

Before coding your reservation system work it out on paper and make sure that it works for all the generic cases you can think of

  1. One train following another
  2. Two trains on a collision course
  3. There are one or more switches in the path

Feedback Control

Control Concepts

  1. System to be controlled
  2. Time-dependent variables to be controlled
  3. Control parameters
  4. Objectives (goals)
  5. Control algorithm

Fundamental Problem is Noise

We try to set the velocity as we wish,

How do we tame noise?

  1. Measure the real position, y(t), as often as we can
  2. Modify the velocity to reduce y(t) - x(t), the difference of the desired position from the real one.
  3. Example: v(t) = B(t-t0) - C(y(t) - x(t))

Suppose we can measure continuously and instantaneously. Then

This looks pretty good, BUT

There is always a Time Lag

At time t, we really know y(t-D), where D is an inevitable time lag. Now what happens?

  1. u(t) = d(y(t) - x(t)) / dt = - C(y(t-D) - x(t)). This is pretty intractable.
  2. However, we should know the lag, or the average lag, or whatever, and we can solve
  3. d(y(t) - x(t)) / dt = - C(y(t-D) - x(t-D))
  4. Hypothesize a solution of the form exp( -zt ) and solve for z
  5. z = C exp( zD ) or log(z) = zD + log(C)
  6. Sometimes there is no real solution

The solution is Predictive Control

Change step 3 to

  1. d(y(t) - x(t)) / dt = - C(y(t-D) + Dv(t) - x(t)), which is close to

    d(y(t) - x(t)) / dt = - C(y(t) - x(t))

  2. And we are back to a solution we like.

There are whole textbooks about different ways of doing predictive control; there are whole journals with articles describing new ways of doing predictive control.

Using predictive a little loosely, predictive control is what you are doing.

Return to: