Você está na página 1de 3

CSC373 Algorithm Design, Analysis, and Complexity Spring 2012

Solutions for Assignment 4: Approximation Algorithms and Linear Programming

1. LP and Dual LP for Knapsack. 1a) Select rows {s1 , s2 , s3 } = {1, 4, 7} of the LP. Then the linear system and solution for x is 1 1 1 0 0 w1 w2 w3 x = B , so x = (B w1 )/w2 . 0 0 1 0 0 Since we were given w1 < B < w1 + w2 , we have 0 < Ax = (1,
Bw1 T w2 , 0, B) T Bw1 w2

(1)

< 1, and it follows that 0 x 1. Moreover,

b . Therefore x is a feasible vertex of the LP. cT x = v T x = v1 + (v2 /w2 )(B w1 ). (2)

The prot for this vertex x is 1b) The feasibility constraints for the dual LP are yT A I4 vT 0T , (3)

where I4 is the 4 4 identity matrix. For the above choice of rows which dene the vertex x of the LP, we have (s) = (1 0 0 1 0 0 1). Therefore the corresponding columns from equation (3) are specied by (t) = (1 1 0 0 1 1 0). That is, the corresponding vertex of the Dual LP (if it is feasible) is formed from the linear system using columns t = {1, 2, 5, 6} of (3). In particular, 1 0 0 0 0 1 1 0 = v1 v2 0 0 . (4) yT 0 0 0 1 w1 w2 0 0 The solution of this system is y T = (w1 [v1 /w1 v2 /w2 ], 0, 0, v2 /w2 )T . It follows from the sorted order that v1 /w1 v2 /w2 and y is non-negative. Moreover, again by the ordering of vk /wk , y TA = v1 v2 w3 v2 /w2 w4 v2 /w2 v1 v2 w3 v3 /w3 w4 v4 /w4 = v T = c T. (5)

Therefore y is a feasible vertex of the dual LP. The prot for this vertex is y T b = w1 [v1 /w1 v2 /w2 ] + Bv2 /w2 = v1 + (v2 /w2 )(B w1 ). (6)

1c) Since x and y are feasible solutions for the LP and the dual LP, respectively, and the prot (2) of x is equal to the prot (6) of y, we conclude (by the LP Duality Theorem) that the vertex x is an optimal solution of the LP. (Moreover, y is an optimal vertex of the dual LP.) 2. Greedy Knapsack. 2a) Ga Knap is not a -approximation. To see this, consider the set of examples with (v1 , w1 ) = (2, 1) and (v2 , w2 ) = (B, B), where B is the capacity of the knapsack. Note v1 /w1 > v2 /w2 . The algorithm Ga Knap therefore produces the solution Sa = {1}. The value of this solution is V (Sa ) = v1 = 2. However, for B > 2 the optimum solution is S = {2} with V (S ) = B. As B we see that a lower bound on the approximation ratio is V (S )/V (Sa ) = B/2 . Therefore there is no upper bound for this approximation ratio. 1

2b) Gb Knap is not a -approximation. To see this, consider the set of examples with (v1 , w1 ) = (2, B) and (vk , wk ) = (1, 1) for k = 2, 3, . . . , K with K = B + 1. Then v1 > v2 = . . . = vK , so the items are already sorted in the order considered by the algorithm. It follows that Gb Knap produces the solution Sb = {1}, which lls the knapsack. The value of this solution is V (Sa ) = v1 = 2. However, for B > 2 the optimum solution is S = {2, 3, . . . , K} with V (S ) = B. As B we see that a lower bound on the approximation ratio is V (S )/V (Sb ) = B/2 . Therefore there is no upper bound for this approximation ratio. 2c) We prove below that Gc Knap is a 2-approximation. As in the assignment handout we suppose vk /wk have been sorted in decreasing order and each wk B. K In the case that all the items (together) t in the knapsack, namely k=1 wk B, it is easily seen that all the greedy algorithms, G[a-c] Knap, return the optimal solution (i.e., all items). Therefore we consider only the case
K

wk > B.
k=1 j1

(7)

Dene j to be the largest integer such that k=1 wk B. By eqn (7) we know j <= K. It now follows from the sorted order of vk /wk that the algorithn Ga Knap produces the solution
j1

Sa = {1, 2, . . . , j 1}, and V (Sa ) =


k=1

vk .

(8)

From the assumption that wk B for each item k we know that algorithm Gb Knap must return at least the item of largest value. That is, k Sb , with k = arg max vk , and V (Sb ) vk = max vk .
k k

(9)

Finally, the value returned by Gc Knap is V (Sc ) = max{V (Sa ), V (Sb )}. We use these expressions for the returned values of the greedy algorithms further below. Next consider the relaxed LP which is a direct generalization of equations (1) and (2) in the assignment handout to K variables. Then it follows from a similar argument to the solution of problem (1) that the optimum solution of this LP is x = (1, 1, . . . , 1,
vj wj (B j1 k=1

(10)

vj (B wj

j1

wk ), 0, . . . , 0)T .
k=1

(11)

In equation (11), the term and optimal for the LP.

wk ) is the j th coecient of x. We omit the proof that x is feasible

The optimum prot for the LP is therefore


j1

OPT(LP) = v T x =
k=1 j1

vk + vj ,
j1 k=1

(12)
j1 k=1

with = (B k=1 wk )/wj . By the denition of j we know j1 follows that 0 B k=1 wk < wj , and so [0, 1).

wk B < wj +

wk . It therefore

The integer linear program (ILP) corresponding to Knapsack (as in a previous tutorial) consists of the same prot and feasibility conditions in equations (1) and (2) of the assignment handout, plus the constraint that xk {0, 1} for each k. Then this ILP corresponds to the original knapsack problem through the 2

indicator variables xk , where xk = 1 i item k is in the knapsack. Let OP T (ILP ) denote the optimal prot of this ILP, which is also the optimal value that can be placed in the knapsack. Then we have OP T (ILP ) OP T (LP ), since the feasible set of LP is a strict subset of ILP (and the prots are the same). Moreover, by (8), (9), (10), and (12), we have OPT(ILP) OP T (LP ) = V (Sa ) + vj V (Sa ) + V (Sb ), (1 + )V (Sc ),
1 where [0, 1). There V (Sc ) 1+ OP T (ILP ) > 1 OP T (ILP ). Since OP T (ILP ) is the optimum 2 solution of the original Knapsack problem, it follows that Gc Knap is a 2-approximation.

Você também pode gostar