Discrete Event Simulation of Bus Terminals: A Modular Approach with a High Spatial Resolution

Interchange stations with their many connecting modes and lines are central for a high-quality public transport system. Bus access at the station needs to operate reliably and efficiently in order to prevent congestion and queues. To this end, a conceptual simulation model for evaluation of bus terminal operations is presented in this paper. It is based on discrete event simulation and able to describe the detailed movements and interactions that occur between vehicles at larger terminals. emodel has a modular approach, where common spatial sections at terminals are represented bymodules that can be easily combined intomany different terminal layouts. An implementation of the model is presented and, as a first sensitivity test, applied in a numerical experiment representing Norrköping interchange station in Sweden. e results indicate that the model can be a useful tool in planning processes.


Introduction
A high-quality public transport system is becoming increasingly important for cities all over the world hoping to reduce the pollution and congestion caused by car traffic. All parts of such a system need to be well-functioning, and, in particular, its transfer nodes and interchange stations need to have a reliable and efficient operation without introducing unnecessary delays into the system. ese nodes and stations have a high impact on the system as a whole since they connect the various lines and modes of the system, facilitate transfers and make it possible to achieve a high degree of connectivity within a city or a region. While this is important, it is also a vulnerability. Delays originating at a station may propagate through the system due to the many intersecting lines, reducing both punctuality and reliability.
ere is also the fact that while transfers between lines are important to the connectivity and quality of the system, travellers tend to dislike them. It has been shown repeatedly that the time spent in transfer is perceived as significantly less comfortable than in-vehicle time, see [1].
An important factor for a reliable and punctual service that facilitates fast transfers is the capacity of the bus terminal, here defined as an area separated from other motorized traffic modes that has two or more bus stops. e capacity is the amount of vehicles that can use the terminal without causing excessive congestion and queues. Too low capacity results in delays and an unreliable service. In practice, terminals are not always planned with sufficient capacity. is is the case in many metropolitan regions, such as the Stockholm region in Sweden [2]. Insufficient capacity can be due to an increase in traffic volumes over time but also a result of the common requirement of compact terminals that do not occupy large areas. Besides the bus terminal, there are typically also train platforms, waiting areas, and commercial facilities competing for the limited space. Compact terminals with short walking distances are also in the interest of the travellers since this reduces the time spent in transfer.
In order to evaluate the trade-off between capacity and size and plan for efficient terminals, good evaluation methods are needed. Terminal design guidelines and capacity handbooks, such as the Public Transport Interchange Design Guidelines [3], the Geometric Design Guide for Transit Facilities on Highways and Streets [4], and the Transit Capacity and Quality of Service Manual [5], give analytic capacity formulas for individual bus stops and small stations as well as approximate estimates on the number of stops needed at a terminal. ese methods are less suitable for larger terminals with their many interactions between vehicles and between the vehicles and the system. Many of these interactions may also vary from time to time in a way that can be difficult to capture with an analytical model. is argument is also put forward by Al-Mudhaffar et al. [2], who state that deterministic methods can only be used for very simple cases and not for larger bus terminals. In this paper, we propose a discrete event simulation model for terminal capacity analysis. With a simulation approach, various situations can be tested, and the many interactions and statistical variations of the system captured. A bus terminal simulation model can be used to test and compare various solutions in the planning processes. is can be invaluable in projects where there is a big risk of congestion and many factors to consider. In the rebuilding project of Slussen in central Stockholm, for instance, the new bus terminal is only one part of the bigger project with limited space available. e old terminal was congested, and simulation studies are absolutely necessary to ensure the functionality of this new terminal. Simulation studies require large amounts of data, however, a common drawback of such models. For bus terminals, this is less of a problem nowadays due to the increasing use of automatic data gathering technologies within public transport, such as automatic vehicle location, automatic passenger counting, and automated fare collection systems.
Discrete event simulation makes use of the fact that a bus terminal can be described based on a set of clearly defined events, for example, driving to a stop and dwelling, together with their interdependencies. In many bus terminals, vehicles can be expected to follow the rules and regulations and have predictable interactions, which makes discrete event simulation a suitable approach. It has previously been tested on a small system consisting of a combined bus and tram stop [6]. Previous terminal simulation studies either use models with an event-based approach or a time-based one, where the time-based models typically use existing traffic simulation software. e traffic simulation programs focus on road traffic and vehicle interactions such as car-following and lane-changing. is focus makes them difficult to use at bus terminals with their specific properties and behaviour, such as scheduling of lines, blocking, and queuing, and interactions between vehicles at the terminal. e limitations have been discussed by Kramer [7] and Askerud and Wall [8]. Previous event-based models, on the other hand, typically model terminals explicitly. To our knowledge, there is no such model that include interactions between vehicles in such a way that queues and congestion can be properly captured, however. ese models also tend to be formulated for a specific bus terminal, rather than having a more general approach.
In this paper, a conceptual bus terminal simulation model is formulated, implemented in a simulation environment and demonstrated in a real-world example as an initial test of the modelling approach. e objective of the study is to develop a flexible discrete event microsimulation model describing vehicle movements and interactions at bus terminals of various kinds. e model should be able to evaluate a wide range of terminal designs and traffic scenarios by having a modular approach where modules representing spatial parts of a terminal can be combined into various constellations. e focus of the model should be on the vehicles, their movements, and when and where blocking between vehicles takes place. e latter is an important requirement for an accurate representation of congestion since queues may block the access to stops and various sections of the terminal. e contribution of the study is the development and implementation of a bus terminal simulation model meeting these requirements. e rest of this paper is organised as follows. Section 2 presents the background and previous work within the field of bus terminal simulation. e conceptual model is presented in detail in Section 3-5 and its implementation in Section 6. It is followed by a presentation of the case study in Section 7 and the results of the case study in Section 8. Conclusions and future work conclude the paper in Section 9.

Simulation of Bus Terminals
In this section, studies into terminal and stop simulation are presented and key components of the applied models identified. Each of the identified components is then discussed and gaps in the previous models presented.

Simulation Studies of Terminals and Stops.
Previously proposed models of bus terminals vary in size and modelling approach. Seriani and Fernández use a time-based approach and existing traffic simulation software both for traffic and pedestrian simulation [9]. e software is used to evaluate pedestrian traffic management measures at a new type of two stop bus rapid transit bus station. Another approach can be found in [10,11], who both use an event-based stop simulation model, which was first presented in [12]. Fernández et al. integrate the model with an existing, time-based traffic simulation software and apply it to several cases, including a ten-stop interchange station partly integrated with road traffic [10]. A smaller three-stop bus terminal is studied by Adhvaryu, who investigates ways to improve the terminal by comparing three layout alternatives [11]. Liang and Wang develop their own event-based model of a five-stop terminal in order to optimize the bus dispatch scheme [13]. An eventbased model is also developed by Figueras Jové and Casanovas-García as they analyse the operations of a system consisting of shuttle buses connecting a cruise terminal to an intermobility centre where passengers transfer to taxis [14]. e results include the number of needed bus stops for the suggested design.
Simulation of single bus stops is closely related to terminal simulation. Such stops are generally integrated or in close proximity to the road traffic and lack the interactions associated with having several stops gathered in a terminal. Stop simulation models range from smaller dedicated models to models of larger systems. Some focus on improving stop modelling in a road traffic simulation model [15]; others simulate larger public transport systems [16,17] or focus on modelling the stop itself [18,19].
A number of components used in terminal simulation can be identified from the presented studies. Both stop and terminal models typically calculate a dwell time based on the number of alighting and boarding passengers and some include simulation of the passengers and the surrounding road traffic. While none of the terminal articles goes into details of the modelling of bus arrivals, this is another component needed for terminal simulation. Interactions between the buses are included to varying degrees, while the routing of vehicles through the terminal is included at some level in all terminal simulation studies.

Terminal Modelling Components.
Dwell-time modelling has been an ongoing field of research for decades due to its impact on the average speed of the vehicles and the travel time of the passengers. e dwell time depends on a number of factors, the most important being the number of passengers boarding and alighting. Various functions can be formulated with varying functional forms and number of factors included. Common varieties are linear in form and include the number of boarding and alighting passengers together with constants specifying the number of doors, time per boarding or alighting, and the dead time, which is the time needed for opening and closing of doors and other activities not dependent on the number of passengers [9,20]. Some studies include more factors or use more complex functional forms [18,21].
Modelling of passengers in terminal and stop simulation can be included with various degree of detail, from pedestrian simulation [9], to versions where passengers are simply represented as numbers that are to board/alight. e latter can be found from probability distributions describing either the number of passengers for each departure or the arrival of passengers [18].
Surrounding traffic can also be modelled in various degree of detail, from the detailed descriptions in microscopic traffic simulation software to simple probability distributions at entries and exits.
Vehicle arrivals need to be modelled if the simulation is delimited to the terminal itself.
is can be included in various ways depending on the system that is to be modelled. For high-frequency bus lines, modelling of arrivals may be based on the headways between arrivals [22], while for lines with lower frequency or irregular headways, a timetable based approach may be more appropriate [23].
Vehicle interactions are important to capture since congestion and queues can cause delays. To our understanding, only the stop and terminal simulation studies that use traffic simulation software include driving activities with a sufficient spatial resolution and in that way capture congestion and queueing throughout the systems. e vehicle interactions at a terminal differ from road traffic, however, with other priority rules that need to be properly captured.
Routing of vehicles through the system is needed for all models and increases in complexity for larger terminals. is can be challenging when using traffic simulation models since rules and behaviour at the terminal differ from road traffic. Examples from the terminal simulation studies of terminal specific routing include routing vehicles to different stops and selecting between routes depending on whether or not a stop is occupied.

Deficiencies in Previously Proposed
Models. As has been presented in this section, many of the components needed for terminal simulation have been studied previously. ere is, however, a need to improve the modelling of interactions between vehicles. When generic traffic simulation models have been used in the context of bus terminals, these interactions follow the rules of ordinary road traffic. Terminals are significantly different from road systems, however, with different behaviour and rules related to routing and vehicle priority. Generic traffic simulation models can also be quite complex with functionality and parameters that may not be relevant to terminal simulation.
is can make adaptations and analyses of results unnecessarily difficult. A dedicated terminal simulation model can include vehicle interactions, while at the same time reduce the complexity in relation to a traffic simulation model by focusing on the aspects important for terminals. To our knowledge, proper modelling of vehicle interactions and the resulting queues and congestion are not included in any previous dedicated terminal simulation model.
Another observation is the fact that dedicated terminal simulation models typically model a specific terminal. is makes it difficult to adapt the models to other terminals. To our knowledge, no previous study incorporates the concept of modules presented in this paper. Having such an approach allows the model to be easily applied to various terminal designs.

Conceptual Model
In this section, a conceptual model for generic bus terminals is presented. e basic structure of the model consists of a set of modules, where each module represents a physical section of a bus terminal, and a set of functions used to calculate the time a vehicle spends in various parts of a terminal. e modular structure makes it possible to adapt the model to various bus terminals and layouts. Figure 1 shows the path of one vehicle through the modules of the model. e various parts of the figure will be explained in the coming sections, after giving a more overview description within this section.
Journal of Advanced Transportation is includes presentations of the modelling approach, the events, and network description that form the basis of the modules, the modular approach itself, and some details of the modelling of the driving and vehicle interactions.

Modelling Approach and Delimitations.
e simulation model presented in this paper is based on discrete event simulation. In this approach, the state of a system is updated at discrete points in time as an event occurs (see [24] for an introduction to discrete event simulation).
is can be contrasted to the time-based approach common in road traffic simulation where the system is updated with fixed time intervals (see [25] for a presentation of this simulation approach). e model is discrete not only in time but also in space and divides a terminal into cells.
ese are small enough for a vehicle to occupy several cells simultaneously. By keeping track of the occupation of the cells, interactions in the form of vehicles blocking each other can be modelled and included. is makes it possible to get a sufficient spatial resolution to capture congestion. e modelled system is delimited to the terminal itself and the vehicles at the terminal. While outside road traffic at entrances and exits is not included, passengers are included indirectly by affecting dwell times as well as waiting times at pedestrian crossings. With the focus of the model being on queues and blockages between vehicles, several simplifications are made in respect to acceleration behaviour and differences between vehicles. All vehicles are assumed to be driving at the same constant speed and having the same minimum time distance to any vehicle driving in front. e cell length puts restraints on all lengths of a terminal, as well as the length of vehicles, which all need to be an integer number of cells.
In the following subsections, a network description of a terminal will first be presented together with the events associated with a terminal. is is followed by a presentation of the modular approach of the model.

Events and Network Representation.
A bus passing through a terminal will experience a number of events and activities. First, there is the event of arriving at the terminal, then the one of starting to drive to some new position, followed by the arrival to this position. Each of these is instant event that change the state of the system. In between events, there may be activities associated with a time duration, such as driving to the new position in the previous example. In an event-based description, these activities do not change the state of the system. Using this description of events and activities, a terminal can be represented by a network where the nodes are associated with events changing the state of the system, while the arcs represent the activities and thus have a time duration. A small example network is given in Figure 2. One node may be associated with several events, and all events are related to a particular position at the terminal (e.g., where a vehicle starts to drive into a stop).
In order to formulate a terminal model using the presented network description, the various events and activities of a terminal need to be defined. e activities of the model are driving through the cells of the terminal, dwelling at a stop, waiting at a pedestrian crossing, and waiting at an exit. Added to the listed activities is the event of a vehicle arriving at the terminal. For each of these, a function can be formulated that can calculate the time duration of each process, and in the case of arrivals, the time between vehicle arrival events. ese calculations can vary from simple probability distributions to more complex calculations that take many factors into regard. All functions proposed in this study will be discussed in more detail in Section 4.

Modular Approach.
As described in the previous section, a terminal simulation model can be described by a set of events. In this subsection, the organization of events into modules is presented. By formulating a set of modules that can be combined in numerous ways, diverse terminals can be modelled and simulated. is idea is based on the terminal property of repeating sections. In general, a terminal will consist of a limited number of sections repeated throughout the terminal, such as a particular type of stop or a driving section. is property can be incorporated by constructing modules based on common sections that may be present at terminals.
Here, four types of modules have been identified; entry, exit, driving section, and stop, where each type of stop needs a separate module. Each module is associated with a set of events and activities. A terminal entry, for example, has a set of vehicle generation related events and is considered a single point where the vehicles arrive at the terminal. A stop, on the other hand, will have an extension in space and events related to dwell time and entering and leaving the stop. Figure 3 shows how one module, in this case a simplified driving module, relates to the cells of a terminal and to the network description (the full driving module is presented in Section 5.3). e modules can be combined in various ways in order to simulate a range of layouts and terminals. An example flow chart of a terminal with four stops constructed from these modules can be seen in Figure 4, and the general path of one vehicle through the modules of a terminal could be seen in Figure 1. e four types of modules and the main events and activities associated with them are shown in Figure 5. Each module will be presented in more detail in Section 5.
When a module initializes an event, the time of the event or the duration of the associated activity is needed. ese can be found from the functions presented in Section 3.2. e connections between the various modules and the functions can be seen in Figure 1.

Driving and Vehicle Interactions.
As presented previously, a terminal can be constructed from the proposed modules. Vehicles are routed from event to event through the networks of the modules as point particles. Interactions between vehicles can only occur when a vehicle is driving (or trying to, but blocked) and thus only during the driving activity. For this reason, all vehicle interactions can be modelled in the driving-time function and included by affecting the driving times of the vehicles. e modelling is based on the idea that interactions can be included by storing cell occupation time windows. Each cell in a driving section can either be occupied by a vehicle or free at any point in time. Various vehicle interactions can be modelled by checking which cells are occupied by other vehicles. When a vehicle is to drive through a specific cell, its occupation time interval is stored, so that other vehicles can react to it at a later stage. is is presented in more detail in Section 4.2.
In the cell-based modelling approach presented, one driving activity would in general correspond to driving through one cell. In order to have generalizable modules where the length of driving sections can vary, this is simplified so that the cells of a driving section without any branching are combined into one driving activity. To get the driving time, the current state of each cell of the section is checked and the time needed to wait on blocking vehicles and drive through the cells is calculated. Only the state of the first cell can be known to stay fixed during the combined activity, however, since all information needed to calculate the driving times through later cells are not yet known. When reaching cells further ahead, the situation may have changed (e.g., a vehicle in front may have stopped). If the initially calculated time of the activity is incorrect, this is updated and adjusted after the activity has finished. Figure 6 shows a network description of the two activities representing driving through a section. First, a nominal driving activity is initiated based on the initial state. is is followed by an additional driving activity which is iterated until there is no need for further adjustments. e additional activity is made possible by continuously keeping track of any vehicle's effect on neighbouring vehicles and the associated extra waiting times of these. e additional driving-time activity is iterated until there is no stored extra waiting time.

Time of Events and Activity Duration Functions
In this section, the functions of the conceptual model calculating time duration of activities and time between events are presented.

Vehicle Generation Function.
e vehicle generation function calculates the intergeneration time between vehicle arrivals. is can be done in various ways depending on the Journal of Advanced Transportation system that is to be modelled. For high-frequency bus lines, a headway probability distribution might be appropriate, for example, the Poisson distribution. For lines with lower frequencies, the arrival time is instead related to the timetable. To include the variability inherent to the process, a probability distribution can be added. e intergeneration time between vehicle k − 1 and k then becomes where t timetable_arr k is the planned arrival time for vehicle k, t actual_arr k−1 is the simulated arrival time of the previous vehicle, and a is a parameter used to allow for negative adjustment of the departure time if the distribution does not allow for negative values (e.g., the lognormal and gamma   Journal of Advanced Transportation distributions). X gen is a random variable with, for instance, a lognormal, gamma, or normal distribution.

Driving-Time Function.
e driving-time function calculates the driving time through (parts of ) a module. e interactions and time calculations differ for different types of driving activities. ese activities are driving through the section (drive through each cell of the module when they are unoccupied), driving into a stop (drive to the stop and enter when it is free), dwelling at a stop, driving out from a stop (drive through the cells adjacent to the stop with any need to wait on passing vehicles taken into account), and driving through a junction (drive through when the junction and the road on the other side are unoccupied). e two main tasks of the driving-time function are to calculate the driving time and to keep track of the occupation of cells. By storing occupation time windows for both cells and stops together with vehicle ID and length and using this to check which ones are occupied by other vehicles, various vehicle interactions can be modelled. As a vehicle is to drive through a section, the state of each cell is checked, any need to wait is determined, and occupation time windows is calculated. is may include checking more cells than the one the vehicle is about to enter in order to determine priority between vehicles. e occupation time window of a cell corresponds to the time from the arrival of the front of a vehicle to the departure of its rear end.
When calculating the arrival and departure times from a cell, two assumptions are made. First, any need to wait in cells further ahead is not included. is means that if the vehicle does need to wait further ahead, the departure time of all cells it presently occupies needs to be updated. Second, since the driving times through all cells of the section are calculated at once, the future state of all cells is assumed to be known when arriving at the first one (this was previously discussed in Section 3.4). When a vehicle stops, any following vehicles may be affected and need to stop too. When this happens, their departure times and arrival times to cells they have not yet arrived at are updated. is extra waiting time is also stored so that it can be retrieved by the followers after they have finished their current activity. e presented methodology for calculating the driving time through the cells of a section is summarized in Algorithm 1.
After having determined the arrival and departure times from all cells, the total driving time through the section can be calculated.

Dwell-Time Function.
e dwell-time function calculates the time needed for boarding and alighting processes. As previously discussed in Section 2, dwell time can be modelled in various ways with increasing complexity. Here, a version with a set of simple linear functions is presented.
is is similar to other linear models, such as in [9], the difference being how the doors of the vehicle are used. ere are three variants of the dwell-time function depending on whether the bus is to let passengers alight, board, or both. Boarding passengers are assumed to only use the door in the front, while alighting passengers are assumed to spread evenly over the rest (a minimum of two doors are required). If the bus is only letting passengers alight, the dwell time between node i and j can be calculated from  where t 0 is the dead time, a constant that captures the time a vehicle is dwelling at a stop without letting passengers board or alight (including opening and closing of the doors), t alight is the time per alighting passenger, n alight is the number of alighting passengers, and n doors is the number of doors. e dwell time for a bus only letting passengers board is where t to_dep is the time until the planned departure time, t board is the time per boarding passenger, and n board is the number of boarding passengers. If both boarding and alighting are to take place, the dwell time is Needed for the dwell-time calculations are the number of boarding or alighting passengers, n board/alight . is can be found from an appropriate probability distribution.
An alternative to calculating the dwell time from functions such as the ones presented is to use a probability distribution. is can be appropriate in cases when the data required for dwell-time functions is lacking but data for distribution parameter estimation are available.

Waiting Time Functions.
ere are two waiting time functions, delay at an exit and at a pedestrian crossing. ese can be modelled in various ways depending on the system, for instance, whether there is a traffic signal or not. Here, modelling of one version of a pedestrian crossing and two versions of exits will be presented.
For an unsignalized pedestrian crossing or exit, the need to wait first needs to be determined. One way is to simply assign a probability p for needing to wait. If it is needed, this is followed by a calculation of the waiting time, which can be modelled with a probability distribution. e waiting time then becomes where T d ij is the waiting time, either at a pedestrian crossing, d � wait_ped, or at an unsignalized exit, d � wait_unsign_exit, and X d is a random variable with, for instance, a normal, lognormal, or gamma distribution.
Another alternative exit is one controlled by a vehicle actuated traffic signal, where the signal is red until a vehicle is detected. ere will always be a waiting time at such traffic signals, unless a vehicle arrives when it has just been activated by another vehicle.
is waiting time can also be modelled with a probability distribution.

Modules of the Model
In this section, the four modules of the conceptual model are presented. A wide range of designs can conveniently be constructed by arranging and connecting these modules. e modules and their network description are, to a degree, straightforward to implement in a discrete event simulation software.

Entry Module.
e entry module handles arrivals of vehicles to the terminal. Here, buses can be generated iteratively with intergeneration times found from the vehicle generation function (Section 4.1). A network representation of the entry module can be seen in the left part of Figure 7. It has one single node where vehicles are generated before being forwarded to the next module.

Exit Module.
e exit module handles departures of vehicles from the terminal. e module includes a short stretch of driving and a vehicle may need to wait on a traffic light or outside traffic. e driving time can be retrieved from the driving-time function (Section 4.2) and the waiting time from the waiting time at exit function (Section 4.4). e right part of Figure 7 shows a network representation of the exit module.
ere are two nodes, one that initiates the combined activity of waiting at the exit and driving, and one that removes the vehicle.

Driving Section Module.
A driving section module represents a stretch of the terminal roadway without any branching and merging within the section (this is instead modelled by combining driving sections). ere are three versions of this module for slightly varying situations; a general driving module, the first driving section module after vehicle generation, and a junction module. e general module allows for a pedestrian crossing in the beginning of the road stretch. e first driving section module needs to be able to handle vehicles arriving from generation when the road ahead is blocked. A junction can be used whenever driving paths cross each other. is is modelled with one module for each combination of origin and destination in the junction. Figure 8 shows network representations of the three versions of the driving section module. In the general module, vehicles may need to wait on pedestrians before driving through the section. ese two activities are merged into one activity (possible since there is no decision point in between). e time of the activities are given by the driving time and the waiting time at pedestrian crossing functions (Sections 4.2 and 4.4). At the end of the activity, at node j, there may be a need to adjust the initially calculated nominal driving time, as discussed previously in Section 3.4. e other two driving section modules are similar to the general module. ey do not allow for pedestrian crossings, but both can have other waiting times. e first driving section module after generation starts with a queue where vehicles waits if the road into the terminal is not clear. e junction module starts with an iterative waiting activity until the junction is free. Vehicles are assumed not to enter the junction if another vehicle is already driving through it or if the vehicle will need to stop in the middle of the crossing due to a vehicle standing still on the other side. Since the waiting time depends on the state of cells, this is calculated in the driving-time function. Another important behavioural aspect for driving sections, both for junctions and for merging of two driving section modules, is the question of priority. For simplicity, vehicles are here assumed to follow a first arrival drive first principle.

Stop Module for Independent Linear Bus Stop with Adjacent Driving Lane.
A stop module represents one stop at the terminal together with adjacent roadways. Different stop layouts need to be modelled differently, and the presented module represents two very similar types of stops. ese have either a linear or a sawtooth design and consist of one berth with an adjacent driving lane, possibly with a pedestrian crossing before the stop, see Figure 9 for the linear type. e stop operates independently, meaning that a vehicle wanting to enter or leave the stop can do so even if there is an occupied stop in the front or in the back. e module includes the stop itself, the adjacent driving lane, and the driving section before the stop (for a row of stops this will be the driving section between stops).
A network representation of the stop module can be seen in Figure 10. At node i, which corresponds to the left border of the rectangle in Figure 9, the vehicle may need to wait on a pedestrian crossing and then either drives past the stop or to the front of the stop. At node j, there is a possibility to (iteratively) adjust the time of the initial driving-time calculation if this was too short (as previously described in Section 3.4). A dwell-time activity then initiates at k, corresponding to the front of the stop, followed by a new driving activity at l as the vehicle drives out from the stop. At m, there is, again, a possibility to adjust the driving-time calculation. ese adjustments finish at n, corresponding to the right border of the rectangle in Figure 9 e behaviour of the buses and their drivers will have an effect on the events of the module. A number of assumptions are made, based on qualitative terminal observations and reasonable assumptions. First, if a vehicle is to enter a stop that is already occupied, it will wait behind the bus in the stop and block the way for any bus wanting to drive past. Second, a bus entering a stop will be completely out of the driving lane when the back of the vehicle enters the stop. ird, a vehicle will not let passengers board and alight while waiting to enter an already occupied stop. Fourth, when there is a conflict between a bus wanting to leave a stop and another bus wanting to drive past, the passing bus will drive first if its front is parallel with the stop; otherwise, the bus in the stop will drive first. All of these vehicle interactions are handled when calculating the driving times in the drivingtime function.

Model Implementation
In this section, details of the model implementation and how the model can be adapted to various systems will be presented.

Modules, Functions, and Routing.
e model has been implemented in SimEvents, a discrete event simulation engine and component library developed by MathWorks [26]. In the implementation, the modules are constructed from components in the SimEvents component library, and the functions consist of MATLAB functions accessible from the SimEvents model. e implemented modules closely follow the presented network descriptions of each module, together with various logical components. ese are used for vehicle routing through the system. A vehicle carries a set of parameters and variables that can be used for routing purposes.

Parameters.
Parameters of the implemented model can be divided into three categories, local module parameters, global parameters accessible to all modules and functions, and vehicle-specific parameters.
Local module parameters are kept to a minimum in order to keep the modules general. ese include module identification number, module variant (if there are different versions of the module), and parameters specifying how the module is situated in relation to other modules and routing parameters (e.g., which lines are to use a stop). Most parameters specifying a module are instead global parameters accessible through the module identification number.
Global parameters include cell length, dwell-time parameters (e.g., time per boarding and alighting passenger), parameters controlling driving behaviour (e.g., vehicle speed and minimum time gap between vehicles), planning parameters (e.g., line numbers and timetable), distribution parameters for time calculations, relations between modules parameters, and module length parameters.
Vehicle-specific parameters are associated with vehicles at generation through the vehicle generation function. ese include vehicle parameters (e.g., length and type), planning parameters (e.g., line number and individual timetable), dwell-time-related parameters (e.g., number of doors and board or alight), and routing parameters (e.g., if the vehicle will use a layover area and which exit to use). Added to the vehicle-specific parameters is a set of variables that are used for statistics (e.g., the driving delay of a vehicle) and routing (e.g., where a vehicle should be going next). Saving statistics is handled by the exit module at vehicle termination.

Time Calculations.
e time duration of activities can be calculated in various ways, as presented in Sections 4.1-4.4. Some of these alternatives have been implemented in the model. When selecting the probability distributions to implement, the lognormal distribution has in most cases been selected due to being a well-known distribution with a right tail. e various modelled time durations can be expected to have such a tail with most measurements centred around a value and with some outliers representing extraordinary delays. e lognormal distribution has, for instance, been used for arrival delay [23] and dwell time [27]. In the absence of an asymmetric right tail, the normal distribution can often be a good choice. e choices of distributions are discussed in relation to empirical measurements in Section 7.  (1), is modelled with a lognormal distribution with parameters μ gen and σ gen : is distribution has been used, for instance, by Rietveld et al., who showed that the lognormal distribution had the best fit to their data of interurban bus arrivals of the tested distributions [23].
Two versions of dwell-time modelling have been implemented, the linear equations presented in equations (2)-(4) and a simpler alternative in the form of a lognormal distribution with parameters μ DT and σ DT : e waiting time at a pedestrian crossing is implemented with a probability of having to wait and a distribution modelling the waiting time, as in equation (5). e implemented distribution is the lognormal distribution with parameters μ wait_ped and σ wait_ped : e waiting time at an exit has two versions implemented, an unsignalized exit and a vehicle actuated traffic signal. e unsignalized exit is modelled in the same way as the pedestrian crossing with a probability to wait and a lognormal distribution for the waiting time with parameters μ wait_unsign_exit and σ wait_unsign_exit : e vehicle actuated traffic signal is implemented with a lognormal probability distribution and parameters μ wait_sign_exit and σ wait_sign_exit : e number of boarding and alighting passengers is modelled with two normal distributions, rounded up to the nearest integer, with parameters μ boarding , σ boarding , μ aligting , and σ aligting : n aligting � ⌈X aligting ⌉, X aligting ∼ N μ aligting , σ aligting 2 . (11b)

Adapting the Model.
e basic idea of the presented model is to be as general as possible in order to be easily adaptable to various terminals. e modules make it possible to construct and evaluate various systems, timetables, and traffic planning. Here, the steps taken to adapt the model to a specific system will be presented. First, the system needs to be studied to identify the modules needed and how to order them. e modules are then added to an adapted simulation model and numbered, and, when there are alternatives, variants are selected. e modules are also connected to each other and their order and connections are described as global parameters in order to be accessible to the functions. Added is also a number of logical components that handles vehicle routing. ese are modified as needed for the vehicles to be routed to the right positions. A switch could, for instance, send a vehicle with the exit parameter equal to 1 in one direction and one with exit parameter equal to 2 in another direction. e presented functions are also added and for those with alternative modelling, one approach is selected.
Added to the routing and variant parameters, all other parameters presented in Section 6.2 need to be set. Terminal dimensions and planning and vehicle parameters may be known to operators or public transport authorities. e dwell time and behaviour parameters are typically not known; however, distribution parameters can be estimated from empirical data, if such is available (e.g., the arrival delay can be estimated from empirical measurements of arrival times together with the planned arrival times).
Depending on the terminal, the modelled modules and functions may be insufficient to describe the system. ere may be other types of stops or other priority rules, for instance. In these cases, new modules or variants of modules need to be constructed. Due to the modular approach, these can easily be added to the model.

Case Study
e model is tested and evaluated in a case study of the bus terminal at Norrköping interchange station in Sweden. A number of scenarios are simulated and evaluated for the afternoon peak period between 3 and 5 pm. In this section, the bus terminal of the case study will be presented, followed by details of the model implementation, the performance measures, and the data used.

Norrköping Bus Terminal.
Norrköping interchange station is a multimodal station with over 6000 boarding passengers each day and expected increases in demand over the coming years. e bus terminal of the station consists of 18 bus stops (14 in use during normal operations) and is used by several types of bus lines, both regional and long-distance. e stops are arranged in three rows with six sawtooth bus stops each (Figure 11). On the south-east side there is a combined entry and exit connected to a roundabout and on the south-west side, there is an exit regulated by a vehicle actuated traffic light. Next to the two rows of stops at the top is a driving lane for buses going from east to west. e third row of stops has two adjacent lanes, making it possible to drive in both directions. To the north-east, there is a layover area used when buses need to wait between arrival and departure from the terminal. e lengths of various parts of the terminal are determined by taking measurements of a terminal drawing.

Model Adaptation.
e terminal is modelled with 47 modules: 1 entry module, 2 exit modules, 18 stop modules, and 26 driving section modules, including two sets of junction modules used on the east side of the terminal were many routes intersect. Since observations of the terminal have made it obvious that there are very few interactions between pedestrians and vehicles, no pedestrian crossings are included. is means that pedestrians are assumed to cross when no vehicle will be affected. e layover area is considered to be outside of the terminal and is modelled as a simple waiting time activity. Routing of vehicles is based on the line number of the vehicle (each stop associated with one or more line number), the time between arrival and new departure (for layover operations) and which exit to use. e cell size is set to 1 meter. e rest of the parameters and the data used to estimate them will be presented in the following sections.

Performance Measures Used in the Case Study.
ere are a great variety of public transport performance measures used by the many service providers throughout the world. A guidebook for developing a transit performance-measurement system [28] presents a huge number of measures within a large number of categories. Several of these relate to bus stops, bus terminals, and operation of the buses, including capacity of individual bus stops and reliability related measures such as the on-time performance (punctuality) and the headway regularity. Punctuality and regularity have also been pointed out by other studies as the relevant time reliability metrics of bus stops [29]. In this case study, we use the average deviation from the planned departure time in the timetable, the lateness, to represent the punctuality. is shows the effects of delays and congestion on the passengers. e metric does not only depend on the situation on the terminal but also on delays originating outside of the terminal. Since it is defined as the lateness at departure from the stop, it does not include any delays occurring as vehicles leave the terminal. e lateness is calculated based on the simulated departure time from the stop, t actual_dep_stop k , and the planned departure time, t For bus terminals, it is also of interest to know how the functioning of the terminal itself is affecting the vehicles. Two more performance measures are used to this regard. e first is the driving delay, the time spent waiting at blocking vehicles. Near or over capacity, one can expect more time spent waiting in this way for each individual vehicle.
is measure does not include delay at arrival, layover time, or lateness in relation to the timetable and thus indicates how well the terminal itself is functioning. For a total of m vehicles, the average driving delay is where T driving_delay k,q is the driving delay of vehicle k for each situation it has been delayed (waiting in a queue or on a blocking vehicle), denominated as q.
e third performance measure is the terminal time, which is the time from arrival to departure from the terminal. It includes both delays, planned processes, and planned waiting times. It can, together with the other two metrics, give a deeper understanding of the functioning of the terminal. e average terminal time is calculated based on the arrival time to the terminal entry, t

Timetables, Vehicles, and Vehicle Arrivals.
Timetables for spring 2018 are used in the case study. ese include 21 regional lines with up to six arrivals and departures to the terminal during the time period, between 3 and 5 pm. Additional arrivals and departures are also used during a 30 minutes warm-up period before 3 pm. e arrival times are used in equation (1) for assigning values to t timetable_arr,k . Each line always uses the same stop, both for alighting and boarding, as well as the same exit. Most of the lines have the terminal as the start or end of their route and a vehicle arriving as one line may depart as another one. e time between arrival and departure varies and vehicles with longer waiting times drive to the layover area in order to not occupy a stop. In accordance with regulations, these vehicles need to drive back to the departure stop five minutes before departure. For this reason, the time limit for when the layover area is used is set to 6 minutes until the departure time.
Four different bus types stop at the terminal, one of these being a double-decker bus. e buses are of low-floor type and have lengths between 12 and 15 meters and two doors. Boarding is only allowed at the front door and alighting at the back door, except for the double-decker bus where both processes are allowed at both doors. Aside from the regional bus lines, there are also a total of 13 long-distance departures. ese do not use the layover area. No empirical data have been available for the long-distance lines, and for this reason, these are assumed to behave as the regional ones. eir lengths are assumed to be 15 meters. For the regional lines, data of vehicle arrivals for a period of close to five weeks during January and February 2018 have been received fromÖstgötatrafiken, the regional public transport authority responsible for Norrköping. is data give the arrival time to the stop and have been adjusted to the terminal entry by using the distances between stops and entry and the same speed as the one used in the simulations. Incomplete data points were removed, together with arrivals registered incorrectly (not registered until the time of their new departure).
is leaves 1188 measurements with an average arrival time of 0.63 minutes before the planned arrival time. Using the gathered data and the maximum likelihood method, the parameters of the lognormal probability distribution, see equation (6), was then estimated.
is distribution was a good candidate since plots of the data had a similar form with a right tail. e same distribution was used for all lines. In the estimation, all values were shifted to positive values (needed for the lognormal distribution) and not too close to 0 (forces a rapid increase of the lognormal distribution which gives a bad fit to the data). We calculate this shift, a, from where the first term shifts the data so that the smallest value, t smallest_meas_arr , is moved to 0. e second term shifts the measurements further from 0 based on the difference of the largest measurement, t largest_meas_arr , and the smallest together with a scaling factor. e parameter values are given in Table 1.

Dwell-Time-Related Data.
e dwell time is calculated using the linear formulas in equations (2)-(4) and the normal distribution for the number of boarding and alighting passengers. e parameters needed include the normal probability distribution parameters, the time per boarding passenger, t board , the time per alighting passenger, t alight , and the deadtime, t 0 . Here, dwell-time function parameters from Tirachini are used [21]. Boarding time per passenger is set to 4.6 s, alighting time to 1.3 s, and dead time to 5.2 s. is corresponds to a low-floor bus, payment using a magnetic strip prepaid card at the front door and alighting at the back door. e same values are used for all bus types, including the double-decker.
For the estimation of the number of boarding passenger distribution parameters, registered smart card passenger boardings have been available for a period of almost six weeks with a total of 1392 measurements. e average number of boardings per departure was calculated for each line and a normal probability distribution was estimated using the maximum likelihood method (Table 1). While the number of boarding passengers is discrete, the general form of the distribution is appropriate. e number of boardings is simulated using the same distribution for all lines. is distribution is expected to slightly underestimate real values since boarding passengers can pay not only by smart card but also with a credit and a mobile app. e boarding data are thus incomplete, but since boardings during the period in question largely consist of commuters, smart card is expected to be the most common means of payment. As for alighting passengers, no data were available and the same estimated distribution as for boarding passengers was used as a simple approximation.

Exits and Driving Parameters.
Delays at the two exits of the terminal are controlled by probability distributions. At the west exit, with a vehicle actuated signal, vehicles always need to wait until the signal changes unless they have been waiting in a queue at the exit. is is usually only a short delay, but sometimes vehicles experience longer delays due to congestion on the road outside of the terminal. When this happens, the signal only lets one vehicle through at a time and queuing vehicles get more delay at the signal. e congested situation is not included in the base scenario but in a separate one (Section 8.2). Both these situations are modelled with the lognormal distribution in equation (10) with parameters estimated from empirical measurements at the west exit during two time periods (two days). Plots of the data have a tail to the right, making the lognormal distribution suitable. e maximum likelihood method was used in the estimation. For the uncongested case, the smallest values come too close to 0 for a good fit. A small shift of the measurements is for this reason used. At the east exit, with a roundabout, vehicles will not always need to wait. Both the likelihood of having to wait, p, and the parameters of the probability distribution for the waiting time in equation (5) need to be estimated. Empirical measurements of one time period have been carried out for this purpose. Again, plots show a right tail and the lognormal distribution is used. e parameter estimation is based on the maximum likelihood method. e probability of having to wait is 37.5%, and all exit delay distribution parameters can be found in Table 1.
e driving parameters are the speed of the vehicles and the minimum time gap between vehicles. e former is set to a value suggested by a practitioner, 5.6 m/s, and the latter is taken from measurements of stop-and-go road traffic in Neubert et al. and set to 1.8 s [30].

Results
A number of scenarios have been simulated as a first test of the model and how it can be used to evaluate the operations of a terminal. e first scenario investigates a possible future where there is an increase in the number of passengers. In the second scenario, the effect of increased traffic at the south-west exit is investigated by increasing the exit delay. In the last scenario, the bus lines have been reallocated in order to use fewer stops. is investigates the effect of reducing the size of the terminal. All scenarios have been simulated with 100 replications, where each of these has between 46 and 55 observations (i.e., vehicles leaving the terminal).

Increased Number of Passengers.
In this scenario, the effect of an increase in the number of passengers is simulated. e expected values of the normal distributions determining the number of boarding and alighting passengers are increased to four and ten times the current number of passengers (from 10.7 to 42.8 and 107). e terminal in question has few departures in relation to its size and large increases in demand are expected to have little effect on its operation. e results for driving delay, lateness, and terminal time are shown in Table 2 in the form of averages of the results from individual iterations of the simulation with 95% confidence intervals. e driving delay is almost identical to the base case at four times the number of passengers and higher at ten times the number. Increased dwell times thus result in more and longer driving delay. e driving delay can be set in relation to the total time vehicles spend on the terminal, the terminal time. It is evident from Table 2 that the effect on this metric is smaller when increasing the number of passengers. e terminal time includes planned layover time (the average time between arrival and departure is 12 minutes). Neither the driving delay nor the terminal time tells anything of a vehicle's lateness at departure, which instead is given by the third metric. As expected, increased dwell times result in more lateness, almost twice as high for four times the number of passengers and over seven times as high for ten times as many. ese values do not include any blockages occurring between the stop and the terminal exit. e presented results indicate that the number of passengers can be greatly increased, at least four times the present number, with very little effect on the vehicles. It should be pointed out, however, that an increase in the number of passengers may also affect pedestrian crossings. Here, it has been assumed that the passengers still only cross the roads when no vehicle needs to wait, as in the base case. If the vehicles need to wait on crossing pedestrians, all three metrics would likely increase.

Longer Delay at the South-West Exit.
e situation with outside congestion at the south-west exit is examined in this scenario.
e parameters of the probability distribution controlling delay at this exit are estimated from a congested situation instead of an uncongested one (Table 1). is will affect not only vehicles that are to use this exit but may also affect other vehicles. If more than one vehicle is waiting on the exit, the return lane used to get to the other exit, the layover area, and to return to another stop will be blocked.
e results for driving delay, lateness, and terminal time are shown in Table 3. Again, in the form of averages of the results from individual iterations of the simulation with 95% confidence intervals, the average driving delay has increased substantially, even though it does not include the delay at the exit. While the terminal time includes the delay at the exit, it is still only slightly increased. e lateness is almost not affected by the situation at the exit at all. All of this means that a queue is indeed forming at the exit at times, blocking vehicles that need to drive past to return to the other side.
is delay is still small enough, however, to be absorbed into the layover time before departure and much smaller than the terminal time.

Reallocation of Lines to Stops.
In this last scenario, the lines have been allocated differently to the stops in order to reduce the number of stops needed. Out of the 18 stops, 14 are used in the base case (see the solid squares in Figure 11). In the reallocation scenario, a number of these have been merged without introducing conflicts (if the vehicles would arrive and depart according to the planned times).
is results in only 9 stops being used (see the dark grey filled squares in Figure 11). e reduction in the number of stops is expected to worsen the situation, but this may not necessarily be the case since the departures per stop are still relatively few. e results for this scenario can be seen in Table 4 in the form of averages of the individual iterations with 95% confidence intervals. e average driving delay is almost the same and so is the average time spent at the terminal and the deviation from the timetable at departure.
is indicates that the Norrköping terminal is greatly overdimensioned in relation to the current amount of traffic at the terminal and could operate sufficiently with much fewer stops.

Discussion of the Discrete Event Approach.
A number of lessons can be learnt from the modelling process and the case study. e discrete event modelling approach has been well-suited to capture the important events of a terminal and their connections to physical locations. is forms a good basis to construct terminal modules. e modules themselves have proven a useful and flexible way to model a terminal. ey form a good basis to add upon as modelling of new terminal sections or behaviour is needed.
A disadvantage with the discrete event approach is the non-straightforward way to handle the spatially distributed vehicle interactions that can occur at any point at the terminal. e approach presented here, with cells that are either free or occupied, has been able to capture such interactions with a resolution dependant on the size of the cells. is makes it possible to adjust the resolution to the adaptation and the modelled layout. Driving through the cells of a section was merged into one activity in order to let the number of cells be easily changeable and in that way facilitate modularity (Sections 3.4 and 4.2). Since this relies on future states of the system, it results in a need to continuously update the driving times. is process is complex to implement and slows down simulations. Alternative ways to model the driving activity without relying on future states, but still retain the modularity and capture the vehicle interactions, can be of interest to explore further. e case study has shown that the approach is promising for evaluations and comparisons of terminals and scenarios. Validation studies of the model are needed, however, in order to test how accurate it can represent reality. For such a study, a more congested terminal than the Norrköping bus terminal is needed. An important aspect to take into consideration is the often limited amount of empirical data available for terminals and if this is sufficient for calibration and validation of the model. is is investigated in Lindberg et al. [31].

Conclusions
In this study, a conceptual discrete event simulation model of bus terminals has been formulated and implemented. A modular structure allows for easy adaptations to various terminal layouts, which was demonstrated in a numerical experiment. e model was able to capture blockages and queues by modelling spatially distributed vehicle interactions. is has, to our knowledge, not been included in previous event-based terminal simulation models. A set of performance measures are also formulated, which were used to analyse different aspects of the performance of the case terminal. Driving delay showed the time spent blocked or queuing, terminal time showed the full time through the terminal, including driving times and planned waiting times, and lateness at departure showed the effects on the individual vehicles. e numerical experiment verified that the important events on a terminal could be simulated. It also demonstrated the potential of the modelling approach where various scenarios could be compared and analysed. is could be very useful in planning processes of new terminals or redesign of existing ones. e modelling approach was also analysed where some important lessons learned include the straightforward way to model events and structure these into modules and the challenge to model the vehicle interactions and blockages that can occur at any point at the terminal.
Future work includes validation of the model using data for a more congested case terminal as well as case studies of both new terminals and exiting ones. An open question is if data gathered from automatic data sources are enough for model calibration and validation or if manual measurements are needed. e model can also be extended to include more performance measures and types of stops, as well as other dwell-time formulas and probability distributions for vehicle arrivals. ere are several ways the model can be further developed, including introducing heterogeneous vehicle movements where vehicles can differ in their speed or distance to a leading vehicle. Of interest is also to study how to plan the allocation of lines to stops at the terminal.
Data Availability e bus terminal planning and empirical data used in the numerical example of this study are available from the corresponding author upon request.

Disclosure
A previous version of this paper was presented at the 14th International Conference on Advanced Systems in Public Transport (CASPT 2018) [32].

Conflicts of Interest
e authors declare that there are no conflicts of interest regarding the publication of this paper.