04.09.2013 Views

Algorithm Design

Algorithm Design

Algorithm Design

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

526<br />

Chapter 8 NP and Computational Intractability<br />

local farmers’ markets, gathering fresh fruits and vegetab!es for the new<br />

health-food restaurant they’ve opened, Chez Alanisse.<br />

In the course of trying to save money on ingredients, they’ve come<br />

across the following thorny problem. There is a large set of n possible raw<br />

ingredients they could buy, I1, I2 ..... In (e.g., bundles of dandelion greens,<br />

jugs of rice vinegar, and so forth), ingredient Ij must be purchased in units<br />

of size s(j) grams (any purchase must be for a whole number of units),<br />

and it costs c(j) dollars per unit. Also, it remains safe to use for t(j) days<br />

from the date of purchase.<br />

Now, over the next k days, they want to make a set of k different daffy<br />

specials, one each day. (The order in which they schedule the specials<br />

is up to them.) The i t~ daffy special uses a subset Si _ {I1, I2 ..... Ia} of<br />

the raw ingredients. Specifically, it reqmres a(i, j) grams of ingredient Ij.<br />

And there’s a final constraint: The restaurant’s rabidly loyal customer<br />

base only remains rabidiy loyal if they’re being served the freshest meals<br />

available; so for each daffy special, the ingredients Si are partitioned into<br />

two subsets: those that must be purchased on the very day when i_he daffy<br />

special is being offered, and those that can be used any day while they’re<br />

still safe. (For example, the mesclun-basfl salad special needs to be macie<br />

with basil that has been purchased that day; but the arugula-basfl pesto<br />

with Cornel! dairy goat cheese special can use basil that is several days<br />

37.<br />

old, as long as it is still safe.)<br />

This is where the opportunity to save money on ingredients comes<br />

up. Often, when they buy a unit of a certain ingredient I~, they don’t need<br />

the whole thing for the special they’re making that day. Thus, if they can<br />

follow up quickly with another special that uses I~ but doesn’t require it to<br />

be fresh that day, then they can save money by not having to purchase I)<br />

again. Of course, scheduling the basil recipes close together may make it<br />

harder to schedule the goat cheese recipes close together, and so forth-this<br />

is where the complexity comes in.<br />

So we define the Daily Special Scheduling Problem as follows: Given<br />

data on ingredients and recipes as above, and a budget x, is there a way to<br />

schedule the k daffy specials so that the total money spent on ingredients<br />

over the course of all k days is at most x?<br />

Prove that Daily Special Scheduling is NP-complete.<br />

There are those who insist that the initial working title for Episode XXVII<br />

of the Star Wars series was "IP = ~f~P"--but this is surely apocryphal. In anY<br />

case, ff you’re so inclined, it’s easy to find NP-complete problems lurking<br />

just below the surface of the original Star Wars movies.<br />

Exercises<br />

Consider the problem faced by Luke, Leia, and friends as they tried to<br />

make their way from the Death Star back to the hidden Rebel base. We can<br />

view the galaxy as an undirected graph G = (V, E), where each node is a<br />

star system and an edge (u, v) indicates that one can travel directly from u<br />

to v. The Death Star is represented by a node s, the hidden Rebel base by a<br />

node t. Certain edges in t~s graph represent !onger distances than others;<br />

thus each edge e has an integer length ee >- O. Also, certain edges represent<br />

routes that are more heavily patrolled by evil Imperial spacecraft; so each<br />

edge e also has an Integer risk r e >_ O, indicating the expected amount<br />

of damage incurred from special-effects-intensive space battles if one<br />

traverses this edge.<br />

It would be safest to travel through the outer rim of the galaxy, from<br />

one quiet upstate star system to another; but then one’s ship would run<br />

out of fuel long before getting to its destination. Alternately, it would be<br />

quickest to plunge through the cosmopolitan core of the galaxy; but then<br />

there would be far too many Imperial spacecraft to deal with. In general,<br />

for any path P from s to t, we can define its total length to be the sum of<br />

the lengths of all its edges; and we can define its total risk to be the sum<br />

of the risks of all its edges.<br />

So Luke, Leia, and company are looking at a complex type of shortestpath<br />

problem in this graph: they need to get from s to t along a path whose<br />

total length and total risk are both reasonably small. In concrete terms, we<br />

can phrase the Galactic Shortest-Path Problem as follows: Given a setup<br />

as above, and integer bounds L and R, is there a path from s to t whose<br />

total length is at most L, and whose total risk is at most R?<br />

Prove that Galactic Shortest Path is NP-complete.<br />

38. Consider the following version of the Steiner Tree Problem, which we’ll<br />

refer to as Graphical Steiner Tree. You are given an undirected graph<br />

G = (V, E), a set X _ V of vertices, and a number k. You want to decide<br />

whether there is a set F ~ E of at most k edges so that in the graph (V, F),<br />

X belongs to a single connected component.<br />

Show that Graphical Steiner Tree is NP-complete.<br />

39. The Directed Disjoint Paths Problem is defined as follows. We are given<br />

a directed graph G and/c pairs of nodes (Sl, tl), (s~, t 2) ..... (sk, tk). The<br />

problem is to decide whether there exist node-disjoint paths P1, P2 ..... Pk<br />

so that Pi goes from & to t~.<br />

Show that Directed Disjoint Paths is NP-complete.<br />

40. Consider the following problem that arises in the design of broadcasting<br />

schemes for networks. We are given a directed graph G = (V, E), with a<br />

527

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

Saved successfully!

Ooh no, something went wrong!