# A Heuristic Approach to Solving the Train Traffic Re-Scheduling Problem in Real Time
## Appendix A  
The MIP formulation is based on the model developed by [PERSON] and [PERSON] (2007). The model was implemented in Java and solved by Gurobi 6.5.1. Let \(J\) be the set of trains, \(M\) the set of segments, defining the rail infrastructure, and \(O\) the set of events. An event can be seen as a time slot request by a train for a specific segment. The index \(j\) is associated with a specific train service, and index \(m\) with a specific infrastructure segment, and \(i\) with the event. An event is connected both to an infrastructure segment and a train. The sets \(O_{j}\subseteq O\) are ordered sets of events for each train \(j\), while \(O^{m}\subseteq O\) are ordered sets of events for each segment \(m\). Each event has a point of origin, \(m_{j,i}\), which is used for determining a change in the direction of traffic on a specific track. Further, for each event, there is a scheduled start time and an end time, denoted by \(b_{j,i}^{\mathit{initial}}\) and \(e_{j,i}^{\mathit{initial}}\), which are given by the initial timetable. The disturbance is modelled using parameters \(b_{j,i}^{\mathit{static}}\) and \(e_{j,i}^{\mathit{static}}\), denoting the pre-assigned start and end time of the already active event. There are two types of segments, modeling the infrastructure between stations and within stations. Each segment \(m\) has a number of parallel tracks, indicated by the sets \(M_{m}\) and each track requires a separation in time between its events (one train leaving the track and the next enters the same track). The minimum time separation between trains on a segment is denoted by \(\Delta_{m}^{\mathit{Meting}}\) for trains that travel in opposite directions, and \(\Delta_{m}^{\mathit{Following}}\) for trains that follow each other; the separation is only required if the trains use the same track on that specific segment. The parameter \(ps_{j,i}\) indicates if event \(i\) includes a planned stop at the associated segment (i.e., it is then normally a station). The parameter \(d_{j,i}\) represents the minimum running time, pre-computed from the initial schedule, if event \(i\) occurs on a line segment between stations. For station segments, \(d_{j,i}\) corresponds to the minimum dwell time of commercial stops, where transfers may be scheduled. The variables in the model are either binary or continuous. The continuous variables describe the timing of the events and the delay, and the binary variables describe the discrete decisions to take on the model concerning the selection of a track on segments with multiple tracks or platforms, and the order of trains that want to occupy the same track and/or platform. The continuous, non-negative, variables are \(x_{j,i}^{begin}\), \(x_{j,i}^{end}\), and \(z_{j,i}\) (delay of the event \(i,i\in O\), exceeding \(\upmu\) time units, which is set to three minutes here). The variables \(x_{j,i}^{end}\) and \(x_{j,i}^{begin}\) are modelling the resource allocation, where a resource is a specific track segment. The arrival time at a specific segment is given by \(x_{j,i}^{begin}\) and departure from a specific segment is given by \(x_{j,i}^{end}\) for a specific train. The binary variables are defined as:  
\[q_{j,i,u}=\left\{ \begin{array}{l}1,\text{if event $i$ uses track $u$, $i\in O^{m}$, $u\in M_{m},m\in M,j\in J$}\\ 0,\text{otherwise}\end{array} \right.\]  
\[\gamma_{j,i,j,i},t_{i}=\left\{ \begin{array}{l}1,\text{if event $i$ occurs before event $i^{\prime}$, $i\in O^{m}$, $m\in M:i<i^{\prime}$,$j$ and $jt\in J$}\\ 0,\text{otherwise}\end{array} \right.\]  
\[\lambda_{j,i,j,i},t_{i}=\left\{ \begin{array}{l}1,\text{if event $i$ is rescheduled to occur after event $i^{\prime},i\in O^{m}$, $m\in M:i<i^{\prime}$,$j$ and $jt\in J$}\\ 0,\text{otherwise}\end{array}