Headway
The Headway plugin contains a snippet and a script template to calculate the headway.
Headway
Headway is the distance or duration between vehicles in a transit system measured in space or time.
The calculation is done by simulating two trains that run on the same section, and by varying the intermediate departure time at the origin and calculating the arrival delay to the destination of the second train. The delay is calculated relative to the theoretical minimum time, ignoring possible margins, and considering only the minimum stopping time.
Quick start
- Install or enable the Headway plugin.
- Right-click the icon of a Scripted Simulation project, New, Other..., Headway script.
- Customize the script.
trainortrain1andtrain2: train number, or train number pairs of the trains to be simulated. In the first case, the train will be duplicated, with a-bissuffix.fromStationandtoStation: beginning and end of the section for which to calculate the headway. All the trains must run on the same section on the same line.initialHeadwayMin,initialHeadwayMaxandinitialHeadwayStep: initial, final and increment values for the iterative calculation of the best headway.RollingStock,TimetableandMicro: the projects used for the simulation.- In the default slot, you can configure other characteristics of the script. advanced
- Execute the simulation.
- During the simulation, the script draws the results on two charts: the first one shows the section exit headway related to the variation of the section entrance headway, the second one shows the number of conflicts of the second train related to the variation of the section entrance headway. Two annotations denote the first point for which the delay fo the second train is zero and the first point for which the second train does not encounter any conflict.
Here is an example:
snippet('lib/Headway',
// snippet configuration
rollingStock: 'RollingStock',
timetable:'Timetable',
micro: 'Micro2019',
// trains
train1: '745',
train2: '601',
// reference section
fromStation: 'OSL',
toStation: 'SV',
// initial headway
initialHeadwayMin: 0,
initialHeadwayMax: 300,
initialHeadwayStep: 1
) {
// script log file
withLog()
}
Tutorials
Batch calculation
In batch calculation, it is possible to simulate many combinations of train pairs and to produce a headwaySummary.csv output file that shows, for each train pair, the first value of initial headway for which the second train does not have any delays.
The snippet to be used in this case is HeadwayBatch; you can get started from the script seen in the Quick start or you can create a new script with the Headway script (Batch mode) script template.
Instead of pointing out the first and second train, you must use a list with all the numbers of the involved trains.The snippet will create all the possible train pairs.
snippet('lib/HeadwayBatch',
// snippet configuration
rollingStock: 'RollingStock',
timetable:'Timetable',
micro: 'Micro2019',
// trains
trains: ['601', '745'],
// reference section
fromStation: 'OSL',
toStation: 'SV',
// initial headway
initialHeadwayMin: 0,
initialHeadwayMax: 300,
initialHeadwayStep: 1
) {
// fork()
// script log file
withLog()
}
Batch calculation from file
If instead of testing all the combinations of the trains on a section, you want to calculate the headway of specific pairs of trains on various sections, you can use the HeadwayBatchFile snippet which can load the configuration from a CSV file. The file must have a header line with the following columns: train1, train2, fromStation, toStation.
The snippet produces an output file which the best initial headway for each line of the input file. In case a pair of trains is impossible to simulate, or the simulation produces an error, instead of the minimum headway a dash is written.
The initial headway configuration is common to all the simulations, thus suitable values must be found for all the sections. It is possible to start from a very high range with a step of 15 seconds, to have an initial idea of how variable the initial headway can be, and later reduce the range and use a smaller step in order to have more accurate values.
snippet('lib/HeadwayBatchFile',
// snippet configuration
rollingStock: 'RollingStock',
timetable:'Timetable',
micro: 'Micro2019',
// input file
inputFile: 'Headway.csv',
// initial headway
initialHeadwayMin: 15,
initialHeadwayMax: 300,
initialHeadwayStep: 5
) {
// fork()
// script log file
withLog()
}
Input
| train1 | train2 | fromStation | toStation |
|---|---|---|---|
| 601 | 601 | OSL | SV |
| 601 | 745 | OSL | SV |
| 745 | 601 | OSL | SV |
| 745 | 745 | OSL | SV |
| 601 | 601 | SV | ASR |
| 601 | 745 | SV | ASR |
| 745 | 601 | SV | ASR |
| 745 | 745 | SV | ASR |
| 601 | 601 | ASR | DRM |
| 601 | 745 | ASR | DRM |
| 745 | 601 | ASR | DRM |
| 745 | 745 | ASR | DRM |
Output
| train1 | train2 | fromStation | toStation | headwayNoDelay | conflictsNoDelay | headwayNoConflicts | conflicts | trainset1 | trainset 2 | | ------ | ------ | ----------- | --------- | ------- | --------- | | 601 | 601@1 | OSL | SV | 105 | 11 | | 601 | 745 | OSL | SV | 120 | 7 | | 745 | 601 | OSL | SV | 170 | 2 | | 745 | 745@1 | OSL | SV | 170 | 1 | | 601 | 601@1 | SV | ASR | - | - | | 601 | 745 | SV | ASR | - | - | | 745 | 601 | SV | ASR | - | - | | 745 | 745@1 | SV | ASR | 130 | 5 | | 601 | 601@1 | ASR | DRM | 175 | 3 | | 601 | 745 | ASR | DRM | 15 | 4 | | 745 | 601 | ASR | DRM | 110 | 4 | | 745 | 745@1 | ASR | DRM | 145 | 6 |