## 2 The Bus Synchronization Problem
### Mathematical Formulation
#### Variables
In the pursuit of increasing the number of possible transfers, it becomes necessary to schedule a greater number of trips of the bus lines, thereby escalating the overall system cost. Conversely, opting for a more reduced cost of the system by scheduling only a limited number of trips may lead to challenges in effectively synchronizing successful transfers. Regarding Constraints, Constraint (3) enforces \(z_{rsb}^{hg}\) to take value 0 whenever passengers should wait longer than \(\mathit{Tol}_{b}^{hg}\) at transfer zone \(b\in B\) before the next trip of bus line \(g\in H\) arrives (i.e., when a successful transfer is not achieved). \(\mathit{BigM}\) is a sufficiently large value to prevent the right-hand side from becoming negative. Constraint (4) forces \(z_{rsb}^{hg}\) to be 0 if passengersfrom trip \(r\in R^{h}\) of line \(h\in H\) do not have enough time to walk to the subsequent bus stop at zone \(b\in B\) to board the \(s\in R^{g}\) of line \(g\in H\). Constraint (5) calculates the auxiliary variable \(a_{rb}^{h}\), which indicates the arrival time of trip \(r\in R^{h}\) of bus line \(h\in H\) to transfer zone \(b\in B\), adding the travel time to the zone to the departure time. The characterization of synchronization events with \(z_{rsb}^{hg}\) variables deserves further elaboration. Figure 2 shows a hypothetical synchronization attempt, where a passenger on the \(r\)-th bus on line \(h\) alights at some stop with the intention of boarding the next bus on line \(g\). Let us assume that the picture spans the entire transfer zone \(b\), that is, there are only two stops involved. The time at which this passenger arrives at the first stop is \(a_{rb}^{h}=x_{r}^{h}+TT_{b}^{h}\): the result of adding the departure time of the bus \(r\) (\(x_{r}^{h}\)) with the travel time \(TT_{b}^{h}\) is necessary for that bus to move from the departure station until transshipment zone \(b\). In the example above, the boarding stop is different from the first, so the passenger has to walk to the other stop to catch the next bus, which requires a walking time \(Wd_{b}^{hg}\). Those situations where both stops are one (i.e., there is no need to walk) can be modeled by setting \(Wd_{b}^{hg}=0\). Once the passenger arrives at the bus stop for line \(g\), they take the following bus, namely the \(s\)-th bus of that line, which arrives at time \(a_{sb}^{g}=x_{s}^{g}+TT_{b}^{g}\). Both arrival times are computed by means of constraint (5). Observe that in Equation (1), since variables \(z_{rsb}^{hg}\) are factors multiplying positive values (\(0<Hd_{h}^{min}\leq x_{r}^{h}-x_{r-1}^{h}\) because of Equation (11)), the optimization itself is going to push \(z_{rsb}^{hg}\) values upwards, so \(z_{rsb}^{hg}\) are to be \(1\) whenever they allowed for it. When the arrival time \(a_{sb}^{g}\) of bus \(s\) surpasses the time at which the passenger reaches the second stop (\(a_{rb}^{h}+Wd_{b}^{hg}\)), plus the waiting tolerance (\(Tol_{b}^{hg}\)), Equation (3) prohibits \(z_{rsb}^{hg}\) from having a value of \(1\). In addition, the bus \(s\) cannot be taken by the passenger when the bus arrives at the stop (\(a_{sb}^{g}\)) earlier than the passenger itself (\(a_{rb}^{h}+Wd_{b}^{hg}\)), a case that is covered by Equation (4). It is possible yet that more than one bus (\(s_{1}\), \(s_{2}\), etc.) could satisfy Equations (3) and (4). Since the passenger is only to take one bus, constraint (6) sets that the number of transfers between two trips of two bus lines in the same transfer zone cannot be counted more than once. Constraint (7) forces \(a_{r}^{h}\) to be \(1\) when the trip \(r\in R^{h}\) of bus line \(h\in H\) is to be scheduled (within the planning horizon). Only the trips that are scheduled with a departing time within the planning horizon (i.e., less than or equal to \(T\)) are considered valid trips and are counted in the solution.