Google Analytics

Wednesday 23 February 2022

Signalling

I recently mentioned four boxes of discoloured colour slides I came across when scanning in. Several people suggested, and indeed showed, it was not difficult to recover at least something like their original appearance. I said I’d try, but needed to get out an old computer with Photoshop Elements which came bundled free with a scanner. These days they expect you to buy it over and over again with a subscription. I refuse to be treated as an income stream.

I got out the old computer but have not made much progress yet. This is not down to any difficulty with Photoshop, but because of distraction. The old computer also contains a set of PC-Rail signalling simulations.    

They might not sound it, but they’re great, they really are – not because of what you do or see but because of what you imagine. You pretend you are controlling all the trains through York, the noise and the power and the enormity of the things, and imagine being on board, remembering journeys once made.  

It could be the summer of 1983, when they invited me to interview for a research job in the world-famous Department of Artificial Intelligence at the University of Edinburgh. I travelled up from Hull and back in a day, changing at Selby during its last months as a station on the East Coast Main Line before being bypassed by the coalfield diversion They wanted to offer me the job too – they phoned the same evening – but were then overruled by the funding council who insisted on someone either with or close to finishing a Ph.D.

Or it could be any one of the many other times I’ve been through York by train, up to Newcastle, Edinburgh or Glasgow, visiting clients when I was with the software company, or later, to see students on work placement. I once went to Aberdeen on the overnight sleeper, did what I had to do there, returned the next night and was back at work by 9 a.m.

It’s tricky signalling a path through York for the Scarborough Transpennines. They come in from Leeds on the top left of the above screen and need to get to Platform 4 and the Scarborough line on the bottom right. The screen shot shows train 1B23 (Blackpool to Scarborough) nearly there after crossing the East Coast Main Line just outside the station. I have to be careful not to hold up trains from Doncaster and London. I am being distracted by train 2C26 coming in from Harrogate at the other end of the station (below) where it has to get to Platform 8 without  holding up trains from Newcastle and Edinburgh. Fortunately, it’s not very busy – not yet. 

Sheffield is great, too – quite demanding. You control everything from Dore Junction and the Bradway tunnel south of the station (on the left in the screenshot below), to Meadowhall to the north. You have to put goods trains into loop lines to give priority to the London and Cross Country expresses on the Midland Main Line. Oh to be on the Aberdeen to Penzance!

I’ve been through Sheffield a lot too: south to the East Midlands where the software company was based, north to Leeds, York and beyond, and East towards Doncaster and Hull when I lived and worked there. These days you might find me taking the Barnsley branch home. Mother-in-law used to do it when she travelled up from Hertfordshire and changed trains at Sheffield, complaining it was so much easier when we lived near Nottingham, horrified by the Barnsley accents on the local train and dreading her grandchildren might grow up to speak like that. They got called posh at school.  

The full simulations are not free, but there are evaluation versions which run for thirty minutes or so without charge, which is all I have ever done. With well over a hundred different stations or eras, there is plenty to do. Some are “heritage” simulations which recreate mechanical lever-framed signal boxes communicating with adjacent boxes through working block instruments and bells. I’ve played with quite a lot of them, both modern and heritage, always there personally in the mind’s eye.

Now, what about those photographs.

Friday 18 February 2022

Factorials (or Bonding with Brague)

Dear Bob,

As I am sure you know, the factorial of any positive whole number is that number multiplied by all the numbers between it and 1.

So the factorial of 3 = 1 x 2 x 3 = 6
And the factorial of 5 = 1 x 2 x 3 x 4 x 5 = 120

I am also sure that, as a computer programmer, you could quickly write a program to calculate the factorial of any number N. One way to do it would be to set up a counter to cycle through all the numbers between 1 and N, multiplying each by a running total that is initially set to 1. In an imaginary programming language it might look like this:

RunningTotal = 1
FOR Counter = 1 to N
Multiply RunningTotal by Counter; (thereby altering the value of RunningTotal)
The factorial of N = RunningTotal

So, in calculating the factorial of 5, each step of the cycle would produce the following values:

 Counter   Multiplication of
 RunningTotal x Counter 
 New Value of
 RunningTotal 
1 1  x  1 1
2 1  x  2 2
3 2  x  3 6
4 6  x  4 24
5 24  x  5 120

But there is a more elegant way. This involves thinking of the factorial of any number N as being that number multiplied by the factorial of N-1.

So the factorial of 3 = 3 x 2 = 6
And the factorial of 5 = 5 x 24 = 120
And the factorial of 6 = 6 x 120 = 720

In our imaginary programming language, the program to calculate factorials using this method might look like this:

The factorial of 1 = 1
The factorial of N = N x the factorial of (N-1)

This is known as a recursive function because it has to re-use itself at each step of the calculation. For example:

The factorial of 5 = 5 x (the factorial of 4)
    The factorial of 4 = 4 x (the factorial of 3)
        The factorial of 3 = 3 x (the factorial of 2)
            The factorial of 2 = 2 x (the factorial of 1)
                The factorial of 1 = 1 (this causes the calculation to “unwind”)
            So, the factorial of 2 = 2 x 1 = 2
        So, the factorial of 3 = 3 x 2 = 6
    So, the factorial of = 4 x 6 = 24
So, the factorial of 5 = 5 x 24 = 120

Isn’t that just exquisite!

Now, for homework, please would you explain the operation of recursive descent parsing giving examples from the Hebrew and Cherokee languages.

Sincerely yours