Beruflich Dokumente
Kultur Dokumente
David S. Johnson
Massachusetts Institute of Technology
Cook and Karp in [1,5] have shown the exis- MAXIMUM CLIQUE: Given a graph, find the max-
tence of a class of combinatorial problems, the imum subgraph all of whose points are mutually
"polynomial complete" problems, such that if any adjacent.
of these problems can be solved in polynomial time,
then they all can. Many of these problems such as Work on the above-mentioned BIN-PACKING pro-
tautology testing and the traveling salesman blem [2,3,4] has suggested an approach that may be
problem, have become notorious for their compu- applied to the others. Since no fast algorithm
tational intractability, and it is widely conject- for finding an optimal solution could be found,
ured that none of them can be done in polynomial simple heuristic algorithms that seemed likely to
time. Many problems of this class are in the form generate fairly good packings were studied. It was
of optimization problems. Some examples of poly- found that certain of these simple algorithms could
nomial complete optimization problems are: guarantee near-optimal results. For instance, the
FIRST FIT DECREASING algorithm guarantees that,
SUBSET-SUM: Given a finite set of positive asymptotically, no more than 11/9 times the optimal
numbers and another positive number called the number of bins will be used.
"goal", find that subset whose sum is closest to,
without exceeding, the goal. This paper examines polynomial-time heuristic
"approximation algorithms" for the other optimiza-
tion problems listed above, in an attempt to get
Work reported herein was supported in part by similar results. We discover that a wide variety
Project MAC, an MIT research program sponsored by of worst case behaviors are possible.
the Advanced Research Projects Agency, Department
of Defense, under Office of Naval Research Con- Some algorithms, such as the ones we present
tract Number N00014-70-A-0362-0006 and the Nat'l. for SUBSET-SUM and MAXIMUM SATISFIABILITY, have the
Science Foundation under contract number GJ00-4327. same type of behavior as FIRST FIT DECREASII~ in
Reproduction in whole or in part is permitted for that they guarantee that the solution they generate
any porpose of the United States Government. will be no worse than a constant time the optimal,
and indeed that constant can be quite close to I.
38
For other algorithms, such as the ones we mation algorithm for problem P, then the perform-
present for the two SET COVERING problems, there ante A(U)p of A for input u is defined
is no fixed bound on the ratio of the worst case
results to the optimal, but that ratio can grow A(U)p = WORST {mp(x): x 6 SOep(U) and x is
no faster than the log of the problem size. choosable by A on i n p u t
u},
For still others, such as some of the coloring
algorithms we give and all of the algorithms for
where WORST is M I N if BEST is MAX, and vice versa.
MAXIMUM CLIQUE that have been suggested, the ratio
As a measure of the relative worst case behavior of
grows at least as fast as O(ne), where n is the algorithm A on input u, we shall use the ratio
problem size and e > 0 depends on the algorithm.
rp(A,u) = Up*/A(U)p, if P is a maximization
We also consider the possibility of using the problem,
reductions which show that problems are polynomial
A(U)p/Up*, if P is a minimization
equivalent to translate our results from one optim-
problem.
ization problem to another Karp's reductions in
[5] are all between language recognition problems,
Note that this ratio has been defined so as to al-
but we can often extend them directly to the assoc-
ways be greater than or equal to I.
iated optimization problems. Difficulties arise,
however, since a "good" approximate solution for
For a given input u, the problem size lul is
one problem may map to a solution for the other
the number of symbols required to describe u in
which is not at all good according to the measure
some standard notation. Our measure of the overall
for that problem.
worst case behavior of algorithm A with respect to
In Section 2 we introduce a formal framework problem P will be a function R[A,P]:N+ ~ R defined
within which to discuss the above problems, defin- by
ing what we mean by "optimization problem",
"approximation algorithm", "worst case behavior", R[A,P](n) = MAX(rp(A,u): u 6 INPUTp and
etc. Each of the next six sections is devoted to
one of the problems, and finally Section 9 presents
some general observations and conclusions.
As defined, R[A,P] is an increasing function of n.
3. A measure mp:SOLp(INPUTp) ~ Q defined for all This maximization problem is a simple form of
the well known "knapsack problem". We shall de-
possible approximate solutions.
note it by SS, and restate it in terms of our for-
mal definitions:
In addition, the problem P is specified as a
maximization problem or a minimization problem,
INPUTss = [<T,s,b>: T is a finite set, s:T-~
depending on whether the goal is to find an appro-
is a map which assigns to each
ximate solution with maximal or minimal measure.
x 6 T a size s(x), and b > 0 is a
For each u E IINPUTP, the optimal measure Up* is
single rational number].
defined by
39
2. If for all x E LEFT, s(x) + S U M > b, halt and For the lower bound on the limit, consider the in-
return SUB. put <T,s,b> where
3. Let y be an element of LEFT for which s(y) +
SUM is closest to~ without exceeding, b. T = ia I . . . . . ak+2} ,
4. Set LEFT = LEFT - {Y}, SUB = SUB U iY], SUM =
S U M + s(y). s(ai) = [I + E, for i = I,
5. Go to 2. l I, otherwise.
where T_BIG
i = {x E ri: S(X) > b/(k+l)} ' and r~iMALL = Let L = U Ixi,xi] be a set of literals. A
i>O
T. - ~BIG. We thus have, for i E [0,I}, clause will be any finite subset C c_ L. A truth
i 1 assignment will be any subset T c L such that for
SMALL. :n~ i > 0 is [xi,xl} c_ T. Truth assignment T sa___~-
m(T i) = m(T~ IG) + m(T i ).
isfies clause C if C N T ~ . The MAXIMUM SATIS-
FIABILITY problem, denoted by MS, is given by:
By Step I of algorithm Ak, m(T~ IN) ~ m(T~Ig).
INPUTMs = iS: S is a finite set (CI,C2,...,Cp}
If T SMALL
I D T~MALL we would also have m(T SMALL
I ) of clauses].
SMALL.
m(T 0 ), and so T 1 w o u l d be o p t i m a l . SOLMs(T) = IS' = S: there exists a truth
assignment T which satisfies every
On t h e o t h e r h a n d , if some x ~ T~
MALL- w e r e e x - clause C E S'}.
cluded from T SMALL
1 t h e n by S t e p 2 o f Ak, s ( x ) +
m(Tl) > b - s(x) ~ b - b/(k+l) = kb/(k+l) MS(k) will denote the sub-problem with inputs
restricted to sets of clauses, each clause of which
[k/(k+l)]<T,s,b>*. contains at least k distinct elements. MS(k) is
polynomial complete for all k ~ i.
Thus in all cases we have r(Ak,<T,s,b>)
(k+l)/k, and the upper bound is proven. Each of our algorithms will work by generating
a truth assignment TRUE, while keeping track of the
t0
associated set SUB of satisfied clauses. The first, 3. Let y be any literal occuring in both LIT and
Bl, is a simple heuristic requiring time propor- a clause of LEFT. Let YT be the set of clauses
2 in LEFT and containing y, YF the set of clauses
tional to n .
in LEFT containing y.
i. Set SUB = @, TRUE = @, LEFT = S, LIT = L. 4. If ~ w(C) ~ ~ w(C), set TRUE = TRUE U {y},
2. If no literal in LIT is contained in any clause C6YT CEYF
of LEFT, halt and return SUB. SUB = S U B U YT, LEFT = L E F T - YT, and for each
3. Let y he the literal in LIT which is contained C E YF, set w(C) = 2w(C).
in the most clauses of LEFT, and YT he the set Otherwise, set TRUE = TRUE U [y}, SUB = SUB U
of clauses in LEFT which contain y., YF, LEFT = LEFT - YF, and for each C E YT, set
4. Set SUB = SUB U YT, LEFT = LEFT - YT, TRUE== w(C) = 2w(c).
TRUE U {y], and LIT = LIT - [y,y), (where x. = 5. Set LIT = LIT - [y,y], and go to 2.
xi). i
5. Go to 2. Note that since the choice of which literal to
consider at step 3 is left largely undetermined,
Theorem 2. For all k m I and n > 0, there is room in this algorithm for the insertion
of heuristics which might improve its average case
R[BI,MS(k)](n) ~ (k+l)/k, behavior. Its worst case behavior is already a
perhaps surprising improvement on that of algorithm
Bl:
with equality for all sufficiently large n.
Theorem 3. For k m 1 and n > 0,
Proof. Suppose algorithm Bl is being applied
to a set S of clauses, all of which contain at
least k literals. Each time a literal is added to R[B2,MS(k)](n) ~ 2k/(2k-l),
TRUE, the number of clauses saved, i.e.~ added to
SUB, is by Step 3 at least as large as the number
of clauses remaining in LEFT which are wounded, with equality for all sufficiently large n.
i.e., have one of their literals removed from LIT
without being added to TRUE. When the algorithm Proof. Suppose algorithm B2 is applied to a
halts, the only clauses left in LEFT are t h o s e set S, all of whose clauses contain at least k lit-
which have been wounded as many times as they con- erals. Initially, the total weight of all the
tain literals, and hence are dead. This means clauses in LEFT cannot exceed !S~/2 k. During each
that when the algorithm halts there are at least iteration, the weight of the clauses removed from
k'ILEFT wounds, and hence ISUB I ~ k. ILEFT I. Thus LEFT is, by Step 4 of algorithm B2, at least as
S* ~ S = ISUBI + ILEFTI ~ [(k+l)/k].ISUB I The large as the weight added to those remaining clauses
upper bound follows. which receive new wounds. Thus the total weight of
the clauses in LEFT can never increase, and so, when
For the lower bound, we give an example when the algorithm halts, it still cannot exceed IS]/2 k.
k = 3. Similar examples can be constructed for any But each of the dead clauses in LEFT when the algor-
other k > 0. Consider the input ithm halts must have been wounded as many times as
it had literals, hence must have had its weight
doubled that many times, and so must have final
S = {{Xl,X2,X3~, [Xl,X4,X5],
weight = I. Therefore ILEFT I ~ ISI/2 k, and so
(x2,x6,x 7} ,
ISUBI ~ ISI(l-i/2 k) and the upper bound follows.
{X3,X8,X9} }
We again give a lower bound example for k = 3
which can be generalized for arbitrary k. Consider
Clearly S* = 4 since the truth asslgmnent T = [Xl,
the input
x4,x6,x8] will satisfy all four clauses. However,
each of the literals occurs exactly once, so that S = [[Xl,X2,X3}, {Xl,X4,x5 ],
Bl might choose TRUE = [Xl,X2,X3} , thus killing
the clause {Xl,X2,X3]. Hence BI(S) = 3 and so [Xl,X2,X3}, {Xl,X6,X7 ],
r(BI, S) = 4/3 = (k+l)/k. [Xl,X2,X3}, [Xl,X8,X9 },
41
1/2 ~ ~ w(C) = 1/2, and so Xl would have been with equality for all sufficiently large n.
C6YF
added to TRUE, with the consequence that one of the Proof. First we show that the bound is attain-
four clauses containing x I must eventually die. able for sufficiently large n. Let the set to be
covered, T, consist of k.k! points, as shown in
Thus B2(S) = 7, and so r(B2,S) = 8/7 = 2k/(2k-l). Figure i. F will consist of k! sets making up the
An interesting fact about the proof of Theorems optimal subcover F 0, and k!o(~ (l/j)) additional
2 and 3 is that they are independent of the value J=l
O f S*, and hence actually prove stronger results sets which will make up a subcover F I that CI might
than are given by the statements of the theorems. choose. Divide T into k segments of k! points
The proof of Theorem 3, for instance, guarantees each, labeled from I to k, as shown.
that B2 will y l e l d a s e t s at least [~I(2k-I)/2~,
no matter what S* is, and the reader may verify The optimal subcover Foconslsts of kl dis-
joint sets, each containing one point from each of
that S* may be as small as [!SI(2k-i)/2K].-- the k segments. The choosable
5. SET COVERING I
msc(F' ) = IF'[.
per
4e
thus define a configuration K of the algorithm to Suppose the Lemma holds for h = k-l. We shall
be a triple show it also holds for h = k. So let KI be a legal
configuration, MO be a set such that MAX[IKI[i]]:
~NK, UNCOVK, <Krl],K[2] ..... K[NK]>>, i e MO] = k and U Kl[i] = UNCOVKi, and suppose
i6M0
the set M1 is selectable from KI. Since M1 is
where N K is a value for N, UNCOV K is a value for selectable, there is a run R = <~[l,Jl,K2,...Jt_l,
UNCOV, K[i] is a value for SET(i), i ~ i ~ NK, and Kt> such that M1 = numbers(R). Let r be the index
of the first ]i in the run for which IKirJi] I < k,
the values satisfy N~ K[i] = UINIOVK.
i=l that is, the first Ji for which- ISET(Ji) I was less
A run R from a configuration K will be a se- than k when Ji was chosen, (if none exists, let
quence r = t).
R = < KI,Ji,K2,J2 .... K(t-l),Jt_l,Kt> If we let MI' = {Ji: i < r] and COV = UNCOVKi-
UNCOVKr , then, since every j chosen prior to Jr
of alternating configurations and integers such had ]SET(j)I m k at the time it was chosen, we must
that KI = K, UNCOVKi ~ ~, i < t, UNCOVKt = ~, and have
such that if the algorithm enters Step 2 in con-
figuration Ki, it can choose Ji at Step 3, and the IMI'I ~ Icovl/k. (5.1)
resulting configuration, after choosing Ji and up-
dating at Step 4, is K(i+l). We may think of a run Now let us turn to configuration Kr. The set
as a possible pass through the algorithm, and say Mr = fJi: i ~ r} = M1 - MI' is selectable from Mr,
for instance that when Ji was chosen, the value of since R' = <Kr,Jr,...,Jt_l,Kt> is a run from Kr,
SET(Ji) was Ki[ji]. inheriting this property from R. Furthermore,
consider the sets Kr[i], i c M0. None of these
Note that all the Ji's in the sequence must
sets can have more than k-I elements, since Jr can
be distinct, since once Ji is chosen, SET(Ji) is be chosen from gr at Step 3, and so for all i
set to @, and so Ji cannot be chosen again. Let i ~ NKr = Nkl, |Kr[i]I ~ IKr[Jr] I < k. Moreover,
numbers(R) be the set of the Ji's in the run R. since Kr[i] = Kl[i] - COV, we have that
We say that a set MI of integers is selectab~e from
U Kr[i] = [J KI[i] - COV = U~OVKr
configuration K if there is a run R from K such i~0 i~0
that Mi = numbers(R). The following lermna is an
obvious consequence of these definitions: Thus the induction hypothesis for k-I applies
to Kr, Mr, and M0, and we have
Lermna I. Suppose F I ~ F is a subcover and
MI = [i: S i e Fi]. Let K be the configuration of IKrrill
C I after it has been given input F and initialized IMrl ~ ~ (~ (i/j)). (5.2)
itself via Step I. Then FI is ehoosable by CI i6MO J=l
given F if and only if MI is selectable from K.
The desired upper bound will be a consequence Now for each i 6 M0,
of a second, less trivial, lemma:
43
Since k can be taken to be arbitrarily large,
it follows that R[Ci,SC] must be at least 0(in(n)).
IKl[i][ IKr[i]l
by (5.1) and (5.2). Thus the le~mna holds for h = One Set
k and, by induction, is proved.
3.2 k'l
To conclude the upper bound proof: Let F be Points
any family, no set of which contains more than k
elements, F 0 an optimum subcover, and F 1 a choos-
able subcover with CI(F) = IFiI. Let K be the con-
figuration of C1 after it has been given input F
and initialized itself via Step I. Let M0 = {i:
S i e F0} and M1 = [i: S i e FI]. Since F 1 is choos- One Set
able given F, M1 must be selectable from K, by 3.2 k-2
Lemma I. Moreover, since F 0 is a suhcover, Points
k k 2k P t s 2k P t s 2k P t s
44
Theorem 5. For all k ~ I and n > O, Surprisingly, however, there exists an algorithm
C2 which, when applied to problem EC, will have be-
havior quite similar to that of CI applied to SC.
R [ C 1 , R c ' ( k ) ] ( n ) ~ 2,
C2 also requires time proportional to n 2 and is
described as follows:
and for all sufficiently large n, R[CI,NC'(k)](n)
(2k-l)/k. I. Set SUB = , LEFT = F, UNCOV = U s.
SEF
The upper bound given here is better than the 2. If UNCOV = , halt and return SUB.
one guaranteed by the SC(k) result for all k ~ 4. 3. Let S' LEFT be that set S whlch minimizes
However, note that if all points of T occur in pre- Ratio(S) = Is - UNCOVl/IS n U N C O V l
cisely two sets of F and all sets have precisely k 4. Set SUB = SUB U (S'}, UNCOV = UNCOV - S',
elements, IF I = (2[T!)/k = 2(Irl/k ) ~ 2F*. Al- LEFT = LEFT - (S').
though this constitutes a short proof of the the- 5. Go to 2.
orem's upper bound, its major significance is that
it shows that the algorithm which simply says, Theorem 6. For all k ~ I and n > 0,
"Given input F, return F," can guarantee this same k
upper bound without doing any work at all! R[C2,EC(k)](n) K I + in(k) ~ ~(I/j) + 1/2,
J=l
solutions for both SC and EC would be the same. If at a given time a set S' is chosen with RatiOS')
However, for less restricted inputs, the two pro- = IS' - UNCOVl/Is' N UNCOV I ~ y, then at this time
blems diverge, and optimal solutions for one can each S F 0 can have at most I/(y+l) of its points
be bad for the other. For instance, if OSC is an in UNCOV. For if S e F 0 N SUB, S has n__opoints in
algorithm which always chooses an optimal solution
for the SC problem, then (proof omitted): UNCOV; otherwise we must have Ratio(S) ~ Ratio(S')
y, so IS O UNCOVI/Is I ~ I/(y+l). Thus
lim R[OSC,EC(k)](n) = k.
F*/(y+l) = aIrl/(y+l ).
Conversely, an algorithm OEC which always chooses
an optimal solution to the EC problem will have
reciprocal inapplicability: And therefore, at least ITi(l-a/(y+l)) points, and
quite possibly more, must be outside of UNCOV, i.e.,
R[OEC,SC(k)] = k, for all sufficiently largen. already covered. Thus we cannot choose an S' with
R[OEC,SC] = O(n). Ratio(S') ~ y until l-a/(y+l) of the points of T
45
have been covered. Conversely, if x = IT-UNCOVI/
ITI, then Ratio(S') for the next set S' chosen can = a[0-1n(a) + In(k)] - I + a/k + a - a/k
not exceed a/(l-x)-l.
a[In(k) + I] - I.
Ratio(S') gives, for each new point covered
by the set S', the number of points in the set
which overlap points already covered. This fact Thus OV(F I) ~ IT1(a[In(k) + I] - I), and so
leads to interpretation of OV(Fi) as the area under
a curve. See Figure 3.
m(Fl) ~ Irl + Irl(a[In(k) + I] - I)
We divide the X-axis into a sequence of inter-
vals of length I/IT I corresponding to the points of = alTI[In(k ) + I] = F*[in(k) + I].
T, laid out along the X-axis in the order the points
were covered by the algorithm. The Y-value for
each interval is the number of overlaps contributed The upper bound follows.
by the corresponding point, as measured by RatiOS')
for the first set S' that covered it. The function Thus, despite the differences in measures and
f so defined is an increasing step function on the the differences in algorithms, our results for
interval (0,I), with maximum value k-l, and R[C2,EC(k)] are practically the same as the results
for R[CI,SC(k)]. Continuing the parallel, we also
OV(FI) = IT I ~f(x)dx. have R[C2,EC] = 0(In(n)). The lower bound example
0 is a modification of that given in Figure 2, where
F 0 is as before, and each of the smaller sets of
has points added to it from the largest one to
Y bring its total cardinality up to 3.2 k'l. Thus
C2(F) = (k+l)(3"2k-l), and so r(C2,F) = (k+l)/2 =
0(In(n)), where the problem size n is the same as
in the original example.
7. GRAPH COLORII~
46
I. Set DOM = CHROM = H = ~, COLOR = I, REST = N. then would have to start with a second color on the
2. If DOM = N, halt and return H. remaining graph, which is just H k. Since H I re-
3. If each node in REST is connected to some node
quires two colors, we thus can conclude that D2(Hk)
in CHROM, set COLOR = COLOR + I, CHROM = @.
4. Let x be a node in REST not connected to any = k+l, r(D2,Hk) = (k+l)/2, and R[D2] ~ O(log2n ).
node in CHROM.
5. Set H = H U [(x,COLOR)}, CHROM = CHROM U [x},
DOM = DOM U Ix], REST = REST r Ix].
6. Go to 2.
47
is of size 2. Thus r(E2,G) = k /2, and again
INPUTMc = (G = (N,A): G is a finite undirected R[E2] ~ o(nl/2).
graph with nodes N and
arcs A].
mMc(N'> = {N'{.
E1 in this process.
PI
Our best lower bound on R[FJ] is 0(nl/j+l).
P2
Figure 8 shows a graph with N k j+l points (k >> j),
k of which form a clique of size k, for which FI
will only find a clique of size j+2. For each sub-
clique J of size j in the k-clique, there are k
P0 Fk additional points PJ,I thru PJ,k" PJ,I and the
nodes of the clique J are mutually connected to the
k-I other Pj,i's. Since each point Pi outside of
FIGURE 6
J but still in the k-cllque is only mutually con-
nected with the nodes of J to k-j-I other points,
algorithm E1 started on SUB = J will next choose
The alternative approach of starting with N PJ,I and thus have to settle for a clique of size
and deleting nodes until a clique remains is just
J+2. Thus r(FI,G) = k/(j+2). Since there are N k j
as bad. Consider algorithm E2:
I. Set SUB = N.
2. If SUB is a clique, halt and return SUB. PJ,I
3. Let y e SUB be the node connected to the fewest
other nodes in SUB.
4. Set SUB = SUB - [y] and go to 2. ~ ~ , PJ, 2
48
subcllques of size j in a clique of size k, our 5. R.M. Karp, "Reducibility among combinatorial
graph has N k j+l points, thus our example yields problems", COMPLEXITY OF COMPUTER COMPUTATIONS,
R.E. Miller and J.W. Thatcher, eds. Plenum Press,
the lower bound R[Fj] o(nl/j+l). New York, 1972.
The cost for this apparent improvement in 6. J.H. Spencer, private co~nunicatlon.
worst case behavior is a running time proportional
to n j+2. If we wish to further increase our ex- 7. U.J.A. Welsh and M.B. Powell, '%n upper bound
pense, we could modify E1 so that in Step 3 it to the chromatic number of a graph and its
looked for a clique of size j instead of a single application to time-tabling problems", The
point. This however, would only lower the constant Computer Journal, Vol I0 (1967), p. 85.
of proportionality in the lower bound, as can be
seen by substituting a clique of size j for each of 8. D.C. Wood, "A technique for coloring a graph
the points PJ,i in the above example. applicable to large scale time-tabling problem,S
The Computer Journal, Vol 12 (1969), p. 317.
We have found n_qpolynomlal-tlme algorithm E
for this problem for which there does not exist an
> 0 such that R[E] > 0(nE), and no way to reduce
the ~ without significantly increasing the algor-
ithm's cost.
9o CONCLUSION
ACKNOWLEDGMENTS
BIBLIOGRAPHY
49