Planning Public Transportation with Raku

Intervals NEW

by Arne Sommer

Intervals NEW

[159.5.4] Published 31. December 2021.

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

The changes in v.0.0.3 (#001 vehicle code using the intervals + #007 individual intervals in each direction) opens up new possibilities - and some problems.

Consider this simplistic route network:

Routes 1 and 2 are combined at «Southwest», with the vehicles running through the stop after a short layover.

The three routes are defined like this, with the main stops only:

File: intervals/01.def
#
# 1 Southwest - North
# -------------------------------------
#
AA001 A    B:10 Southwest
AA002 B:10 A:10 South
AA003 C:10 D:10 Central
AA004 A:10 B    North
File: intervals/02.def
#
# 2 Southwest - East
# -------------------------------------
#
AA001 B    A:10 Southwest
AA005 B:10 A:10 West
AA003 A:10 B:10 Central
AA006 A:10 B    East
File: intervals/03.def
#
# 3 Northwest - East
# -------------------------------------
#
AA007 A    B:15 Northwest
AA005 A:15 B:10 West
AA003 A:10 B:10 Central
AA006 A:10 B    East

Then the network setup file, with 15 a minute interval on route 1 and 2, and 30 minutes on route 3:

File: intervals/simple.setup
## Networkplanner ##

route set 1 file:01.def interval:15 down:2
route set 2 file:02.def interval:15 down:2
route set 3 file:03.def interval:30 down:2 up:13

tp :tabulated Central

vehicles vehicles.def

The vehicles definition file, with rute 1 and 2 combined:

file: intervals/vehicles.def
=1000
1 U North/1;North          10
2 D Southwest/2;Southwest  2
2 U East/2;East            10
1 D Southwest/1;Southwest  2

=3000
3 D Northwest 10
3 U East      10

The output:

Central [A]
07 22 -- 37 52 -- | 2 East
-- -- 27 -- -- 57 | 3 East

Central [B]
10 -- 25 40 -- 55 | 2 Southwest
-- 23 -- -- 53 -- | 3 Northwest

Central [C]
07 22 37 52 | 1 North

Central [D]
10 25 40 55 | 1 Southwest

                  1001  1002  1003  1004  1005  1006  1007  1008  1009  1010
----------------------------------------------------------------------------
North/1     dep   0000  0015  0030  0045  0100  0115  0130  0145  0200  0215 
Southwest   arr   0030  0045  0100  0115  0130  0145  0200  0215  0230  0245 
Southwest/2 dep   0032  0047  0102  0117  0132  0147  0202  0217  0232  0247 
East        arr   0102  0117  0132  0147  0202  0217  0232  0247  0302  0317 
East/2      dep   0115  0130  0145  0200  0215  0230  0245  0300  0315  0330 
Southwest   arr   0145  0200  0215  0230  0245  0300  0315  0330  0345  0400 
Southwest/1 dep   0147  0202  0217  0232  0247  0302  0317  0332  0347  0402 
North       arr   0217  0232  0247  0302  0317  0332  0347  0402  0417  0432 
North/1     dep   0230  0245  0300  0315  0330  0345  0400  0415  0430  0445 

                3001  3002  3003  3004
--------------------------------------
Northwest dep   0002  0032  0102  0132 
East      arr   0037  0107  0137  0207 
East      dep   0113  0143  0213  0243 
Northwest arr   0148  0218  0248  0318 
Northwest dep   0202  0232  0302  0332 

1000: Number of vehicles: 10
3000: Number of vehicles: 4
---------------------------------------
Total number of vehicles: 14

It would be nice to have en even interval between the vehicles on the shared east - west section (West - Central - East). The different intervals on the routes (2 and 3) makes this challenging, as shown above. And I have not tried that hard.

Let us adjust the intervals on route 2, from «15» (or «15+15») to «10+20», to make a slot for route 3:

File: intervals/skewed.def
## Networkplanner ##

route set 1 file:01.def interval:15    down:2
route set 2 file:02.def interval:10;20 down:2
route set 3 file:03.def interval:30    down:17 up:20

tp :tabulated Central

vehicles vehicles.def

The timingpoints for the east - west section show that we got it right, with an even 10 minute combined interval:

Central [A]
02 -- 22 32 -- 52 | 2 East
-- 12 -- -- 42 -- | 3 East

Central [B]
-- 10 20 -- 40 50 | 2 Southwest
00 -- -- 30 -- -- | 3 Northwest

Central [C]
07 22 37 52 | 1 North

Central [D]
10 25 40 55 | 1 Southwest

The vehicle part is not so good, as it has an error:

                  1001  1002  1003  1004  1005  1006  1007  1008  1009  1010  1011
----------------------------------------------------------------------------------
North/1     dep   0000  0015  0030  0045  0100  0115  0130  0145  0200  0215  0230 
Southwest   arr   0030  0045  0100  0115  0130  0145  0200  0215  0230  0245  0300 
Southwest/2 dep   0032  0042  0102  0112  0132  0142  0202  0212  0232  0242  0302 
East        arr   0102  0112  0132  0142  0202  0212  0232  0242  0302  0312  0332 
East/2      dep   0130  0140  0200  0210  0230  0240  0300  0310  0330  0340  0400 
Southwest   arr   0200  0210  0230  0240  0300  0310  0330  0340  0400  0410  0430 
Southwest/1 dep   0202  0217  0232  0247  0302  0317  0332  0347  0402  0417  0432 
North       arr   0232  0247  0302  0317  0332  0347  0402  0417  0432  0447  0502 
North/1     dep   0245  0300  0315  0330  0345  0400  0415  0430  0445  0500  0515 

                3001  3002  3003  3004
--------------------------------------
Northwest dep   0017  0047  0117  0147 
East      arr   0052  0122  0152  0222 
East      dep   0120  0150  0220  0250 
Northwest arr   0155  0225  0255  0325 
Northwest dep   0217  0247  0317  0347 

1000: Number of vehicles: 11
3000: Number of vehicles: 4
---------------------------------------
Total number of vehicles: 15

The marked departures are 3 minutes before arrival, which is impossible. The problem is the multiple interval (10;20), as the program does not take them into account when dispatching vehicles. This is a bug (#015). The workaround is to swap them around (20;10) so that this does not happen:

File: intervals/reskewed.def
## Networkplanner ##

route set 1 file:01.def interval:15    down:2
route set 2 file:02.def interval:20;10 down:2
route set 3 file:03.def interval:30    down:7 up:10

tp :tabulated Central

vehicles vehicles.def

Note that I had to adjust the departures on route 3, as the route 2 depatures has been shifted 10 minutes. (I could have adjusted the «up» and down values for route 2 instead.)

Central [A]
-- 12 22 -- 42 52 | 2 East
02 -- -- 32 -- -- | 3 East

Central [B]
00 10 -- 30 40 -- | 2 Southwest
-- -- 20 -- -- 50 | 3 Northwest

Central [C]
07 22 37 52 | 1 North

Central [D]
10 25 40 55 | 1 Southwest

                  1001  1002  1003  1004  1005  1006  1007  1008  1009  1010  1011
----------------------------------------------------------------------------------
North/1     dep   0000  0015  0030  0045  0100  0115  0130  0145  0200  0215  0230 
Southwest   arr   0030  0045  0100  0115  0130  0145  0200  0215  0230  0245  0300 
Southwest/2 dep   0032  0052  0102  0122  0132  0152  0202  0222  0232  0252  0302 
East        arr   0102  0122  0132  0152  0202  0222  0232  0252  0302  0322  0332 
East/2      dep   0120  0140  0150  0210  0220  0240  0250  0310  0320  0340  0350 
Southwest   arr   0150  0210  0220  0240  0250  0310  0320  0340  0350  0410  0420 
Southwest/1 dep   0202  0217  0232  0247  0302  0317  0332  0347  0402  0417  0432 
North       arr   0232  0247  0302  0317  0332  0347  0402  0417  0432  0447  0502 
North/1     dep   0245  0300  0315  0330  0345  0400  0415  0430  0445  0500  0515 

                3001  3002  3003  3004
--------------------------------------
Northwest dep   0007  0037  0107  0137 
East      arr   0042  0112  0142  0212 
East      dep   0110  0140  0210  0240 
Northwest arr   0145  0215  0245  0315 
Northwest dep   0207  0237  0307  0337 

1000: Number of vehicles: 11
3000: Number of vehicles: 4
---------------------------------------
Total number of vehicles: 15

Note that this network requires 1 vehicle more than the original one. If you are a public transportation undertaking, you may not see the value (for you) of the increased cost. But the passengers on the east- west route get a better interval.

Feel free to have a go at reducing the number of vehicles by 1, by tweaking the parameters.

The Super Combo(s)

An alternative is to split route 1 and 2 in two, and operate them separately. Then we can add route 3 to one of them, reducing the number of vehicles (as route 3 has a liberal amount of layover time).

You may have seen this approach before, with routes 12 and 28 of the Lisboa tram network.

File: intervals/complicated.def
## Networkplanner ##

route set 1  file:01.def interval:30 down:17
route set 2  file:02.def interval:30 down:7  up:10
route set 3  file:03.def interval:30 down:22 up:20
route set 1a file:01.def interval:30 down:2  up:15
route set 2a file:02.def interval:30 down:17

tp :tabulated :merge[1;1a] :merge[2;2a] Central

vehicles vehicles-complicated.def

The support for multiple «:merge» arguments was added in v.0.0.3.

File: intervals/vehicles-complicated.def
=1000
1a U North/1;North          10
2a D Southwest/2;Southwest  2
2a U East/2;East            10
1a D Southwest/1;Southwest  2

=3000
1 U North/1;North          10
2 D Southwest/2;Southwest  2
3 U East/3;East            10
3 D Northwest/3;Northwest  10
2 U East/2;East            10
1 D Southwest/1;Southwest  2

The output:

Central [A]
07 -- 27 37 -- 57 | 2 East
-- 17 -- -- 47 -- | 3 East

Central [B]
-- 10 20 -- 40 50 | 2 Southwest
00 -- -- 30 -- -- | 3 Northwest

Central [C]
07 22 37 52 | 1 North

Central [D]
10 25 40 55 | 1 Southwest

                  1001  1002  1003  1004  1005
----------------------------------------------
North/1     dep   0015  0045  0115  0145  0215 
Southwest   arr   0045  0115  0145  0215  0245 
Southwest/2 dep   0047  0117  0147  0217  0247 
East        arr   0117  0147  0217  0247  0317 
East/2      dep   0130  0200  0230  0300  0330 
Southwest   arr   0200  0230  0300  0330  0400 
Southwest/1 dep   0202  0232  0302  0332  0402 
North       arr   0232  0302  0332  0402  0432 
North/1     dep   0245  0315  0345  0415  0445 

                  3001  3002  3003  3004  3005  3006  3007  3008  3009
----------------------------------------------------------------------
North/1     dep   0000  0030  0100  0130  0200  0230  0300  0330  0400 
Southwest   arr   0030  0100  0130  0200  0230  0300  0330  0400  0430 
Southwest/2 dep   0037  0107  0137  0207  0237  0307  0337  0407  0437 
East        arr   0107  0137  0207  0237  0307  0337  0407  0437  0507 
East/3      dep   0120  0150  0220  0250  0320  0350  0420  0450  0520 
Northwest   arr   0155  0225  0255  0325  0355  0425  0455  0525  0555 
Northwest/3 dep   0222  0252  0322  0352  0422  0452  0522  0552  0622 
East        arr   0257  0327  0357  0427  0457  0527  0557  0627  0657 
East/2      dep   0310  0340  0410  0440  0510  0540  0610  0640  0710 
Southwest   arr   0340  0410  0440  0510  0540  0610  0640  0710  0740 
Southwest/1 dep   0347  0417  0447  0517  0547  0617  0647  0717  0747 
North       arr   0417  0447  0517  0547  0617  0647  0717  0747  0817 
North/1     dep   0430  0500  0530  0600  0630  0700  0730  0800  0830 

1000: Number of vehicles: 5
3000: Number of vehicles: 9
---------------------------------------
Total number of vehicles: 14

It may look impressive (and indeed it was quite a job to get it right), but the result is network that is a nightmare to operate. Whenever something happens (as e.g. a derailment at Northwest on route 3), all three routes will be affected. The result, from a passenger perspective, will be delayed and/or missing departures on the entire network.

Multiple Intervals

You can set up the intervals in any way you want, but routes (directions of them) that are combined with a «vehicles» command must have the same interval. If you have multiple intervals, the mean value of all of them in the same series must be the same. (I.e. the same number of departures within the timeframe; whether it is one hour or more.)

File: intervals/complicated-error.setup
## Networkplanner ##

route set 1  file:01.def interval:30 down:17
route set 2  file:02.def interval:30 down:7  up:10
route set 3  file:03.def interval:20 down:22 up:20
route set 1a file:01.def interval:30 down:2  up:15
route set 2a file:02.def interval:30 down:17

tp :tabulated :merge[1;1a] :merge[2;2a] Central

vehicles vehicles-complicated.def

The result, with an error message instead of the 3000-series:

Central [A]
07 27 37 -- 57 | 2 East
07 27 -- 47 -- | 3 East

Central [B]
10 20 -- 40 50 | 2 Southwest
10 -- 30 -- 50 | 3 Northwest

Central [C]
07 22 37 52 | 1 North

Central [D]
10 25 40 55 | 1 Southwest

The sections do not have the same accumulated intervals

                  1001  1002  1003  1004  1005
----------------------------------------------
North/1     dep   0015  0045  0115  0145  0215 
Southwest   arr   0045  0115  0145  0215  0245 
Southwest/2 dep   0047  0117  0147  0217  0247 
East        arr   0117  0147  0217  0247  0317 
East/2      dep   0130  0200  0230  0300  0330 
Southwest   arr   0200  0230  0300  0330  0400 
Southwest/1 dep   0202  0232  0302  0332  0402 
North       arr   0232  0302  0332  0402  0432 
North/1     dep   0245  0315  0345  0415  0445 

1000: Number of vehicles: 5
---------------------------------------
Total number of vehicles: 5

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