# A subway network

# Station definitions, each ending with a blank line.  Each station
# name is followed by a list of platforms in that station.  Station
# names and platform names cannot be identical!
#
# The station and platform names must be defined before anything else.

station StGeorge    stgE

station Bay         bayE bayW

station Yonge       yongeE yongeW bloorN

station Sherbourne  sherE sherW

station CastleFrank frankE frankW

station Broadview   broadW

station Rosedale    roseS

# The track consists of section, each of which can be occupied by at
# most one train.  We first define the main lines.  Each line is a
# sequence of (x,y) ident (x,y) ident (x,y) ... where '(x,y)' is the
# position of a section endpont and 'ident' is the identifier of a
# section of track between two endpoints.  
#
# If you don't care to identify a section, call it 'x'.  
#
# Each platform must be given the platform identifier from the station
# definition (above).  A platform section should be 170 metres long.
#
# Each main line definition starts with 'main' and ends with a blank line.
# The main lines must appear immediately after the stations in this
# configuration file.

main # eastbound Bloor-Danforth 
(-1085,-10) stgE (-915,-10) x (-895,-20) x (-885,-40) x (-885,-100) x
(-875,-120) x (-855,-130) x (-810,-130) x (-790,-120) x (-780,-100) x
(-780,-40) x (-770,-20) x (-750,-10) x (-700,-10) x (-650,-60) x
(-600,-60) bayE (-400,-10) x (-200,-10) x (20,-10) yongeE (190,-10) x
(250,-10) x (400,-50) x (500,-50) sherE (670,-50) x (800,-40) x
(950,-20) x (1100,-20) frankE (1270,-20) x (1400,-20) x (1600,-20) sw2
(1950,-20)

main # westbound Bloor-Danforth 
(2170,10) broadW (2000,10) x (1950,0) x (1600,0) x (1400,0) x (1270,0)
frankW (1100,0) x (950,0) x (800,-20) x (670,-30) sherW (500,-30) x
(400,-30) x (250,10) x (190,10) yongeW (20,10) x (-200,10) x (-400,10)
bayW (-600,10) sw1 (-865,10)

main # northbound Yonge
(0,60) bloorN (0,230) x (0,250) sw4 (0,830)

main # southbound Yonge
(-20,1030) roseS (-20,850) x (-20,830) sw3 (-20,250)


# Sections of track, called switches, may be placed between different
# main lines.  Each point on a main line may have only one switch
# attached to it!  If you need more, add more sections to the main
# line.  
#
# Each switch definition starts with the word 'switch', followed by a
# switch name, followed by two attachment points, and ends with a
# blank line.  Each attachment point is on one end of another track
# section, which is named.  If the switch is attached to the rear of
# the other section, this is indicated with `rear'.  Otherwise it is
# attached to the front of the other section, which is indicated with
# `front'.  Front and rear are according to the ordering along the
# main line.
#
# All main lines must be defined before any switches are defined.
#
# Example:  switch thisSwitchName stgE front sw4 front
#
#                stgW <- x <- sw1 <-
#                           /
#                      -----
#                     /     
#                stgE -> x -> x ->

switch crossToStgE stgE front sw1 front

switch crossToBroadW broadW front sw2 front

switch crossToBloorN sw3 front bloorN front

switch crossToRoseS sw4 front roseS front

# A passenger arrives at a source station, intending to travel to a
# destination station.  For each possible (source,destination) pair,
# we must provide (1) the departure platform in the source station,
# (2) the mean interarrival time at the source of persons who want to go to
# that destination, and (3) if the person must transfer before getting
# to the destination, the name of the station at which they must
# transfer.  
#
# Three arrays describe this information.  Each array ends with a
# blank line.  Each row of an array corresponds to a source station,
# in the order given above under 'stations' above.  Similarly, each
# column corresonds to a destination station, in the same order.  The
# row and column stations are shown in comments below:

# (1) array of platforms (row=source, column=destination)

platforms
  .           stgE        stgE        stgE        stgE        stgE        stgE       # StGeorge
  bayW        .           bayE        bayE        bayE        bayE        bayE       # Bay
  yongeW      yongeW      .           yongeE      yongeE      yongeE      bloorN     # Yonge
  sherW       sherW       sherW       .           sherE       sherE       sherW      # Sherbourne
  frankW      frankW      frankW      frankW      .           frankE      frankW     # CastleFrank
  broadW      broadW      broadW      broadW      broadW      .           broadW     # Broadview
  roseS       roseS       roseS       roseS       roseS       roseS       .          # Rosedale

# StGeorge    Bay         Yonge       Sherbourne  CastleFrank Broadview   Rosedale


# (2) array of mean interarrival times, in minutes.  '0' means 'never'.

arrivals
  0           1           0.3         1           2           1           0          # StGeorge
  1.5         0           0.1         5           5           2           4          # Bay
  0.05        0.1         0           0.3         0.1         0.1         0.5        # Yonge
  1           1           0.5         0           5           3           0          # Sherbourne
  2           1.4         1           5           0           2           4          # CastleFrank
  1           0.7         0.2         3           3           0           0          # Broadview
  1           0.1         1           1           1           1           0          # Rosedale

# StGeorge    Bay         Yonge       Sherbourne  CastleFrank Broadview   Rosedale


# (3) array of transfer stations ('.' means no transfer)

transfers
  .           .           .           .           .           .           Yonge      # StGeorge
  .           .           .           .           .           .           Yonge      # Bay
  .           .           .           .           .           .           .          # Yonge
  .           .           .           .           .           .           Yonge      # Sherbourne
  .           .           .           .           .           .           Yonge      # CastleFrank
  .           .           .           .           .           .           Yonge      # Broadview
  Yonge       Yonge       .           Yonge       Yonge       Yonge       .          # Rosedale

# StGeorge    Bay         Yonge       Sherbourne  CastleFrank Broadview   Rosedale

# A train has a cycle of stations that it visits.  In this cycle can
# appear the word 'reverse', which causes the train to reverse
# direction and switch to the main line in the other direction.  Also,
# a switch name can appear, in which case the train takes the switch
# when it is reached.  The first item after 'train' is the platform at
# which the train starts.

train
stgE
Bay Yonge Sherbourne CastleFrank crossToBroadW Broadview reverse
CastleFrank Sherbourne Yonge Bay crossToStgE StGeorge reverse

train
broadW
CastleFrank Sherbourne Yonge Bay crossToStgE StGeorge reverse
Bay Yonge Sherbourne CastleFrank crossToBroadW Broadview reverse

train
bloorN
crossToRoseS Rosedale reverse
crossToBloorN Yonge reverse
