Approximation of the Quadratic Knapsack Problem

Report 4 Downloads 161 Views
O(n2/5) Approximation of the Quadratic Knapsack Problem Richard Taylora

arXiv:1509.01866v1 [cs.DS] 6 Sep 2015

a

Defence Science and Technology Group, Canberra, ACT 2600, Australia

Abstract For any given  > 0 we provide an algorithm for the Quadratic Knapsack Problem that has an approximation ratio of O(n2/5+ ) and a run time of O(n1/ ). Keywords: Quadratic knapsack Approximation algorithm 1. Introduction The quadratic knapsack problem (QK) can be defined in graph theoretic terms as follows. Let G be a graph with vertices vi , i = 1, .., n with costs ci ≥ 0 associated with the vertices and weights wij ≥ 0 associated with each edge ij and each vertex i (corresponding to wii ). Given a cost limit c the problem is to find a collection of vertices with total cost at most c with the total weight (the sum of all weights of vertices and edges in the induced subgraph) as large as possible. A particular form of this problem where the costs and weights are all 1 is equivalent to the densest k-subgraph problem (DkS). Thus DkS asks for the selection of k vertices so that the induced subgraph on those vertices has a maximum number of edges. The reader is referred to [4] for a survey of the QK problem, and the recent article [5] on approximating QK for special graph classes. In particular we note that [5] has no results on approximating QK in the general case, and the author is not aware of any such previously published results.

2. The Theorem Theorem. Let M be any approximation algorithm for DkS that has an approximation ratio of O(nα+ ), 0 < α < 1 and runs in time O(n1/ ). Then Preprint submitted to Operations Research Letters

September 8, 2015

M can be used to provide an approximation algorithm M 0 for QK that has 2α an approximation ratio of O(n 1+α + ) and runs in time O(n1/ ). 1 Since [1] provides an approximation algorithm for DkS with ratio O(n 4 + ) and runs in time O(n1/ ) the following corollary is immediate. Corollary. There is an algorithm for the Quadratic Knapsack Problem that has an approximation ratio of O(n2/5+ ) and a run time of O(n1/ ). Proof of the theorem. Let G be a graph with cost limit c. 2.1. Pruning, Rounding and Grouping We may prune all vertices with ci > c and all edges ij where ci + cj > c since these cannot be part of a feasible solution. Further if ci = 0 then the vertex can be pruned and the attached edge values added to the neighbouring vertices without affecting the problem. Also if wij = 0 then the edge ij can be pruned. Notation: Let M AX[G, c] be the maximum total weight of the solution to QK applied to the Graph G with cost limit c. Let GM AX [c] be a subgraph of G corresponding to a maximum solution. Let any subgraph in which the total cost of the vertices is at most c be termed feasible. Let eG denote the number of edges in any graph G. Let w∗ be the largest wij and 2l the largest power of 2 at most w∗ . Now form the graph G0 from G with each wij rounded down to the nearest weight among {2l , 2l−1 , .., 2l−p , 0} where p is the smallest integer above log2 n2 = 2log2 n. Then M AX[G0 , c] ≥ 1/4M AX[G, c] since the effect of deleting all edges with weights less than 2l−p and rounding down the remaining weights each reduce the maximum weight by a factor of at most 1/2. Similarly let c∗ be the largest ci and 2k the smallest power of 2 at least c∗ . Now group the vertices into buckets Vi , i = 1, .., l + 1 where l is the smallest integer above log2 n and Vi , i ≤ l is the collection of vertices vj where 2k−i < cj ≤ 2k+1−i and Vl+1 is the collection of vertices vj where 0 < cj ≤ 2k−l . 2.2. Five subgraph classes The edge and vertex weights of G0 can be shared among at most 2(log2 n+ 1)3 +1 subgraphs within five classes, with Classes 2-5 below based on the cost 2α groupings and weight roundings. We shall show how to obtain O(n 1+α + ) or better approximations for each of these classes in time O(n1/ ) or better. Class 1: The subgraph of G0 obtained by removing all of the edges. 2

Class 2: Subgraphs with costs within Vl+1 and edge weights some power of 2, and no vertex weights. Class 3: Subgraphs with costs within Vi , i ≤ l and edge weights some power of 2, and no vertex weights. Class 4: Bipartite subgraphs with one part having costs within Vl+1 , the other with costs within Vi , i ≤ l, and edge weights some power of 2, and no vertex weights. Class 5: Bipartite subgraphs with one part having costs within Vi , i ≤ l, the other with costs within Vj , i < j ≤ l, and edge weights some power of 2, and no vertex weights. Class 1 corresponds to the Knapsack problem and so has an algorithm that has an approximation ratio of 1 +  and a run time of O(n1/ ) [2], [3]. Since c ≥ c∗ then 2k−l ≤ c/n so Class 2 subgraphs have the sum of all vertex costs at most c. Thus the maximum edge weight is found by summing all the edge weights. Class 3: Let H be any subgraph in this class. We can scale the costs and weights and so assume without loss of generality that the vertex costs are between 1 and 2, and that the edge weights are all 1. Then the number of vertices r in any maximum solution must be between c/2 and c. So let H M AX [c] have r vertices. We may assume r ≥ 4 or else the problem is trivial. Let H t , t = bc/2c be any subgraph of H with a maximum number of edges formed by choosing t vertices. In particular we can choose t vertices from  r M AX H [c] in t ways and the collection of these choices counts each edge M AX of H [c] r−2 times. It follows that some such subgraph with t vertices t−2 must have a number of edges at least  r−2 t(t − 1) M AX 1 t−2  H M AX [c] = H [c] ≥ H M AX [c] (1) r r(r − 1) 10 t the minimum corresponding to r = 5, t = 2. Thus H t must have at least as many edges as this subgraph and is also feasible. H t can be approximated by algorithm M and provides a O(nα+ ) approximation algorithm that runs in time O(n1/ ). We note that α < 2α/(1 + α). This completes this class. In Classes 4 and 5 we shall have occasion to treat real fractions (such as |A|/4 and c/(4d)) as if they were integers. This is not important to the conclusions however if we ensure these fractions are at least 1. In the following for a bipartite graph H[A, B] with parts A and B, if A0 ⊂ A, B 0 ⊂ B then 3

H[A0 , B 0 ] refers to the subgraph of H[A, B] induced on A0 and B 0 . Class 4: Let H[A, B] be any subgraph in this class with parts A and B, with the vertex costs of A between 0 and 2k−l , and the vertex costs of B between d and 2d, d a power of 2. Since the edge weights are all equal we can assume without loss of generality that they are all 1. We may assume c ≥ 4d otherwise the problem is essentially finite by considering all choices of at most 4 the vertices of B. For each such choice the choice of corresponding vertices from A amounts to an instance of the Knapsack problem. Similarly we assume |A| ≥ 4. Select B 0 to be the c/(4d) highest degree vertices of B in H[A, B]. Then eH[A, B 0 ] is at least (1/4)M AX[H, c] since any feasible solution has at most c/d vertices from B. Now select A0 to be the |A|/4 highest degree vertices of A in H[A, B 0 ]. Then eH[A0 , B 0 ] ≥ (1/4)eH[A, B 0 ]. Thus eH[A0 , B 0 ] ≥ (1/16)M AX[H, c], and since 2k−l ≤ c/n the subgraph H[A0 , B 0 ] is also feasible as the total cost of vertices in each part is at most c/2. This completes this class. Class 5: Let H[A, B] be any subgraph in this class with parts A and B. We first observe that without loss of generality we can scale the edge weights to 1, and scale the vertex costs so that the vertices in A have costs between 1 and 2, the vertices of B have costs between d and 2d, where d is a positive power of 2 as in figure 1. We may also assume c ≥ 4d (see the argument in Class 4). We consider two cases. Case 1 |A| ≤ c(1+α)/(1−α) : Select the c/(4d) highest degree vertices B 0 of B. Then eH[A, B 0 ] ≥ 1/4M AX[H, c] since any feasible solution can have at most c/d vertices of B. Now select the c/4 highest degree vertices A0 of A in H[A, B 0 ]. This must reduce the number of edges of H[A, B 0 ] by a factor of at most c/(4|A|). So H[A0 , B 0 ] is feasible and since n ≥ |A| c eH[A, B 0 ] 4|A| 1 1−α ≥ |A| 1+α −1 eH[A, B 0 ] 4 1 −2α ≥ n 1+α M AX[H, c]. 16

eH[A0 , B 0 ] ≥

4

(2)

Figure 1: bipartite graphs H and H ∗

2.3. A transformation method Case 2 |A| > c(1+α)/(1−α) : Construct a graph H ∗ from H by replacing B by d copies B1 , .., Bd of the vertices of B with edges between A and each Bi copying the edges between A and B. Thus if A = {ai , i = 1, .., r}, B = {bi , i = 1, .., s} and Bj = {bij , i = 1, .., s, j = 1, .., d} then (ai , bj ) is an edge of H iff (ai , bjk ), k = 1, .., d is an edge of H ∗ .

(3)

In H ∗ set cost(bij )=(1/d)cost(bi ) and so between 1 and 2 (see figure 1). Now M AX[H ∗ , c] ≥ dM AX[H, c] since any feasible subgraph of H can be replicated d times to a feasible solution of H ∗ . Use algorithm M to approximate the DkS problem for H ∗ with k = c to within an approximation ratio of say p. Let H ∗∗ [A0 , B10 , B20 , .., Bd0 ] be an induced subgraph corresponding to this approximation. Define δij be the degree of bij in H ∗∗ (if bij is not in H ∗∗ then δij = 0), and δi∗ = maxj {δij }. Now choose a subgraph of H as follows. Select B 0 be those bi for which δi∗ is among the c/(4d) highest values among {δj∗ }. Then since ∪Bi0 contains at most c vertices eH[A0 , B 0 ] ≥

1 1 eH ∗∗ [A0 , B10 , B20 , .., Bd0 ] ≥ M AX[H ∗ , c]. 4d 4dp

5

(4)

Now select A00 to be the c/4 highest degrees of A0 in H[A0 , B 0 ]. Since |A0 | is at most c, eH[A00 , B 0 ] ≥ (1/4)eH[A0 , B 0 ] and so 1 1 M AX[H ∗ , c] ≥ M AX[H, c]. (5) eH[A00 , B 0 ] ≥ 16dp 16p H[A00 , B 0 ] is feasible since the total cost of vertices in each part is at most c/2. By the inequality defing this case 1−α

1−α

c < |A| 1+α ≤ n 1+α

(6)

so H ∗ has at most nd vertices where 1−α 1 1 1 2 nd ≤ nc < n1+ 1+α ≤ n 1+α . (7) 4 4 4 Thus the selection of H[A00 , B 0 ] through the use of M provides an approx2α imation ratio of at most O(n 1+α + ) to M AX[H, c] by inequality 5. This completes this case and also this class. To complete the proof of the theorem we note that G0M AX [c] must share a vertex/edge weight of at least 1/[2(log2 n+1)3 +1] of M AX[G0 , c] with at least one of the subgraphs H in classes 1-5. Thus the largest weight found among the approximations to M AX[H, c] over the subgraphs must approximate α + 0 1+α ) (the log coefficient M AX[G , c], and so M AX[G, c], to within O(n term can effectively be absorbed into the  term). It is straightforward to also verify the run time is at most O(n1/ ). References [1] A Bhaskara, C Charikar, E Chlamtac, Detecting High Log-Densities an O(n1/4 ) Approximation for Densest k-Subgraph, STOC’10, June 5-8 2010, Cambridge Massachusetts, USA, Berlin, (2010) [2] V Vazirani, Approximation Algorithms, Springer, (2003) [3] M Garey, D Johnson, Computers and Intractability - A guide to the theory of NP-Completeness (1979) [4] D Pisinger, The quadratic knapsack problem - a survey, Discrete Applied mathematics 155, pp 623-648 (2007) [5] U Pferschy, J Schauer, Approximating the Quadratic Knapsack Problem on Special Graph Classes, Lecture Notes in Computer Science 8447, pp 61-72 (2014) 6