Abstract 1 Introduction 2 Exact algorithm 3 Approximation algorithm References

Covering Weighted Points Using Unit Squares

Chaeyoon Chung ORCID Department of Computer Science and Engineering, Pohang University of Science and Technology, South Korea Jaegun Lee ORCID Department of Computer Science and Engineering, Pohang University of Science and Technology, South Korea Hee-Kap Ahn ORCID Department of Computer Science and Engineering, Graduate School of Artificial Intelligence, Pohang University of Science and Technology, South Korea
Abstract

Given a set of n points in d-dimensional space, each assigned a positive weight, we study the problem of finding k axis-parallel unit hypercubes that maximize the total weight of the points contained in their union. In this paper, we present both exact and (1ε)-approximation algorithms for the case of k=2. We present an exact algorithm that runs in O(n2) time in the plane, improving the previous O(n2log2n)-time result. This algorithm generalizes to higher dimensions and larger k in O(ndk/2) time for fixed d and k. We also present a (1ε)-approximation algorithm that runs in O(nlogmin{n,1/ε}+1/ε3) time for k=2 in the plane, improving the best known result. Our approximation algorithm also extends to higher dimensions.

Keywords and phrases:
Maximum coverage, Unit squares, Approximation algorithms
Copyright and License:
[Uncaptioned image] © Chaeyoon Chung, Jaegun Lee, and Hee-Kap Ahn; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Computational geometry
Funding:
This work was partly supported by the National Research Foundation of Korea (NRF) grant funded by the Korea government(MSIT) (RS-2023-00219980), and the Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korea government (MSIT) (No.RS-2019-II191906, Artificial Intelligence Graduate School Program (POSTECH)) and (No. 2017-0-00905, Software Star Lab (Optimal Data Structure and Algorithmic Applications in Dynamic Geometric Environment)).
Editors:
Ho-Lin Chen, Wing-Kai Hon, and Meng-Tsung Tsai

1 Introduction

The maximum coverage problem is a classic and widely studied problem in theoretical computer science and computational geometry. Given a set of weighted elements, a collection of subsets, and an integer k, the goal is to choose up to k subsets that maximize the total weight of the elements contained in the union of the subsets. This problem naturally models many real-world scenarios such as facility location, sensor placement, and resource allocation. It is well-known that the maximum coverage problem is NP-hard and cannot be approximated within a factor better than (11/e) unless P = NP [5, 6, 13].

In this paper, we study a geometric version of the problem, specifically the variant where the covering objects are axis-parallel unit hypercubes.

Definition 1 (k-Cover(P)).

Given a set P of n points in d-dimensional space, where each point is assigned a positive weight, find k axis-parallel unit hypercubes such that the total weight of points covered by their union is maximized.

The problem k-Cover(P) is NP-hard when k is part of the input, even for d=2 [10]. There are results for fixed and small k. For 1-Cover(P), Imai and Asano [7], and Nandy and Bhattacharya [12] gave exact algorithms which run in O(nlogn) time. This is proven to be optimal in the algebraic decision tree model [1]. For 2-Cover(P), Mahapatra et al. [9] gave an algorithm that runs in O(n2log2n) time using O(nlogn) space. They also studied a variant where the solution pair of squares must not share a common input point and gave an O(n2)-time algorithm. Cabello et al. [2] considered a more restricted version of 2-Cover(P) where the solution pair of squares must be disjoint and gave an O(nlogn)-time algorithm.

There are also approximation algorithms for this problem. For 1-Cover(P), Tao et al.[14] gave a randomized approximation scheme that computes a (1ε)-approximate solution with probability at least 11/n and runs in O(nlog(1/ε))+nloglogn) time. This was later improved by Jin et al.[8] with an algorithm with running time O(nlog(1/ε)).

For k3, de Berg et al. [4] gave an algorithm that can be extended to compute a (1ε)-approximate solution to k-Cover(P) in O(n(k/ε)O(k)) time. Jin et al. [8] gave an (1ε)-approximation algorithm for k-Cover(P) which runs in O((n/ε)log(1/ε)+(k/ε)log(1/ε)+k(1/ε)Δ) time, where Δ=O(min(k,1/ε)).

There are work on the problem in higher dimensions d3. For k=1, the problem reduces to the well-known maximum depth problem that, given a set of weighted hypercubes, finds a point maximizing the total weight of the hypercubes containing the point. Chan [3] gave an O(nd/2)-time algorithm for this problem when d3. For k2, however, little is known in higher dimensions (d3). Mostafavi and Hamzeh [11] studied the problem of approximating the smallest axis-parallel box that covers a given set of points in d while allowing z outliers, and gave a 2-approximation algorithm with running time O(ndlogn).

1.1 Our results

We present both exact and approximation algorithms for 2-Cover(P). We present an O(n2)-time algorithm for 2-Cover(P) in the plane by reducing the problem to the Depth problem (See Section 1.2). Our approach extends for any fixed d,k>2 with little modification, resulting in an O(ndk/2)-time algorithm for k-Cover(P) in d-dimensional space. More importantly, we present a (1ε)-approximation algorithm for 2-Cover(P) in the plane running in O(nlogmin{n,1/ε}+1/ε3) time. This improves upon the previous best result by Jin et al. [8], which runs in O((n/ε)log(1/ε)+(1/ε)O(1)) time, with big hidden constants. In contrast, our algorithm runs faster, is simple, and easy to implement. Our algorithm extends for any fixed d3 with little modification, running in O((n/εd2)log(1/ε)+1/ε2d1) time.

Hidden Constants in the running time of the algorithm in [8].

For k=2, it takes O((n/ε)log(1/ε)+(1/ε)O(1)) time. It begins by constructing a grid G with cells of size 6/ε. For each cell c of G, it first computes a (1ε)-approximate solution to 1-Cover(Pc), where Pc denotes the set of points in P contained in c. Among all cells in G, it greedily selects two cells whose (1ε)-approximate solution to 1-Cover(Pc) covers the maximum weight. To approximate 2-Cover within each cell, it constructs an additional finer grid consisting of O(1/ε3) horizontal and vertical lines, yielding O(1/ε6) grid points. Each grid point is considered as a potential candidate for the upper-left corner of a square. Furthermore, this process is repeated over O(1/ε) different grids. Thus, the second term is Ω(1/ε7) time.

1.2 Preliminaries

For simplicity, we omit the terms “unit” and “axis-parallel” when they are clear from the context. For a compact set X, we use int(X) to denote the interior of X.

We denote by P a set of positively weighted points in d-dimensional space, and by w(P) the total weight of points in P. We say that a region R covers weight w if the total weight of the points in P contained in R is w. For any region R, we denote by w(R) the total weight of points in P covered by R. Let opt(P) denote the total weight of points covered by an optimal pair of hypercubes to 2-Cover(P).

Definition 2 (k-Depth(R)).

Given a set R of n positively weighted boxes (hyperrectangles) in d-dimensional space, find k points in d that maximizes the sum of weights of the boxes in R containing at least one of the points. Let Depth(R) denote 1-Depth(R).

2 Exact algorithm

We show that an instance of 2-Cover in the plane can be reduced to an instance of Depth in 4-dimensional space. This yields an O(n2)-time algorithm for 2-Cover in the plane, improving upon the previously best-known O(n2log2n)-time algorithm. We then generalize this approach to higher dimensions and larger k, reducing an instance of k-Cover in d-dimensional space to an instance of Depth in dk-dimensional space, which can be solved in O(ndk/2) time for d3 [3].

2.1 Two squares in the plane

For a set P of n points in the plane, we give a reduction from 2-Cover(P) to an instance of Depth in 4-dimensional space. For a unit square s in the plane, we represent its location by the coordinates of its top-right corner, denoted by (sx,sy) (See Figure 1(a)). By representing a pair of unit squares (s,s) as a point in 4-dimensional space, (sx,sy,sx,sy), there is a one-to-one correspondence between a placement of a pair of squares and a point in 4-dimensional space.

A unit square s covers a point p=(px,py) in the plane if and only if pxsxpx+1 and pysypy+1. Let H(p) denote the set of points in 4-dimensional space that correspond to all placements of two unit squares containing p in their union. Then, H(p)=H1(p)H2(p) and Hi(p)={(x1,y1,x2,y2)pxxipx+1,pyyipy+1} for i=1,2. See Figure 1.

Figure 1: (a) A point p=(px,py) and a pair of squares (s,s) whose union covers p. (b) A bounding box B is represented by dashed lines. For illustration, we show the projection of H(p)B onto the x1x2-plane (gray region). The pair of unit squares (s,s) corresponds to a point (sx,sy,sx,sy) in the 4-dimensional parameter space, and its projection is also shown.

By restricting the parameter space to a sufficiently large bounding box B=[bmin,bmax]4, H(p) can be represented as a union of interior-disjoint boxes in B. (Let bmin be the minimum coordinate value over all points in P and let bmax be the maximum coordinate value over all points in P plus one.) Clearly, H(p)B can be represented as the union of O(1) mutually interior-disjoint boxes in the 4-dimensional space. Let B(p) denote this set of interior-disjoint boxes such that the weight of each box is set to the weight of p. Let T denote the collection of the boxes in B(p) for all pP. We now show that an optimal point for Depth(T) corresponds to an optimal pair of squares for 2-Cover(P). Here, we slightly abuse the notation so that opt(T) denotes the total weight of boxes in T containing an optimal point of Depth(T).

Lemma 3.

opt(T)=opt(P).

Proof.

Let (s,s) be an optimal pair of squares for 2-Cover(P). This pair corresponds to the point qs,s=(sx,sy,sx,sy) in the 4-dimensional parameter space. Let PP be the set of points covered by the union of s and s, that is, w(P)=opt(P). By definition, we have qs,sH(p) for every pP. Thus, for each pP, there is at least one box in B(p) that contains qs,s, implying opt(T)opt(P).

Let qr,r=(rx,ry,rx,ry) be an optimal point for Depth(T), and let TT be the set of boxes in T that contain qr,r. (By a symbolic perturbation to the boxes, we can avoid double counting while preserving the maximum depth.) Then the total weight of points pP such that qr,rH(p) is exactly opt(T). This means the pair of squares (r,r) together cover the total weight opt(T) which is at most opt(P).

As |T|=O(n) and Depth(T) can be solved in O(nd/2) time [3], we have the following.

Theorem 4.

Given a set P of n positively weighted points in the plane, we can compute an optimal pair of unit squares for 2-Cover(P) in O(n2) time.

2.2 Extension to larger 𝒌 and higher dimensions

We can naturally extend this framework to handle k-Cover(P) for general k3. By representing the placement of k squares can also be specified by their top-right corners, it corresponds to a single point in 2k-dimensional parameter space. There is a one-to-one correspondence between a point in this 2k-dimensional space and a specific placement of the k squares in the plane. Then H(p),Hi(p), and B(p) can be defined for a point p analogously. The remaining procedure is exactly the same as in the case of k=2.

Corollary 5.

Given a set P of n positively weighted points in the plane, we can compute an optimal set of k unit squares for k-Cover(P) in O(nk) time.

Our approach also extends to higher dimensions with little modification, except that the location of a hypercube, represented by one of its corners, now requires d coordinates. As a result, we obtain a set T of boxes in dk-dimensional space.

Corollary 6.

Given a set P of n positively weighted points in d-dimensional space, we can compute an optimal set of k unit hypercubes for k-Cover(P) in O(ndk/2) time.

3 Approximation algorithm

Given a set P of n positively weighted points in the plane, we present a (1ε)-approximation algorithm for 2-Cover(P) that runs in O(nlogmin{n,1/ε}+1/ε3) time for any fixed ε>0. Specifically, it returns a pair of squares whose union covers a weight at least (1ε)opt(P). Compared to the (1ε)-approximation algorithm by Jin et al. [8], our algorithm runs faster asymptotically. Moreover, our algorithm is simple and easy to implement, and it can be extended to higher dimensions with little modifications.

3.1 Types of solutions

For any pair (s1,s2) of squares, either (1) int(s1)int(s2)= or (2) int(s1)int(s2). See Figure 2 for an illustration. We solve two cases of the problem: Type (1) case finds two squares (s1,s2) with int(s1)int(s2)= whose union covers the maximum weight. Type (2) case finds two squares (s1,s2) with int(s1)int(s2) whose union covers the maximum weight. An optimal solution to the type (1) case can be computed in O(nlogn) time [2]. We show how to find a (1ε)-approximate solution to the type (1) case for 2-Cover(P) in O(nlog(1/ε)) time.

Lemma 7.

Given a set P of n positively weighted points in the plane, a (1ε)-approximate solution to the type (1) case can be computed in O(nlog(1/ε)) time.

Proof.

We note that Jin et al. [8] presented an algorithm that computes a (1ε)-approximate square for 1-Cover(P) in O(nlog(1/ε)) time. We adopt their grid-shifting technique for our problem. Let G3(a,b) denote the square grid with mesh size 3, where the vertical and horizontal grid lines are defined as:

G3(a,b)={(x,y)2x=a+3k,k}{(x,y)2y=b+3k,k}.

Consider the following nine grids: G3(a,b) for all a,b{1,2,3}. It can be easily shown that for any two unit squares s1 and s2, there exists at least one of these grids such that both s1 and s2 do not intersect any grid lines Therefore, for every grid G{G3(a,b)a,b{1,2,3}}, we aim to compute a pair of disjoint unit squares that do not intersect any grid lines of G, and we return the pair that covers the maximum total weight.

For a grid G{G3(a,b)a,b{1,2,3}}, we perform the following preprocessing. We compute a (1ε)-approximate square for 1-Cover(Pc) for every nonempty cell c of G where Pc denotes the set of points of P in c. We note that Jin et al. [8] give an algorithm, MaxCovCell(c), which computes a (1ε)-approximate to 1-Cover(Pc) in O(|Pc|log(1/ε)+1/ε2) time for a cell c of G if the size of c is constant. For each cell of G which contains larger than (1/ε)2 points, we run MaxCovCell. For the remaining nonempty cells, we run the exact algorithm which runs in O(|Pc|log|Pc|) time [2]. Let n1nj(1/ε2)nj+1nj+k be the sorted sequence of the number of points in nonempty cells of G. Then the total running time is i=1jO(nilog(1/ε)+(1/ε)2)+i=1kO(ni+jlog(ni+j)), which is O(nlog(1/ε)).

To make use of the above results, we consider two cases based on whether there exists an optimal disjoint pair of squares for 2-Cover(P) such that the two squares are contained in different cells of G, or the two squares are contained in different cells of G.

Case 1.

We first consider the case where there exists an optimal pair of squares of type (1) for 2-Cover(P) such that the two squares are contained in different cells of G. In this case, there always exist at least two cells of G whose respective (1ε)-approximate solutions together cover at least the weight of εopt(P). Therefore, among all cells of G, we select the pair of cells whose (1ε)-approximate solutions together cover the maximum total weight. The union of these two (1ε)-approximate solutions then forms a (1ε)-approximate solution for 2-Cover(P).

Before moving onto the second case, we provide a summary of MaxCovCell(c).

MaxCovCell(c).

For a given cell c, they form another (non-uniform) grid G which consists of O(1/ε) horizontal lines and O(1/ε) vertical lines such that the following property holds: For a unit square q, it holds that w(r(q)c)εw(qc) where r(q) denotes the largest axis-parallel rectangle contained in q whose corners all lie on grid points of G. They construct such grid G in O(|Pc|log(1/ε)) time. The details of the method used to construct G can be found in Lemmas 1 and 2 of [8].

For each cell c of G, they calculate the sum of weights of points at the interior, edges, or corners of c in O(|Pc|log(1/ε)) time. Then they enumerate every vertex of G and consider the unit square q which has its top-left corner on the vertex. While enumerating those vertices and corresponding unit squares q, they calculate w(r(q)c). Then the one that covers the maximum weight can be found in O(1/ε2) time with a standard incremental algorithm, and it is a (1ε)-approximate solution to 1-Cover(Pc).

Case 2.

Now we consider the case where an optimal pair of squares of type (1) for 2-Cover(P) is contained in the same cell of G. We can observe that once we compute a (1ε)-approximate pair of squares to 2-Cover(Pc) for every cell c of G, and we can return the pair which covers the maximum total weight as a (1ε)-approximate solution to 2-Cover(P).

We first note that there exists an O(nlogn)-time exact algorithm for 2-Cover(P) in the case where a disjoint optimal pair of squares exists [2]. For any cell c with |Pc|1/ε2, we can directly apply this algorithm for 2-Cover(Pc), which takes O(|Pc|log|Pc|)=O(|Pc|log(1/ε)) time. Therefore, we now focus on the remaining cells c with |Pc|>1/ε2.

To compute a (1ε)-approximate solution of type (1) for 2-Cover(Pc), we further utilize the information obtained from the procedure MaxCovCell(c). Recall that we calculated w(r(q)c) for the squares q which has its top-left corner on the vertex of G. Among the rectangle r(q)’s, we find a disjoint pair whose union covers the maximum total weight. This can be done using the observation that there always exists a horizontal or vertical line that separates the two disjoint squares. Without loss of generality, we can sweep a horizontal line across the plane and, at each position, track the maximum value of w(r(q)c) achievable by placing q on one side of the sweep line. We repeat this process by sweeping the line in both directions. By combining the results from both sweeps, we can identify two disjoint rectangles among the r(q)’s whose union covers the maximum total weight. We note that this procedure can be implemented as part of the MaxCovCell(c). Then a pair of unit squares, each containing one of the rectangles, is a (1ε)-approximate solution to 2-Cover(Pc).

Among all the cells c of G, the pair of squares for 2-Cover(Pc) that covers the maximum total weight is a (1ε)-approximate solution to 2-Cover(P).

For each grid G{G3(a,b)a,b{1,2,3}}, we compute a (1ε)-approximate solution for both cases in O(nlog(1/ε)) time and take the one that covers the larger total weight. Then we repeat this process for every grid G{G3(a,b)a,b{1,2,3}}, and we return the pair of squares that covers the maximum total weight.

Figure 2: Solutions for 2-Cover with unit-weighted points. (a) A solution for the type (1) case, which is optimal for 2-Cover. No optimal to the type (2) case is optimal to 2-Cover. (b) Two optimal solutions (red and blue) to the type (2) case, which are optimal for 2-Cover. No optimal to the type (1) case is optimal to 2-Cover.

If an optimal pair of squares for the type (1) case is an optimal pair of squares for 2-Cover(P), we can compute a (1ε)-approximate solution for 2-Cover(P) in O(nlog(1/ε)) time by Lemma 7. From now on, we assume that every optimal pair of squares for 2-Cover(P) intersect each other in their interior, and we focus on computing a (1ε)-approximate solution to the type (2) case. Once we obtain a (1ε)-approximate solution to the type (2) case, we compare it with the approximate solution to the type (1) case and return the one with the larger total weight.

3.2 Search space of the type (2) case

We begin with reducing the search space for 2-Cover(P). We use s to denote an optimal square for 1-Cover(P).

Lemma 8.

There is an optimal pair of squares for 2-Cover(P) such that both squares intersect int(s).

Proof.

Suppose that, for an optimal pair (s1,s2) for 2-Cover(P), s2 does not intersect int(s). See Figure 3(a). Since s is an optimal square for 1-Cover(P), w(s1)w(s). Thus, w(s1s2)w(s1)+w(s2)w(s)+w(s2), implying that (s,s2) is an optimal pair of squares for 2-Cover(P). Observe that int(s)int(s2)=, which contradicts our assumption that every optimal pair of squares for 2-Cover(P) intersect each other in their interiors.

Figure 3: (a) An optimal square s for 1-Cover(P) and an optimal pair (s1,s2) for 2-Cover(P). (s,s2) is also an optimal pair for 2-Cover(P). (b) 3×3 square centered at s. (c) A set Q={q1,q2,,q5} of squares and a grid 𝒢 formed by Lv and Lh (gray lines). The rectangles in R={r(q)qQ} are drawn in red. Note that r(q2)=r(q3).

Lemma 8 immediately implies the existence of an optimal pair of squares for 2-Cover(P) that are contained in the 3×3 square centered at s. See Figure 3(b). We have a similar statement for a (1ε)-approximate square s~ for 1-Cover(P).

Lemma 9.

There exists a (1ε)-approximate pair of squares (s1,s2) for 2-Cover(P) such that int(s1)int(s~) or int(s2)int(s~).

Proof.

Suppose that neither s1 nor s2 intersects int(s~). Without loss of generality, assume that w(s1)w(s2). Then, w(s1)(1ε)opt(P)/2. Since s~ is a (1ε)-approximate square for 1-Cover(P), 2w(s~)(1ε)opt(P). Thus, w(s1s~)=w(s1)+w(s~)(1ε)opt(P), implying that (s~,s1) is a (1ε)-approximate pair of squares for 2-Cover(P).

Recall that we compute a (1ε)-approximate solution to the type (2) case. By Lemma 9, we have the following.

Lemma 10.

There exists a (1ε)-approximate pair (s1,s2) of squares for 2-Cover(P) such that both s1,s2 are contained in the 5×5 square centered at s~.

By Lemmas 8, 9, and 10, the search space for 2-Cover(P) is a 5×5 square centered at s or s~. We compute either s or s~ depending on the comparison between n and 1/ε, identify the corresponding search space, and remove the points of P lying outside this search space. Since s can be computed in O(nlogn) time [2] and s~ can be computed in O(nlog(1/ε)) time by Lemma 7, this step can be completed in O(nlogmin{1/ε,n}) time.

From now on, we assume that every point of P lies in the 5×5 square. Clearly, there is a unit square that contains a subset of P whose total weight is at least w(P)/25.

Lemma 11.

opt(P)w(P)/25.

3.3 Reduction to 𝟐-Depth

Consider a dual mapping between a weighted point and a weighted square. For a point p=(a,b) with weight wp, the dual p¯ of p is a unit square centered at (a,b) and with weight wp. For a square s with weight ws centered at (a,b), the dual s¯ of s is the point (a,b) with weight ws. Observe that s contains p if and only if p¯ contains s¯.

Let Q denote the set of weighted squares p¯ for each pP. Throughout this section, for a square qQ, we denote by w(q) the weight q. For an optimal pair (p1,p2) of points for 2-Depth(Q), (p¯1,p¯2) form an optimal pair of squares for 2-Cover(P). Thus, we transform P into Q, and solve 2-Depth(Q). We then return the pair of squares that is dual to the solution to 2-Depth(Q) as a solution for 2-Cover(P). Since we aims to compute a (1ε)-approximate solution for 2-Cover(P), it suffices to compute a (1ε)-approximate solution to 2-Depth(Q). To do this, we construct a grid 𝒢 and snap round each rectangle in Q to 𝒢.

Grid.

We construct a grid 𝒢 with O(1/ε) horizontal and vertical lines with respect to 𝖰 using the following lemma, which is obtained by combining Lemmas 1 and 2 of [8].

Lemma 12 ([8]).

Given n positively weighted points with distinct x-coordinates in the plane whose weight sum is W, and a value wd with 0<wdW, we can find O(W/wd) vertical lines such that the sum of the weights of points lying in the interior of the slab bounded by any two consecutive lines is at most wd in time O(nlog(W/wd)).

Let VQ denote the set of corners of the squares in Q. The weight of vVQ is set to the weight of its corresponding square. Let Lv be the set of vertical lines obtained by applying Lemma 12 with wd=εw(P)/50. Let Lh be the set of horizontal lines defined in exactly the same way. Let 𝒢 denote the grid formed by Lv and Lh. By Lemma 12, 𝒢 can be constructed in O(nlog(min{n,1/ε})) time. In particular, when n<1/ε, we can simply draw horizontal and vertical lines through every point in VQ.

Snap rounding.

For each square qQ, let r(q) be the largest axis-parallel rectangle contained in q whose corners all lie on grid points of 𝒢. Let R={r(q)qQ}. The weight of r(q) is set to the weight of q. If two or more squares in Q have the same rectangle snap-rounded in 𝒢, R contains exactly one snap-rounded rectangle for those squares and the weight of the rectangle is set to the sum of the weights of those squares. See Figure 3(c). For a rectangle rR, we denote by w(r) the weight of r. Let opt(R) and opt(Q) denote the total weights obtained by 2-Depth(R) and 2-Depth(Q), respectively.

Lemma 13.

opt(R)(1ε)opt(Q).

Proof.

For a point p2, let Q(p)={qQpq}. Note that there may exist squares qQ(p) with pr(q). Let Qc(p)={qQ(p)pr(q)}.

Let (p1,p2) be an optimal pair of points for 2-Depth(Q). Assume that p1 lies in the interior of a vertical slab Γv bounded by two consecutive lines in Lv. Also, assume that p1 lies in the interior of a horizontal slab Γh bounded by two consecutive horizontal lines in Lh. Every square in Qc(p1) must have at least two corners lying in int(Γv) or at least two corners in int(Γh). Since the total weight of the corners in VQ contained in int(Γv) or int(Γh) is at most εw(P)/25, w(Qc(p1))εw(P)/50. Since opt(P)=opt(Q)w(P)/25 by Lemma 11, w(Qc(p1))εopt(Q)/2. The same argument applies to p2, implying w(Qc(p2))εopt(Q)/2.

By defining R(p) analogously to Q(p), we have w(R(p1)R(p2))w(Q(p1)Q(p2))w(Qc(p1))w(Qc(p2)). Since w(Qc(p1))+w(Qc(p2))εopt(Q) and w(Q(p1)Q(p2))=opt(Q), we have opt(R)(1ε)opt(Q).

For a rectangle r=[x1,x2]×[y1,y2], let x(r)=[x1,x2] and let y(r)=[y1,y2]. Let x={x(r)rR} and y={y(r)rR}.

Lemma 14.

For any two elements I=[x1,x2] and I=[x1,x2] in x, we have x2x2 if x1<x1, and x1x1 if x2<x2. The same property holds for y.

Proof.

Let q and q be the squares in 𝖰 with x(r(q))=I and x(r(q))=I. Let x(q)=[a1,a2] and x(q)=[a1,a2]. Since x1<x1, and q,q are unit squares, we have a1<a1, and thus a2<a2. This implies that x2x2 by the snap rounding method. The same can be shown for the other cases analogously. By Lemma 14, we obtain the following corollary. Note that R{α×βαx,βy}.

Corollary 15.

Both |x| and |y| are O(1/ε). |R|=O(1/ε2).

Recall that 𝒢 can be constructed in O(nlogmin{n,1/ε}) time. After sorting the grid lines, we can use binary search to snap round every square in Q in O(nlogmin{n,1/ε}) total time.

Theorem 16.

Given a set P of n positively weighted points in the plane, we can compute in O(nlogmin{n,1/ε}) time a set R of positively weighted rectangles in the plane such that |R|=O(1/ε2) and the dual of an optimal solution for 2-Depth(R) is a (1ε)-approximate solution for 2-Cover(P).

3.4 Algorithm

Let R be the set of O(1/ε2) positively weighted rectangles obtained by Theorem 16. Recall that each corner of a rectangle in R lies on a grid point of 𝒢. As defined in Section 3.3, 𝒢 is formed by a set Lv of O(1/ε) vertical lines and a set Lh of O(1/ε) horizontal lines. Let Lv={1,2,,t}. For each i from 1 to t1, i and i+1, form a vertical slab which we denote by Γi (See Figure 4(a)). Then there is a pair of index (i,j) such that 2-Depth(R) has an optimal pair of points (p1,p2) with p1Γi and p2Γj. For every possible pair of indices (i,j) for 1ij<t, we compute an optimal pair of points, (p1,p2), for 2-Depth(R) while restricting that p1Γi and p2Γj. Among all the pairs of points, the one (p1,p2) that maximizes the sum of weights of the rectangles in R containing p1 or p2 is an optimal solution for 2-Depth(R).

Figure 4: (a) Rij={r7}, Rji={r6}, Ri,j={r1,r3,r4,r5}. (p1,p2) for 2-Depth(R) with total weight of 5 for unit weight rectangles. Ri,j(γ)={r1,r3,r4}, Ri,jc(γ)={r5}. Depth(RijRi,j(γ))=3, Depth(RjiRi,jc(γ))=2. (b) R=[r1,r2,r3,r4,r5,r8,r7,r6,r9], Rr=[r1,r2,r3,r4,r5,r6,r8,r7,r9], Rt=[r4,r5,r8,r9,r1,r2,r3,r7,r6], Iij=[I1,2,I3], Iji=[I8,9,I7,I6], Ii,j=[I4,5].

For two indices 1ij<t, we denote by 2-Depth(Γi,Γj), or simply 2-Depth(i,j), the case of 2-Depth(R) in which we seek a pair of points (p1,p2) maximizing the total weight of rectangles in R containing at least one of them, subject to the constraint that p1Γi and p2Γj.

Without loss of generality, we assume that 2-Depth(i,j) has an optimal pair (p1,p2) such that p1 lies to the left of and above p2. The remaining cases can be handled analogously. For ease of description, we assume that p1 and p2 lie in int(Γi) and int(Γj), respectively. The cases where either p1 or p2 lies on the boundary can be handled in a similar manner.

For a rectangle r, let ry denote the y-coordinate of its top side. For a set H of rectangles and a real value α, let H(α)={rHα<ry} and Hc(α)=HH(α). For a set H of weighted rectangles, let y(H)={Iy(r)rH}. We abuse the notation and use Depth(H) to denote the total weight of rectangles in H hit by an optimal point for Depth(H). See Figure 4(a) for the following definition.

Definition 17.

Let Ri={rRrint(Γi)} for 1i<t. For two indices i and j, 1i<j<t, let Rij=RiRj, Rji=RjRi, and Ri,j=RiRj. For i=j, let Rii= and Ri,i=Ri.

For a point p2, let x(p) and y(p) denote its x and y-coordinates.

Lemma 18.

For any fixed i,j with 1ij<t, let opt(i,j) be the total weight of rectangles in R hit by an optimal solution for 2-Depth(i,j). If there is an optimal pair of points (p1,p2) for 2-Depth(i,j) with p1Γi,p2Γj and y(p1)>y(p2), there is a real value γ satisfying Depth(RijRi,j(γ))+Depth(RjiRi,jc(γ))=opt(i,j).

Proof.

Let Q1R be the set of rectangles hit by p1. Let Q2R be the set of rectangles hit by p2 but not by p1. Note that w(Q1)+w(Q2)=opt(i,j) as Q1Q2=.

Let γ=max{ryr(Q2Ri,j)}. See Figure 4(a). Observe that y(p2)γ<y(p1). We will prove that w(Q1)=Depth(RijRi,j(γ)) and w(Q2)=Depth(RjiRi,jc(γ)).

Every rectangle rQ1 has y(p1)ry by the definition. Every rectangle in Q1 is from either Rij or Ri,j. (Note that Rij and Ri,j are disjoint.) For a rectangle of the latter case, that is rQ1Ri,j, observe that rRi,j(γ) as we have γ<y(p1)ry. Therefore Q1(RijRi,j(γ)).

Every rectangle in Q2 is from either Rji or Ri,j. (Note that Rji and Ri,j are disjoint.) For a rectangle of the latter case, that is rQ2Ri,j, observe that ryγ by the definition of γ. Therefore such r is contained in Ri,jc(γ). Therefore Q2(RjiRi,jc(γ)).

Now we first show that w(Q1)=Depth(RijRi,j(γ)). As Q1(RijRi,j(γ)), it is clear that w(Q1)Depth(RijRi,j(γ)). Now suppose w(Q1)<Depth(RijRi,j(γ)). As every rectangle in (RijRi,j(γ)) intersects int(Γi), there always exists an optimal point p for Depth(RijRi,j(γ)) such that pΓi. Let R be the set of rectangles in (RijRi,j(γ)) hit by p, that is w(R)=Depth(RijRi,j(γ)). Observe that RQ2= because we have R(RijRi,j(γ)), Q2(RjiRi,jc(γ)), and (RijRi,j(γ))(RjiRi,jc(γ))=. Then the total weight of rectangles in R hit by a new pair (p,p2) is w(R)+w(Q2)>w(Q1)+w(Q2), which contradicts that (p1,p2) is an optimal pair of points for 2-Depth(i,j).

In a similar way, we can show that w(Q2)=Depth(RjiRi,jc(γ)).

3.4.1 Data Structures and Invariants

Given an input set R of weighted rectangles, we store them in three lists. The first list, R, stores the rectangles in increasing order of the x-coordinates of their left sides. The second list, Rr, stores the rectangles in increasing order of the x-coordinates of their right sides. In the case of a tie, the rectangles are further sorted by increasing order of the y-coordinates of their top sides. If the tie still remains unsolved, we sort them by increasing order of the y-coordinates of their bottom sides. See Figure 4(b). The third list, Rt, stores the rectangles in increasing order of the y-coordinates of their top sides. In the case of a tie, the rectangles are further sorted by increasing order of the y-coordinates of their bottom sides. If the tie still remains unsolved, we sort them by increasing order of the x-coordinates of their right sides.

We compute R and Rr once at the beginning of the algorithm. Since |R|=O(1/ε2) by Corollary 15, this can be done in O((1/ε2)log(1/ε)) time. For any fixed indices i and j with 1ij<t, recall that y(Rij) denotes the set of weighted intervals induced by Rij in the y-direction. By Lemma 15, there are O(1/ε) intervals in y(Rij).

Note that two or more rectangles in Rij may have the same interval, ignoring their weights. In such a case, we merge them into a single interval. The weight of the merged interval is set to the total weight of those intervals. Let Iij denote the resulting set of intervals, which satisfies |Iij|=O(1/ε). In the same way, we define Iji and Ii,j with respect to y(Rji) and y(Ri,j), respectively. We always maintain the lists Iij, Iji, and Ii,j in increasing order of the right endpoints of the intervals. In the case of a tie, the intervals are further sorted by their left endpoints.

3.4.2 Algorithm for fixed indices 𝒊,𝒋

We consider two fixed indices i and j with 1ij<t, and present an algorithm that finds an optimal pair of points for 2-Depth(i,j). For now, we assume that the sorted lists Iij, Iji, and Ii,j are given. We will later show how to compute them efficiently. By Lemma 18, there is a real value γ such that an optimal point p1Γi for Depth(RijRi,j(γ)), and an optimal point p2Γj for Depth(RjiRi,jc(γ)) together form an optimal pair (p1,p2) for 2-Depth(i,j). Thus, our goal is to find such γ and the corresponding optimal pair (p1,p2).

Since every rectangle in RijRi,j(γ) intersects int(Γi), Depth(RijRi,j(γ)) can be reduced to the one-dimensional problem Depth(y(Rij)y(Ri,j(γ))). Recall that for any fixed point p on the real line, the total weight of intervals in y(Rij)y(Ri,j(γ)) hit by p is the same as the total weight of intervals in IijIi,j(γ) hit by p. (Here, we slightly abuse the notation: For a list I of intervals on the real line and a real value α, let I(α) denote the set of intervals in I whose right endpoints are larger than α, and let Ic(α) denote the remaining intervals in I. Let II denotes the set consisting of all intervals from I and I.) Therefore, for any fixed γ, it suffices to compute Depth(IijIi,j(γ)). Similarly, Depth(RjiRi,jc(γ)) is reduced to Depth(IjiIi,jc(γ)).

Thus, our objective is to find a real value γ that maximizes Depth(IijIi,j(γ))+Depth(IjiIi,jc(γ)). Imagine that γ decreases from . Then Depth(IijIi,j(γ)) does not decrease, and we can easily maintain this using a simple incremental update since the intervals in IijIi,j satisfy the property described in Lemma 14. For Depth(IjiIi,jc(γ)), we increase γ from , and the update can be done in a similar manner. Since all the lists are already sorted, this entire process takes linear time, and we can find the value of γ that maximizes Depth(IijIi,j(γ))+Depth(IjiIi,jc(γ)). As there are O(1/ε) intervals in Iij, Iji, and Ii,j, we have the following lemma.

Lemma 19.

For any fixed i and j with 1ij<t, once we have Iij, Iji, and Ii,j, we can solve 2-Depth(i,j) in O(1/ε) time.

3.4.3 Final algorithm

For any fixed i with 1i<t, we show how to compute 2-Depth(i,j) for every j=i,i+1,,t1 in total time O((1/ε2)log(1/ε)). Since t=O(1/ε), this can be done by running the algorithm from Lemma 19 for each j in the range (ti+1)=O(1/ε), resulting in a O((1/ε2)log(1/ε)) time in total.

However, it remains to show that the lists Iij, Iji, and Ii,j are properly updated as we enumerate j from i to t1. To this end, we introduce new notations Si and Ti, and provide inductive relations for Rij, Rji, and Ri,j.

Definition 20.

For an index 1i<t, let Ri={rRrint(Γi)}. Let R0=Rt=. We then define Si=RiRi1 and Ti=RiRi+1 for 1i<t.

For any fixed i with 1i<t, the rectangles of Si appear as a contiguous sublist in R, and they appear before those of Si+1 in R. Symmetrically, the rectangles of Ti appear as a contiguous sublist in Rr, and they appear before those of Ti+1 in Rr.

Observation 21.

For i and j with 1ij<t, Rij+1=Rij(Ri,jTj), Rj+1i=(RjiTj)Sj+1, and Ri,j+1=Ri,jTj.

Using the inductive relation above, we prove the following lemma.

Lemma 22.

For any fixed i with 1i<t, the lists Iij, Iji, and Ii,j for all j=i,,t1 can be computed in time O(1/ε2) in total.

Proof.

For the base case where i=j, recall that Rii= and Ri,i={rRrΓi}. Thus, we initialize Iij and Iji as empty lists. For Ii,i, we find the rectangles in Ri,i and store them in increasing order of the y-coordinates of their top sides. This can be done by scanning the list Rt. Note that two or more rectangles in Rij may have the same interval, ignoring their weights. In such a case, we merge them into a single interval. The weight of the merged interval is set to the total weight of those intervals. This process takes O(|Rt|)=O(1/ε2) time, producing the correct Ii,j.

We maintain two pointers, one each for R and Rr. As j increases, the pointer in R moves to the first element contained in Sj+1. and the pointer in Rr moves to the first element contained in Tj.

Assuming we already have Iij, by Observation 21, we need to find rectangles in (Ri,jTj) to obtain Iij+1. This can be done by scanning the elements in Rr starting from its pointer, which takes O(|Tj|) time. Note that these rectangles share the same right-side x-coordinate and are sorted by the y-coordinates of their top sides. Hence, we can convert them into intervals, and merge the same intervals (ignoring their weights) as done in the previous paragraph. This also takes O(|Tj|) time. By Lemma 15, the resulting set of intervals, say Inew, has size O(1/ε). We then merge Inew into Iij. We merge the same intervals as done in the previous paragraph if necessary. Since both Iij and Inew are sorted by their right endpoints, this merge can be done in O(|Iij|+|Inew|)=O(1/ε) time.

Similarly, we need to find the rectangles in (RjiTj)Sj+1 to obtain Ij+1i from Iji. The rectangles in (RjiTj) can be found by scanning the elements in Rr, as before. We then convert these rectangles into intervals and merge the same intervals, which can be done in O(|Tj|) time. After that, we update Iji by removing or decreasing the weights of the corresponding intervals. In the same way, we find the rectangles in Sj+1 by scanning the elements in R from its pointer, convert them into intervals, and process them similarly. Therefore, the total time required is O(|Tj|+|Sj+1|+1/ε). The update for Ii,j+1 can be handled in the same manner.

It takes O(|Tj|+1/ε) time for computing Iij+1, O(|Tj|+|Sj+1|+1/ε) time for computing Ij+1i, and O(|Tj|+1/ε) time from computing Ii,j+1. Summing over j=i to t1, the total time is j=it1O(|Sj+1|+|Tj|+1/ε)=O(|R|)+O(1/ε2)=O(1/ε2).

By combining Lemmas 19 and 22, we can conclude that for any fixed index i with 1i<t, we can compute 2-Depth(i,j) for all j=i,,t1 in O(1/ε2) total time. Repeating this process for all i=1,,t1 takes O(1/ε3). Since it takes O(nlogmin{n,1/ε}) time to compute the set R by Theorem 16, we obtain the following result.

Theorem 23.

Given a set P of n positively weighted points in the plane, we can compute a (1ε)-approximate pair of squares for 2-Cover(P) in O(nlogmin{n,1/ε}+1/ε3) time.

3.5 Extension to higher dimensions

Our algorithm extends naturally to higher dimensions. For any fixed d3, an optimal pair to the type (1) case can be computed in O((n/εd2)log(1/ε)) time by extending the algorithm of Lemma 7.

Consider the type (2) case. As in Section 3.2, the search space can be reduced to a constant-size d-dimensional box, and the same duality transform can also be applied. By applying a lemma analogous to Lemma 12, we can construct a grid such that there are O(1/ε) grid hyperplanes along each axis xi for i=1,,d. After performing snap rounding for each dual hypercube into hyperrectangle, the algorithm proceeds in exactly the same manner as in the two-dimensional case.

Let Γ1,,Γt denote the slabs formed by two consecutive grid hyperplanes along the x1-axis. For any fixed 1ijt, we solve 2-Depth(i,j). We can observe that once i and j are fixed, all the hyperrectangles of our interest intersect either Γi or Γj. We then project the problem onto the plane orthogonal to the x1-axis and recursively solve the lower-dimensional instance.

Thus, we obtain the following theorem.

Theorem 24.

Given a set P of n positively weighted points in d-dimensional space, we can compute a (1ε)-approximate pair of hypercubes for 2-Cover(P) in O((n/εd2)log(1/ε)+1/ε2d1) time for any fixed d3.

References

  • [1] Michael Ben-Or. Lower bounds for algebraic computation trees. In Proceedings of 15th Annual ACM Symposium on Theory of Computing, pages 80–86, New York, NY, USA, 1983. Association for Computing Machinery.
  • [2] Sergio Cabello, J. Miguel Díaz-Báñez, Carlos Seara, J. Antoni Sellès, Jorge Urrutia, and Inmaculada Ventura. Covering point sets with two disjoint disks or squares. Computational Geometry, 40(3):195–206, 2008. doi:10.1016/J.COMGEO.2007.10.001.
  • [3] Timothy M. Chan. Klee’s measure problem made easy. In 2013 IEEE 54th Annual Symposium on Foundations of Computer Science, pages 410–419, 2013. doi:10.1109/FOCS.2013.51.
  • [4] Mark de Berg, Sergio Cabello, and Sariel Har-Peled. Covering many or few points with unit disks. Theory of Computing Systems, 45(3):446–469, 2009. doi:10.1007/S00224-008-9135-9.
  • [5] Uriel Feige. A threshold of lnn for approximating set cover. Journal of the ACM, 45(4):634–652, 1998. doi:10.1145/285055.285059.
  • [6] Dorit S. Hochbaum and Anu Pathria. Analysis of the greedy approach in problems of maximum k-coverage. Naval Research Logistics, 45(6):615–627, 1998.
  • [7] Hiroshi Imai and Takao Asano. Finding the connected components and a maximum clique of an intersection graph of rectangles in the plane. Journal of Algorithms, 4(4):310–323, 1983. doi:10.1016/0196-6774(83)90012-3.
  • [8] Kai Jin, Jian Li, Haitao Wang, Bowei Zhang, and Ningye Zhang. Near-linear time approximation schemes for geometric maximum coverage. Theoretical Computer Science, 725:64–78, 2018. doi:10.1016/J.TCS.2017.11.026.
  • [9] Priya Ranjan Sinha Mahapatra, Partha P. Goswami, and Sandip Das. Placing two axis-parallel squares to maximize the number of enclosed points. International Journal of Computational Geometry & Applications, 25(04):263–282, 2015. doi:10.1142/S0218195915500156.
  • [10] Nimrod Megiddo and Kenneth J. Supowit. On the complexity of some common geometric location problems. SIAM Journal on Computing, 13(1):182–196, 1984. doi:10.1137/0213014.
  • [11] Ali Mostafavi and Ali Hamzeh. High-dimensional axis-aligned bounding box with outliers. In Proceedings of 34th Canadian Conference on Computational Geometry, pages 264–269, 2022.
  • [12] Subhas C. Nandy and Bhargab B. Bhattacharya. A unified algorithm for finding maximum and minimum object enclosing rectangles and cuboids. Computers & Mathematics with Applications, 29(8):45–61, 1995.
  • [13] George L. Nemhauser, Laurence Wolsey, and M.L. Fisher. An analysis of approximations for maximizing submodular set functions-I. Mathematical Programming, 14(1):265–294, 1978. doi:10.1007/BF01588971.
  • [14] Yufei Tao, Xiaocheng Hu, Dong-Wan Choi, and Chin-Wan Chung. Approximate MaxRS in spatial databases. In Proceedings of the VLDB Endowment, pages 1546–1557. VLDB Endowment, 2013. doi:10.14778/2536258.2536266.