Convex-Hull Algorithms: Implementation, Testing, and Experimentation
<p>The left-turn predicate written in C<tt>++</tt>. The compile-time function <tt>cphmpl::width<T></tt> returns the width of the coordinates of type <tt>T</tt> in bits. The class template <tt>cphstl::bbb<math display="inline"><semantics> <mrow> <mi mathvariant="double-struck">Z</mi> </mrow> </semantics></math><b></tt> provides fixed-width integers; the width of the numbers is <tt>b</tt> bits and, for numbers of this type, the same operations are supported as for built-in integers.</p> "> Figure 2
<p>In-place <span class="html-small-caps">plane-sweep</span> algorithm illustrated.</p> "> Figure 3
<p><span class="html-small-caps">torch</span> algorithm illustrated; the staircase in <math display="inline"><semantics> <msub> <mi>Q</mi> <mn>1</mn> </msub> </semantics></math> is displayed in red and all hollow points are discarded during the staircase formation.</p> "> Figure 4
<p>A visualization of the general recursive step in <span class="html-small-caps">quickhull</span>.</p> "> Figure 5
<p>The region uncovered by <span class="html-small-caps">throw-away</span> preprocessing for the disc data set.</p> ">
Abstract
:1. Introduction
- The algorithm—as it was presented in [2]—was incorrect.
- The implementation given in [4] was not reliable—calculations could overflow and degenerate inputs were not handled correctly.
- The implementation required too much memory to be used when the size of the problem reached that of the main memory of the computer.
- The source code of the competing implementations was not made publicly available so we had to implement them ourselves.
- Not enough details were provided on the experiments so that we could reproduce them.
- We describe a simple way of making the implementations of convex-hull algorithms robust.
- We identify an error in the original version of torch and propose a corrected, in-place version.
- We prove that, when the coordinates of the n input points are integers drawn from a bounded universe of size U, quickhull runs in worst-case time. We also explain how its worst-case performance can be reduced to —we call this variant introhull.
- We implement six convex-hull algorithms—plane-sweep, torch, quickhull, poles-first, throw-away, and introhull—and show that these implementations are space-efficient and time-efficient, both in theory and practice.
- We introduce a test framework that can be used to make the programs computing convex hulls self-testing.
- We compare the performance of four space-efficient convex-hull algorithms—plane-sweep, torch, quickhull, and throw-away—in the integer-arithmetic setting.
2. Preliminaries
2.1. Definitions
2.2. Test Environment
- Square data set. The coordinates of the points were random integers uniformly distributed over the interval (i.e., random ints). The expected size of the output is [14].
- Disc data set. As above, the coordinates of the points were random ints, but only the points inside the circle centred at the origin with the radius were accepted to the input collection. In this case, the expected size of the output is .
- Bell data set. The points were drawn according to a two-dimensional normal distribution by rounding each coordinate to the nearest integer value (of type int). The mean value of the distribution was 0 and the standard deviation where . For this data set, the expected size of the output is .
2.3. Robustness
3. Pilot Experiments
3.1. Rotational Sweep
- The routine did not operate in place, but the output was produced on a separate stack.
- The routine had the same robustness issues as Gomes’ program: The arithmetic operations in the orientation test and the distance calculation could overflow.
- The C library qsort was used in sorting; this program is known to be slower and less reliable than the C++ standard-library introsort [27]. Gomes used introsort in his own program.
- [](P const& p, P const& q) → bool {
- return p.x < q.x;
- }
- [](P const& p, P const& q) → bool {
- return (p.x < q.x) or (p.x q.x and p.y < q.y);
- }
- [&](P const& p, P const& q) → bool {
- int turn = orientation(o, p, q);
- if (turn 0) {
- return (L∞distance(o, p) < L∞distance(o, q));
- }
- return (turn +1);
- }
3.2. Gift Wrapping
3.3. Output-Sensitive Algorithms
4. Implementations
4.1. Plane Sweep
- (A)
- Sort the input points in non-decreasing order according to their x-coordinates.
- (B)
- Determine the leftmost point (west pole) and the rightmost point (east pole). If there are several pole candidates with the same x-coordinate, let the bottommost of them be the west pole; and on the other end, let the topmost one be the east pole.
- (C)
- Partition the sorted sequence into two parts, the first containing those points that are above or on the line segment determined by the west pole and the east pole, and the second containing the points below that line segment.
- (D)
- Scan the two monotone chains separately by eliminating all concave points that are not on the convex hull. For an early description of this backtracking procedure relying on cross-product computations, see [33].
- (E)
- Concatenate the computed convex chains to form the final answer.
- (1)
- Find the west and east poles by scanning the input sequence once. Place the poles at their respective ends of the input sequence. If the poles are the same point, stop and return the position of the successor of the west pole.
- (2)
- Partition the input sequence into two parts: (a) the upper-hull candidates, i.e., the points that are above or on the line segment determined by the west pole and the east pole; and (b) the lower-hull candidates, i.e., the points below that line segment.
- (3)
- Apply the function chain with the poles, the upper-hull candidates, and comparison function less than. This gives us the upper hull from the west pole to the east pole, excluding the east pole.
- (4)
- Swap the east pole to the beginning of the lower-hull candidates, and apply the function chain with the two poles—this time giving the east pole first, the lower-hull candidates, and the comparison function greater than. After this we also have the lower hull, but it is not in its final place.
- (5)
- Move the computed lower hull just after the computed upper hull (if it is not there already). This is a standard in-place block-swap computation. Finally, return the position of the first eliminated point (or the past-the-end position if all points are in the convex hull).
4.2. Torch
- (B’)
- Find the topmost point (north pole) and the bottommost point (south pole) by one additional scan and resolve the ties in a similar fashion as in Step (B).
- (C’)
- Group the input points into four (overlapping) candidate collections such that, for , the i’th collection contains the points that are not dominated by the adjacent poles in the respective direction (north-west, north-east, south-east, or south-west), i.e., these points are in the quadrant of Figure 3. Note that the quadrant includes the borders.
- (D’)
- In each of the candidate collections, compute the boundary points before discarding the concave points that are not in the output polygon.
- (1)
- Only the x-coordinates are compared when sorting the points.
- (2)
- The number of the orientation tests performed is proportional to the number of maximal points, the coefficient being at most two times the average number of directions the points are dominant in.
- four arrays of indices—implemented as std::vector—to keep track of the points in each of the four candidate collections,
- an array of points—implemented as std::vector—to store the boundary points in the approximation, and
- a stack—implemented as std::deque—to store the output.
- (1a)
- Partition the input sequence such that the points in the north-west quadrant ( in Figure 3) determined by the west and north poles are moved to the beginning and the remaining points to the end (normal two-way partitioning).
- (1b)
- Sort the points in according to their x-coordinates in non-decreasing order.
- (1c)
- Find the boundary points in and move the eliminated points at the end of the zone occupied by the points of . Here the staircase goes upwards.
- (1d)
- Scan the boundary points in to determine the convex chain from the west pole to the north pole. Again, the eliminated points are put at the end of the corresponding zone.
- (2a)
- Consider all the remaining points (also those eliminated earlier) and partition the zone occupied by them into two so that the points in become just after the west-north chain ending with the north pole.
- (2b)
- Sort the points in according to their x-coordinates in non-increasing order.
- (2c)
- Find the boundary points in as in Step (1c). Also here the staircase goes upwards.
- (2d)
- Reverse the boundary points in place so that their x-order becomes non-decreasing.
- (2e)
- Continue the scan that removes the concave points from the boundary points to get the convex chain from the north pole to the east pole.
- (3)
- Compute the south-east chain of the convex hull for the points in as in Step (2), except that now the staircase goes downwards and the reversal of the boundary points is not necessary.
- (4)
- Compute the south-west chain of the convex hull for the points in as in Step (2), except that now the sorting order is non-decreasing and the staircase goes downwards.
4.3. Quickhull
- solve many geometric problems,
- work in the d-dimensional space for any ,
- be output sensitive,
- reduce space requirements, and
- handle most of the rounding errors caused by floating-point arithmetic.
- we had full control over any further tuning and
- we could be sure that the computed output was correct as, also here, we relied on exact integer arithmetic.
4.4. Other Elimination Heuristics
5. Testing
5.1. Test Framework
- empty_set,
- one_point,
- two_points,
- three_points_on_a_vertical_line,
- three_points_on_a_horizontal_line,
- ten_equal_points,
- four_poles_with_duplicates,
- random_points_on_a_parabola,
- random_points_in_a_square (10,000 test cases),
- corners_of_the_universe.
5.2. Test-First Development
- Small instances. It is trivial to handle the cases and , but already the case introduces a complication: If the two points are duplicates, special handling is necessary. For larger n, it is also possible that the west pole and the east pole coincide, so this special case must be handled separately.
- Referential integrity. Let p and q be two iterators pointing to some elements. A typical way of swapping these elements is to invoke std::iter_swap(p, q). An unfortunate consequence of this swap is that the iterators are not valid after this operation. It may be necessary to execute std::swap(p, q) just after it. The situation becomes worse when there is another iterator r pointing to the same position as p or q. After the swap, this iterator is not valid any more.
- Empty ranges. Often a subroutine expects to get a range specifying a sequence of elements. In most cases the range is non-empty, but we should also be prepared to handle the empty case.
- Duplicates. These can appear in many places, including places where you do not expect them. For a set of points in general position, it may be enough to execute a single assignment, but in the case of duplicates we may need a loop to jump over them.
- Points on a rectilinear line. When several points are on the same rectilinear line and this happens when finding a pole, a rule is needed to know which one to choose. To break the tie, we use lexicographic ordering even though we want to avoid it in sorting. In a typical case, there is only one pole per direction, so we wanted to avoid the overhead of maintaining two poles per direction, i.e., the bottommost west pole and the topmost west pole.
- Elimination of concave points. After a pole is found, there may be other points on the same rectilinear line. The standard backtracking procedure [33] is not always able to process collinear points correctly. Therefore, a separate routine is needed to find the next convex-hull point that is on the same line and farthest away from the found pole.
- Points on a line. When finding the farthest point from a line segment and several points are equally far, it is necessary to use lexicographic ordering as a tiebreaker. Again, the reason is the standard backtracking procedure—it may fail if collinear points are not processed in the correct order.
- Index arithmetic. When computing the convex hull in pieces, the points may not be in consecutive positions any more. For example, it may be necessary to perform index arithmetic modulo n to get access to the west pole when processing the lower hull after the upper hull has already be computed. Because we operate on iterators, this index arithmetic is not allowed. Therefore, it may be necessary to add some additional parameters for the functions or it may even be convenient to have two copies of the same function where the other takes care of some special case.
5.3. Uncovering Algorithm Vulnerability
6. Workhorse Experiments
6.1. Experimental Design
- Multi-precision arithmetic. As described in Section 2.3, we performed intermediate calculations using the multi-precision integers available at the CPH STL [22]. This solution is generic, works for any type of integer coordinates, and the program code is beautiful.
- Double-precision arithmetic. We specialized the geometric primitives to use double-precision integers (signed/unsigned long long), kept track of all the possible overflows, and dealt with them accordingly. This ad-hoc solution relies on the fact that the coordinates are of type int. Unfortunately, we must admit that the resulting code is inelegant.
- Floating-point filter. We converted the coordinates to floating-point numbers and performed the intermediate calculations using them. Only if the result was not known to be correct due to accumulation of rounding errors would we use the multi-precision numbers to redo the calculations. In the present case, we employed Shewchuk’s filter coded in [45]. A readable explanation of how the filter works can be found in [46].
6.2. Time Performance
6.3. Other Performance Indicators
7. Conclusions
- Robustness. Everyone in computer science knows the problems associated with arithmetic overflows. In the convex-hull algorithms, one has to analyse a single-line formula to determine the maximum precision needed when doing the calculations in an orientation test. This is a type function that maps the type of the input coordinates to the type of some higher-precision numeric type. This mapping can be carried out at compile time. This solution leads to fast performance since the compiler can optimize the generated code. Our message is that a heavyweight static-analysis tool, described in [47], to do automatic code analysis may be an overkill in this particular application, even thought the aim is the same—perform as much work at compile time as possible. On the other end, arbitrary-precision arithmetic provided, for example, by GMP [48] may also be an overkill because the width of the numbers is extended dynamically at run time.
- Correctness. Experimental results can be misleading if the programs do not produce a correct answer. Naturally, testing is not enough to guarantee correctness, but it is a necessary evil to avoid great humiliation. In the case of convex-hull algorithms, a test framework similar to ours can help improve code quality.
- Space requirements. By using less memory, one can avoid the overhead caused by memory management and incur less cache misses. There is a big difference if the amount of extra space used is or words. We explained how plane-sweep, torch, poles-first, and throw-away can be implemented in place.
- Arithmetic complexity. For in-situ variants in the integer-arithmetic setting, our experiments indicate that the improvement provided by torch compared to plane-sweep is marginal. However, the situation may change if the arithmetic operations are expensive. Namely, it is expected that torch will execute a fewer number of arithmetic operations than the other investigated algorithms, which always perform orientation tests.
- Reproducibility. In experimental work, a “key principle is that the experiment should be verifiable and reproducible” ([1], Chapter 14). All the programs and scripts used to run the experiments discussed in this paper are publicly available; a frozen release is available as a supplement from the journal (https://www.mdpi.com/1999-4893/11/12/195/s1) and the latest updated release from the home page of the CPH STL [49].
- Smarter sorting. In a sorting-based approach, when sorting a sequence of points according to their x-coordinates, if two points are seen to have the same x-coordinate, the point with the smaller (or larger) y-coordinate could be eliminated. More generally, it is possible to sort n elements having at most ℓ different values in worst-case time. Another possibility is to use bucketsort when sorting the points [28].
- More aggressive elimination. The idea of eliminating interior points during the computation is good! However, in contemporary computers, sorting is fast. So an elimination procedure should not be complicated. In a follow-up paper [51], we implemented a bucketing algorithm ([52], Section 4.4), for which the elimination overhead is three scans and the elimination effectiveness is better than that for the throw-away algorithm. The work space used by this algorithm is words, but because of random access its competitive advantage may fade away when the problem size becomes large.
- Better integration. Many good algorithms are hybrids of several other algorithms. One of the goals is to reach good worst-case and average-case performance at the same time. Taking inspiration from introsort [27], we proposed introhull that combines quickhull [8] and plane-sweep [3]. Gomes’ torch [2] combines the rectilinear-convex-hull algorithm by Ottmann et al. [37] and plane-sweep. However, because of introsort, the average-case running of this hybrid is . As shown by Bentley et al. [14], a divide-and-conquer algorithm could be used to compute a superset which will reduce the average case of the combined algorithm to , keeping the worst case unchanged. Does this pruning-before-sorting approach have any practical significance?
- Parallel processing. In our benchmarks, only one core was in use even though both of our test computers had four cores. Some previous studies (see, e.g., [53]) have shown that the additional cores can be used to speed up Quicksort, Quickhull, and other divide-and-conquer algorithms. A further study, where speed is at the focus, must consider how technological changes affect the existing algorithms.
Supplementary Materials
Author Contributions
Funding
Acknowledgments
Conflicts of Interest
References
- Zobel, J. Writing for Computer Science, 3rd ed.; Springer: London, UK, 2014. [Google Scholar]
- Gomes, A.J.P. A total order heuristic-based convex hull algorithm for points in the plane. Comput. Aided Des. 2016, 70, 153–160. [Google Scholar] [CrossRef]
- Andrew, A.M. Another efficient algorithm for convex hulls in two dimensions. Inf. Process. Lett. 1979, 9, 216–219. [Google Scholar] [CrossRef]
- Gomes, A.J.P. Git Repository. Available online: https://github.com/mosqueteer/TORCH/ (accessed on 2 October 2018).
- Graham, R.L. An efficient algorithm for determining the convex hull of a finite planar set. Inf. Process. Lett. 1972, 1, 132–133. [Google Scholar] [CrossRef]
- Jarvis, R.A. On the identification of the convex hull of a finite set of points in the plane. Inf. Process. Lett. 1973, 2, 18–21. [Google Scholar] [CrossRef]
- Chan, T.M. Optimal output-sensitive convex hull algorithms in two and three dimensions. Discrete Comput. Geom. 1996, 16, 361–368. [Google Scholar] [CrossRef] [Green Version]
- Eddy, W.F. A new convex hull algorithm for planar sets. ACM Trans. Math. Softw. 1977, 3, 398–403. [Google Scholar] [CrossRef]
- Bykat, A. Convex hull of a finite set of points in two dimensions. Inf. Process. Lett. 1978, 7, 296–298. [Google Scholar] [CrossRef]
- Green, P.J.; Silverman, B.W. Constructing the convex hull of a set of points in the plane. Comput. J. 1979, 22, 262–266. [Google Scholar] [CrossRef] [Green Version]
- Akl, S.G.; Toussaint, G.T. A fast convex hull algorithm. Inf. Process. Lett. 1978, 7, 219–222. [Google Scholar] [CrossRef]
- Devroye, L.; Toussaint, G.T. A note on linear expected time algorithms for finding convex hulls. Computing 1981, 26, 361–366. [Google Scholar] [CrossRef]
- McGeorg, C.C. A Guide to Experimental Algorithmics; Cambridge University Press: Cambridge, UK, 2012. [Google Scholar]
- Bentley, J.L.; Kung, H.T.; Schkolnick, M.; Thompson, C.D. On the average number of maxima in a set of vectors and applications. Inf. Process. Lett. 1978, 25, 536–543. [Google Scholar] [CrossRef]
- Brönnimann, H.; Iacono, J.; Katajainen, J.; Morin, P.; Morrison, J.; Toussaint, G. Space-efficient planar convex hull algorithms. Theor. Comput. Sci. 2004, 321, 25–40. [Google Scholar] [CrossRef]
- Hoare, C.A.R. Quicksort. Comput. J. 1962, 5, 10–16. [Google Scholar] [CrossRef] [Green Version]
- Kettner, L.; Mehlhorn, K.; Pion, S.; Schirra, S.; Yap, C. Classroom examples of robustness problems in geometric computations. Comput. Geom. 2008, 40, 61–78. [Google Scholar] [CrossRef]
- Bhattacharya, B.K.; Toussaint, G.T. Time- and storage-efficient implementation of an optimal planar convex hull algorithm. Image Vis. Comput. 1983, 1, 140–144. [Google Scholar] [CrossRef]
- McQueen, M.M.; Toussaint, G.T. On the ultimate convex hull algorithm in practice. Pattern Recognit. Lett. 1985, 3, 29–34. [Google Scholar] [CrossRef]
- Warren, H.S., Jr. Hacker’s Delight, 2nd ed.; Addison-Wesley Professional: Westford, MA, USA, 2012. [Google Scholar]
- Katajainen, J. Pure Compile-Time Functions and Classes in the CPH MPL; CPH STL report 2017-2; Department of Computer Science, University of Copenhagen: Copenhagen, Denmark, 2017; Available online: http://hjemmesider.diku.dk/~jyrki/Myris/Kat2017R.html (accessed on 27 November 2018).
- Katajainen, J. Class templates <b> and <b> for fixed-precision arithmetic. 2018; work in progress. [Google Scholar]
- Schirra, S. Robustness and precision issues in geometric computation. In Handbook of Computational Geometry; Sack, J.-R., Urrutia, J., Eds.; Elsevier: Amsterdam, The Netherlands, 2000; pp. 597–632. [Google Scholar]
- Sanders, P. Presenting data from experiments in algorithmics. In Experimental Algorithmics—From Algorithm Design to Robust and Efficient Software; Fleischer, R., Moret, B., Meineche Schmidt, E., Eds.; Springer: Berlin/Heidelberg, Germany, 2002; LNCS; Volume 2547, pp. 181–196. [Google Scholar] [CrossRef]
- GeeksforGeeks. Convex Hull ∣ Set 2 (Graham Scan). Available online: http://www.cdn.geeksforgeeks.org/convex-hull-set-2-graham-scan/ (accessed on 2 October 2018).
- Cormen, T.H.; Leiserson, C.E.; Rivest, R.L.; Stein, C. Introduction to Algorithms, 3rd ed.; The MIT Press: Cambridge, MA, USA, 2009. [Google Scholar]
- Musser, D.R. Introspective sorting and selection algorithms. Softw. Pract. Exp. 1997, 27, 983–993. [Google Scholar] [CrossRef]
- Allison, D.C.S.; Noga, M.T. Some performance tests of convex hull algorithms. BIT Numer. Math. 1984, 24, 2–13. [Google Scholar] [CrossRef] [Green Version]
- Bhattacharya, B.K.; Sen, S. On a simple, practical, optimal, output-sensitive randomized planar convex hull algorithm. J. Algorithms 1997, 25, 177–193. [Google Scholar] [CrossRef]
- Chan, T.M.Y.; Snoeyink, J.; Yap, C.K. Output-sensitive construction of polytopes in four dimensions and clipped Voronoi diagrams in three. In Proceedings of the 6th Annual ACM-SIAM Symposium on Discrete Algorithms, San Francisco, CA, USA, 22–24 January 1995; pp. 282–291. [Google Scholar]
- Kirkpatrick, D.G.; Seidel, R. The ultimate planar convex hull algorithm? SIAM J. Comput. 1986, 15, 287–299. [Google Scholar] [CrossRef]
- Wenger, R. Randomized quickhull. Algorithmica 1997, 17, 322–329. [Google Scholar] [CrossRef]
- Sklansky, J. Measuring concavity on a rectangular mosaic. IEEE Trans. Comput. 1972, C-21, 1355–1364. [Google Scholar] [CrossRef]
- Katajainen, J.; Pasanen, T. Stable minimum space partitioning in linear time. BIT Numer. Math. 1992, 32, 580–585. [Google Scholar] [CrossRef] [Green Version]
- Lipton, R.J. Galactic Algorithms. Available online: https://rjlipton.wordpress.com/2010/10/23/galactic-algorithms/ (accessed on 27 November 2018).
- Williams, J.W.J. Algorithm 232: Heapsort. Commun. ACM 1964, 7, 347–349. [Google Scholar] [CrossRef]
- Ottmann, T.; Soisalon-Soininen, E.; Wood, D. On the definition and computation of rectilinear convex hulls. Inf. Sci. 1984, 33, 157–171. [Google Scholar] [CrossRef]
- Devroye, L. A note on finding convex hulls via maximal vectors. Inf. Process. Lett. 1980, 11, 53–56. [Google Scholar] [CrossRef]
- Bentley, J.L.; Clarkson, K.L.; Levine, D.B. Fast linear expected-time algorithms for computing maxima and convex hulls. Algorithmica 1993, 9, 168–183. [Google Scholar] [CrossRef]
- Katajainen, J. Worst-case-efficient dynamic arrays in practice. In Proceedings of the 15th International Symposium on Experimental Algorithms, St. Petersburg, Russia, 5–8 June 2016; Goldberg, A.V., Kulikov, A.S., Eds.; Springer: Cham, Switzerland, 2016. LNCS. Volume 9685, pp. 167–183. [Google Scholar] [CrossRef]
- Barber, C.; Dobkin, D.; Huhdanpaa, H. The Quickhull algorithm for convex hulls. ACM Trans. Math. Softw. 1996, 22, 469–483. [Google Scholar] [CrossRef]
- Barber, C.B. Qhull Manual. Available online: http://www.qhull.org/ (accessed on 2 October 2018).
- Scowen, R.S. Algorithm 271: Quickersort. Commun. ACM 1965, 8, 669–670. [Google Scholar] [CrossRef]
- Overmars, M.H.; van Leeuwen, J. Further comments on Bykat’s convex hull algorithm. Inf. Process. Lett. 1980, 10, 209–212. [Google Scholar] [CrossRef]
- Shewchuk, J.R. Adaptive Precision Floating-Point Arithmetic and Fast Robust Predicates for Computational Geometry. Available online: http://www.cs.cmu.edu/~quake/robust.html (accessed on 27 November 2018).
- Ozaki, K.; Bünger, F.; Ogita, T.; Oishi, S.; Rump, S.M. Simple floating-point filters for the two-dimensional orientation problem. BIT Numer. Math. 2016, 56, 729–749. [Google Scholar] [CrossRef]
- Fortune, S.; van Wyk, C.J. Static analysis yields efficient exact integer arithmetic for computational geometry. ACM Trans. Graph. 1996, 15, 223–248. [Google Scholar] [CrossRef]
- gmplib.org. GMP: The GNU Multiple Precision Arithmetic Library. Available online: https://gmplib.org/ (accessed on 27 November 2018).
- Gamby, A.N.; Katajainen, J. Convex-Hull Algorithms in C++; CPH STL report 2018-1; Department of Computer Science, University of Copenhagen: Copenhagen, Denmark, 2018; Available online: http://hjemmesider.diku.dk/~jyrki/Myris/GK2018S.html (accessed on 27 November 2018).
- Hoang, N.D.; Linh, N.K. Quicker than Quickhull. Vietnam J. Math. 2015, 43, 57–70. [Google Scholar] [CrossRef]
- Gamby, A.N.; Katajainen, J. A faster convex-hull algorithm via bucketing. 2018; work in progress. [Google Scholar]
- Devroye, L. Lecture Notes on Bucket Algorithms; Birkhäuser: Basel, Switzerland, 1986. [Google Scholar]
- Näher, S.; Schmitt, D. A framework for multi-core implementations of divide and conquer algorithms and its application to the convex hull problem. In Proceedings of the 20th Annual Canadian Conference on Computational Geometry, Montreal, QC, Canada, 13–15 August 2008; pp. 203–206. [Google Scholar]
- Gamby, A.N.; Katajainen, J. A Note on the Implementation Quality of a Convex-Hull Algorithm; CPH STL report 2017-3; Department of Computer Science, University of Copenhagen: Copenhagen, Denmark, 2017; Available online: http://hjemmesider.diku.dk/~jyrki/Myris/GK2017R.html (accessed on 27 November 2018).
(a) |
Processor. Intel Core™ i7-6600U CPU @ 2.6 GHz (turbo-boost up to 3.6 GHz)—4 cores |
Word size. 64 bits |
First-level data cache. 8-way set-associative, 64 sets, KB |
First-level instruction cache. 8-way set-associative, 64 sets, KB |
Second-level cache. 4-way set-associative, 1 024 sets, 256 KB |
Third-level cache. 16-way set-associative, 4 096 sets, 4.096 MB |
Main memory. 8.038 GB |
Operating system. Ubuntu 17.10 |
Kernel. Linux 4.13.0-16-generic |
Compiler. g++ 7.2.0 |
Compiler options.-O3 -std=c++17 -x c++ -Wall -Wextra -fconcepts |
(b) |
Processor. Intel Core™ i7-4700MQ CPU @ 2.40 GHz—4 cores and 8 logic processors |
Word size. 64 bits |
First-level data cache. 8-way set-associative, KB |
First-level instruction cache. 8-way set-associative, KB |
Second-level cache. 4-way set-associative, KB |
Third-level cache. 12-way set-associative, 6 MB |
Main memory. DDR3, 8 GB, DRAM frequency 800 MHz |
Operating system. Microsoft Windows 10 Home 10.0.15063 |
Compiler. Microsoft Visual Studio 2017 |
Compiler options./Ox /Ob2 /Oi /Ot /std:c++17 |
(a) | |||
-Sorting | Lexicographic Sorting | Angular Sorting | |
36.65 | 38.06 | 162.5 | |
54.03 | 56.31 | 244.7 | |
71.48 | 75.16 | 329.9 | |
89.37 | 94.89 | 412.7 | |
162.7 | 178.2 | 572.6 | |
(b) | |||
-Sorting | Lexicographic Sorting | Angular Sorting | |
40.49 | 43.40 | 595.1 | |
62.62 | 67.17 | 922.5 | |
85.18 | 90.70 | 1247 | |
109.1 | 115.5 | 1579 |
n | 3-introhull | 4-introhull | poles-first | throw-away | ||||
---|---|---|---|---|---|---|---|---|
Square | Disc | Square | Disc | Square | Disc | Square | Disc | |
3.37 | 12.0 | 0.06 | 0.30 | 51.0 | 37.9 | 4.29 | 12.2 | |
0.60 | 10.2 | 0.02 | 0.85 | 50.9 | 36.5 | 0.71 | 10.2 | |
0.10 | 9.99 | 0.00 | 0.66 | 51.3 | 36.3 | 0.12 | 9.99 | |
0.01 | 9.97 | 0.00 | 0.64 | 50.6 | 36.3 | 0.01 | 9.97 | |
0.00 | 9.97 | 0.00 | 0.64 | 50.4 | 36.3 | 0.00 | 9.97 |
Algorithm | Worst Case | Average Case | Work Space |
---|---|---|---|
introsort [27] | |||
plane-sweep [3] | [15] [*] | ||
torch [2] | [*] | ||
quickhull [8,9,10] | [*] | [44] | [*] |
throw-away [12] | [*] |
(a) | |||||
introsort | plane-sweep | torch | quickhull | throw-away | |
36.65 | 55.92 | 49.62 | 34.67 | 27.32 | |
54.03 | 72.18 | 64.68 | 30.92 | 26.02 | |
71.48 | 89.24 | 82.40 | 31.06 | 24.40 | |
89.37 | 107.9 | 101.1 | 30.78 | 25.03 | |
162.7 | 281.3 | 334.4 | 245.8 | 247.4 | |
(b) | |||||
introsort | plane-sweep | torch | quickhull | throw-away | |
40.52 | 53.27 | 62.40 | 51.98 | 34.50 | |
64.37 | 73.86 | 84.40 | 48.67 | 30.90 | |
83.76 | 94.82 | 106.5 | 49.54 | 30.52 | |
106.8 | 124.6 | 130.4 | 48.92 | 30.58 |
(a) | |||||
introsort | plane-sweep | torch | quickhull | throw-away | |
36.31 | 52.75 | 55.01 | 33.04 | 27.31 | |
53.84 | 69.10 | 69.94 | 30.90 | 26.96 | |
71.20 | 86.21 | 87.37 | 31.06 | 28.33 | |
88.94 | 104.1 | 105.4 | 31.59 | 30.96 | |
212.5 | 281.3 | 350.9 | 226.3 | 242.3 | |
(b) | |||||
introsort | plane-sweep | torch | quickhull | throw-away | |
40.16 | 58.66 | 58.62 | 47.48 | 32.84 | |
62.19 | 78.96 | 79.67 | 44.64 | 32.41 | |
85.24 | 101.9 | 102.2 | 45.31 | 34.13 | |
108.6 | 126.6 | 125.7 | 46.46 | 36.29 |
(a) | |||||
introsort | plane-sweep | torch | quickhull | throw-away | |
36.94 | 53.68 | 49.96 | 14.41 | 20.01 | |
54.05 | 70.67 | 64.97 | 12.92 | 19.12 | |
71.11 | 88.02 | 81.72 | 13.22 | 18.78 | |
88.96 | 105.8 | 102.5 | 11.51 | 18.67 | |
224.2 | 283.0 | 308.5 | 152.2 | 226.3 | |
(b) | |||||
introsort | plane-sweep | torch | quickhull | throw-away | |
40.10 | 53.51 | 60.39 | 22.11 | 25.95 | |
62.68 | 73.19 | 82.24 | 20.32 | 24.18 | |
84.98 | 95.27 | 104.6 | 20.38 | 23.29 | |
114.0 | 124.9 | 128.8 | 20.05 | 23.55 |
n | plane-sweep | torch | quickhull | throw-away |
---|---|---|---|---|
2.31 | 0.02 | 4.95 | 2.04 | |
2.34 | 0.00 | 4.86 | 2.01 | |
2.34 | 0.00 | 4.82 | 2.00 | |
2.39 | 0.00 | 4.70 | 2.00 | |
2.09 | 0.00 | 5.37 | 2.00 |
n | introsort | plane-sweep | torch | quickhull | throw-away |
---|---|---|---|---|---|
12.0 | 14.8 | 21.3 | 2.26 | 15.0 | |
18.1 | 20.9 | 28.0 | 2.25 | 15.0 | |
24.2 | 27.1 | 35.3 | 2.25 | 15.0 | |
30.2 | 33.3 | 42.3 | 2.25 | 15.1 | |
36.5 | 39.0 | 49.2 | 2.25 | 15.2 |
n | introsort | plane-sweep | torch | quickhull | throw-away |
---|---|---|---|---|---|
19.1 | 30.1 | 21.3 | 15.2 | 21.2 | |
26.2 | 37.2 | 28.0 | 14.7 | 20.2 | |
33.3 | 44.3 | 35.3 | 14.5 | 20.1 | |
40.5 | 51.5 | 42.3 | 14.5 | 20.0 | |
47.4 | 57.8 | 49.2 | 16.4 | 20.4 |
© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
Gamby, A.N.; Katajainen, J. Convex-Hull Algorithms: Implementation, Testing, and Experimentation. Algorithms 2018, 11, 195. https://doi.org/10.3390/a11120195
Gamby AN, Katajainen J. Convex-Hull Algorithms: Implementation, Testing, and Experimentation. Algorithms. 2018; 11(12):195. https://doi.org/10.3390/a11120195
Chicago/Turabian StyleGamby, Ask Neve, and Jyrki Katajainen. 2018. "Convex-Hull Algorithms: Implementation, Testing, and Experimentation" Algorithms 11, no. 12: 195. https://doi.org/10.3390/a11120195
APA StyleGamby, A. N., & Katajainen, J. (2018). Convex-Hull Algorithms: Implementation, Testing, and Experimentation. Algorithms, 11(12), 195. https://doi.org/10.3390/a11120195