Quantcast
Channel: Algorithm Soup
Viewing all articles
Browse latest Browse all 10

Train Tracks with Gaps: Applying the Probabilistic Method to Trains (Best Paper, FUN 2020)

$
0
0

Some Context:  This post is a shortened version of a paper that won the best-paper award at FUN 2020.  The paper is ostensibly about trains but the real-world applicability may be somewhat… limited.  The actual purpose of the paper is educational: we get to see some of the funnest techniques in probabilistic combinatorics being used to solve a cute problem involving trains.

Part 1: A Consequential Train Ride   

A few years ago, while traveling on a train, and on only a few hours of sleep, I was staring out the window. The train crossed a bridge over a road, and the ground was momentarily replaced by a steep drop. Startled, my sleep-deprived mind briefly wondered whether there was still a track underneath us. “Of course there is,” I thought to myself. “Without a track, the train car would have fallen into the gap.”

“Ah, no so fast!” responded the latent mathematician inside me. “If the train car had more than two sets of wheels, then perhaps it could cross the bridgeless gap without falling in.” It was true.

Consider, for example, a train with four sets of wheels: one set in the rear, one set in the front, and one set in each of the first and third quartiles.

basic_gap-1

As long as the gap in the track is less than the distance between any pair of wheels, then at least three sets of wheels will touch track at all times. Assuming that the center of mass of the train is in the middle half of the train, then the the train does not fall into the gap.

“In fact,” continued the latent mathematician, “what if we have {n} sets of wheels? Maybe we can build a mono-rail using an asymptotically small amount of track.”

“That’s a stupid idea,” responded I. “Gaps in train track are not something to optimize.”

But I was sleep deprived, so I did it anyway.

The Basic Observation: More Wheels Means Less Track.   

Consider a train car with {2n} sets of wheels. Half the sets are evenly dispersed across the first quarter of the train car, and half the sets are evenly dispersed across the final quarter. The train can safely drive down the track as long as at least one set of wheels from each side of the train car is touching track at all times. The train car looks something like this:

Want to build a monorail, but you’re short on track? No problem! You can get away with filling in only an {O(1/n)} fraction of the track:

ezgif.com-gif-maker

Every quarter of a train length, we place a piece of track whose length is a {\frac{1}{4n}} fraction of the length of the train car. We get asymptotic cost savings!

To see that this is the best we can do, suppose that the fraction of track that is filled in is less than {\frac{1}{n}}, and for symmetry sake suppose the track is circular (i.e., the end of the track loops back to the start). If we place the train at a random position in the circular track, then each wheel has a less than {\frac{1}{n}} chance of touching track. By a union bound, it follows that the probability of any wheel in the rear quarter of the train touching the track is less than {1}. Thus no matter how the track is placed, if the total fraction of track that is filled in is less than {\frac{1}{n}}, then there is some position at which the train falls through.

Part 2: Trains with Non-Uniform Wheel Placements

Consider a train car that has {n} wheels in its rear quarter and {n} wheels in its front quarter, but suppose that the wheels aren’t evenly spaced. For example, maybe the rear of the car looks something like this:

uneven_wheels1-1

Can we still fill in an asymptotically small fraction of the track in a way that will allow the train car to drive down the track? In other words, can we place down a small amount of track in a way so that, as the train drives down it there is always at least one wheel from each of the front and rear quarters of the train touching track? It turns out that, via a simple application of the probabilistic method with alterations, we can.

To formalize the situation, let’s focus just on the first quarter of the train. (In particular, up to a constant factor in the amount of train track that we install, we can consider the two quarters of the train separately.) Suppose this portion of the train is {f} feet long, and assume that each of the {n} sets of wheels resides at a distinct integer offset from the rear of the train. Our goal is to build a train track that is {\ell} feet long. We build the train track out of pillars that are each {1} foot long and are each placed at integer positions on the track. We are required to put down the pillars in a way so that, as the train drives down the track, at least one wheel from the rear quarter is always touching the track (i.e., touching some pillar). We want to use as little track as possible, with the best we could hope for being a total of {\frac{\ell}{n}} pillars.

As a reminder, there are three variables: the number of wheels {n} (in the quarter of the train car that we’re considering), the length {f} of one quarter of the train car, and the length {\ell} of the train track. In general, we have {n \le f \le \ell}. Note that, although {n} and {f} could reasonably be close to one another (e.g., {f = 2n}), we also want to be able to handle cases where {n \ll f}. This allows for the train car to be configured in truly strange ways — for example, the positions of the wheels could even form a geometric series:

uneven_wheels2-1

A Randomized Algorithm for Building Track.  

Our algorithm for deciding where to put the pillars is a simple example of the probabilistic method with alterations. In particular, we begin by randomly constructing a track that uses only a small number of pillars, and then we show that this track can be slightly altered in order to support (the rear quarter of) the train car at every point. The result will be a train track of length {\ell} using only {O\left(\frac{\ell \ln n}{n}\right)} pillars (and as we shall see later, this is optimal).

We begin by installing each pillar randomly with probability {\frac{\ln n}{n}}. Even though this strategy has nothing to do with the structure of where the wheels are on the train, it already does remarkably well. In particular, if we place the train at some given position on the track, then there are {n} different pillar positions that could potentially hold up the rear quarter. Each of these pillars positions has a {\frac{\ln n}{n}} probability of having a pillar installed. It follows that, for a given position on the track, the rear quarter of the train has a

\displaystyle \left(1 - \frac{\ln n}{n} \right)^{n}

probability of falling through the track. Taking advantage of the identity {\left(1 - \frac{1}{k}\right)^k \le \frac{1}{e}}, which holds for any {k \ge 1}, we see that the wheels fall through the track with probability at most,

\displaystyle \frac{1}{e^{\ln n}} = \frac{1}{n}.

In other words, out of all the places we can place the train on the track, only a {\frac{1}{n}}-fraction of them will be problematic (in expectation). To fix this, we can just install one additional pillar to remedy each of these problematic positions. The result is a train track that fully supports the rear quarter of our train, and that uses only {\left(\frac{1 + \ln n}{n}\right) \ell} total feet of track, in expectation.

The construction is kind of fun to visualize. We start with some random pillars, and then we add additional pillars as needed so that the train never falls through the track:

Webp.net-gifmaker (2) (1)

Of course, our bound of {\left(\frac{1 + \ln n}{n}\right) \ell} isn’t quite as good as we did when the wheels were evenly spaced out (we are a roughly {\ln n} factor worse). But it’s still pretty amazing! No matter how the wheels are distributed across each quarter of the train car, we can get away with installing only a {O\left(\frac{\ln n}{n} \right)} fraction of the track!

Part 3: A Matching Lower Bound

In the rest of this post, we’re going to prove that the construction above is optimal. (This is where the math gets really cool.) That is, we’ll show that there exists a train car configuration for which {\Omega\left(\ell \frac{\ln n}{n} \right)} pillars are necessary. We are going to again use the probabilistic method, but this time in a more sophisticated way.

We continue to focus only on the rear quarter of the train car, which is {f} feet long. We set {f = 2n}, and we will construct the rear quarter of the train car by placing {n} wheels at integer positions in the set {\{1, 2, \ldots, 2n\}}. We will then consider a track of length {\ell = 2f}, and show that {\Omega(\log n)} pillars are necessary in order to support the rear quarter of the train car at all positions on the track. Recall that each pillar is one foot wide and is placed at an integer offset on the track.

Let {C} be the set of wheel-positions in the rear quarter of the train car. We choose {C} by placing a wheel at each position in {\{1, 2, \ldots, 2n\}} independently with probability {\frac{1}{2}}. This means that {C} has {n} wheels in expectation, but may not actually have exactly {n} wheels. The important thing to note is that, with at least {50\%} probability, {C} has {n} or more wheels.

Now consider a track layout given by a subset {T} of {\{1, 2, \ldots, 4n\}}, and satisfying {|T| = \frac{\ln n}{4}}. Whereas {C} is a random variable, {T} is a fixed set.

Define {X_{C, T}} to be the event that, for every possible position of the rear quarter of the train on the track, at least one wheel from the rear quarter of the train is supported by track. From the perspective of the train car, {X_{C, T}} is a good event. Formally, {X_{C, T}} occurs if for every offset {k \in \{0, 1, \ldots, 2n\}}, we have {(k + C) \cap T \neq \emptyset}.

The key to proving the desired lower bound is to show that the probability of {X_{C, T}} occurring is very small, namely that {\Pr[X_{C, T}] < \frac{1}{2 \binom{4n}{(\ln n) / 4}}}. Because {T} is a {\frac{\ln n}{4}}-element subset of {\{1, 2, \ldots, 4n\}}, there are at most {\binom{4n}{(\ln n) / 4}} possibilities for {T}. Taking a union bound over all of these possibilities implies that

\displaystyle \Pr[X_{C, T} \text{ for any }T] < \frac{1}{2}.

On the other hand, we know that the number of wheels {|C|} is less than {n} with probability at most {1/2}. By a union bound, the probability that either {|C|} has fewer than {n} wheels or that {X_{C, T}} holds for some {T} is less than {1}. Hence there must exist a car {C} with {n} or more sets of wheels, and such that no track {T} of size smaller than {(\ln n) / 4} satisfies {X_{C, T}}. In fact, with slightly more careful bookkeeping, one can show that an even stronger property is true: almost all choices of how to place {n} wheels in {C} require a track of size larger than {(\ln n) / 4} to support the car.

To complete the lower bound, the challenge becomes to show that {\Pr[X_{C, T}]} is very small. That is, for a given choice of track {T} containing {(\ln n)/4} pillars, the probability that {T} supports the rear-quarter of the train car {C} is small.

Rather than examine the event {X_{C, T}} directly, we instead examine a related quantity. Define {Y_{C, T}} to be the number of positions {k \in \{0, 1, \ldots, 2n\}} for which {(k + C) \cap T = \emptyset} (i.e., the number of positions in which the rear quarter of the car, given by {C}, falls through the track {T}).

The relationship between {X_{C, T}} and {Y_{C, T}} is that {X_{C, T}} occurs if and only if {Y_{C, T} = 0}. Our approach to completing the analysis will be to first show that {\mathop{\mathbb E}[Y_{C, T}]} is relatively large, and then to show that the probability of {Y_{C, T}} deviating substantially from its expected value is small. This, in turn, implies that {\Pr[Y_{C, T} = 0]} is small, completing the analysis. In other words, the problem of proving that there exists a train-car configuration requiring a large amount of track is reduced to the problem of proving a concentration inequality on the random variable {Y_{C, T}}.

For each position {k \in \{0, 1, \ldots, 2n\}}, the set {T - k} consists of {(\ln n) / 4} elements. Since each of these elements is contained in {C} with probability {1/2}, the probability that {C} avoids all of the elements in {T - k} is given by,

\displaystyle \frac{1}{2^{(\ln n) /4}} = \frac{1}{n^{1/4}}.

Summing over the values of {k}, it follows that the expected number of positions {k} in which {(C + k) \cap T = \emptyset} is

\displaystyle \mathop{\mathbb E}[Y_{C, T}] = 2n \cdot \frac{1}{n^{1/4}} > n^{3/4}.

The final step of the analysis is to prove a concentration inequality on {Y_{C, T}}. Standard Chernoff bounds do not apply here because {Y_{C, T}} is not a sum of independent indicator random variables. Instead, we employ a more powerful tool, namely McDiarmid’s Inequality:

McDiarmid’s Inequality (1989): Let {A_1, \ldots, A_m} be independent random variables over an arbitrary probability space. Let {F} be a function mapping {(A_1, \ldots, A_m)} to {\mathbb{R}}, and suppose {F} satisfies,

\displaystyle \sup_{a_1, a_2, \ldots, a_m, \overline{a_i}} |F(a_1, a_2, \ldots, a_{i - 1}, a_i, a_{i + 1}, \ldots , a_m) - F(a_1, a_2, \ldots, a_{i - 1}, \overline{a_i}, a_{i + 1}, \ldots , a_m)| \displaystyle \le R,

for all {1 \le i \le m}. That is, if {A_1, A_2, \ldots, A_{i - 1}, A_{i + 1}, \ldots, A_m} are fixed, then the value of {A_i} can affect the value of {F(A_1, \ldots, A_m)} by at most {R}; this is known as the Lipschitz Condition. Then for all {S > 0},

\displaystyle \Pr[|F(A_1, \ldots, A_m) - \mathop{\mathbb E}[F(A_1, \ldots, A_m)]| \ge R \cdot S] \le 2e^{-2S^2 / m}.

To apply McDiarmid’s Inequality to our situation, recall that {Y_{C, T}} is defined to be the number of positions in the track {T} that the rear quarter of the car, given by {C}, falls through. Whereas the track {T} is fixed, each of the {2n} possible wheels in {C} is picked with probability {1/2}. Define the indicator random variables {A_1, A_2, \ldots, A_{2n}} so that {A_i} indicates whether {i \in C}. As required by McDiarmid’s Inequality, the {A_i}‘s are independent of one-another, and {Y_{C, T}} is a function of the {A_i}‘s.

Now we show that the Lipschitz Condition holds with {R = (\ln n) / 4}. Recall that the track {T} consists of only {(\ln n) / 4} pillars. Out of the {2n} possible wheels {i} that {C} could contain, each of those wheels {i} is only relevant (to the car’s stability) when the car is {k} feet down the track for some {k} that places wheel {i} on top of a pillar. Since there are only {(\ln n)/4} pillars, each wheel {i} is only relevant to the train car’s stability for {(\ln n) / 4} positions {k} on the track. In other words, for a given wheel position {i \in \{1, 2, \ldots, 2n\}}, there are only {(\ln n) / 4} values of {k \in \{0, 1, \ldots, 2n\}} for which {(C + k) \cap T} can possibly contain {i}. As a result, each {A_i} can only affect the value of {Y_{C, T}} by at most {(\ln n) / 4}, meaning that the Lipschitz Condition holds with {R = (\ln n) / 4}.

Applying McDiarmid’s Inequality, we can deduce that

\displaystyle \Pr[n^{3/4} - Y_{C, T} > n^{5/8} \cdot (\ln n) / 4] \le 2e^{-n^{1/4}}.

When {n} is large, this probability is much smaller than {\frac{1}{2 \binom{4n}{(\ln n) / 4}}}. It follows that

{\Pr[X_{C, T}] = \Pr[Y_{C, T} = 0] < \frac{1}{2 \binom{4n}{(\ln n) / 4}}}.

Summing over all possible options for the track {T}, the probability that any of them support the train car {C} is therefore less than {1/2}. This completes the proof: we have shown (non-constructively) that some train car {C} with {n} or more wheels fails to be supported by any track {T} consisting of {(\ln n)/4} or fewer pillars.

Conclusion.  If you’ve made it to here, you might want to take a look at the paper that this blog post is based on. It turns out that there’s even more fun to be had: in fact, the train-track problem can be used to give illustrative examples of some of the most useful techniques in probabilistic combinatorics, including, e.g., the Lovász Local Lemma and the Method of Conditional Expectations!

1 This research was partially sponsored by the United States Air Force Research Laboratory and was accomplished under Cooperative Agreement Number FA8750-19-2-1000. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the United States Air Force or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation herein.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles



Latest Images