04.09.2013 Views

Algorithm Design

Algorithm Design

Algorithm Design

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

802<br />

Epilogue: <strong>Algorithm</strong>s That Run Forever<br />

Now, if we want to maintain nonnegative slacks over time, then we need<br />

to worry about counterbalancing events that cause Slack(p) to decrease. Let’s<br />

return to the description of a single time step and think about how such<br />

decreases can occur.<br />

One step under sped-up input/output queueing:<br />

Packets ~rrive on input li~ks snd are placed in input buffers<br />

The switch moves a matching<br />

At most one packet departs from each output buffer<br />

The switch moves a matching<br />

Consider a given packet p that is unprocessed at the beginning of a time<br />

step. In the arrival phase of the step, IC(p) could increase by 1 if the arriving<br />

packet is placed in the input buffer ahead of p. This would cause Slack(p)<br />

to decrease by 1. In the departure phase of the step, OC(p) could decrease<br />

by !, since a packet with an earlier time to leave will no longer be in the<br />

output buffer. This too would cause Slack(p) to decrease by 1. So, in summary,<br />

Slack(p) can potentially decrease by 1 in each of the arrival and departure<br />

phases. Consequently, we will be able to maintain property (i) if we can<br />

guarantee that Slack(p) increases by at least 1 each time the switch mov~s<br />

a matching. How can we do this?<br />

If the matching to be moved includes a packet in I[p] that is ahead of p, then<br />

IC(p) will decrease and hence Slack(p) will increase. If the matching includes<br />

a packet destined for O[p] with an earlier time to leave than p, then OC(p) and<br />

Slack(p) will increase. So the only problem is if neither of these things happens.<br />

Figure E.B gives a schematic picture of such a situation. Suppose that packet<br />

x is moved out of I[p] even though it is farther back in order, and packet y<br />

is moved to O[p] even though it has a later timeto leave. In this situation, it<br />

seems that buffers I[p] and O[p] have both been treated "unfairly": It would<br />

have been better for I[p] to send a packet like p that Was farther forward, and<br />

it would have been better for O[p] to receive a packet like p that had an earlier<br />

time to leave. Taken together, the two buffers form something reminiscent of<br />

an instability from the Stable Matching Problem.<br />

In fact, we can make this precise, and it provides the key to finishing the<br />

algorithm. Suppose we say that output buffer 0 prefers input buffer I to I’<br />

if the earliest time to leave among packets of type (/, O) is smaller than the<br />

earliest time to leave among packets of type (I’, 0). (In other words, buffer I<br />

is more in need of sending something to buffer 0.) Further, we say that input<br />

buffer I prefers output buffer 0 to output buffer O’ if the forwardmost packet<br />

of type (I, O) comes ahead of the forwardmost packet of type (/, 0’) in the<br />

ordering of I. We construct a preference list for each buffer from these rules;<br />

I[p] (front)<br />

Epilogue: <strong>Algorithm</strong>s That Run Forever<br />

Ix<br />

O[p]<br />

Figure E.3 Choosing a matching to move.<br />

It would be unfair to move~<br />

and ybut not movep.<br />

J<br />

and if there are no packets at all of type (I, 0), then I and 0 are placed at the<br />

end of each other’s preference lists, with ties broken arbitrarily. Finally, we<br />

determine a stable matching M with respect to these preference lists, and the<br />

switch moves this matching M.<br />

~ Analyzing the <strong>Algorithm</strong><br />

The following fact establishes that choosing a stable matching will indeed yield<br />

an algorithm with the performance guarantee that we want.<br />

(E.2) Suppose the switch always moves a stable matching M with respect<br />

to the preference lists defined above. (And for each type (I, O) contained in<br />

M, we select the packet of this type with the earliest time to leave). Then, for<br />

all unprocessed packets p, the value Slack(p) increases by at least 1 when the<br />

matching M is moved.<br />

Proof. Consider any unprocessed packet p. Following the discussion above,<br />

suppose that no packet ahead of p in I[p] is moved as part of the matching<br />

M, and no packet destined for O[p] with an earlier time to leave is moved as<br />

part of M. So, in particular, the pair (![p], O[p]) is not inM; suppose that pairs<br />

(F, O[p]) and (![p], 0’) belong to M.<br />

Nowp has an earlier time to leave than any packet of type (/’, O[p]), and it<br />

comes ahead of every packet of type (![p], 0’) in the ordering of I[p]. It follows<br />

that I[p] prefers O[p] to 0’, and O[p] prefers I[p] to I’. Hence the pair (![p], O[p])<br />

forms an instability, which contradicts our assumption that M is stable. ,<br />

Thus, by moving a stable matching in every step, the switch maintains<br />

the property Slack(p) > 0 for all packets p; hence, by (E.!), we have shown<br />

the following.<br />

803

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!