1 Introduction
Consider a set consisting of set points and a set consisting of blue points in the three dimensional space. A separating box for and is a box (hyperrectangle) that contains all the red points in and the fewest blue points in . We call a separating box a maximumvolume bichromatic separating box (MBSB) of and , or simply maximum separating box, if it has the largest volume among all boxes separating and . The problem was introduced in [4]. In this paper, we improve the running time of in [4] and provide an algorithm that takes to find one optimal solution.
An example of MBSB in shown in Figure 1.
There are quite a few interesting real world applications of this problem. For instance, in oncology, one may be interested in separating a tumor from the healthy threedimensional tissue. The tumor cells are indicated by red points, while the healthy cells and background stoma are indicated by blue points. Often times, an oncology pathologist may seek to surgically cut out the largest tissue containing the tumor while minimizing healthy tissue removall, which leads to the problem we solve.
Another application would be in spatial databases. Suppose the goal is to retrieve all ”red” data from a table with 3 realvalued columns and a discrete label column, which can be ”red” or ”blue”, while minimizing the number of records with ”blue” label retrieved. Similarly, there are applications in data science and machine learning, where we are given a dataset with 3 realvalued features and two classes, red and blue, and the goal is to train a classifier that can classify the data as red or blue. If much higher weight is assigned to red misclassifications than to blue misclassifications, then computing the largest separating box of the point sets is important, as it misses no red points.
1.1 Related Work
Geometric separability is a very important problem in the field of geometric optimization. Strong separability problems ask for perfect separators, where no misclassifications are allowed, whereas in weak separability problems, the goal is to minimize an error measure related to classification. Error measures may include number of misclassifications, total misclassification weight, or other. For instance, computing the largest (maximumvolume) separating box is a weak separability problem which minimized the number of misclassified blue points.
Perhaps the most commonly studied separability topic is the linear separability, in which the separator is a line, a plane, or a hyperplane. The hyperplane separability problem was introduced by Megiddo et. al
[26]. Given a set of red points and a set of blue points, the goal is to find a hyperplane such that points from no more than one set can be found on either side of the hyperplane. They show how to solve the decision version of the problem in linear time using linear programming. In addition, they prove that
line separability, which ask whether two points sets are separable by lines, is NPcomplete. Aronov et. al [6] studied linear separability of points in dimensions using 4 error metrics, one of which is ther total number of misclassified points. The other metrics measure the maximum euclidean distance of a misclassified point to the hyperplane, the sum of these distances, and the squared sum of these distances, respectively. For minimizing the number of misclassifications, they give an time algorithm. Later on, Chan [9] solved the relaxed version of the problem in 2 and 3 dimensions, in which up to violations are allowed. Their algorithm for the 2D version runs in time, while their 3D algorithm runs in . Dobkin solved the problem of linear separability of polyhedra, for which they provide a linear time algorithm [14].Circular separability was introduced by Fisk [17]. They study the optimization version, in which the goal is to find the separating circle with no violations and of minimum radius. They provide a time algorithm involving nearest and farthest Voronoi diagrams. Later on, O’Rourke et. al improved the result to linear time [28] for the decision problem, and time for the optimization problem. In the weak circular separability problem, the minimumradius circle containing all of the red points and the fewest of the blue points is sought. Weak circular separability was introduced by Bitner et. al [8], who presented two solutions. One of them is based on furthestpoint Voronoi Diagrams and requires time and space. The other involves circular range queries and takes time and space. Later on, Armaselu et. al [3] solved the dynamic version of the problem, in which blue points are inserted and removed dynamically. They provide three data structures, one of which requires space and can answer insertion queries in time, deletion queries in time, and is updated in time. The other two are designed for insertions only (respectively, deletions only) and can answer queries in time, at the expense of an space requirement and time requirement.
Rectangular separability was studied by Armaselu and Daescu. They provide a time algorithm for the 2D axisaligned version of the problem, which asks for the largest area axisaligned rectangle separating red and blue points in the plane [5]. They also solve the planar arbitrary orientation version, in which the target rectangle has arbitrary orientation, in time, and the 3D axisaligned version in time [4], which we improve in this paper.
An interesting related problem is the problem of computing the largest empty rectangle among a set of planar points, introduced by Hsu et. al [18]. They solve trhe axisaligned version with an algorithm that takes worstcase, expected time to find all optimal solutions. Later, Chazelle et. al improved the running time to time to find one optimal solution. Aggarwal et. al [2] further improved the running time to to find one optimal solution, which is currently still the best known algorithm for the axisaligned version. For the arbitrary orientation version, Mukhopadhyay et. al [27] and Chaudhuri et. al [10] independenlty provided algorithms to find all optimal solutions in time and space. The 3D axisaligned case was introduced by Nandy et. al, who give a cubic time, linear space algorithm to find all optimal solutions [30]. Kaplan et. al considered the problem of computing the largest empty rectangle containing query point [22]. They come up with a data structure that answers queries in time, with time preprocessing, where is the very slowgrowing inverse Ackermann function.
Various other separators have been considered by Hurtado et. al, such as wedges, strips [20], and double wedges [19] in 2D. All these separation problems can be decided in time [19, 20]. They also extend the single and double wedge separability to 3D and consider separability by other 3D geometric loci, such as prisms and pyramids [21], for which they describe polynomialtime algorithms. Demaine et. al studied the separability by line segments, chords, and multichords [13], for which they give polynomial time algorithms and also prove lower bounds.
1.2 Our Results
In this paper, we improve the running time of the algorithm in [4] for computing an MBSB, using a more clever approach which breaks down all possible configurations of optimal solutions into 6 cases, and uses clever tricks to solve the most complex of these cases in time, after the smallest enclosing rectangle is computed. In total, our algorithm takes time, which is an improvement of at least a factor of compared to the previous known bounds.
The rest of the paper is structured as follows. In Section 2, we make some importnant preliminary observations. Then, in section 3, we analyze all the situations in which a largets separating box can be found, provide a detailed description of the algorithm, and analyze its running time. Finally, in Section 4, we draw the conclusions and list some future directions.
2 Preliminaries
We begin by computing the smallest enclosing box and disarding the blue points inside , and they are inevitable. Then we extend outwards in each direction parallel to itself until it hits a blue point, and denote the resulting box by , as in [4]. The planes that define partition into and 26 other regions (see Figure 2 for an illustration). Specifically, there are:

8 corner regions, which are boxes cornered by one corner of and the corresponding corner of (e.g. toprightfront (TRF) corner of and TRF corner of , bottomleftback (BLK) corner of and BLK corner of )

6 side regions, which are boxes bounded by one face of (e.g. top face) and the corresponding face of (e.g. top face)

12 edge regions, which are boxes bounded by one edge of (e.g. topright or TR) and the corresponding edge of .
Note that the side regions may not contain any blue points, otherwise they would redefine . We sort all blue points first by , then by , and then by coordinate.
A candidate box is a separating box that cannot be extended in any direction without including a blue point. Every candidate box is supported by 6 blue points, called supports, each of them supporting a face of the box.
A halfspace of is a halfspace bounded by the plane supporting a face of and not containing . A halfspace of is said to be perpendicular to another halfspace of , and we write , if is bounded by a plane supporting a face of and not containing .
If is a halfspace of , we denote the face of supporting the plane bounding by , and the complement of by .
We call a combination of 2 supports a pair, a combination of 3 supports a triple, and a combination of 4 supports a quadruple.
Let be the maximal rectilinear polyhedron that contains all red points and none of the blue points, i.e. cannot be extended in any direction without including a blue point.
By convention, we consider a point to be in front of (resp., to the back of) another point if (resp., ), where is the Y coordinate of point . We also consider that the scene is viewed by a camera located at . That is, the near direction is towards Y while the far direction is towards +Y. Similarly, is considered above (resp., below) another point if (resp., ). Finally, is considered to the right of (resp., to the left of) another point if (resp., ).
Observation 1.
For every face of a candidate box , once adjacent supports are established, the support can be found by extending in the direction of until it hits a blue point. For instance, once the top and back supports of are established, the right support of can be found by extending to the right until it hits a blue point (see Figure 3 for details).
Observation 2.
For each edge region , the portion of within , denoted , has the shape of a prism with a staircaseshaped base (as shown in Figure 4).
Observation 3.
For each corner region , the portion of within , denoted , has a threedimensional staircase shape (as displayed in Figure 5).
Observation 4.
For every corner region , there are triples with all 3 supports from .
From now on, for each corner region , whenever understood, we will refer to as the polyhedron of . In addition, for each edge region , we will refer to as the staircase of .
3 A breakdown of the situations a candidate box can be found in
Note that:

no more than 5 supports of a candidate box can be located in any halfspace of ,

no more than 4 supports can be located in the intersection of two halfspaces of ,

no more than 3 supports can be located in two staircases within a halfspace of , and

no more than 3 supports can be found in any corner region.
Based on the location of the supports, a candidate box can be in one of the following cases.

Case 1. 5 supports in a halfspace of , out of which 4 in a halfspace of .

Case 2. 5 supports in a halfspace of , out of which 3 in a halfspace of .

Case 3. 5 supports in a halfspace of , out of which 2 in a halfspace of , and at least one in an edge region adjacent to a corner region within

Case 4. 5 supports in a halfspace of , out of which 3 in two edge regions adjacent to a corner region within

Case 5. 4 supports in a halfspace of , 3 of which in the complement of a halfspace of .

Case 6. 4 supports in a halfspace of , with one support in each corner region within .

Case 7. 4 supports in a halfspace of , with two supports in one of the corner regions of .

Case 8. 3 supports in 2 opposite corner regions.
In the following subsections we will analyze the number of candidate boxes in each case. For cases 1 through 7 assume, without loss of generality, that is the right face of and is the back face of .
3.1 Case 1
Refer to Figure 6 for an illustration of this case.
Suppose wlog that the 4 supports in are the top, back, right, and bottom supports for . Thus, may only have one valid front support. Once the top, back, right, and bottom supports are determined, the front support of can be found by extending frontwards until it hits a blue point. The left support of is now uniquely determined. To bound the number of topbackrightbottom quadruples coming from the back side of , we note the following. The top support cannot come from the topback edge region, since it is outside , so it must come from the topbackright corner region, which makes the bottom support uniquely determined. Since there are choices of top supports, it follows that there are combinations of topbackrightbottom quadruples, which in turn implies there are candidate boxes in case 1.
3.2 Case 2
See Figure 7 for a depiction of this case.
First, assume the 3 supports in to be the top, back, and bottom supports for . In this case there are valid frontright pairs. Specifically, there is one pair with the right support from the righttop or the rightbottom edge region, one pair with the front support from the fronttop or the frontbottom edge region, pairs from the frontright staircase, and pairs from the frontrighttop and frontrightbottom rectilinear polyhedra. For each frontright pair, there is a unique left support. To bound the number of topbackbottom triples, note that, once the top, right, and back supports are established, the bottom support is unique. Since the topback pairs come from the toprightback polyhedron, there are such pairs, and for each of them we have valid rightbottomfrontleft quadruples. It follows that there are candidate boxes with topbackbottom triples from .
Now assume the 3 suports in to be the top, back, and right supports for . The situation where the supports are bottom, back, and right supports for is symmetric. In this case there are valid frontbottom pairs. Specifically, there is one pair with the bottom support from the bottomright or bottomleft edge region, one pair with the front support from the frontleft or frontright edge region, and pairs from the frontrightbottom rectilinear polyhedron. For each frontbottom pair, there is a unique left support. As for the number of topbackright supports, note that, once the top and back supports are established, the right support is unique. Since the topback pairs come from the toprightback polyhedron, there are such pairs, and for each of them we have valid rightbottomfrontleft quadruples. This implies an total candidate boxes with toprightback triples from .
We conclude that candidate boxes are in case 2.
3.3 Case 3
Figure 8 supports the description of this case.
First, suppose wlog that the 2 supports in are the top and back supports of . If they come from the same polyhedron, then the right support is unique. Since only the top and the back support are in , the right support must come either from or from the halfspace of opposite to . If it comes from , then the bottom support is unique, which in turn uniquely determins the front support, which finally uniquely determins the left support. Otherwise, the bottom support must come from a staircase, which means the front and right supports must be located in . This gives us valid frontright pairs for the subcase where the top and back supports come from the same polyhedron. If the back and top supports come from different polyhedra, then the right and the bottom supports are unique. This in turn causes the front and the left supports to be unique. Thus, there are candidare boxes in the subcase where the 2 supports in are the topback pair.
Now wlog suppose that the 2 supports in are the back and right supports of . If they come from a staircase, then the top and the bottom supports are unique, which in turn makes the front and the left supports unique. Otherwise, suppose that the back support comes from a polyhedron. If the right support comes from the same polyhedron, then the pair uniquely determines either the top or the bottom support. As a consequence, there are valid bottomfront (resp., bottomback) pairs, and for each of them there is a unique left support. If, on the contrary, the right support comes from a staircase or another polyhedron, then both the top and the bottom supports are established, which uniquely determines the front and the left supports. Hence, there are candidate boxes where the 2 supports in are the rightback pair.
Since there are topback pairs, as well as rightback pairs, it follows that there are candidate boxes in case 3.
3.4 Case 4
Assume wlog that the topright pair comes from the topright edge region and the bottom support comes from the bottomright edge region . Then the front and back supports are uniquely determined, which in turn implies that the left support is uniquely determined (see Figure 9). Since there are topright pairs, it follows that there are candidate boxes in case 4.
3.5 Case 5
Assume wlog that is the right face of , and is the back face of (refer to Figure 10).
If two of the supports in are from the rightback staircase, then either the top or the bottom support is in . Wlog suppose the top support is in . If the bottom support is in , then it is the only valid bottom support. Otherwise, the front support is in , and similarly it follows that it is the only valid front support. Either way, there are valid pairs involving the left support: leftfront or leftbottom pairs. Also, there are rightback pairs from the rightback staircase, which gives a total of candidate boxes with rightback pairs from .
If no two supports in are from the rightback staircase, then the top and the bottom support are both in . Wlog suppose the right support is in . By a similar argument as in the previous paragraph, we obtain candidate boxes with exactly one support in .
Summing up, there are candidate boxes in case 5.
3.6 Case 6
A depiction of this case can be found in Figure 11.
Wlog suppose the 4 supports from form the toprightbackbottom quadruple, and the top support comes from the toprightback polyhedron. Then the back support must come from the bottomrightback polyhedron, the bottom support must be located in the bottomrightfront polyhedron, and the right support must be located in the toprightfront polyhedron. For the frontleft pair, we are left with valid choices. For the top support, we have choices, and for every one of them, we have valid bottomrightback pairs, which give us frontleft pairs each. That is, there are candidate boxes in case 6.
3.7 Case 7
An illustration of this case can be found in Figure 12.
As in case 6, suppose wlog that the 4 supports from are the toprightbackbottom quadruple. Also let the topback pair come from the toprightback corner region, and the bottomright pair come from the bottomrightfront corner region (the other case can be treated in a similar manner). There are such topback pairs, and for each of them there are such choices of bottomright pairs. Once toprightbackbottom quadruple is established, there are still choices of frontleft pairs, as noted in case 6. That gives us total candidate boxes in case 7.
3.8 Case 8
Refer to Figure 13 for details.
Wlog assume the toprightback triple is given by the toprightback polyhedron, and the bottomleftfront triple is given by the bottomleftfront polyhedron. Each toprightback triples is given by an inner corner of the toprightback polyhedron, and since the complexity of a retilinear polyhedron is , we get potential toprightback triples. Similarly, we obtain candidate bottomleftfront triples. It follows that there are candidate boxes in case 8.
3.9 The Data Structure
In order to find each candidate box in time, we need the ability to find the support of a face in given the supports of two adjacent faces.
Thus, for each blue point , we need to store the following pointers, as displayed in Figure 14.

for each edge region , a pointer to the lowest point in the staircase of above

for each corner region , a pointer to the lowest point in the polyhedron of above

for each edge region , a pointer to the highest point in the staircase of below

for each corner region , a pointer to the highest point in the polyhedron of below

for each edge region , a pointer to the leftmost point in the staircase of to the right of

for each corner region , a pointer to the leftmost point in the polyhedron of to the right of

for each edge region , a pointer to the rightmost point in the staircase of to the left of

for each corner region , a pointer to the rightmost point in the polyhedron of to the left of

for each edge region , a pointer to the furthest point in the staircase of in front of

for each corner region , a pointer to the furthest point in the polyhedron of in front of

for each edge region , a pointer to the nearest point in the staircase of behind

for each corner region , a pointer to the nearest point in the polyhedron of behind
After computing the staircases and polyhedra, the pointers can be computed in time each by traversing the staircases and polyhedra, and they are never updated. Since we store pointers for each blue point, we only need additional time to compute all the pointers. After computing all the pointers, we only require time to compute each candidate box.
Since only case 7 may require processing time, from now on, we shall focus on case 7.
Let
be a tensor whose values are volumes of boxes with the topback pair given by the row index, the bottomright pair given by the column index, and the frontleft pair given by the depth layer index.
It has been proved [1] that all rowmaxima of a totally (inverse) monotone matrix can be computed in time. If we can prove that a depth slice of (layer) either is totally (inverse) monotone, or can be transformed into a totally (inverse) monotone matrix, then we would find all rowmaxima of a layer in time. By repeating the process for each layer, we find the maxima of all rows of all layers in time, and store them in an associative list that maps the row, collumn, and layer index in to the volume of the box. After that, we simply traverse and report the candidate box having the largest volume.
Lemma 1.
For every layer of , the depth slice can be transformed into a totally (inverse) monotone matrix .
Proof. First note that, since not all bottomright pairs may occur with a given topback pair and the th frontleft pair, some portions of may be undefined. However, the defined portion of is contiguous. If we could prove that the defined portion of
is totally (inverse) monotone, we would then pad each side of
with real values, as indicated in [5], to produce a totally (inverse) monotone matrix . Indeed, since the frontleft pair is the same for all of , and all of the other supports come from a single halfspace , one can project these supports on the plane supporting to form, for each candidate box, a candidate rectangle supported by the respective topbackbottomright quadruple. The largest boxes defined by then correspond to the largest rectangles among these candidate rectangles. Thus, we transform by replacing volumes of boxes by areas of their corresponding rectangles. The total monotonicity of the transformed consisting of areas of rectangles follows from [23]. ∎Note that, in order to avoid quadratic computations of the entries of for each , we need only evaluate whenever queried, rather than storing the whole matrix in memory [5]. Since only a linear number of such queries are performed [5, 23], it follows that all row maxima of are computed in time. Thus, we have the following result.
Lemma 2.
All candidate boxes in case 7 can be computed in time.
We are now in a position to state the following.
Theorem 1.
The MBSB of a blue point set and a red point set in three dimensions can be computed in time.
Proof. We compute and in time [4]. We then compute the staircases of all edge regions in time, and the polyhedra of all corner regions in time. While computing the staircases, we also compute all needed pointers using an additional time. After having computed the pointers, we spend to compute each candidate box in all cases except case 7. Since there are boxes, we spend in all of these cases. By Lemma 2, we also spend time in case 7. Thus, we spend a total of time. ∎
4 Conclusion and Future Work
We addressed the problem of finding the maximum volume bichromatic separating box among red points and blue points in 3D, and provided an algorithm that takes time. We leave for future work computing the maximum volume bichromatic separating box of arbitrary orientation.
Acknowledgement
The author would like to thank Dr. Ovidiu Daescu for the useful discussions.
References
 [1] A. Aggarwal, M. Klawe, S. Moran, P. Shor and R. Wilber, Geometric Applications of a Matrix Search Algorithm, Algorithmica, 2 (2): 195–208, 1987
 [2] A Aggarwal and S Suri, Fast Algorithms for Computing the Largest Empty Rectangle, Symposium on Computational Geometry 1987: 278290
 [3] B. Armaselu and O. Daescu, Dynamic minimum bichromatic separating circle, Theoretical Computer Science 774: 133142 (2019)
 [4] B. Armaselu and O. Daescu, Maximum area rectangle separating red and blue points, CCCG’2016: 244251
 [5] B. Armaselu and O. Daescu, Maximum area rectangle separating red and blue points, arXiv: 1706.03268, June 2017
 [6] B. Aronov and D. Garijo, Y. Núñez, D. Rappaport. C. Seara and J. Urrutia, Measuring the error of linear separators on linearly inseparable data, Discrete Applied Mathematics 160(1011): 14411452 (2012)
 [7] Blender software, https://www.blender.org/
 [8] S. Bitner, Y. K. Cheung, and O. Daescu, Minimum separating circle for bichromatic points in the plane, ISVD ’2010: 5055
 [9] T. Chan, LowDimensional Linear Programming with Violations, SIAM Journal on Computing, vol. 34, 2005, issn: 00975397, pp.879–893, http://dx.doi.org/10.1137/S0097539703439404, Society for Industrial and Applied Mathematics, Philadelphia, PA, US
 [10] J. Chaudhuri, S. C. Nandy and S. Das, Largest empty rectangle among a point set, J. Algorithms, 46, Vol. 1, pp. 5478, 2003
 [11] B. Chazelle, R.L. Drysdale III, D.T. Lee, Computing the largest empty rectangle, SIAM Journal of Computing, 1986, 15: 300315
 [12] A. Datta and S. Soundaralakshmi, An efficient algorithm for computing the maximum empty rectangle in three dimensions, Information Sciences, Vol. 128 (12) 2000: 4365
 [13] E. Demaine, J. Erickson, F. Hurtado, J. Iacono, S. Langerman, H. Meijer, M. Overmars, and S. Whitesides, Separating Point Sets in Polygonal Environments, Journal of Computational Geometry and Applications, vol. 15, 2005, pp. 403420
 [14] D. Dobkin and D. Kirkpatrick, A Linear Algorithm for Determining the Separation of Convex Polyhedra, Journal of Algorithms, vol. 6, 1985, pp.381392
 [15] A. Dumitrescu and M. Jiang, On the largest empty axisparallel box amidst points, Algorithmica 66(2): 225248 (2013)
 [16] A. Dumitrescu and M. Jiang: On the Number of Maximum Empty Boxes Amidst Points. Symposium on Computational Geometry 2016: 36:136:13
 [17] S. Fisk, Separating Point Sets by Circles, and the Recognition of Digital Disks, IEEE Transactions on Pattern Analysis and Machine Intelligence, July 1986, pp.554556
 [18] W.L. Hsu, D.T. Lee and A. Namaad, On the maximum empty rectangle problem, Discrete Applied Math, 1984, 8: 267277
 [19] F. Hurtado and M. Noy and P. A. Ramos and C. Seara, Separating objects in the plane by wedges and strips, Discrete Applied Mathematics, vol. 109, 2001, pp. 109138
 [20] F. Hurtado and M. Mora and P. A. Ramos and C. Seara, Separability by two lines and by nearly straight polygonal chains, Discrete Applied Mathematics, vol. 144, 2004, pp. 110122, http://dx.doi.org/10.1016/j.dam.2003.11.014
 [21] F. Hurtado, C. Seara, and S. Sethia, RedBlue Separability Problems in 3D, International Journal of Computational Geometry, vol. 15, 2005, pp.167=192
 [22] H. Kaplan and M. Sharir, Finding the Maximal Empty Rectangle Containing a Query Point, CoRR abs/1106.3628 (2011)
 [23] H. Kaplan, S. Mozes, Y. Nussbaum and M. Sharir, Submatrix maximum queries in Monge matrices and partial Monge matrices, and their application, SODA 2012: 338355
 [24] M. Klawe and D.J. Kleitman, An almost linear time algorithm for generalized matrix searching, SIAM Journal of Discrete Math. (1990), Vol. 3, pp. 8197
 [25] S. Kosaraju, J. O’Rourke and N. Megiddo, Computing circular separability, Journal of Discrete Computational Geometry, 1:105–113, 1986
 [26] N. Megiddo, On the complexity of Polyhedral Separability, Journal of Diescrete Computational Geometry, 1988, vol. 3, pp. 325337
 [27] A. Mukhopadhyay and S.V. Rao, Computing a Largest Empty Arbitrary Oriented Rectangle. Theory and Implementation, International Journal of Computational Geometry & Applications Vol. 13, No. 3 (2003) 257271
 [28] J. O’Rourke and S. Kosaraju and N. Megiddo, Computing Circular Separability, Discrete Computational Geometry, vol. 1, pp. 105113, 1986
 [29] Subhas C. Nandy, Arani Sinha and Bhargab B. Bhattacharya, Location of the Largest Empty Rectangle among Arbitrary Obstacles, FSTTCS 1994: 159170
 [30] Subhas C. Nandy and Bhargab B. Bhattacharya, Maximal empty cubiods among points and blocks, Journal of Computers & Mathematics with Applications, Vol. 36 (3), August 1998, pp. 1120
Comments
There are no comments yet.