No-boarding buses: Synchronisation for efficiency

We investigate a no-boarding policy in a system of N buses serving M bus stops in a loop, which is an entrainment mechanism to keep buses synchronised in a reasonably staggered configuration. Buses always allow alighting, but would disallow boarding if certain criteria are met. For an analytically tractable theory, buses move with the same natural speed (applicable to programmable self-driving buses), where the average waiting time experienced by passengers waiting at the bus stop for a bus to arrive can be calculated. The analytical results show that a no-boarding policy can dramatically reduce the average waiting time, as compared to the usual situation without the no-boarding policy. Subsequently, we carry out simulations to verify these theoretical analyses, also extending the simulations to typical human-driven buses with different natural speeds based on real data. Finally, a simple general adaptive algorithm is implemented to dynamically determine when to implement no-boarding in a simulation for a real university shuttle bus service.


Introduction
In many bus systems, bus bunching is a natural repercussion where an initially staggered configuration of buses ends up with multiple buses getting closer to each other [1][2][3][4][5][6]. An intuitive mechanism that explains this phenomenon is that if there is some perturbation in the spacing between buses or the number of people at bus stops waiting to board a bus, then a bus may have to stop a bit longer to pick up people as well as allow people to alight. Consequently, the bus immediately behind catches up and by the time it reaches the bus stop, there may be less people for it to pick up. With less people, it need not stop as long as the bus ahead of it, allowing it to further catch up. Eventually, the leading bus has to pick up the majority of the people (which also increases the required stoppage time for it to allow more people to alight), whilst the trailing bus picks up relatively fewer people. These two buses inevitably end up bunching, due to the positive feedback which tends to slow down the leading bus and speed up the trailing bus. As these two bunched buses move in a single unit, people who just miss this pair would have to wait longer for the next bus (or for this same pair to return, if there are only two buses), compared to the situation where the buses are staggered such that the waiting time would only be a fraction of it. It is therefore undesirable for buses to bunch as it significantly delays passengers by inefficiently increasing their waiting time for a bus to arrive.

Holding back buses, stop-skipping, deadheading
There have been much efforts carried out in attempting to address bus bunching. A common idea is to hold back some buses when bunching is perceived to be imminent, with extensions to adaptive and dynamic controls according to real-time situations [7][8][9][10][11][12][13][14][15][16][17][18][19], although holding back buses generally slows down the entire system. A holding strategy could be executed based on the goal of sticking to a schedule or maintaining the buses' headway.
In contrast to holding buses, some have considered the option of skipping bus stops to speed up a slow bus [14,[20][21][22][23][24], as well as deadheading where an empty bus is dispatched directly to a target bus stop [21,[24][25][26][27]. Deadheading may be theoretically viewed as a special case of stop-skipping [24]. In the stop-skipping strategy, a simple formulation would be to designate a stretch of bus stops to be skipped and passengers who wish to go there would alight at a bus stop just before that stretch. These passengers are forced to wait for another bus, of course, losing priority for seats to those already on board [21,23]. The solution method usually involves numerically optimising some objective function, using nonlinear integer programming for instance. An interesting extension to stop-skipping was investigated by Ref. [23]: A bus would allow passengers who wish to alight at a bus stop (where it would otherwise skip) to do so, and if so it would then also allow boarding at that bus stop. The performance of this policy, however, is quite susceptible to the passenger distribution patterns especially if every bus stop generally has people who would like to visit. Incidentally, some of these studies aimed to optimise both performance improvement for passengers as well as cost reduction for the transit operators [15,22,24].
Alternatively, a study which combined holding and stop-skipping strategies found this to be undesirable as such tight controls may induce poorer performance [28]. Perhaps a worthy way forward is to have buses with wide doors or "no doors" [29][30][31], so that multiple passengers may simultaneously board and alight as compared to queuing through a single narrow entry. However, this would risk other issues like fare evasion. Another possible approach involves city planning where the locations of bus stops along the bus routes are engineered to facilitate efficiency of the bus system [32]. Some other work considered optimising some objective function, involving various algorithms to enhance the bus system [33][34][35], as well as being data driven [36].

Boarding limits: A no-boarding policy
Buses can be sped up by limiting the number of people who are allowed to board the bus [37][38][39], i.e. a no-boarding policy. An initial investigation on trying to speed up a bus by limiting the number of people allowed to board was carried out by Ref. [37], where they combined this with the holding strategy. The performance of the bus system was compared with only the holding strategy and without any form of control. It turns out that the inclusion of boarding limits is beneficial, as observed from their simulations. The setup there comprises buses serving a loop of bus stops, where they start from one terminal and end at that same place after completing the loop. The optimal actions to be taken by a bus when it is at a bus stop are determined by an objective function (solved numerically, subject to a number of constraints) that comprises waiting time of commuters at bus stops, extra time spent on buses due to holding, as well as additional time spent at bus stops when passengers are denied boarding or if capacity limit is reached. All buses are assumed to have identical speed, no overtaking is allowed, and buses are held down at some point along the route, then designated waiting bays must have been planned and allocated beforehand otherwise they would obstruct traffic-something unfeasible in dense city centres which are already short of sought after prime land. A noboarding policy does not require any specific engineering, making it readily applicable in any existing city or landspace. Whilst this idea is similar to skipping bus stops [14,[20][21][22][23][24], it always allows passengers to alight at their desired destinations. Plus, the instruction to the passengers is arguably clearer: "Please do not board." This is direct, compared to the potentially confusing, "We are skipping this, � � �, and that bus stops.".
In this paper, we derive a comprehensive analytical theory of the no-boarding policy which improves upon the work in Ref. [39], as we account for passengers alighting the bus both in our theory and simulations. The aim of the no-boarding policy here is to maintain a reasonably staggered headway between all buses serving a loop of bus stops. Our theory allows us to understand the mechanism of no-boarding leading to stable headway between buses, as well as deriving when such a no-boarding policy would fail or backfire. As was noted in Ref. [38], this would work well for buses with short headway and high demand from their simulations. In fact, we will find this to be true-corroborating with Ref. [38], and are actually able to work out analytically that the no-boarding policy backfires in the lull period defined in Ref. [1], due to buses having different natural speeds. The full mathematical derivation for this critical transition where no-boarding fails is given in Ref. [41]. This paper then concludes with extensive simulations based on parameters measured from a real university campus loop shuttle service, where buses serve a loop of bus stops continually with no start/stop terminal. Live data for those buses can be found on a website that is listed as Additional Information at the end of this paper. In contrast to Refs. [37,38], we allow overtaking in our theoretical analysis and simulations as this is commonly observed in the university shuttle bus loop service [1].

Outline and organisation of this paper
After some preliminaries in the next section, we proceed to investigate how such a no-boarding policy can significantly improve passenger service. To do so, we carry out exact analytical calculations in the case where buses move with identical natural frequency (which is the way forward, when self-driving buses become the norm in the near future [42]) to show that the average waiting time of passengers can be reduced dramatically compared to a system with no such interference policy where all buses end up bunching. This is because the no-boarding policy ensures that the buses are reasonably spaced out and not bunch. In fact, two possible noboarding policies are explored, by looking at the phase difference of a bus from the bus immediately ahead (Section 3) or immediately behind (Section 4). Our analytical results provide clear evidence on the efficacy of this mechanism and how exactly improvement is achieved, even though it may appear a bit simplified under our assumptions.
To illustrate and test our analytical results, we carry out extensive simulations which turn out to agree very well with the analytical results. These simulations also provide further insights into the actual behaviour of the bus system under the no-boarding policy. Apart from that, we apply this no-boarding policy to a simulation of a bus system having M = 12 staggered bus stops in a loop, served by N buses moving with different natural frequencies, in Section 5. This setup is modelled after a university shuttle bus service [1] to see how the no-boarding policy would pan out in a real human-driven bus system, instead of programmable self-driving buses with identical natural frequency. In addition, we describe a simple adaptive algorithm which dynamically determines what angle (phase difference) to implement the no-boarding policy, in a bus system where the rates of people arriving at the various bus stops differ and are stochastic in Section 6. Those real parameters used in our simulations are measured from the university shuttle bus service [1], thereby providing support that our analytical theory's results are indeed applicable to realistic systems with varying demand for service. The simplicity of this adaptive algorithm makes it general enough to be directly implemented in generic bus systems, which can be further improved and fine-tuned towards specific systems especially given prior knowledge and empirical data of the real systems.
A flow diagram in Fig 1 summarises the layout and organisation of this paper.

Preliminary
Consider a bus loop system comprising N buses serving M staggered bus stops around the loop. This loop can be mapped isometrically (preserving distances) to the unit circle. Each bus i, where i 2 {1, . . ., N}, moves with its natural (angular) frequency ω i = 2πf i = 2π/T i . With bus stop j present in the loop, where j . . . {1, . . ., M}, each bus i must spend a stoppage τ ij to let passengers board or alight. We consider the process of boarding new passengers to occur after all passengers on the bus who wish to alight have done so. This is similar to the elevator scenario where new users would only enter the elevator after everyone currently inside (who intends to exit at that level) has completely vacated. Hence, this stoppage τ ij is due to P j ≔ number of people at bus stop j, Q ij ≔ number of people on bus i who are alighting at bus stop j, and l ≔ loading rate of passengers onto the bus which we assume is the same as the unloading rate of passengers off the bus, i.e. τ ij = (P j + Q ij )/l. On average, especially if the M bus stops are equally popular, we have P j * Q ij (i.e. the number of people originating from a bus stop is comparable to the number of people heading to that bus stop) so that τ ij * 2P j /l. However, this is not necessarily true especially during peak hours due to a bias where people from one region (say homes in the morning) tend to head towards another part of the bus route (offices, business district). Incidentally, P j depends on the time headway Δt ij between bus i and the bus immediately ahead (temporal phase difference) together with the average rate of people arriving at bus stop j to wait for a bus, denoted by s j , i.e. P j = s j Δt ij . This implies that the larger the headway between bus i and the bus immediately ahead, the more people it has to pick up and consequently the longer it has to stay at bus stop j-slowing it down even more and further increasing Δt ij . This positive feedback inevitably leads to the perennial and notorious problem of bus

PLOS ONE
bunching which significantly reduces the bus system's efficiency and lengthens the waiting time for passengers. For simplicity of the subsequent analysis to present the key ideas, we first focus on the system of N = 2 buses serving M = 1 bus stop in a loop and the two buses have the same natural (angular) frequency ω = 2πf = 2π/T (this T excludes stoppage at the bus stop). In steady state, we can approximate P j = Q ij giving τ ij = 2P j /l, because there is only one bus stop and every passenger who boards there must alight there after one loop. We should emphasise that P j and Q ij generally fluctuate instead of being equal, but are on average equal over the time scale of several T. In particular, P j = s j Δt ij is true but Q ij depends on Δt ij from the previous time when these people boarded instead of the present Δt ij . This would lead to a recursive relation between Δt ij for this round in terms of Δt ij for the previous round. Nevertheless over several T so that P j * Q ij , we have with k j ≔ s j /l < 1 being parameters that determine the strength of coupling between the buses. This equation would hold in general for any N and M, if we have the condition P j = Q ij to be true. We adopt this assumption in our subsequent theoretical analysis for general N and M to enable a tractable analytical treatment towards gleaning useful insights on the bus system. In that case, we may consider each bus stop as equally popular and so all s j = s, with k ≔ s/l. In our simulations, we find that the steady state results turn out to match with the analytical results thereby justifying the simplification and approximation made here. Later in Section 6, we drop such simplification that all bus stops have the same s j = s in our simulations and find that the key results from the analytical theory carry over to realistic systems based on realworld parameters. The setup here is motivated and modelled from our Nanyang Technological University's (NTU) campus loop shuttle bus service. A bus typically completes a loop within 20 minutes, serving M = 12 reasonably staggered bus stops. (More details in Section 3.2). Bus bunching is a common occurrence for this loop service [1,43]. There is no traffic light on campus, hence work in Ref. [1] found that the primary mechanism for bus bunching in such a system is due to the coupling amongst buses from stopping at bus stops to embark and disembark passengers. There is no start/end terminal, with the buses continuously looping around the route, though buses occasionally pull out and new buses add to the service. The interarrival times between two buses are quite frequent, viz. as short as a couple of minutes during peak hours to about 10 minutes during off-peak hours. Hence, if a bus implements no-boarding, it would cost only several minutes before the next bus arrives.
We assume that there are enough buses going around to meet the demand, such that the finite bus capacity of the buses is not reached. In other words, a passenger is not able to board a bus only because the bus implements no-boarding. Also, it may occur that a passenger is denied boarding by more than one bus consecutively, and the extended waiting time is tracked by the simulations. It turns out that in steady state, the overall average waiting time would be better than normal buses and follows the analytical results derived here.
In future work, one may move on with imposing finite bus capacity, traffic conditions, different loading/unloading rates, and other real-world features of specific bus systems. The effect of traffic conditions would then extend the analysis of how the no-boarding policy would fare in situations where buses may bunch due to uncertainty in arrival times and fluctuations due to traffic congestion. The aim of this paper is to elucidate what a no-boarding policy can do, at least in an idealised situation.
In comparison with other strategies like holding, stop-skipping and deadheading, Refs. [37,38] have shown via their simulations that the inclusion of the no-boarding policy helps improve the performance of the bus system, as compared to only implementing the holding strategy. We further explore the performance of the no-boarding strategy and the holding strategy elsewhere in Ref. [44] using a reinforcement learning approach. In our setup here where every bus stop has people boarding as well as alighting, the idea of stop-skipping would necessarily force a fair amount of passengers to alight at an earlier stop and then board another bus just to complete their journey. This certainly increases their total waiting and travel times, with the inconvenience of getting off and then on a new bus. Besides that, the idea of deadheading implies the dedication of a bus for this purpose which reduces the number of buses serving other bus stops. Since every bus stop has people who need service, there is no benefit from deadheading here. Instead, deadheading would be useful if there is some particular bus stop that serves as a hub, i.e. with significantly higher demand for service compared to other bus stops. This is consistent with other work showing that it is not quite desirable as it has its own problems (see second paragraph of Section 1A). In the bus loop system comprising N = 2 buses serving M = 1 bus stop, suppose the two buses never bunch due to some implemented policy, i.e. their spatial headway or phase differenceΔθ on the unit circle is never equal to 0 or 2π radians, but is maintained to remain within a small range of ideal angles. In such a steady state, both buses must, on average, spend an equal stoppage τ at the bus stop, otherwise one bus systematically stopping shorter than the other would lead to bunching. Therefore, one revolution by each bus takes a time of T + τ, with a total of s(T + τ) people arriving at the bus stop. Each of the two buses picks up half this number of people, over an average time interval of τ/2 (since the other τ/2 is for people to alight) at a rate of l. This gives the relationship: tðk; TÞ ¼ kT The geometric series expansion is valid since k < 1, and looks like a convenient way of expressing � tðkÞ [also for the general case with N buses, cf. Eq (16)]. Here, we have defined � t equals to τ per unit T as a normalisation unit. In other words, when the two buses are in such a steady state where they both spend an equal average stoppage τ at the bus stop, then � t is given by Eq (4), which depends only on k ≔ s/l. The number of people picked up by each bus is then Without any intervention, the two buses cannot remain staggered because such a configuration is unstable. This would be exemplified by systems with the buses moving at different natural frequencies, where frequency detuning leads to periodic bunching during lull periods, otherwise sustained bunching is the outcome during busy periods [1]. To prevent bunching, some form of intervention has to be executed. A way to go would be to implement a no-boarding policy when the phase difference Δθ deviates too much from the staggered configuration. To be precise, if bus i is at bus stop j, then bus i checks its phase difference with respect to the bus immediately ahead, Δθ. (Alternatively, it can check its phase difference with respect to the bus immediately behind, discussed in the next section). Since bus i is stationary at the bus stop, then Δθ is non-decreasing (it can be momentarily unchanging if the bus immediately ahead happens to be at a bus stop, for a system with M > 1 bus stops). If Δθ exceeds some critical angle θ 0 , then according to this no-boarding policy, bus i disallows any further boarding to halt its delay with respect to the bus immediately ahead. Of course, if there are still people on bus i who need to alight, then bus i would wait until they have completely alighted.
3.1.2 Lower bound to θ 0 : θ min . Note that there is a lower bound to θ 0 where no-boarding is implemented if Δθ > θ 0 . This lower bound arises, because if θ 0 is too small, then the buses would too frequently disallow boarding whenever Δθ > θ 0 with the repercussion that they are not picking up people faster than people arriving at the bus stop-leading to an unbounded growth of people at the bus stop waiting for service. We can calculate the lower bound to θ 0 , denoted as θ min as follows. In Fig 2(a) (top panel), bus A implements the no-boarding policy since it sees Δθ = θ min , and leaves the bus stop. Fig 2(b) (top panel) is the moment when bus B just arrives at the bus stop, and the phase difference remains as θ min -strictly speaking, since bus B is now at the bus stop, it is bus B that measures its phase difference with respect to bus A. Shown here is the situation where θ 0 is the lower bound θ min , before the system is picking up people slower than people arriving at the bus stops. Bottom panel: In steady state, the phase difference Δθ(t) fluctuates around the effective angle θ eff , which is bounded by θ 0 (i.e. θ eff < θ 0 ). On average, bus A and bus B would stop over the same duration τ and pick up the same number of people L. Since bus B is lagging due to its large phase difference with respect to bus A, a portion of (1 − π/θ eff ) × 100% of the people waiting for bus B would have to wait longer to board bus A instead, because bus B would have implemented the no-boarding policy when Δθ > θ 0 . Hence if θ eff is closer to π, then fewer people would have to be denied boarding by bus B. A closer-to-antipodal configuration would improve the overall average waiting time, given by Eq (15). Therefore, the phase difference is Δθ = 2π − θ min < π. As bus B remains at the bus stop, bus A advances until in Fig 2(c) (top panel) where Δθ grows to θ min . If the time taken by bus A to go from (b) to (c) is less than τ, then bus B has to implement no-boarding and stop for a duration less than τ given in Eq (3). Consequently, bus B picks up less than L people given in Eq (5)monotonically creating a growing list of disgruntled people waiting for service. This θ min is the critical lower bound such that bus B is able to spend exactly τ to be able to pick up the required L number of people. Since the time interval from (b) to (c) is (2θ min − 2π)/ω (the time taken by bus A to travel) and this equals to τ (the stoppage duration of bus B), we get x min ðkÞ ≔ y min 2p where we have defined x min ≔ θ min /2π being a normalisation unit. We find that this minimum angle depends on k. If demand is higher, then the lower bound to the angle for implementing no-boarding is larger, i.e. the buses should be given greater leeway and duration to actually let people board since there are more people demanding service.

Average waiting time, W.
An important parameter which quantifies the efficiency of a bus system is how long a passenger takes to complete the journey, i.e the total trip time, which includes the waiting time at the bus stop and the time spent on the bus. Without the noboarding intervention, bus bunching is inevitable, and so for the N = 2, M = 1 system, the bunched pair is effectively one large bus with twice the capacity of a single bus and twice the loading/unloading rate. If the system's two buses can "magically" remain antipodally staggered, the average waiting time would be halved. It is easy to see that if an unlucky person barely misses a bus: in the bunched case the waiting time is roughly one full revolution; whereas in the antipodally staggered case it is only about half a revolution.
Note that since the no-boarding policy always allows passengers who wish to alight to do so, it never extends their time spent on the bus. In other words, with the total trip time being the sum of the waiting time at the bus stop and the time spent on the bus, since the latter is unaffected, an improvement on the waiting time at the bus stop directly implies an improvement in the total trip time. This is in contrast to the holding strategy where there is a trade-off between waiting time and time spent on the bus: If a bus is held down, then the time spent on the bus is lengthened for those passengers on the bus.
We can work out the average waiting time more precisely, where people are assumed to be arriving at the bus stop uniformly over time at a fixed rate of s. These people should obey the first-come-first-served rule, i.e. the person who arrived at the bus stop earlier would be ahead on the waiting list to board the bus, after everybody on the bus has alighted. In addition, a bus is assumed to have only one door for one person to alight or board at a time, at a rate of l. This simplifies our calculations for the average waiting time of people at the bus stop for a bus to arrive, as it eliminates the possibility for multiple passengers simultaneously alighting or boarding. With one door, it is clear that the ordering on the waiting list of people is welldefined and a person ahead of the list necessarily gets up the bus first.
When the no-boarding policy is implemented at Δθ > θ 0 , the (so-called "slower") bus at the bus stop disallows further boarding and leaves. Subsequently, the other (so-called "faster") bus would stop at the bus stop and the phase difference approaches the antipodal configuration. After this "faster" bus leaves, the cycle repeats with the "slower" bus stopping and the phase difference widening. The effective phase difference between this pair of buses is θ eff , where the actual phase difference Δθ(t) fluctuates around θ eff over the long term. The implemented angle for no-boarding θ 0 would bound Δθ(t) and so θ eff < θ 0 . Occasionally though, Δθ(t) can exceed θ 0 . This happens when there are still people on the bus who wish to alight and the bus must oblige, even though Δθ(t)>θ 0 . Through numerical simulations (next subsection), we find that θ eff is reasonably represented by the median of the buses' phase difference in steady state.
In the bottom panel of Fig 2, bus B is the "slower" one due to its large phase difference with respect to bus A. As a result, bus B would implement the no-boarding policy when Δθ > θ 0 , and people after that would have to wait further to board bus A. On the other hand, bus A always picks up everybody. To calculate the average waiting time for people at the bus stop before being able to board, we consider the waiting times to board bus A and bus B separately. Since people are assumed to be arriving at the bus stop uniformly over time and one person boards/alights at a time, all we need to do is to identify the luckiest and unluckiest people with respect to each bus, viz. the one who arrives at the bus stop just when the bus is there and about to leave or the last person to be allowed boarding before the no-boarding policy is implemented (hence would experience the shortest waiting time), as well as the one who arrives at the bus stop right after the previous bus had just left the bus stop or was just being denied boarding by the previous bus (hence would experience the longest waiting time). Once we know the waiting times for the luckiest and unluckiest people, the average is just half of the sum of their waiting times. Also as mentioned earlier, in steady state, each bus picks up the same number of people (on average). So bus B, being "slower", would pick up L people (on average), and then implement no-boarding and leave, leaving the rest of the people to wait for bus A-who would also pick up a total of L people (on average). Let us now look at each bus: 1. For waiting to board the "slower" bus B, the unluckiest person is the one who is at the bus stop when bus A just left. Since the effective phase difference is θ eff , this person needs to wait for θ eff /ω = θ eff T/2π before bus B arrives, and a further τ/2 for passengers alighting before this person could board. The so-called luckiest person to board bus B is the last person allowed to board before the no-boarding policy is implemented. This last person would have waited θ eff /ω − (T + τ)/2 for bus B to arrive. This duration is (T + τ)/2 less than the unluckiest person because bus B would pick up half of the total number of people per revolution [which is half of s(T + τ) on average], who would have accumulated at the bus stop over a time period of (T + τ)/2 since bus A had left. After bus B arrives, this person has to wait a further τ/2 for people to alight with another τ/2 for those ahead to board first, before finally boarding, i.e. a total of θ eff T/ 2π − T/2 + τ/2.
(From here, we can see that the person who is just denied boarding by bus B would have waited θ eff /ω − T/2 − τ/2, and then wait for another T − θ eff /ω for bus A to arrive-which is a total of T/2 − τ/2. This will be used below). Hence on average, the waiting time to board bus B is 2. For waiting to board the "faster" bus A, the unluckiest person who was just denied boarding by bus B has to wait a total of T/2 − τ/2 for bus A to eventually arrive (as mentioned above), plus τ/2 for people to alight before this person could board. In contrast, the luckiest person who just arrives when bus A is at the bus stop and about to leave would have zero waiting time. Thus on average, the waiting time to board bus A is Since bus A and bus B pick up, on average, an equal number of passengers each time, the overall average waiting time for this system is Wðx; k; TÞ ¼ In the third line, we normalise the effective phase difference between the two buses by (7)]. Note that Eq (7) implies that whilst the ideal situation is the antipodally staggered configuration where θ eff = π or x = 1/2, the lower bound to implement no-boarding is necessarily deviated due to � t, as the bus has to stop for alighting/boarding. Like � t, we have defined � W as the waiting time per unit T. In conclusion, the no-boarding policy linearly reduces the average time for passengers waiting to board the bus with respect to the effective phase difference between these two buses. The implemented angle θ 0 must be such that the effective angle θ eff is not smaller than θ min in Eq (7) otherwise the bus system is not picking up people at a rate higher than the rate of people demanding service.

Simulations based on real bus loop service data
A recent study on Singapore's Nanyang Technological University's (NTU) campus shuttle bus system comprising N buses serving M = 12 reasonably staggered bus stops in a loop was carried out to investigate the mechanisms of bus bunching [1]. The study reported that these buses typically have different natural speeds, due to different human drivers' driving styles. There are distinctively slow drivers and fast drivers. Their average periods around the loop without stopping are within a range of 12 to 18 minutes, i.e. f i 2 [0.93, 1.39] mHz. Further data analysis on this shuttle bus system found that the ratio of the rate of people arriving at each bus stop to the rate of people loading up the bus, k ≔ s/l, averaged over all M = 12 bus stops, is of the order of k * 0.020 during lull periods and k * 0.065 during busy periods. This information implies that with the people taking about a second to get up the bus so that l * 1 person per second, then the arrival rate of people at a bus stop is s * 0.020 person per second (1.2 person per minute) during lull periods and s * 0.065 person per second (almost 4 people per minute) during busy periods.
Based on these real data for M = 12 bus stops, we can test our analytical theory of the noboarding policy for a realistic simulated system having N = 2 buses serving M = 1 bus stop in a loop. Let the two buses have identical natural period of T = 12 minutes to complete one loop without stopping. Identical natural period would be applicable to programmable self-driving buses which would be rolled out in the near future [42]. The case of human-driven buses with different natural periods is investigated in Section 5. Normally, there are three or four buses serving the route, with up to seven or even eight buses during busy times. Since we are only dealing with two buses here, we consider a lull period with k = 0.010. This would then produce reasonable number of people demanding service and they are able to fit within the buses' usual capacity of an order of 50 passengers. Nevertheless, we emphasise here that these results hold for any value of k even in busy periods, since there is nothing in the theory that specifically restricts to the lull period or any value of k. Our use of a lull k = 0.010 in this subsection is simply because we are here considering N = 2 buses and pushing up k would make the number of people on each bus higher-which is fine, unless a maximum bus capacity is additionally imposed. Subsequently when we generalise to N buses (last part of this section, below), then more people (higher k, busy period) can be served without unrealistically carrying "hundreds of people per bus".
Anyway, suppose each person takes l = 1 second to board or alight, which translates to a people arrival rate of s = 0.010 person arriving per second or one person arrives every 100 seconds. Since k = 0.010 is a value applicable to M = 12 bus stops in the NTU bus system, for our simulations with only M = 1 bus stop, we should multiply this arrival rate by 12 to generate a comparable proportion of people using the service, i.e. a person arriving every 100/12 seconds. Note that typically people would travel from one part of the loop to another, travelling say an average of about half a loop (or less, since people can take the bus service going in the opposite direction for a shorter path), rather than making one full loop. As our simulations with M = 1 bus stop force people to travel one full loop, we halve the arrival rate in order to more realistically reflect the number of people on the two buses. Therefore, we have one person arriving every 100/6 seconds or rounded down to 16 seconds (because the simulations run on discrete time steps of 1 second).
In the usual situation with no intervention which corresponds to setting θ 0 = 360˚= 2π radians, the two buses bunch and would remain so since their natural speeds are identical. In steady state, our simulation results are as follows: The average waiting time for passengers is 0.515±0.299 units of T = 12 minutes (0.299 is one standard deviation, since people arrive uniformly over time with some having to wait longer than others for the bus to arrive), the time spent on the bus is 1.032 units (there is no uncertainty here, since every passenger spends this same amount of time on the bus), giving a total travel time of 1.546±0.299 units. Both buses spend � t ¼ 0:067 units stopping at the bus stop (there is no uncertainty here, since the bunched pair of buses always spend this same amount of time stopping at the bus stop) to allow alighting followed by boarding (bunched buses share the load). Each bus load carries L = 24 people. These value of � t and L are exactly the values predicted by Eqs (4) and (5). In addition, Eq (15) gives for θ eff = 2π radians (x = 1) and k = 1/16, an average waiting time of � W ¼ 0:517 units which is in agreement with our simulation value.
Next, we show results for this lull period where a person arrives every 16 seconds at this single bus stop, with the no-boarding policy in action. We carry out separate simulations for various (but fixed) θ 0 2 {180˚, 181˚, . . ., 360˚} (360˚means no implementation) . Fig 3(a) indicates excellent agreement between the analytical theory and the simulation results (which are averaged over many rounds during steady state). The stoppage duration is typically averaged around � t ¼ 0:067 units for both buses [with standard deviation of the order of 0 to 0.025 units, depending on the actual θ 0 being implemented, since Δθ(t) fluctuates around θ eff and depends on θ 0 ], and the number of people that they pick up is about L = 24 each (with standard deviation of the order of 0 to 20 people, depending on θ 0 ). These graphs also affirm that when the implemented angle is below the lower bound θ 0 < θ min , then τ and consequently L are less than the demand level [see also Fig 5, which shows the lower bound θ min for any k].  (4) and (5), as well as the lower bound θ min from Eq (7). Shown here [as well as in (b)] is for k = 1/16, and these features similarly hold for any value of (fixed) k. (b) Graphs of Δθ(t) versus time for each of the two buses. The no-boarding policy kicks in if Δθ > 225˚. https://doi.org/10.1371/journal.pone.0230377.g003

PLOS ONE
No-boarding buses: Synchronisation for efficiency Fig 3(b) shows the phase difference for one of these runs between the two buses, measured from each with respect to the other (so they always sum up to 360˚) as a function of time. They start off antipodally staggered and very quickly one bus "goes chasing after" the other "slower one". Here, the no-boarding policy is implemented if Δθ > θ 0 = 225˚which prevents them from bunching, and they settle on a steady state where their phase difference fluctuates around the median of 204.5˚or mean of 209.5˚. From the simulations, the average waiting time is 0.294±0.163 units, certainly much shorter than the bunched case of 0.515 units. It turns out that according to Eq (15), it is the median phase difference of θ eff = 204.5˚corresponding to an average waiting time of � W ¼ 0:301 units, which closely matches the simulation value. In contrast, the mean phase difference plugged into Eq (15) gives 0.308 units, which is a slight overestimate.
These all generalise to various implemented angles θ 0 as shown in Fig 4. Shown here is a collection where each simulation data point is an independent run with different (but fixed) θ 0 . In each plot of Fig 4(a), 4(c) and 4(d), the (red) dash line is the analytical result from Eq (15), whilst the (blue) dots are simulations points . Fig 4(a) shows a "naïve" plot of the simulation results for the average waiting time versus the implemented angle θ 0 . There is some conspicuous shift between the analytical line and the simulation points. This is because the effective phase difference θ eff is smaller than the implemented one θ 0 , with the exception of the "horizontal tail" of points for θ 0 * 360˚. That horizontal tail appears because for those extremely large θ 0 , the no-boarding policy is unable to prevent bunching and once bunched the buses stay bunched, i.e. their effective phase difference is 360˚. But what is a suitable representative value of θ eff < θ 0 in general? Fig 4(b) plots the relationship between θ 0 and the mean as well as median angles, as measured from the steady state part of the simulations. The mean seems to be biased, in the sense that the gradient of the "mean line of points" is not parallel to y = x, i.e. as the implemented angle θ 0 gets smaller, the degree of shift on the mean angle is smaller. On the other hand, the median angle shows a more consistent shift across various implemented angles θ 0 . Consequently in Fig 4(c), when the simulation data points are adjusted based on the mean phase difference, there is still a noticeable deviation from the analytical line. Nevertheless, this difference is not too glaring when adjusted based on the median phase difference in Fig 4(d).
Furthermore, we run separate simulations for this bus system where the no-boarding policy is implemented at various (but fixed) angles θ 0 2 {180˚, 181˚, . . ., 360˚}, for various (but fixed) values of k 2 {1/100, 1/99, . . ., 1/5}. With these extensive simulation data, we find that the analytical theory's predictions are in excellent agreement with the simulation results. In particular, it holds for any (fixed) k which comprises both lull and busy periods. In fact, the analytical curve for θ min (k) in Eq (15) fits nicely as displayed in Fig 5, where simulations show that if θ 0 < θ min , then the waiting times for the passengers blow up to multiple (tens of) revolutions. As explained, this is because the buses are disallowing boarding too frequently whenever their phase difference deviates too much from the staggered configuration and Δθ > θ 0 executes noboarding, to the point where the bus system is not meeting the demand for service. The number of people at the bus stop would grow unbounded as time goes to infinity, when θ 0 < θ min . If θ 0 > θ min , then this number remains bounded although it may not always drop to zero since the no-boarding policy would leave some people there.

N = 2 buses serving many bus stops
With more than M = 1 bus stops, each additional bus stop systematically contributes towards an additional stoppage due to τ where the bus allows alighting/boarding. Obviously such intermediate stoppages at each such bus stop in between would bump up the waiting time. The overall trend corresponds to the analytical result for N = 2 buses serving M = 1 bus stop [see Fig 6(b), below]: the average waiting time decreases linearly with a decrease in θ 0 where noboarding is implemented if Δθ > θ 0 . In particular, the general gradient of the simulation points matches the analytical line but is shifted upwards due to additional stoppages at other bus stops. On top of that, in Fig 6(b) with M = 12 staggered bus stops being 30˚apart from each other, we observe discrete jumps at 210˚, 240˚, 270˚, 300˚, 330˚, where these additional bus stops are located between the two buses.

N buses serving M bus stops-Analytical theory and simulations
We can directly generalise the analytical theory from N = 2 buses to any N � 2 buses serving M = 1 bus stop. Here are the results:

The stoppage duration for each bus is
The geometric series expansion is valid, since k < 1 and N � 2.
2. The lower bound to θ 0 is 3. The average waiting time for passengers at the bus stop before a bus arrives is as follows. where i = 1, 2, . . ., N − 1, is given by where 1/(i + 1) � x � 1/i and x ≔ θ eff /2π.
Eq (16) is derived by having a total of s(T + τ) people per revolution being carried by the N buses, so each bus carries s(T + τ)/N and they do so over an average time interval of τ/2 (since the other τ/2 is for people to alight). This gives s(T + τ)/N = lτ/2, which leads to Eq (16). For Eqs (16) and (17) though, we directly calculated all these expressions individually and case-bycase by hand up to N = 6 in the manner similar to the N = 2 buses serving M = 1 bus stop case in Section 3A, and then write down the generalisation to any arbitrary N = 2, 3, . . . buses serving M = 1 bus stop. In particular for Eq (18) the calculation steps are exactly those for N = 2 buses, which are applied systematically and tediously to more and more buses, one by one, calculating the luckiest and unluckiest people to board each bus, taking note of the proportion of load carried by each bus or each group of bunched buses.
Let us illuminate the content of Eq (18).  (18). Note that the gap between the analytical curve and the simulation points is due to this plot being with respect to the implemented angle θ 0 instead of the effective angle θ eff . With N buses, there are N − 1 independent local phase differences between adjacent buses, since these N local phase differences sum up to 2π. Eq (18) with N > 2 assumes that all N − 1 independent effective angles between any local pair of adjacent buses are equal, whereas in the actual system, they are not and sometimes even differ substantially. Making a single representative θ eff out of those different local phase differences would introduce bias, sometimes giving grossly wild results especially with larger N. Plotting against θ 0 would cleanly circumnavigate this and not artificially tamper with the data points, though we would have that shift between the analytical curve and the simulation points since θ eff < θ 0 .
As mentioned, each of these line segments in Eq (18) represents different situations corresponding to different number of bunched buses. For example with N = 3, when the implemented angle for no-boarding θ 0 is such that θ min < θ eff < 180˚, the three buses are not bunched. However, if θ 0 is larger such that 180˚< θ eff < 360˚, then two of these buses would bunch such that the system becomes a two-bus system where one of them comprises two bunched buses with twice the loading rate. It turns out that this is actually less efficient than a system with two unbunched buses where they have the same loading rate. Intuitively, this is because in the former the bunched pair is so-called "faster" due to its double loading rate and chases after the lone "slower" bus which has to implement no-boarding. The lone bus only picks up 1/3 of the demand, whilst the bunched pair picks up 2/3 of the demand (1/3 each). Similar ramifications are true for N = 4, 5, 6, 7, 8 buses, as shown in Fig 6(a). The bunched pair becomes "faster" and grows into larger bunched group of buses, if the implemented angle θ 0 is large. A bus system with larger bunched group of buses performs less efficiently compared to smaller bunched group of buses.
With many bus stops, each bus stop adds additional waiting time, just like the case of N = 2 buses discussed in the preceding subsection. Fig 6(b) shows simulation results for N = 2, 3, 4, 5, 6, 7, 8 buses, respectively, serving M = 12 bus stops. In these simulations, we set k = 0.010. Nevertheless, similar results hold for any (fixed) value of k. As the number of buses increases, since we keep the demand level to be the same lull k = 0.010, having more buses would spread out the load and so each bus would spend shorter � t at the bus stops [Eq (16)]. Therefore, the jump at each bus stop diminishes with larger N.
We do not proceed to repeat the laborious calculations for the general case of N buses serving M bus stops, because the analytical results from N buses serving 1 bus stop are sufficient to describe and understand the behaviour as θ 0 is changed. As the simulation results indicate in Fig 6(b), the precise corrections from what would be painstakingly going through each piece of individual case-by-case calculations only amounts to adjusting for the small shifts due to additional bus stops without affecting the already known behaviour of the system.
There is one important remark regarding decreasing the implemented angle θ 0 towards θ min . For each N, as y 0 ! y þ min , after the linear decrease, the average waiting time begins to increase before eventually blowing up by several orders once θ 0 < θ min [see Fig 6(a) and 6(b)]. These increases in the average waiting time when y 0 ! y þ min are more prominent with more buses, suggesting that with more buses the system is more susceptible to perturbations which nudge the buses to implement no-boarding too soon as its Δθ(t) gets larger than θ 0 . In particular, adding more buses does not always seem to lead to the expected improved average waiting time near θ min . For instance in Fig 6(b), the simulated best average waiting time for N = 8 buses is higher than 0.2 units, way above its theoretical minimum of less than 0.1 units. In contrast, the N = 3 and N = 4 systems do achieve simulated best average waiting times below 0.2 units, which are better than the N = 8 system. Therefore, whilst it is desirable to implement θ 0 as small as possible, one needs to beware that setting it too close to θ min would risk having the system implement no-boarding too frequently due to fluctuations in Δθ(t).
Incidentally, note that in the expression for the average waiting time in Eq (18), the kdependence solely arises from � t. If we define the quantity Vðx; NÞ ≔ � Wðx; k; NÞ À � tðk; NÞ=4, then this quantity is purely a function of The leftmost boundary point is when i = N, i.e.
whilst the rightmost boundary point is when i = 1, i.e.
The rightmost boundary point for any curve of constant N is the same point. This is where all buses bunch into a single unit, and the average waiting time is half units of T (plus � t=4).

The curve
passes through all those points in Eq (19). This equation shows that the overall decrease in average waiting time as x decreases (or as θ 0 approaches the staggered configuration) is in fact, hyperbolic. (22), it is clear that as N ! 1, the curves shift upwards and leftwards, approaching an "L"-shaped asymptotic curve defined by the horizontal line y = 1/2 (from x = 0 to x = 1) and the vertical line x = 0 (from y = 0 to y = 1/2). This is a manifestation of a larger group of bunched buses being less efficient than a smaller bunched group due to greater asymmetry in the system. Higher N also allows for further reduction in waiting time, since there are more buses-with diminishing returns, however.

With Eq
4. The set of leftmost boundary points for each curve of constant N, viz.
as well as their common rightmost boundary point (1, 1/2), all lie on the straight line y = x/2. (18) readily extends to include the degenerate situation of N = 1 bus. Here, θ eff = 2π as measured from itself to itself since there is just one bus serving the loop, and the average waiting time is always half units plus � t=4. So Eq (18) is just the point ð1; 1=2 þ � t=4Þ for N = 1, with i = 0, x = 1 (or θ eff = 2π), � t ¼ 2k=ð1 À 2kÞ. In this case, k has to be less than 1/2 in order for that lone bus to meet the demand for service.

No-boarding policy: Looking behind
Looking at the bus immediately ahead seems natural, since the number of people to be picked up is directly determined by how long ago the bus immediately ahead has left. But is this the only way to decide on a no-boarding policy? Instead of looking at the bus immediately ahead, it is also possible to consider measuring the phase difference with respect to the bus immediately behind [13,17]. When a bus is boarding people at a bus stop, if the phase difference with respect to the bus immediately behind Δθ is less than some threshold θ 0 , it is an indication that it is "too slow" and bunching may be imminent. To prevent this, it should disallow further boarding and leave. Similar calculations can be carried out, analogous to the looking-ahead rule in Section 3. Firstly, the average stoppage time spent by each of the N buses serving 1 bus stop in a loop is the same as in Section 3, given by Eq (16). Therefore, the average number of people picked up is also the same as in Section 3. The threshold θ 0 for implementation of no boarding must be less than 2π/N in a system with N buses. For example let N = 2 and set θ 0 = 181˚, where no boarding is implemented if Δθ < 181˚. Consider the staggered configuration where the two buses have a phase difference of 180˚. According to this threshold θ 0 = 181˚, whenever one bus is at a bus stop, it measures Δθ = 180˚which is less than θ 0 = 181˚and implements no boarding. This would always be the case, and nobody would ever be picked up! Hence in general, one should choose θ 0 < 2π/N. For N = 2, we can calculate this upper bound more precisely to be The derivation is analogous to calculating the lower bound to θ 0 in the looking-ahead rule in Section 3. For N > 2 however, the corresponding method does not work since looking behind is not equivalent to looking ahead.
Recall from the previous section on looking ahead where increasing θ 0 from 2π/N to 2π would lead to the N buses undergoing transitions where buses progressively bunch into one large group. This is different for looking behind. For all values of θ 0 2 (0, 2π/N), the N buses are always in a completely unbunched configuration (and increasing θ 0 beyond 2π/N would lead to the buses always implementing no boarding, as explained above). The analytical results for the average waiting time for a passenger waiting at a bus stop for a bus to arrive, in a system of N buses serving 1 bus stop is: where x ≔ θ eff /2π. This relation between � W and x is the same as that of Eq (18) with i = N − 1 (which corresponds to N unbunched buses), i.e. it has the same gradient in terms of magnitude, and peaks with a value of 1=2 þ � t=4 (when x = 0) where all buses bunch into one single unit. [In Eq (18), it also peaks with the same value at x = 1 where all buses bunch into one single unit.] However, the gradient here has an opposite sign since it is a larger Δθ from behind that improves the separation of the buses compared to a smaller Δθ from ahead. Fig 7(a) shows the average waiting time for N = 2, 3, 4, 5, 6, 7, 8 buses, respectively, serving M = 1 bus stop in a loop, with Fig 7(b) showing the corresponding situation with M = 12 bus stops. Just like the previous section, additional bus stops bump up the waiting time since the bus has to spend some stoppage there for alighting/boarding. In these graphs, the simulation points are plotted with respect to implemented angles, which are generally smaller than the effective angles (analogous to looking-ahead in the previous section, where the implemented angle is larger than the effective angle). This leads to the shift between the simulation points and the analytical curves.
In comparison with looking immediately ahead, here looking immediately behind never allows any bunching. In fact, simulations show that the system does achieve a best average waiting time which is close to the theoretical minimum. In particular, the N = 8 system has the best result, with sub-0.1 units of average waiting time. However, the range θ 0 for implementing the no-boarding policy gets narrower with increasing N, in contrast to the implementation with respect to the bus immediately ahead where the range of θ 0 grows with increasing N.

No-boarding policy on buses with different natural frequencies
In the previous two sections, we assumed that buses move with the same natural frequency. This allowed us to analytically calculate the average waiting time of the passengers waiting at the bus stop for a bus to arrive, complemented by simulations. Let us now test the no-boarding policy on a bus system where the buses move at different natural frequencies, as this is typical in human-driven buses.
As mentioned in Section 3B, the NTU campus bus system comprises N buses serving M = 12 reasonably staggered bus stops in a loop. The average periods of the buses around the loop without stopping are within a range of 12 to 18 minutes, or f i 2 [0.93, 1.39] mHz. Ref. [1] found that for the system served by N = 2 buses with f 1 = 1.39 mHz and f 2 = 0.93 mHz, the critical k = k c ≔ 0.028 marks a phase transition: 1) If k < k c , the two buses are in the lull phase such that they periodically bunch. The bunching occurs periodically because the fast one is able to pull away, opening up the phase difference from the slower one, and subsequently lapping it. 2) On the other hand, if k > k c , these two buses are in the busy phase where they are phase locked. Here, the phase locked pair is bunched permanently. Although the fast bus tries to pull away, the coupling strength at the bus stop is too large such that they bunch againrepeatedly at every bus stop. For N > 2, this value of � k � k c ¼ 0:028 marks the approximate critical coupling strength where the system transitions from the lull phase with no permanent bunching occurring if k < � k, to the busy phase where at least one sustained phase-locked pair of buses exists if k > � k. Let us now investigate the no-boarding policy applied to these situations in the NTU shuttle buses. We shall run simulations with the following setups: The no-boarding policy is effective, as expected from the analysis in the previous two sections, in the busy phase where otherwise the buses would experience sustained phase locking. However, the no-boarding policy backfires when the system is in the lull phase. For the latter, the buses with frequency detuning only bunch periodically, with the fast one pulling away from the slow one after they leave the bus stop. The implementation of the no-boarding policy does not prevent the buses from bunching in the lull phase, because the fast bus can gradually defy the policy's efforts to maintain their phase difference due to its positive relative velocity. In fact, the no-boarding policy turns out to periodically make one of the buses end up not picking up anybody over a significant part of their time when the policy is enforced. See the video found here: https://www.youtube.com/watch?v=SBNqvTr1AjQ (please enable the caption to see the live description in the video), which annotates what happens when the N = 2 bus system implements the no-boarding policy whenever Δθ > 200˚by measuring the phase difference from the bus immediately ahead, during the lull phase (k = 0.010). That video is also given as supplementary information.

Deviation from the analytical curve in the busy phase
It is interesting to note that unlike the previous setup with buses having identical natural frequency, buses with frequency detuning can potentially unbunch. Consequently for the noboarding policy by looking at the bus immediately ahead, here the buses do not get stuck in the (N − 1)-1 bus system since buses can unbunch. This is manifested by the N = 3 and N = 6 systems in the busy phase [middle and bottom plots on the right column of Fig 8(a)], where the simulation points do not lie on the expected curve for an (N − 1)-1 system but we see that they manage to unbunch themselves to more efficient configurations. Furthermore for the N = 6 system, having six buses with different frequencies turn out to be better than forcefully implementing the no-boarding policy over a wide range of implemented angle θ 0 . On the other hand, if the no-boarding policy is based on looking at the bus immediately behind [Fig  8(b)], then the no-boarding policy generally improves the waiting time in the busy phase (right column), since it never allows any bunching in the first place.

A simple general adaptive algorithm for dynamically determining θ 0
For this section, we focus solely on the look-ahead version. A similar application would work with the look-behind version as well. In real bus systems, various sources of stochasticity would imply that the precise value of θ min , i.e. the lower bound to the angle to implement noboarding θ 0 (which would in principle minimise the average waiting time) does not quite exist or would be fluctuating with time. Therefore, we describe a simple algorithm for picking θ 0 which is adaptive towards real-world stochasticity and varying demand levels k j for each bus stop. Before we present this algorithm, we first give some real-world parameters measured from the NTU campus shuttle buses [1]. With this, we can use these parameters to define our simulation environment to mimic a realistic system, where we then implement the adaptive algorithm to dynamically pick θ 0 which minimises the average waiting time.

Passenger arrival rates for the 12 bus stops in the NTU loop campus shuttle bus service
Ref. [1] presented data on the NTU loop campus shuttle bus service for the Blue route, measured over the full working week from 16th to 20th of April, 2018 (live data are found here: https://baseride.com/maps/public/ntu/). More specifically, there are two phases: 1) lull, from 4 pm to 5 pm served by 3 buses; and 2) busy, from 9 am to 10 am served by 6 or 7 buses. In that paper, loop averages are obtained where the values for k are averaged over all 12 bus stops. These loop averages produced data points which have relatively little noise, as the inhomogeneity amongst the bus stops are averaged away. The lull period for that week was measured to have a loop average of k = 0.024±0.004 whilst the busy period at peak demand was measured to have a loop average of k = 0.065±0.017. This peak demand was due to a selection of ten time series with the largest demand to obtain a representative value for the highest demand, where each time series is a tracking of one bus during that time interval. As discussed in the previous section, a phase transition between lull and busy was theoretically predicted to occur at � k ¼ 0:028, given buses with natural frequencies f i 2 [0.93, 1.39] mHz. This value � k denotes the critical value of k where the buses do not experience sustained bunching if k < � k but clusters of phased-locked buses emerge when k > � k. This loop average value of k was obtained by fitting the equation τ = kΔt to the data points (Δt, τ), where the components are averages of the time headways Δt ij and stoppages τ ij over all 12 bus stops, respectively. Note that in the NTU buses, passengers alight and board simultaneously via different doors, and so the stoppage is primarily due to the number of people accumulated during Δt ij at the bus stop, who are then boarding during τ ij . The error in k is the square root of the mean squared deviation of each data point's corresponding k from the best fit line's k. The relatively small errors in the loop average values of k are consistent with the fact that they have reasonable fit with coefficient of determination r 2 values of 0.59 and 0.77 for the lull and busy periods, respectively. As mentioned earlier, the loop average irons out the inhomogeneity amongst the various bus stops' k j .
If we do this linear fit for each individual bus stop however, the measured values of Δt ij and τ ij display a much greater error and deviation from the best fit line. The results are summarised in Table 1. We find that the individual bus stop's error in k j are generally much larger than their loop average values for both the lull and busy periods, respectively. In fact, the variance is more pronounced during the busy period: Some bus stops like H14/15, CH, H8 have noticably small k j , with H4 conspicuously having a negative k j . However, their Δk j is very large with their r 2 values being close to 0. This may be due to surges of people (students) collectively heading out to the bus stops at preferred times, say for example, to meet the 9.30 am lectures. The number of people going to the bus stops is thus not uniform over time, but experiences times when many people appear at the bus stops, as well as times when fewer people are there. The great stochasticity on individual bus stops may also be due to people crossing the road to take the bus service in the opposite direction when that bus arrives, since this is a loop service and people travelling antipodally (or near antipodally) may take a bus in either direction. The purpose of this crude linear fit is to set up a simulation environment (next subsection) to illustrate the adaptive algorithm on dynamically determining the best θ 0 in a stochastic and non-stationary environment (two subsections later).
The τ ij -intercepts for each bus stop are primarily around the order of + 10 seconds to + 30 seconds, which is due to the fact that buses have to wait for clear traffic before rejoining the road (in fact, there are zebra crossings right in front of some of the bus stops, so some people would be crossing the road right after they alighted-impeding the bus from departing) and that the positional data are only updated once in approximately every 10 seconds (which implies that any delay would be recorded in multiples of + 10 seconds). This is consistent with the loop average's τ-intercept values being about + 20 seconds, as discussed in Ref. [1].

A simulated environment to model the NTU system
For our simulated environment to model the NTU system, we assume that the buses are programmable such that they all move with the same natural period of T = 720 seconds (excluding stoppages). We generate the rates of people arriving at each of the 12 bus stops according the their k j values from Table 1 for simulations on the lull and busy periods, respectively. To create some variations in k j with time, at every fixed time interval, we sample k j,sample for each bus stop according to a normal distribution with mean k j and standard deviation Δk j . Note however that this may allow for negative values of k j,sample to be sampled, which is invalid and unphysical. To overcome this, we truncate the normal distribution to take only values from 0 to 2k j in order to maintain the distribution to center around k j . (For H4 during the busy period with negative k j , we take |k j | as the mean). These sampled k j,sample will be taken as the values for s j ≔ average rate of people arrival at the respective bus stops, with l ≔ loading/unloading rate set at 1 person per second. Once k j,sample have been sampled, the number of people arriving at bus stop j is then determined by a Poisson distribution with λ Poisson = k j,sample . As mentioned, the values for k j,sample are resampled every fixed time interval to reflect the varying demand level with time, and this fixed interval is a hyperparameter for this model, i.e. one is free to set any value as desired for the model. We let this interval be the period of each bus T = 720 seconds, i.e. k j,sample for each bus stop are resampled from their respective truncated normal distributions every 720 seconds or 12 minutes, which seems realistic.
Whilst the 12 bus stops are not perfectly staggered around the loop in the NTU campus, they are quite reasonably spaced out [1]. We place them equally spaced out in our simulated environment. Also, we ignore traffic conditions and let the buses move with constant speed when they are not at a bus stop. These should not be considered as unrealistic simplifications, because of the fact that the simulation environment repetitiously draws out k j,sample from the truncated normal distribution every T = 720 seconds. They are then further subjected to Poisson distributions to determine how many people actually arrive at each bus stop, thus already generating pretty high stochasticity in the simulated environment. If buses move with identical natural speeds, they may not be able to unbunch once they are bunched at a bus stop. To overcome this so that the buses may continue to explore other values of θ 0 instead of remaining bunched, we dictate in this simulated environment that if buses bunch at a bus stop, then they may randomly decide to leave. This mechanism thus allows buses with identical natural speeds to unbunch and carry on as if the system gets reset with bunched buses getting repositioned.

A simple general adaptive algorithm for dynamically determining θ 0
Our proposed simple adaptive algorithm for selecting the angle to implement no-boarding θ 0 motivated by the classical multi-armed bandit in reinforcement learning [45]. In this setup, each bus is an agent, and they only experience one state repeatedly. Each time, they can select one out of a set of actions, measure the reward, and subsequently arrive at the same state to select one action, ad infinitum. The set of actions comprises discrete integer values of θ 0 2 (360˚/N, 360˚), where N buses are serving the loop. This range of allowed θ 0 would ensure that θ 0 � 360˚/N never gets picked, which would otherwise always implement no-boarding, as we have found in the analytical theory. Once θ 0 is picked, this is the value where no-boarding would be implemented if Δθ > θ 0 (until the next time the Q-value gets updated and a new θ 0new gets selected, described below). At the start of the run, a value of θ 0 is randomly chosen from its allowed integer values. Each value of θ 0 has a Q-value associated with it, also randomly initialised to some sufficiently high value. These Q-values represent the average waiting time of people at the bus stop for a bus to arrive, associated with that θ 0 . Hence, we aim to minimise the average waiting time here, instead of typically maximising the reward in reinforcement learning [45]. One may choose to let each bus (agent) have its own set of Q-values, or all buses share one single Q-table. Here, we adopt the simple setup with one shared Q-table.
When a bus arrives at a bus stop, it allows passengers who wish to alight there to do so. Once this has completed, this bus measures the phase difference Δθ from the bus immediately ahead of it. If Δθ � θ 0 , then it proceeds to allow boarding until there is nobody left to board and leave, otherwise Δθ > θ 0 triggers the implementation of no boarding and the bus leaves. For people who are boarded, their waiting times are recorded so that the average waiting time is subsequently calculated. For the case where nobody is boarded and the bus just leaves, the waiting times thus far for people denied boarding at the bus stop are recorded instead. This ensures that the bus receives feedback on performance, even in cases where no-boarding is always implemented and nobody gets boarded. In reality, the information on how long a person has waited at a bus stop for a bus to arrive may be collected by a mobile app, where a person registers the intention to board a bus after just arriving at a bus stop. For the NTU campus shuttle bus system, perhaps a nifty way to do so instead, would be to install WiFi routers at bus stops since essentially students, staff, and anybody who regularly present themselves in NTU would access the university WiFi service. By installing WiFi routers at bus stops, not only does the university provide internet service for people spending time at bus stops, but the routers also count how many people are present at a bus stop waiting for a bus to arrive, automatically and in real time. Of course, this is just an approximate data collection mechanism, since some people may have multiple devices or there may be guests who do not log in to the NTU WiFi automatically. Nevertheless, such an approximation should suffice to obtain a representative average waiting time which requires no effort from the passengers since their devices connect to the WiFi routers automatically.
After some fixed time interval U, the average waiting time � W of all passengers waiting at the bus stop for a bus to arrive during this time interval is calculated. This "reward" � W is updated to the Q-value associated with θ 0 by the rule [45]: Here, α 2 (0, 1] is the learning rate for the Q-values. After this update, a new action is selected by a bounded ε-greedy criterion: With a probability of 1 − ε, the bus picks a new θ 0new corresponding to that whose Q-value is minimum, otherwise a new θ 0new is picked randomly from [θ 0 − lower, θ 0 + upper]. We choose lower = 30˚and upper = 5˚which bounds the εgreedy exploration with a bias towards lower values of θ 0 , in order to keep the exploration controllable and headed towards the prior knowledge of the optimal θ 0 to be near and above *360˚/N, based on the analytical theory in Section 3. We set α = 0.2 and ε = 0.2. These are not decayed but kept constant, to be able to continually adapt to the non-stationary environment with varying k j . Furthermore, we set U = 2T, so the Q-value is updated every 1440 seconds or 24 minutes. It is the average waiting time � W for passengers during this interval U which is sent into Eq (26).  Bottom: Graphs of best and actual expected average waiting time versus time for lull (left), busy (middle), and a lull case with frequency detuning (right). In each plot, the actual curve is the thin dotted curve, whereas the best expected curve is the thick curve. The red horizontal line in the bottom graphs represents the average waiting time when the no-boarding policy is not implemented.

Simulation results on the adaptive algorithm for determining θ 0 on the NTU system
https://doi.org/10.1371/journal.pone.0230377.g009 busy periods (served by N = 7 buses), respectively. In each case, a large θ 0 is initially chosen. As the simulation runs, various θ 0 are explored according to the algorithm to minimise the average waiting time of people waiting at a bus stop for a bus to arrive. The plots (left column for lull, middle column for busy) show, as a function of time: 1) the best θ 0 to implement, together with the actual θ 0 taken (which with probability ε is not the current best action, for exploration); 2) the best Q-value (representing the best expected average waiting time, based on the present Q-table), together with the actual average waiting time. Although we start with a large θ 0 , through reinforcement learning, the system is able to eventually seek the optimal θ 0 , and remain near that value since it has learnt that this has the best Q-value and occasionally bumps around to the next best Q-values when stochasticity drives up the average waiting time. This algorithm is also able to adapt to non-stationary situations, since ε is kept fixed to maintain exploration.
Furthermore, when applied to a lull situation where buses have frequency detuning, the system is able to adapt and find the optimal θ 0 to minimise waiting time. The right column in Fig  9 is the adaptive algorithm applied to "setup (1)" from the previous section, where there are N = 2 buses with different natural frequencies, and each of the M = 12 bus stops have k = 0.010. The system is given an initially small θ 0 * 200˚, but is able to explore and find the optimal θ 0 * 340˚which is slightly better than no implementation of the no-boarding policy [cf. top left plot in Fig 8(a)]. Here, we use lower = 15˚, upper = 15˚for the exploration, since we have no prior assumption about what the optimal θ 0 should be.
The purpose of this description is to provide a means of picking an optimal θ 0 under uncertain and stochastic real-world conditions, with some suggested hyperparameters like α = 0.2, ε = 0.2, lower = 30˚, upper = 5˚(or lower = upper = 15˚if no prior assumption is made), U = 2T. Whilst this prescription is intended to be general enough to be applicable to generic bus systems, when more specific details of a particular bus system are known, one may certainly fine-tune the hyperparameters and even make modifications (like giving each bus its own Q-table, instead of a commonly shared one) to improve this simple algorithm for specific bus systems.

Discussion and concluding remarks
Here is a summary of the results presented in this paper: 1. The construction of an analytical theory of how no-boarding significantly improves the bus system, as compared to the corresponding situation with no such implementation. This is for the case where buses have identical speed.
2. Extensive simulation results validate the theory.
3. The analytical theory comprises looking at the headway immediately ahead or immediately behind. The latter is generally better than the former.

4.
Simulation results for the case where buses have different natural speeds show that noboarding works only during the busy period, with an analytical derivation for this critical transition given in Ref. [41].
5. An adaptive algorithm is implemented on a simulation based on parameters measured from a real university loop shuttle bus service, illustrating how the no-boarding policy works in a real bus system. This paper has thus improved upon the previous studies on the no-boarding policy [37][38][39] by providing a thorough theoretical framework that includes both alighting and boarding, elucidating the mechanism on how no-boarding improves and maintains the headways amongst buses, as well as exactly determining when no-boarding works (busy period with high demand) and does not (lull period with low demand).
Whilst the global average waiting time becomes more favorable, this comes with local cost as those denied boarding would experience increased waiting times. This social aspect definitely deserves further scrutiny. Sometimes passengers may have the urgent need for service, or certain weather conditions (heat, thunderstorm, heavy snow) are simply inconsiderately painful for these passengers to experience extended waiting time at the bus stop. It is arguably less of being a pain point when a passenger is on the bus, albeit slowly moving, compared to having to wait in the open at a bus stop [37,38,46]. As a possible rectification, it may be a worthy consideration to allow passengers a choice on whether to obey the no-boarding implementation or defect and just continue boarding. A passenger defection against an implementation of the no-boarding policy would optimise their own local cost, at the expense of bumping up the global cost since this would raise the average waiting time for all passengers. These dynamics would seem to be rich and interesting, where the buses would have to co-evolve their noboarding implementation strategies together with the passengers' strategies on whether to obey or defect (defecting potentially risks incurring a fine, for instance). These social and game theoretic aspects arising from the no-boarding policy would be studied systematically and reported elsewhere.
In particular, we have recently studied what happens when the no-boarding policy is not mandatorily enforced but defections are allowed [47]. This setup mimics the El Farol Bar problem [48], where each agent (player or commuter facing the no-boarding policy but allowed the option to defect) is given two choices and the winners are those in the "minority group", i.e. the smaller group is deemed as winners [49][50][51][52][53][54]. This is a typical problem on social-resource allocations like customers attending a bar with limited seats [48], a lunch/dinner crowd trying to get their meals from a number of possible restaurants [55][56][57][58], the parking space problem [59,60], with even applications to financial markets where for instance if there are fewer buyers than sellers, then demand is weak and the price is low such that the buyers are "winners" (and vice versa) [61][62][63][63][64][65][66][67]. One of the key results of the minority game framework is that there exists a herding phase whereby many agents may tend to choose the same action under certain conditions, which is bad in terms of resource allocation optimisation since many people not using implies excess resource whilst many people using implies overcrowding. For the no-boarding policy with allowance for defections, the herding phase with overwhelming defections would spell disaster and nullify the intended prevention of bus bunching. Nevertheless, we found [47] that since commuters face different groups of other commuters each time a noboarding policy is implemented, this differs from the classical minority game which assumes that the same group of agents play each other repeatedly and therefore, there is no herding behaviour. The conclusion here is that if a strict no-boarding policy is seen as too drastic, then an allowance for defections in a controlled manner (imposing a fine if there are too many defectors and giving rebates to cooperators to encourage cooperation) seems to be a viable way to improve the efficiency of the bus system by preventing bus bunching.
From a different perspective and in a separate paper, we have also carried out an interesting approach where we allow a simulation of buses to "learn to be buses" as well as discover strategies to improve the efficiency of the system-without human input or prior knowledge [44]. The idea there is similar to the sensational AlphaZero programme which successfully dominated three different games of Go, Chess, and Shogi by reinforcement learning [68]. In our work in Ref. [44] (not to be confused with Section 6 in this paper), we allow each of the N buses serving a loop of M bus stops to either stay or leave whenever they are at a bus stop and there is nobody to alight (note that we do not allow for stop-skipping, as we do not wish to force commuters to stay on the bus for another round or having to get off at an earlier stop). The reward for the buses is that the system maintains a reasonably staggered configuration, analogous to the reward for AlphaZero being to win the game. It turns out that, quite remarkably, reinforcement learning by interacting with other buses and without human input lead to the emergence of the no-boarding and holding strategies with a desirable effect of minimising the average waiting time of commuters at the bus stop for a bus to arrive. More specifically, the no-boarding strategy that they learn matches the analytical results derived in this paperincluding the upper bound strictly below 360˚/N where no-boarding is implemented [see Eq (24)]. Furthermore, the buses also learn cooperative strategies where they are able to unbunch (if they happen to bunch) and return to a more ideal configuration.
The no-boarding policy may be viewed as an entrainment mechanism of a system of selfoscillators, as pointed out and discussed in Ref. [1]. Here, the entrainment mechanism for the bus system is triggered by Δθ exceeding a chosen θ 0 (or Δθ < θ 0 in the look-behind version), and then a "corrective forc" is applied by disallowing boarding on the slower bus. The effect is the staggered synchronisation of buses where instead of the buses getting phase-locked with a phase difference of 0˚, they are phased-locked with the ideal phase difference of *360˚/N. This staggered synchronisation achieves significant reduction in the average waiting time of passengers. In fact, we have understood and shown mathematically how the no-boarding and holding strategies would create stable anti-bunched configurations of buses serving a loop of bus stops, by comparing it to the local unidirectionally coupled Kuramoto oscillators which also possess stable staggered configurations if certain conditions are met [41]. On top of that, this idea of synchronisation may also be useful in other systems, for example in the context of collaborative multicentre vehicle routing optimisation [69,70].
Although this study focuses on a loop where buses would continuously move without any start or end, the no-boarding policy is directly applicable to various topologies, viz. loops, linear bus routes with a start terminal and an end terminal, as well as bus routes with branches, etc., as the key idea is to disallow boarding when a slow bus is considered as being too slow. Thus, the main results of this work in terms of improvement of passengers' average waiting time is applicable to bus systems elsewhere apart from our NTU loop campus shuttle bus service, without the need for any sophisticated engineering or design of the bus routes and additional complex infrastructure.
Supporting information S1 Video. A video is included as supplementary information. It can be found here: https:// www.youtube.com/watch?v=SBNqvTr1AjQ (Please enable caption to view the live description). (MP4) S1 Data. NTU campus shuttle buses. Live data on the NTU campus shuttle buses can be found here: https://baseride.com/maps/public/ntu/. (DOCX)