Planning Public Transportation with Raku

Reindeer Expressed

by Arne Sommer

Reindeer Expressed

[159.5.3] Published 15. December 2021.

[ Introduction | Oslo Metro | Oslo Tram | Bergen | Misc. ]
[ Misc. Intro | Lisboa | Railways | Reindeer Expressed | Intervals NEW ]

This article explains the routes shown in the short story Reindeer Express.

Let us start with the proposed Santa Express route network:

We set up 5 different routes, all of them starting at the Megafactory. (The travel time is as shown. The differences for the two directions are caused by the empty haul back to the megafactory beeing faster.)

Then we combine each route to the distribution Centres (RE2 to RE5) with the route to Santa Central (RE1), so that we get five times as many departures to Santa Central as to each distribution centre.

The «networkplanner» program was developed for short routes (typically up to 40 minutes from one end to the other), and with frequent departures (e.g. every tenth minute). But it works with longer routes (timewise) and less frequent departures as well.

Let us consider the «R200» series:

                  R201  R202  R203  R204  R205  R206  R207  R208  R209  R210
----------------------------------------------------------------------------
Santa/RE1   dep   0000  0030  0100  0130  0200  0230  0300  0330  0400  0430
Mega        arr   0040  0110  0140  0210  0240  0310  0340  0410  0440  0510 
Mega/RE2    dep   0110  0140  0210  0240  0310  0340  0410  0440  0510  0540 
America     arr   0155  0225  0255  0325  0355  0425  0455  0525  0555  0625 
America/RE2 dep   0215  0245  0315  0345  0415  0445  0515  0545  0615  0645 
Mega        arr   0250  0320  0350  0420  0450  0520  0550  0620  0650  0720 
Mega/RE1    dep   0330  0400  0430  0500  0530  0600  0630  0700  0730  0800 
Santa       arr   0425  0455  0525  0555  0625  0655  0725  0755  0825  0855 
Santa/RE1   dep   0500  0530  0600  0630  0700  0730  0800  0830  0900  0930

R200: Number of vehicles: 10

Let start with vehicle «R201», the first one in the table. The first departure is from Santa Central at «0000» on route RE1, with arrival at the Megafactory 40 minutes later. After a layover period of 30 minutes, it departs on route RE2 to the American distribution centre, where it arrives 45 minutes later. Then we got a layover period of 20 minutes, before it departs on the same route back to the megafactory. It arrives 35 minutes later, has a 40 minute layover before the return leg on route RE1 to Santa Central. Arrival is 55 minutes later. After a 35 minute layover, we are ready for the next trip, 5 hours after the first one. As we run the series every 30 minutes, this requires 10 vehicles (or Reineer Expresses to be precise).

And we can indeed get the number of vehicles required to do a full run by counting the columns in the table, or looking it up in the summary below it.

The third row gives the actual departure times, in this case with a 30 minute interval.

The last row in the table shows the departures comming just after the ones in the third row. This is for information purposes only. The first one (0500) follows nicely on after the last one on the third row (0430).

It is up to you to interpret the values. They could either indicate a 24/7 operation, literally starting at midnight, or as a snapshop at any given time. Start the departures whenever you want them to, by adding the start time to the values in the output. And stop them when you are done.

The «R200» series combine RE1 and RE2, doing a return trip on both before starting over.

You set this up in the vehicle definition file like this:

File: santa/vehicles.def
=R200
RE12 U Santa/RE1;Santa         30
RE2  D Mega/RE2;Mega           20
RE2  U America/RE2;America     20
RE12 D Mega/RE1;Mega           20

=R300
RE13 U Santa/RE1;Santa         30
RE3  D Mega/RE3;Mega           20
RE3  U Africa/RE3;Africa       20
RE12 D Mega/RE1;Mega           20

=R400
RE14 U Santa/RE1;Santa         30
RE4  D Mega/RE4;Mega           20
RE4  U Asia/RE4;Asia           20
RE12 D Mega/RE1;Mega           20

=R500
RE15 U Santa/RE1;Santa         30
RE5  D Mega/RE5;Mega           20
RE5  U Australia/RE5;Australia 20
RE15 D Mega/RE1;Mega           20

«RE12» (as well as «RE13», «RE14» and «RE15») is a copy of «RE1», as each series (R200, R300, R400 and R500) have their own departure times, and the program does not really support that for a single route. «D» is the down direction (in the route definition file), and «U» is the Up direction. The number at the end of each row is the minimum layover time (in minutes) before a departure.

You set up the routes like this:

File: santa/santa.setup
## Networkplanner ##

route set RE12 file:RE1.def down:0    up:0   interval:30
route set RE2  file:RE2.def down:10   up:15  interval:30

route set RE13 file:RE1.def down: 7.5  up:7.5 interval:30
route set RE3  file:RE3.def down:17.5 up:40  interval:30

route set RE14 file:RE1.def down:15   up:15   interval:30
route set RE4  file:RE4.def down:25   up:10   interval:30

route set RE15 file:RE1.def down:22.5 up:22.5 interval:30
route set RE5  file:RE5.def down:32.5 up:10   interval:30

vehicles vehicles.def

tp :tabulated SA999 SA001

The program supports half-minutes, e.g. 7.5. They will show up as an ' after the (whole) minute in the output from the commands.

The routes have their own definition files:

File: santa/RE1.def
#
# RE1 Megafactory (China) - Santa Central
# ---------------------------------------
SA999 D    A:40 Megafactory (China)
SA001 A:55 D    Santa Central

I have used the platform (or in this case a runway) «D» for departure, and «A» for arrival. The number after the colon is the travel time (in minutes) to that stop.

File: santa/RE2.def
#
# RE2 Megafactory (China) - Distribution Centre America
# -----------------------------------------------------
SA999 D    A:35 Megafactory (China)
SA901 A:45 D    Distribution Centre America
File: santa/RE3.def
#
# RE3 Megafactory (China) - Distribution Centre Africa
# ----------------------------------------------------
SA999 D    A:29 Megafactory (China)
SA902 A:41 D    Distribution Centre Africa
File: santa/RE4.def
#
# RE4 Megafactory (China) - Distribution Centre Asia
# --------------------------------------------------
SA999 D    A:8 Megafactory (China)
SA903 A:12 D   Distribution Centre Asia
File: santa/RE5.def
#
# RE5 Megafactory (China) - Distribution Centre Australia
# -------------------------------------------------------
SA999 D     A:78 Megafactory (China)
SA904 A:100 D    Distribution Centre Australia

The timingpoints, from the «tp» command:

Megafactory (China) [A]
--  -- 10 --  -- -- -- -- --  -- 40 --  -- -- -- -- | RE12 Megafactory (China)
--  -- -- --  -- 20 -- -- --  -- -- --  -- 50 -- -- | RE2 Megafactory (China)
--  -- -- 17' -- -- -- -- --  -- -- 47' -- -- -- -- | RE13 Megafactory (China)
--  09 -- --  -- -- -- -- --  39 -- --  -- -- -- -- | RE3 Megafactory (China)
--  -- -- --  -- -- 25 -- --  -- -- --  -- -- 55 -- | RE14 Megafactory (China)
--  -- -- --  18 -- -- -- --  -- -- --  48 -- -- -- | RE4 Megafactory (China)
02' -- -- --  -- -- -- -- 32' -- -- --  -- -- -- -- | RE15 Megafactory (China)
--  -- -- --  -- -- -- 28 --  -- -- --  -- -- -- 58 | RE5 Megafactory (China)

Megafactory (China) [D]
00 --  --  -- -- --  --  -- 30 --  --  -- -- --  --  -- | RE12 Santa Central
-- --  --  10 -- --  --  -- -- --  --  40 -- --  --  -- | RE2 Distribution Centre America
-- --  07' -- -- --  --  -- -- --  37' -- -- --  --  -- | RE13 Santa Central
-- --  --  -- -- 17' --  -- -- --  --  -- -- 47' --  -- | RE3 Distribution Centre Africa
-- --  --  -- 15 --  --  -- -- --  --  -- 45 --  --  -- | RE14 Santa Central
-- --  --  -- -- --  --  25 -- --  --  -- -- --  --  55 | RE4 Distribution Centre Asia
-- --  --  -- -- --  22' -- -- --  --  -- -- --  52' -- | RE15 Santa Central
-- 02' --  -- -- --  --  -- -- 32' --  -- -- --  --  -- | RE5 Distribution Centre Australia

Santa Central [A]
--  -- --  25 --  -- --  55 | RE12 Santa Central
02' -- --  -- 32' -- --  -- | RE13 Santa Central
--  10 --  -- --  40 --  -- | RE14 Santa Central
--  -- 17' -- --  -- 47' -- | RE15 Santa Central

Santa Central [D]
00 --  -- --  30 --  -- --  | RE12 Megafactory (China)
-- 07' -- --  -- 37' -- --  | RE13 Megafactory (China)
-- --  15 --  -- --  45 --  | RE14 Megafactory (China)
-- --  -- 22' -- --  -- 52' | RE15 Megafactory (China)

Here the internal route IDs «RE12» to «RE15» do turn up.

We can fix that, with the «:merge» option to «tp»:

File: santa/santa2.setup (changes only)
tp :merge[RE1;RE12;RE13;RE14;RE15] SA999 SA001

This tells the timingpoint code to merge all the (semicolon separated) routes given in the brackets (with the same destination). The first route ID will be used. Note that the «:tabulated» option is enabled by this option.

The result:

Megafactory (China) [A]
02' -- 10 17' -- -- 25 -- 32' -- 40 47' -- -- 55 -- | RE1 Megafactory (China)
--  -- -- --  -- 20 -- -- --  -- -- --  -- 50 -- -- | RE2 Megafactory (China)
--  09 -- --  -- -- -- -- --  39 -- --  -- -- -- -- | RE3 Megafactory (China)
--  -- -- --  18 -- -- -- --  -- -- --  48 -- -- -- | RE4 Megafactory (China)
--  -- -- --  -- -- -- 28 --  -- -- --  -- -- -- 58 | RE5 Megafactory (China)

Megafactory (China) [D]
00 --  07' -- 15 --  22' -- 30 --  37' -- 45 --  52' -- | RE1 Santa Central
-- --  --  10 -- --  --  -- -- --  --  40 -- --  --  -- | RE2 Distribution Centre America
-- --  --  -- -- 17' --  -- -- --  --  -- -- 47' --  -- | RE3 Distribution Centre Africa
-- --  --  -- -- --  --  25 -- --  --  -- -- --  --  55 | RE4 Distribution Centre Asia
-- 02' --  -- -- --  --  -- -- 32' --  -- -- --  --  -- | RE5 Distribution Centre Australia

Santa Central [A]
02' 10 17' 25 32' 40 47' 55 | RE1 Santa Central

Santa Central [D]
00 07' 15 22' 30 37' 45 52' | RE1 Megafactory (China)

All you have to do, after installing the Raku module Transit::Network and unpacking the examples zip file, is running this command (in the «santa» directory):

$ networkplanner santa2.setup

Santa takes care of the rest…

[ Introduction | Oslo Metro | Oslo Tram | Bergen | Misc. ]
[ Misc. Intro | Lisboa | Railways | Reindeer Expressed | Intervals NEW ]